Changeset feeac0d in mainline for uspace/srv/audio/hound/hound_ctx.c


Ignore:
Timestamp:
2013-09-10T16:32:35Z (11 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4982d87
Parents:
e8d6ce2
Message:

Simplify use of list_foreach.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/audio/hound/hound_ctx.c

    re8d6ce2 rfeeac0d  
    176176
    177177/**
    178  * List instance helper.
    179  * @param l link
    180  * @return pointer to a hound context structure, NULL on failure.
    181  */
    182 static inline hound_ctx_stream_t *hound_ctx_stream_from_link(link_t *l)
    183 {
    184         return l ? list_get_instance(l, hound_ctx_stream_t, link) : NULL;
    185 }
    186 
    187 /**
    188178 * New stream append helper.
    189179 * @param ctx hound context.
     
    417407        pcm_format_silence(buffer, size, &source->format);
    418408        fibril_mutex_lock(&ctx->guard);
    419         list_foreach(ctx->streams, it) {
    420                 hound_ctx_stream_t *stream = hound_ctx_stream_from_link(it);
     409        list_foreach(ctx->streams, link, hound_ctx_stream_t, stream) {
    421410                ssize_t copied = hound_ctx_stream_add_self(
    422411                    stream, buffer, size, &source->format);
     
    426415        log_verbose("CTX: %p. Pushing audio to %u connections", ctx,
    427416            list_count(&source->connections));
    428         list_foreach(source->connections, it) {
    429                 connection_t *conn = connection_from_source_list(it);
     417        list_foreach(source->connections, source_link, connection_t, conn) {
    430418                connection_push_data(conn, adata);
    431419        }
     
    444432        /* count available data */
    445433        size_t available_frames = -1;  /* this is ugly.... */
    446         list_foreach(sink->connections, it) {
    447                 connection_t *conn = connection_from_source_list(it);
     434        list_foreach(sink->connections, source_link, connection_t, conn) {
    448435                available_frames = min(available_frames,
    449436                    audio_pipe_frames(&conn->fifo));
     
    466453        /* mix data */
    467454        pcm_format_silence(buffer, bsize, &sink->format);
    468         list_foreach(sink->connections, it) {
    469                 connection_t *conn = connection_from_source_list(it);
     455        list_foreach(sink->connections, source_link, connection_t, conn) {
    470456                /* This should not trigger data update on the source */
    471457                const size_t copied = connection_add_source_data(
     
    476462        }
    477463        /* push to all streams */
    478         list_foreach(ctx->streams, it) {
    479                 hound_ctx_stream_t *stream = hound_ctx_stream_from_link(it);
     464        list_foreach(ctx->streams, link, hound_ctx_stream_t, stream) {
    480465                const int ret = stream_push_data(stream, adata);
    481466                if (ret != EOK)
Note: See TracChangeset for help on using the changeset viewer.