Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 13df13c8 in mainline


Ignore:
Timestamp:
2012-07-13T19:48:19Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial
Children:
43c40a3
Parents:
ab07cf0
Message:

hound: Fix sink hook ambiguity by adding a parameter.

Also disconnect source when removing instead of failure.

Location:
uspace/srv/audio/hound
Files:
6 edited

Legend:

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

    rab07cf0 r13df13c8  
    5454}
    5555
    56 static int client_sink_connection_change(audio_sink_t *sink);
     56static int client_sink_connection_change(audio_sink_t *sink, bool new);
    5757static int client_source_connection_change(audio_source_t *source);
    5858static int client_source_update_data(audio_source_t *source, size_t size);
     
    105105}
    106106
    107 static int client_sink_connection_change(audio_sink_t *sink)
     107static int client_sink_connection_change(audio_sink_t *sink, bool new)
    108108{
    109109        //TODO create fibril
  • uspace/srv/audio/hound/audio_device.c

    rab07cf0 r13df13c8  
    4949#define BUFFER_BLOCKS 2
    5050
    51 static int device_sink_connection_callback(audio_sink_t *sink);
     51static int device_sink_connection_callback(audio_sink_t *sink, bool new);
    5252static int device_source_connection_callback(audio_source_t *source);
    5353static void device_event_callback(ipc_callid_t iid, ipc_call_t *icall, void *arg);
     
    9595}
    9696
    97 static int device_sink_connection_callback(audio_sink_t* sink)
     97static int device_sink_connection_callback(audio_sink_t* sink, bool new)
    9898{
    9999        assert(sink);
    100100        audio_device_t *dev = sink->private_data;
    101         if (list_count(&sink->sources) == 1) {
     101        if (new && list_count(&sink->sources) == 1) {
    102102                log_verbose("First connection on device sink '%s'", sink->name);
    103103
     
    118118        }
    119119        if (list_count(&sink->sources) == 0) {
     120                assert(!new);
    120121                log_verbose("No connections on device sink '%s'", sink->name);
    121122                int ret = stop_playback(dev);
  • uspace/srv/audio/hound/audio_sink.c

    rab07cf0 r13df13c8  
    4545
    4646int audio_sink_init(audio_sink_t *sink, const char *name,
    47     void *private_data,int (*connection_change)(audio_sink_t *sink),
     47    void *private_data, int (*connection_change)(audio_sink_t *, bool),
    4848    const audio_format_t *f)
    4949{
     
    108108        if (sink->connection_change) {
    109109                log_verbose("Calling connection change");
    110                 const int ret = sink->connection_change(sink);
     110                const int ret = sink->connection_change(sink, true);
    111111                if (ret != EOK) {
    112112                        log_debug("Connection hook failed.");
     
    130130        list_remove(&source->link);
    131131        if (sink->connection_change) {
    132                 const int ret = sink->connection_change(sink);
     132                const int ret = sink->connection_change(sink, false);
    133133                if (ret != EOK) {
    134134                        log_debug("Connected hook failed.");
  • uspace/srv/audio/hound/audio_sink.h

    rab07cf0 r13df13c8  
    4040#include <async.h>
    4141#include <bool.h>
    42 #include <pcm_sample_format.h>
    4342#include <fibril.h>
    4443
     
    5453        audio_format_t format;
    5554        void *private_data;
    56         int (*connection_change)(audio_sink_t *sink);
     55        int (*connection_change)(audio_sink_t *, bool);
    5756};
    5857
     
    6362
    6463int audio_sink_init(audio_sink_t *sink, const char *name,
    65     void *private_data, int (*connection_change)(audio_sink_t *sink),
     64    void *private_data, int (*connection_change)(audio_sink_t *, bool),
    6665    const audio_format_t *f);
    6766void audio_sink_fini(audio_sink_t *sink);
  • uspace/srv/audio/hound/audio_source.c

    rab07cf0 r13df13c8  
    143143        source->available_data.size -= real_size;
    144144
    145         log_verbose("Mixing successful %p <= %p, %zu",
    146             buffer, source->available_data.position, real_size);
     145//      log_verbose("Mixing successful %p <= %p, %zu",
     146//          buffer, source->available_data.position, real_size);
    147147
    148148        buffer += real_size;
  • 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.