Changeset f3fced0 in mainline


Ignore:
Timestamp:
2012-07-13T05:39:36Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9b2ac3d
Parents:
63d6ff9
Message:

hound: Implement connect code.

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

Legend:

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

    r63d6ff9 rf3fced0  
    100100        audio_device_t *dev = sink->private_data;
    101101        if (list_count(&sink->sources) == 1) {
     102                log_verbose("First connection on device sink '%s'", sink->name);
     103
    102104                int ret = get_buffer(dev);
    103105                if (ret != EOK) {
     
    106108                        return ret;
    107109                }
     110
    108111                ret = start_playback(dev);
    109112                if (ret != EOK) {
     
    115118        }
    116119        if (list_count(&sink->sources) == 0) {
     120                log_verbose("No connections on device sink '%s'", sink->name);
    117121                int ret = stop_playback(dev);
    118122                if (ret != EOK) {
  • uspace/srv/audio/hound/audio_sink.c

    r63d6ff9 rf3fced0  
    5858        sink->private_data = private_data;
    5959        sink->format = *f;
     60        sink->connection_change = connection_change;
    6061        log_verbose("Initialized sink (%p) '%s'", sink, sink->name);
    6162        return EOK;
     
    9091                                sink->format = AUDIO_FORMAT_DEFAULT;
    9192                        } else {
    92                                 log_verbose("Set format base on the first "
    93                                     "source(%s): %u channels, %uHz, %s for "
    94                                     " sink %s.", source->name,
     93                                log_verbose("Set format based on the first "
     94                                    "source(%s): %u channel(s), %uHz, %s for "
     95                                    "sink %s.", source->name,
    9596                                    source->format.channels,
    9697                                    source->format.sampling_rate,
     
    103104        }
    104105
     106        audio_source_connected(source, sink);
     107
    105108        if (sink->connection_change) {
     109                log_verbose("Calling connection change");
    106110                const int ret = sink->connection_change(sink);
    107111                if (ret != EOK) {
    108112                        log_debug("Connection hook failed.");
     113                        audio_source_connected(source, NULL);
    109114                        list_remove(&source->link);
    110115                        sink->format = old_format;
     
    112117                }
    113118        }
     119        log_verbose("Connected source '%s' to sink '%s'",
     120            source->name, sink->name);
    114121
    115122        return EOK;
  • uspace/srv/audio/hound/hound.c

    r63d6ff9 rf3fced0  
    5555                    audio_ ## type ## _list_instance(it); \
    5656                if (str_cmp(name, dev->name) == 0) { \
    57                         log_debug("%s with name '%s' is already present", \
     57                        log_debug("%s with name '%s' is in the list", \
    5858                            #type, name); \
    5959                        return dev; \
     
    8282        list_initialize(&hound->devices);
    8383        list_initialize(&hound->sources);
    84         list_initialize(&hound->available_sources);
    8584        list_initialize(&hound->sinks);
    8685        return EOK;
     
    202201}
    203202
     203int hound_connect(hound_t *hound, const char* source_name, const char* sink_name)
     204{
     205        assert(hound);
     206        log_verbose("Connecting '%s' to '%s'.", source_name, sink_name);
     207        fibril_mutex_lock(&hound->list_guard);
     208        audio_source_t *source =
     209            find_source_by_name(&hound->sources, source_name);
     210        audio_sink_t *sink = find_sink_by_name(&hound->sinks, sink_name);
     211        if (!source || !sink) {
     212                fibril_mutex_unlock(&hound->list_guard);
     213                log_debug("Sink (%p), or source (%p) not found", sink, source);
     214                return ENOENT;
     215        }
     216        list_remove(&source->link);
     217        const int ret = audio_sink_add_source(sink, source);
     218        if (ret != EOK) {
     219                log_debug("Failed add source to sink list: %s", str_error(ret));
     220                list_append(&source->link, &hound->sources);
     221        }
     222        fibril_mutex_unlock(&hound->list_guard);
     223        return EOK;
     224}
     225
     226int hound_disconnect(hound_t *hound, const char* source_name, const char* sink_name)
     227{
     228        return ENOTSUP;
     229}
    204230/**
    205231 * @}
  • uspace/srv/audio/hound/hound.h

    r63d6ff9 rf3fced0  
    5252        list_t devices;
    5353        list_t sources;
    54         list_t available_sources;
    5554        list_t sinks;
    5655} hound_t;
     
    6059int hound_add_source(hound_t *hound, audio_source_t *source);
    6160int hound_add_sink(hound_t *hound, audio_sink_t *sink);
    62 int hound_connect(const char* source_name, const char* sink_name);
    63 int hound_disconnect(const char* source_name, const char* sink_name);
     61int hound_connect(hound_t *hound, const char* source_name, const char* sink_name);
     62int hound_disconnect(hound_t *hound, const char* source_name, const char* sink_name);
    6463
    6564#endif
  • uspace/srv/audio/hound/main.c

    r63d6ff9 rf3fced0  
    145145                ipc_call_t call;
    146146                ipc_callid_t callid = async_get_call(&call);
    147                 log_debug("Got method %u", IPC_GET_IMETHOD(call));
    148147                switch (IPC_GET_IMETHOD(call)) {
    149148                case HOUND_REGISTER_PLAYBACK: {
     
    209208                }
    210209                case HOUND_CONNECT: {
    211                         //TODO Get Name
    212                         //TODO Get Name
    213                         //TODO connect in hound
     210                        const char *name_a = get_name();
     211                        const char *name_b = get_name();
     212                        const int ret = hound_connect(&hound, name_a, name_b);
     213                        if (ret != EOK)
     214                                log_error("Failed to connect '%s' to '%s': %s",
     215                                    name_a, name_b, str_error(ret));
     216                        free(name_a);
     217                        free(name_b);
     218                        async_answer_0(callid, ret);
    214219                        break;
    215220                }
    216221                case HOUND_DISCONNECT: {
    217                         //TODO Get Name
    218                         //TODO Get Name
    219                         //TODO disconnect in hound
     222                        const char *name_a = get_name();
     223                        const char *name_b = get_name();
     224                        const int ret = hound_disconnect(&hound, name_a, name_b);
     225                        if (ret != EOK)
     226                                log_error("Failed to disconnect '%s' from '%s'"
     227                                    ": %s", name_a, name_b, str_error(ret));
     228                        free(name_a);
     229                        free(name_b);
     230                        async_answer_0(callid, ret);
    220231                        break;
    221232                }
    222233                default:
     234                        log_debug("Got unknown method %u",
     235                            IPC_GET_IMETHOD(call));
    223236                        async_answer_0(callid, ENOTSUP);
    224237                        break;
    225238                case 0:
     239                        //TODO remove all clients
    226240                        return;
    227241                }
Note: See TracChangeset for help on using the changeset viewer.