diff options
author | fulup <fulup.arfoll@iot.bzh> | 2018-06-10 22:44:07 +0200 |
---|---|---|
committer | Jonathan Aillet <jonathan.aillet@iot.bzh> | 2018-06-11 01:22:18 +0200 |
commit | 9c88fd2aaf454b4ab5d4cfcb5e510196da3b74b4 (patch) | |
tree | 0c1fbe9fe6902712d55e309912c3dcc02107170a /plugins/alsa/alsa-api-sink.c | |
parent | 2838587fc0d118d504e6ef8e04b98f262f29a712 (diff) |
Autorize direct zone to point on sndcard
Diffstat (limited to 'plugins/alsa/alsa-api-sink.c')
-rw-r--r-- | plugins/alsa/alsa-api-sink.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/plugins/alsa/alsa-api-sink.c b/plugins/alsa/alsa-api-sink.c index 02322de..e38621a 100644 --- a/plugins/alsa/alsa-api-sink.c +++ b/plugins/alsa/alsa-api-sink.c @@ -22,23 +22,36 @@ PUBLIC AlsaPcmHwInfoT *ApiSinkGetParamsByZone(SoftMixerT *mixer, const char *target) { + // try to attach a zone as stream playback sink AlsaSndZoneT *zone = ApiZoneGetByUid(mixer, target); - if (!zone || !zone->sinks) return NULL; + if (zone && zone->sinks) { - // use 1st channel to find attached sound card. - const char *channel = zone->sinks[0]->uid; + // use 1st channel to find attached sound card. + const char *channel = zone->sinks[0]->uid; - // search for channel uid into mixer sinks - for (int idx = 0; mixer->sinks[idx]; idx++) { - for (int jdx = 0; jdx < mixer->sinks[idx]->ccount; jdx++) { - if (mixer->sinks[idx]->channels[jdx]->uid && !strcasecmp(channel, mixer->sinks[idx]->channels[jdx]->uid)) { - return mixer->sinks[idx]->sndcard->params; + // search for channel uid into mixer sinks and derive sound card + for (int idx = 0; mixer->sinks[idx]; idx++) { + for (int jdx = 0; jdx < mixer->sinks[idx]->ccount; jdx++) { + if (mixer->sinks[idx]->channels[jdx]->uid && !strcasecmp(channel, mixer->sinks[idx]->channels[jdx]->uid)) { + return mixer->sinks[idx]->sndcard->params; + } } } } return NULL; } +PUBLIC AlsaSndPcmT *ApiSinkGetByUid(SoftMixerT *mixer, const char *target) { + // if no attached zone found, then try direct sink attachment + for (int idx = 0; mixer->sinks[idx]; idx++) { + if (mixer->sinks[idx]->uid && !strcasecmp(mixer->sinks[idx]->uid, target)) { + return mixer->sinks[idx]; + } + } + + return NULL; +} + PUBLIC int ApiSinkAttach(SoftMixerT *mixer, AFB_ReqT request, const char *uid, json_object * argsJ) { int index; |