Ignore:
Timestamp:
2013-04-02T19:06:27Z (13 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_device.c

    r39c4d1f rfa60cd69  
    4949
    5050static int device_sink_connection_callback(audio_sink_t *sink, bool new);
    51 static int device_source_connection_callback(audio_source_t *source);
     51static int device_source_connection_callback(audio_source_t *source, bool new);
    5252static void device_event_callback(ipc_callid_t iid, ipc_call_t *icall, void *arg);
    5353static int device_check_format(audio_sink_t* sink);
     
    9494        assert(sink);
    9595        audio_device_t *dev = sink->private_data;
    96         if (new && list_count(&sink->sources) == 1) {
     96        if (new && list_count(&sink->connections) == 1) {
    9797                log_verbose("First connection on device sink '%s'", sink->name);
    9898
     
    104104                }
    105105                audio_pcm_register_event_callback(dev->sess,
    106                     device_event_callback, dev);
     106                    device_event_callback, dev);\
     107                // TODO set formats
    107108
    108109                /* Fill the buffer first */
     
    110111                    dev->buffer.base, dev->buffer.size);
    111112
     113                log_verbose("Mixed inputs: %zu/(%u * %u)",
     114                    dev->buffer.size, BUFFER_PARTS, pcm_format_frame_size(&dev->sink.format));
    112115                const unsigned frames = dev->buffer.size /
    113116                    (BUFFER_PARTS * pcm_format_frame_size(&dev->sink.format));
     117                log_verbose("FRAME COUNT %u", frames);
    114118                ret = audio_pcm_start_playback_fragment(dev->sess, frames,
    115119                    dev->sink.format.channels, dev->sink.format.sampling_rate,
     
    122126                }
    123127        }
    124         if (list_count(&sink->sources) == 0) {
     128        if (list_count(&sink->connections) == 0) {
    125129                assert(!new);
    126130                log_verbose("No connections on device sink '%s'", sink->name);
     
    142146}
    143147
    144 static int device_source_connection_callback(audio_source_t *source)
     148static int device_source_connection_callback(audio_source_t *source, bool new)
    145149{
    146150        assert(source);
    147151        audio_device_t *dev = source->private_data;
    148         if (source->connected_sink) {
     152        if (new && list_count(&source->connections)) {
    149153                int ret = get_buffer(dev);
    150154                if (ret != EOK) {
     
    164168                        return ret;
    165169                }
    166         } else { /* Disconnected */
     170        }
     171        if (list_count(&source->connections) == 0) { /* Disconnected */
     172                assert(!new);
    167173                int ret = audio_pcm_stop_capture(dev->sess);
    168174                if (ret != EOK) {
Note: See TracChangeset for help on using the changeset viewer.