Changeset 13df13c8 in mainline for uspace/srv/audio/hound/hound.c


Ignore:
Timestamp:
2012-07-13T19:48:19Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
43c40a3
Parents:
ab07cf0
Message:

hound: Fix sink hook ambiguity by adding a parameter.

Also disconnect source when removing instead of failure.

File:
1 edited

Legend:

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

    rab07cf0 r13df13c8  
    7575        FIND_BY_NAME(sink);
    7676}
     77static int hound_disconnect_internal(hound_t *hound, const char* source_name, const char* sink_name);
    7778
    7879int hound_init(hound_t *hound)
     
    209210        fibril_mutex_lock(&hound->list_guard);
    210211        if (!list_member(&source->link, &hound->sources)) {
    211                 fibril_mutex_unlock(&hound->list_guard);
    212                 return EBUSY;
     212                assert(source->connected_sink);
     213                hound_disconnect_internal(hound, source->name,
     214                    source->connected_sink->name);
    213215        }
    214216        list_remove(&source->link);
     
    224226        log_verbose("Removing sink '%s'.", sink->name);
    225227        fibril_mutex_lock(&hound->list_guard);
     228
    226229        if (!list_empty(&sink->sources)) {
     230                // TODO disconnect instead
    227231                fibril_mutex_unlock(&hound->list_guard);
    228232                return EBUSY;
     
    259263{
    260264        assert(hound);
     265        fibril_mutex_lock(&hound->list_guard);
     266        const int ret = hound_disconnect_internal(hound, source_name, sink_name);
     267        fibril_mutex_unlock(&hound->list_guard);
     268        return ret;
     269}
     270
     271static int hound_disconnect_internal(hound_t *hound, const char* source_name, const char* sink_name)
     272{
     273        assert(hound);
     274        assert(fibril_mutex_is_locked(&hound->list_guard));
    261275        log_verbose("Disconnecting '%s' to '%s'.", source_name, sink_name);
    262         fibril_mutex_lock(&hound->list_guard);
    263276        audio_sink_t *sink = find_sink_by_name(&hound->sinks, sink_name);
    264277        audio_source_t *source = sink ?  find_source_by_name(&sink->sources, source_name) : NULL;
    265278        if (!source || !sink) {
    266                 fibril_mutex_unlock(&hound->list_guard);
    267279                log_debug("Source (%p), or sink (%p) not found", source, sink);
    268280                return ENOENT;
     
    274286                list_append(&source->link, &hound->sources);
    275287        }
    276         fibril_mutex_unlock(&hound->list_guard);
    277         return EOK;
    278         return ENOTSUP;
     288        return EOK;
    279289}
    280290/**
Note: See TracChangeset for help on using the changeset viewer.