Changeset 599034e in mainline for uspace/srv/audio/hound/hound_ctx.c
- Timestamp:
- 2013-04-06T13:11:44Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- eca79ff
- Parents:
- 5c98bb28
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/audio/hound/hound_ctx.c
r5c98bb28 r599034e 56 56 link_initialize(&ctx->link); 57 57 list_initialize(&ctx->streams); 58 fibril_mutex_initialize(&ctx->guard); 58 59 ctx->sink = NULL; 59 60 ctx->source = malloc(sizeof(audio_source_t)); … … 117 118 } 118 119 120 static inline void stream_append(hound_ctx_t *ctx, hound_ctx_stream_t *stream) 121 { 122 assert(ctx); 123 assert(stream); 124 fibril_mutex_lock(&ctx->guard); 125 list_append(&stream->link, &ctx->streams); 126 fibril_mutex_unlock(&ctx->guard); 127 } 128 129 static inline void stream_remove(hound_ctx_t *ctx, hound_ctx_stream_t *stream) 130 { 131 assert(ctx); 132 assert(stream); 133 fibril_mutex_lock(&ctx->guard); 134 list_remove(&stream->link); 135 fibril_mutex_unlock(&ctx->guard); 136 } 137 119 138 hound_ctx_stream_t *hound_ctx_create_stream(hound_ctx_t *ctx, int flags, 120 139 pcm_format_t format, size_t buffer_size) … … 129 148 stream->format = format; 130 149 stream->allowed_size = buffer_size; 131 list_append(&stream->link, &ctx->streams);150 stream_append(ctx, stream); 132 151 log_verbose("CTX: %p added stream; flags:%#x ch: %u r:%u f:%s", 133 152 ctx, flags, format.channels, format.sampling_rate, … … 140 159 { 141 160 if (stream) { 142 //TODO consider DRAIN FLAG 143 list_remove(&stream->link); 161 stream_remove(stream->ctx, stream); 144 162 if (audio_pipe_bytes(&stream->fifo)) 145 163 log_warning("Destroying stream with non empty buffer"); … … 177 195 } 178 196 179 int hound_ctx_stream_add_self(hound_ctx_stream_t *stream, void *data,197 ssize_t hound_ctx_stream_add_self(hound_ctx_stream_t *stream, void *data, 180 198 size_t size, const pcm_format_t *f) 181 199 { … … 185 203 if (copied_size != (ssize_t)size) 186 204 log_warning("Not enough data in stream buffer"); 187 return copied_size > 0 ? EOK : copied_size;205 return copied_size; 188 206 } 189 207 … … 195 213 async_usleep(10000); 196 214 } 197 198 int hound_ctx_stream_add(hound_ctx_stream_t *stream, void *buffer, size_t size,199 pcm_format_t format)200 {201 return ENOTSUP;202 }203 204 215 205 216 int update_data(audio_source_t *source, size_t size) … … 219 230 list_count(&ctx->streams)); 220 231 pcm_format_silence(buffer, size, &source->format); 232 fibril_mutex_lock(&ctx->guard); 221 233 list_foreach(ctx->streams, it) { 222 234 hound_ctx_stream_t *stream = hound_ctx_stream_from_link(it); … … 229 241 connection_push_data(conn, adata); 230 242 } 243 fibril_mutex_unlock(&ctx->guard); 231 244 return EOK; 232 245 }
Note:
See TracChangeset
for help on using the changeset viewer.