• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2017 The Chromium OS Authors. All rights reserved.
2  * Use of this source code is governed by a BSD-style license that can be
3  * found in the LICENSE file.
4  */
5 
6 #include <unordered_map>
7 
8 extern "C" {
9 #include "cras_rstream.h"
10 }
11 
12 namespace {
13 
14 struct cb_data {
15 	std::unordered_map<unsigned int, unsigned int> dev_offset;
16 	int pending_reply;
17 };
18 std::unordered_map<const cras_rstream*, cb_data> data_map;
19 
20 };
21 
rstream_stub_reset()22 void rstream_stub_reset() {
23   data_map.clear();
24 }
25 
rstream_stub_dev_offset(const cras_rstream * rstream,unsigned int dev_id,unsigned int offset)26 void rstream_stub_dev_offset(const cras_rstream* rstream,
27                              unsigned int dev_id,
28                              unsigned int offset) {
29   auto data = data_map.find(rstream);
30   if (data == data_map.end()) {
31     cb_data new_data;
32     new_data.dev_offset[dev_id] = offset;
33     data_map.insert({rstream, new_data});
34   } else {
35     data->second.dev_offset[dev_id] = offset;
36   }
37 }
38 
rstream_stub_pending_reply(const cras_rstream * rstream,int ret_value)39 void rstream_stub_pending_reply(const cras_rstream* rstream,
40                                 int ret_value) {
41   auto data = data_map.find(rstream);
42   if (data == data_map.end()) {
43     cb_data new_data;
44     new_data.pending_reply = ret_value;
45     data_map.insert({rstream, new_data});
46   } else {
47     data->second.pending_reply = ret_value;
48   }
49 }
50 
51 extern "C" {
52 
cras_rstream_record_fetch_interval(struct cras_rstream * rstream,const struct timespec * now)53 void cras_rstream_record_fetch_interval(struct cras_rstream *rstream,
54                                         const struct timespec *now) {
55 }
56 
cras_rstream_dev_attach(struct cras_rstream * rstream,unsigned int dev_id,void * dev_ptr)57 void cras_rstream_dev_attach(struct cras_rstream *rstream,
58                              unsigned int dev_id,
59                              void *dev_ptr) {
60 }
61 
cras_rstream_dev_detach(struct cras_rstream * rstream,unsigned int dev_id)62 void cras_rstream_dev_detach(struct cras_rstream *rstream, unsigned int dev_id) {
63 }
64 
cras_rstream_dev_offset(const struct cras_rstream * rstream,unsigned int dev_id)65 unsigned int cras_rstream_dev_offset(const struct cras_rstream *rstream,
66                                      unsigned int dev_id) {
67   auto elem = data_map.find(rstream);
68   if (elem != data_map.end())
69     return elem->second.dev_offset[dev_id];
70   return 0;
71 }
72 
cras_rstream_dev_offset_update(struct cras_rstream * rstream,unsigned int frames,unsigned int dev_id)73 void cras_rstream_dev_offset_update(struct cras_rstream *rstream,
74                                     unsigned int frames,
75                                     unsigned int dev_id) {
76 }
77 
cras_rstream_playable_frames(struct cras_rstream * rstream,unsigned int dev_id)78 unsigned int cras_rstream_playable_frames(struct cras_rstream *rstream,
79                                           unsigned int dev_id) {
80   return 0;
81 }
82 
cras_rstream_get_volume_scaler(struct cras_rstream * rstream)83 float cras_rstream_get_volume_scaler(struct cras_rstream *rstream) {
84   return 0.0;
85 }
86 
cras_rstream_get_mute(const struct cras_rstream * rstream)87 int cras_rstream_get_mute(const struct cras_rstream *rstream) {
88   return 0;
89 }
90 
cras_rstream_get_readable_frames(struct cras_rstream * rstream,unsigned int offset,size_t * frames)91 uint8_t *cras_rstream_get_readable_frames(struct cras_rstream *rstream,
92                                           unsigned int offset,
93                                           size_t *frames) {
94   return NULL;
95 }
96 
cras_rstream_update_input_write_pointer(struct cras_rstream * rstream)97 void cras_rstream_update_input_write_pointer(struct cras_rstream *rstream) {
98 }
99 
cras_rstream_update_output_read_pointer(struct cras_rstream * rstream)100 void cras_rstream_update_output_read_pointer(struct cras_rstream *rstream) {
101 }
102 
cras_rstream_audio_ready(struct cras_rstream * stream,size_t count)103 int cras_rstream_audio_ready(struct cras_rstream *stream, size_t count) {
104   cras_shm_buffer_write_complete(&stream->shm);
105   return 0;
106 }
107 
cras_rstream_request_audio(struct cras_rstream * stream,const struct timespec * now)108 int cras_rstream_request_audio(struct cras_rstream *stream,
109                                const struct timespec *now) {
110   return 0;
111 }
112 
cras_rstream_update_queued_frames(struct cras_rstream * rstream)113 void cras_rstream_update_queued_frames(struct cras_rstream *rstream)
114 {
115 }
116 
cras_rstream_is_pending_reply(const struct cras_rstream * rstream)117 int cras_rstream_is_pending_reply(const struct cras_rstream *rstream)
118 {
119   auto elem = data_map.find(rstream);
120   if (elem != data_map.end())
121     return elem->second.pending_reply;
122   return 0;
123 }
124 
cras_rstream_flush_old_audio_messages(struct cras_rstream * rstream)125 int cras_rstream_flush_old_audio_messages(struct cras_rstream *rstream)
126 {
127   return 0;
128 }
129 
130 } // extern "C"
131