Changeset 1f440f5f in mainline
- Timestamp:
- 2013-04-05T14:34:41Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6d74977
- Parents:
- f04603e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/audio/hound/hound_ctx.c
rf04603e r1f440f5f 40 40 #include "hound_ctx.h" 41 41 #include "audio_data.h" 42 #include "connection.h" 42 43 #include "log.h" 44 45 static int update_data(audio_source_t *source, size_t size); 43 46 44 47 hound_ctx_t *hound_record_ctx_get(const char *name) … … 60 63 } 61 64 const int ret = audio_source_init(ctx->source, name, ctx, NULL, 62 NULL, &AUDIO_FORMAT_ANY);65 update_data, &AUDIO_FORMAT_DEFAULT); 63 66 if (ret != EOK) { 64 67 free(ctx->source); … … 95 98 return ctx->source == NULL; 96 99 } 100 97 101 98 102 /* … … 140 144 if (audio_pipe_bytes(&stream->fifo)) 141 145 log_warning("Destroying stream with non empty buffer"); 142 audio_pipe_fini(&stream->fifo);143 146 log_verbose("CTX: %p remove stream (%zu/%zu); " 144 147 "flags:%#x ch: %u r:%u f:%s", … … 147 150 stream->format.channels, stream->format.sampling_rate, 148 151 pcm_sample_format_str(stream->format.sample_format)); 152 audio_pipe_fini(&stream->fifo); 149 153 free(stream); 150 154 } … … 156 160 { 157 161 assert(stream); 158 log_verbose("%p: ,%zu", stream, size);162 log_verbose("%p: %zu", stream, size); 159 163 160 164 if (stream->allowed_size && size > stream->allowed_size) … … 188 192 { 189 193 assert(stream); 194 log_debug("Draining stream"); 190 195 while (audio_pipe_bytes(&stream->fifo)) 191 196 async_usleep(10000); … … 198 203 } 199 204 205 206 int update_data(audio_source_t *source, size_t size) 207 { 208 assert(source); 209 assert(source->private_data); 210 hound_ctx_t *ctx = source->private_data; 211 void *buffer = malloc(size); 212 if (!buffer) 213 return ENOMEM; 214 audio_data_t *adata = audio_data_create(buffer, size, source->format); 215 if (!adata) { 216 free(buffer); 217 return ENOMEM; 218 } 219 log_verbose("CTX: %p. Mixing %zu streams", ctx, 220 list_count(&ctx->streams)); 221 pcm_format_silence(buffer, size, &source->format); 222 list_foreach(ctx->streams, it) { 223 hound_ctx_stream_t *stream = hound_ctx_stream_from_link(it); 224 hound_ctx_stream_add_self(stream, buffer, size, &source->format); 225 } 226 log_verbose("CTX: %p. Pushing audio to %zu connections", ctx, 227 list_count(&source->connections)); 228 list_foreach(source->connections, it) { 229 connection_t *conn = connection_from_source_list(it); 230 connection_push_data(conn, adata); 231 } 232 return EOK; 233 } 234 200 235 /** 201 236 * @}
Note:
See TracChangeset
for help on using the changeset viewer.