Changes in uspace/srv/audio/hound/hound_ctx.c [38d150e:b7fd2a0] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/audio/hound/hound_ctx.c
r38d150e rb7fd2a0 45 45 #include "log.h" 46 46 47 static int update_data(audio_source_t *source, size_t size);48 static int new_data(audio_sink_t *sink);47 static errno_t update_data(audio_source_t *source, size_t size); 48 static errno_t new_data(audio_sink_t *sink); 49 49 50 50 /** … … 68 68 return NULL; 69 69 } 70 const int ret = audio_sink_init(ctx->sink, name, ctx, NULL,70 const errno_t ret = audio_sink_init(ctx->sink, name, ctx, NULL, 71 71 NULL, new_data, &AUDIO_FORMAT_DEFAULT); 72 72 if (ret != EOK) { … … 99 99 return NULL; 100 100 } 101 const int ret = audio_source_init(ctx->source, name, ctx, NULL,101 const errno_t ret = audio_source_init(ctx->source, name, ctx, NULL, 102 102 update_data, &AUDIO_FORMAT_DEFAULT); 103 103 if (ret != EOK) { … … 199 199 * @return Error code. 200 200 */ 201 static int stream_push_data(hound_ctx_stream_t *stream, audio_data_t *adata)201 static errno_t stream_push_data(hound_ctx_stream_t *stream, audio_data_t *adata) 202 202 { 203 203 assert(stream); … … 216 216 } 217 217 218 const int ret = audio_pipe_push(&stream->fifo, adata);218 const errno_t ret = audio_pipe_push(&stream->fifo, adata); 219 219 fibril_mutex_unlock(&stream->guard); 220 220 if (ret == EOK) … … 297 297 * @return Error code. 298 298 */ 299 int hound_ctx_stream_write(hound_ctx_stream_t *stream, const void *data,299 errno_t hound_ctx_stream_write(hound_ctx_stream_t *stream, const void *data, 300 300 size_t size) 301 301 { … … 312 312 } 313 313 314 const int ret =314 const errno_t ret = 315 315 audio_pipe_push_data(&stream->fifo, data, size, stream->format); 316 316 fibril_mutex_unlock(&stream->guard); … … 327 327 * @return Error code. 328 328 */ 329 int hound_ctx_stream_read(hound_ctx_stream_t *stream, void *data, size_t size)329 errno_t hound_ctx_stream_read(hound_ctx_stream_t *stream, void *data, size_t size) 330 330 { 331 331 assert(stream); … … 340 340 341 341 pcm_format_silence(data, size, &stream->format); 342 const int ret =342 const size_t ret = 343 343 audio_pipe_mix_data(&stream->fifo, data, size, &stream->format); 344 344 fibril_mutex_unlock(&stream->guard); 345 if (ret == EOK)345 if (ret > 0) { 346 346 fibril_condvar_signal(&stream->change); 347 return ret; 347 return EOK; 348 } 349 return EEMPTY; 348 350 } 349 351 … … 354 356 * @param size Size of the @p data buffer. 355 357 * @param format Destination data format. 356 * @return Size of the destination buffer touch with stream's data, 357 * error code on failure. 358 */ 359 ssize_t hound_ctx_stream_add_self(hound_ctx_stream_t *stream, void *data, 358 * @return Size of the destination buffer touch with stream's data. 359 */ 360 size_t hound_ctx_stream_add_self(hound_ctx_stream_t *stream, void *data, 360 361 size_t size, const pcm_format_t *f) 361 362 { 362 363 assert(stream); 363 364 fibril_mutex_lock(&stream->guard); 364 const int ret = audio_pipe_mix_data(&stream->fifo, data, size, f);365 const size_t ret = audio_pipe_mix_data(&stream->fifo, data, size, f); 365 366 fibril_condvar_signal(&stream->change); 366 367 fibril_mutex_unlock(&stream->guard); … … 390 391 * Mixes data from all streams and pushes it to all connections. 391 392 */ 392 int update_data(audio_source_t *source, size_t size)393 errno_t update_data(audio_source_t *source, size_t size) 393 394 { 394 395 assert(source); … … 424 425 } 425 426 426 int new_data(audio_sink_t *sink)427 errno_t new_data(audio_sink_t *sink) 427 428 { 428 429 assert(sink); … … 457 458 list_foreach(sink->connections, source_link, connection_t, conn) { 458 459 /* This should not trigger data update on the source */ 459 con st size_t copied = connection_add_source_data(460 connection_add_source_data( 460 461 conn, buffer, bsize, sink->format); 461 if (copied != bsize)462 log_error("Copied less than advertised data, "463 "something is wrong");464 462 } 465 463 /* push to all streams */ 466 464 list_foreach(ctx->streams, link, hound_ctx_stream_t, stream) { 467 const int ret = stream_push_data(stream, adata);465 const errno_t ret = stream_push_data(stream, adata); 468 466 if (ret != EOK) 469 467 log_error("Failed to push data to stream: %s",
Note:
See TracChangeset
for help on using the changeset viewer.