Changes in uspace/srv/audio/hound/audio_device.c [b7fd2a0:7f9d97f3] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/audio/hound/audio_device.c
rb7fd2a0 r7f9d97f3 51 51 #define BUFFER_PARTS 16 52 52 53 static errno_t device_sink_connection_callback(audio_sink_t *sink, bool new);54 static errno_t device_source_connection_callback(audio_source_t *source, bool new);53 static int device_sink_connection_callback(audio_sink_t *sink, bool new); 54 static int device_source_connection_callback(audio_source_t *source, bool new); 55 55 static void device_event_callback(ipc_callid_t iid, ipc_call_t *icall, void *arg); 56 static errno_t device_check_format(audio_sink_t* sink);57 static errno_t get_buffer(audio_device_t *dev);58 static errno_t release_buffer(audio_device_t *dev);56 static int device_check_format(audio_sink_t* sink); 57 static int get_buffer(audio_device_t *dev); 58 static int release_buffer(audio_device_t *dev); 59 59 static void advance_buffer(audio_device_t *dev, size_t size); 60 60 static inline bool is_running(audio_device_t *dev) … … 62 62 assert(dev); 63 63 /* we release buffer on stop so this should be enough */ 64 return dev->buffer.base != NULL;64 return (bool)dev->buffer.base; 65 65 } 66 66 … … 72 72 * @return Error code. 73 73 */ 74 errno_t audio_device_init(audio_device_t *dev, service_id_t id, const char *name)74 int audio_device_init(audio_device_t *dev, service_id_t id, const char *name) 75 75 { 76 76 assert(dev); … … 121 121 { 122 122 assert(dev); 123 sysarg_t val; 124 errno_t rc = audio_pcm_query_cap(dev->sess, AUDIO_CAP_CAPTURE, &val); 125 if (rc == EOK && val) 123 if (audio_pcm_query_cap(dev->sess, AUDIO_CAP_CAPTURE)) 126 124 return &dev->source; 127 125 return NULL; … … 137 135 { 138 136 assert(dev); 139 sysarg_t val; 140 errno_t rc = audio_pcm_query_cap(dev->sess, AUDIO_CAP_PLAYBACK, &val); 141 if (rc == EOK && val) 137 if (audio_pcm_query_cap(dev->sess, AUDIO_CAP_PLAYBACK)) 142 138 return &dev->sink; 143 139 return NULL; … … 153 149 * connections. 154 150 */ 155 static errno_t device_sink_connection_callback(audio_sink_t* sink, bool new)151 static int device_sink_connection_callback(audio_sink_t* sink, bool new) 156 152 { 157 153 assert(sink); … … 160 156 log_verbose("First connection on device sink '%s'", sink->name); 161 157 162 errno_t ret = get_buffer(dev);158 int ret = get_buffer(dev); 163 159 if (ret != EOK) { 164 160 log_error("Failed to get device buffer: %s", … … 196 192 log_verbose("Removed last connection on device sink '%s'", 197 193 sink->name); 198 errno_t ret = audio_pcm_stop_playback(dev->sess);194 int ret = audio_pcm_stop_playback(dev->sess); 199 195 if (ret != EOK) { 200 196 log_error("Failed to stop playback: %s", … … 215 211 * connections. 216 212 */ 217 static errno_t device_source_connection_callback(audio_source_t *source, bool new)213 static int device_source_connection_callback(audio_source_t *source, bool new) 218 214 { 219 215 assert(source); 220 216 audio_device_t *dev = source->private_data; 221 217 if (new && list_count(&source->connections) == 1) { 222 errno_t ret = get_buffer(dev);218 int ret = get_buffer(dev); 223 219 if (ret != EOK) { 224 220 log_error("Failed to get device buffer: %s", … … 244 240 if (list_count(&source->connections) == 0) { /* Disconnected */ 245 241 assert(!new); 246 errno_t ret = audio_pcm_stop_capture_immediate(dev->sess);242 int ret = audio_pcm_stop_capture_immediate(dev->sess); 247 243 if (ret != EOK) { 248 244 log_error("Failed to start recording: %s", … … 289 285 log_verbose("Capture terminated"); 290 286 dev->source.format = AUDIO_FORMAT_ANY; 291 const errno_t ret = release_buffer(dev);287 const int ret = release_buffer(dev); 292 288 if (ret != EOK) { 293 289 log_error("Failed to release buffer: %s", … … 300 296 log_verbose("Playback Terminated"); 301 297 dev->sink.format = AUDIO_FORMAT_ANY; 302 const errno_t ret = release_buffer(dev);298 const int ret = release_buffer(dev); 303 299 if (ret != EOK) { 304 300 log_error("Failed to release buffer: %s", … … 309 305 } 310 306 case PCM_EVENT_FRAMES_CAPTURED: { 311 const errno_t ret = audio_source_push_data(&dev->source,307 const int ret = audio_source_push_data(&dev->source, 312 308 dev->buffer.position, dev->buffer.fragment_size); 313 309 advance_buffer(dev, dev->buffer.fragment_size); … … 329 325 * @return Error code. 330 326 */ 331 static errno_t device_check_format(audio_sink_t* sink)327 static int device_check_format(audio_sink_t* sink) 332 328 { 333 329 assert(sink); … … 347 343 * @return Error code. 348 344 */ 349 static errno_t get_buffer(audio_device_t *dev)345 static int get_buffer(audio_device_t *dev) 350 346 { 351 347 assert(dev); … … 362 358 size_t preferred_size = 0; 363 359 364 const errno_t ret = audio_pcm_get_buffer(dev->sess, &dev->buffer.base,360 const int ret = audio_pcm_get_buffer(dev->sess, &dev->buffer.base, 365 361 &preferred_size); 366 362 if (ret == EOK) { … … 378 374 * @return Error code. 379 375 */ 380 static errno_t release_buffer(audio_device_t *dev)376 static int release_buffer(audio_device_t *dev) 381 377 { 382 378 assert(dev); 383 379 assert(dev->buffer.base); 384 380 385 const errno_t ret = audio_pcm_release_buffer(dev->sess);381 const int ret = audio_pcm_release_buffer(dev->sess); 386 382 if (ret == EOK) { 387 383 as_area_destroy(dev->buffer.base);
Note:
See TracChangeset
for help on using the changeset viewer.