Ignore:
Timestamp:
2013-04-02T19:06:27Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
35ab943
Parents:
39c4d1f
Message:

hound: add connection class

This will enable N to M routing in the future

File:
1 edited

Legend:

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

    r39c4d1f rfa60cd69  
    4747
    4848int audio_source_init(audio_source_t *source, const char *name, void *data,
    49     int (*connection_change)(audio_source_t *),
     49    int (*connection_change)(audio_source_t *, bool new),
    5050    int (*update_available_data)(audio_source_t *, size_t),
    5151    const pcm_format_t *f)
     
    5757        }
    5858        link_initialize(&source->link);
     59        list_initialize(&source->connections);
    5960        source->name = str_dup(name);
    6061        source->private_data = data;
    6162        source->connection_change = connection_change;
    6263        source->update_available_data = update_available_data;
    63         source->connected_sink = NULL;
    6464        source->format = *f;
    6565        source->available_data.base = NULL;
     
    7373{
    7474        assert(source);
    75         assert(source->connected_sink == NULL);
    7675        free(source->name);
    7776        source->name = NULL;
    78 }
    79 
    80 int audio_source_connected(audio_source_t *source, struct audio_sink *sink)
    81 {
    82         assert(source);
    83         audio_sink_t *old_sink = source->connected_sink;
    84         const pcm_format_t old_format = source->format;
    85 
    86         source->connected_sink = sink;
    87         if (pcm_format_is_any(&source->format)) {
    88                 assert(sink);
    89                 assert(!pcm_format_is_any(&sink->format));
    90                 source->format = sink->format;
    91         }
    92         if (source->connection_change) {
    93                 const int ret = source->connection_change(source);
    94                 if (ret != EOK) {
    95                         source->format = old_format;
    96                         source->connected_sink = old_sink;
    97                         return ret;
    98                 }
    99         }
    100         return EOK;
    10177}
    10278
Note: See TracChangeset for help on using the changeset viewer.