Changeset 6da3baec in mainline for uspace/srv/audio/hound/hound.c


Ignore:
Timestamp:
2013-04-03T21:25:28Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
be7eccf
Parents:
8f8ec69
Message:

hound: fix ctx removal.

warn if still connected

File:
1 edited

Legend:

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

    r8f8ec69 r6da3baec  
    7979static int hound_disconnect_internal(hound_t *hound, const char* source_name, const char* sink_name);
    8080
     81static void hound_remove_sink_internal(hound_t *hound, audio_sink_t *sink)
     82{
     83        assert(hound);
     84        assert(sink);
     85        log_verbose("Removing sink '%s'.", sink->name);
     86        if (!list_empty(&sink->connections))
     87                log_warning("Removing sink '%s' while still connected.", sink->name);
     88        while (!list_empty(&sink->connections)) {
     89                connection_t *conn =
     90                    connection_from_sink_list(list_first(&sink->connections));
     91                list_remove(&conn->hound_link);
     92                connection_destroy(conn);
     93        }
     94        list_remove(&sink->link);
     95}
     96
     97static void hound_remove_source_internal(hound_t *hound, audio_source_t *source)
     98{
     99        assert(hound);
     100        assert(source);
     101        log_verbose("Removing source '%s'.", source->name);
     102        if (!list_empty(&source->connections))
     103                log_warning("Removing source '%s' while still connected.", source->name);
     104        while (!list_empty(&source->connections)) {
     105                connection_t *conn =
     106                    connection_from_source_list(list_first(&source->connections));
     107                assert(conn);
     108                list_remove(&conn->hound_link);
     109                connection_destroy(conn);
     110        }
     111        list_remove(&source->link);
     112}
     113
    81114int hound_init(hound_t *hound)
    82115{
     
    117150        fibril_mutex_lock(&hound->list_guard);
    118151        list_remove(&ctx->link);
     152        if (ctx->source)
     153                hound_remove_source_internal(hound, ctx->source);
     154        if (ctx->sink)
     155                hound_remove_sink_internal(hound, ctx->sink);
    119156        fibril_mutex_unlock(&hound->list_guard);
    120157        return EOK;
     
    250287        if (!source)
    251288                return EINVAL;
    252         log_verbose("Removing source '%s'.", source->name);
    253         fibril_mutex_lock(&hound->list_guard);
    254 
    255         list_remove(&source->link);
    256         fibril_mutex_unlock(&hound->list_guard);
    257         return EOK;
    258 }
     289        fibril_mutex_lock(&hound->list_guard);
     290        hound_remove_source_internal(hound, source);
     291        fibril_mutex_unlock(&hound->list_guard);
     292        return EOK;
     293}
     294
    259295
    260296int hound_remove_sink(hound_t *hound, audio_sink_t *sink)
     
    263299        if (!sink)
    264300                return EINVAL;
    265         log_verbose("Removing sink '%s'.", sink->name);
    266         fibril_mutex_lock(&hound->list_guard);
    267 
    268         if (!list_empty(&sink->connections)) {
    269                 // TODO disconnect instead
    270                 fibril_mutex_unlock(&hound->list_guard);
    271                 return EBUSY;
    272         }
    273         list_remove(&sink->link);
     301        fibril_mutex_lock(&hound->list_guard);
     302        hound_remove_sink_internal(hound, sink);
    274303        fibril_mutex_unlock(&hound->list_guard);
    275304        return EOK;
     
    383412        list_append(&conn->hound_link, &hound->connections);
    384413        fibril_mutex_unlock(&hound->list_guard);
    385         log_debug("CONNECTED: %s -> %s", source_name, sink_name);
    386414        return EOK;
    387415}
     
    396424}
    397425
    398 static int hound_disconnect_internal(hound_t *hound, const char* source_name, const char* sink_name)
     426static int hound_disconnect_internal(hound_t *hound, const char* source_name,
     427    const char* sink_name)
    399428{
    400429        assert(hound);
Note: See TracChangeset for help on using the changeset viewer.