diff options
author | Thierry Bultel <thierry.bultel@iot.bzh> | 2019-05-13 14:30:01 +0200 |
---|---|---|
committer | Thierry Bultel <thierry.bultel@iot.bzh> | 2019-05-14 15:14:20 +0200 |
commit | b5206132b6fb5b060acacaf2aee45841a7792a8c (patch) | |
tree | ef69b33d17629f6eddd249eadc7f2c446557620a /plugins/alsa/alsa-plug-route.c | |
parent | 6c627f8650b88b19704dd4e513fe7fff701c00c1 (diff) | |
parent | 43df82896d8535f99233b4d3ab35a744b07871e0 (diff) |
Merge branch 'sandbox/tbultel/spec-2387' into guppyguppy_7.0.4guppy_7.0.3guppy_7.0.2guppy/7.0.4guppy/7.0.3guppy/7.0.27.0.47.0.37.0.2guppy
Bug AGL: SPEC-2387
This brings the following commits from master:
* 43df828 loops/avirt: forget saved loops after creation
* 622096c plug route: added a calculation for the number of physical c..
* c950295 streams: improved log output
* 7520fbf core-pcm: fixed channels setting issues
* 293fe69 core pcm: use the same model for writing and reading audio
* e355716 pcm plugs: rework the alsa config cleanup
* eb45566 alsa-api-pcm: added an 'optional' parameter
* 93bf6e6 alsa-transaction: simplify the cleanup
* bb70b48 alsa-api-pcm: added support of quirks
* 93ca785 alsa-utils-dump: added missing ending null char
Change-Id: I8ccc641b1f6827873e479185c0098d732d1b2b0a
Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
Diffstat (limited to 'plugins/alsa/alsa-plug-route.c')
-rw-r--r-- | plugins/alsa/alsa-plug-route.c | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/plugins/alsa/alsa-plug-route.c b/plugins/alsa/alsa-plug-route.c index a192e03..021ef44 100644 --- a/plugins/alsa/alsa-plug-route.c +++ b/plugins/alsa/alsa-plug-route.c @@ -23,6 +23,14 @@ ALSA_PLUG_PROTO(route); +static void routeConfigClean(SoftMixerT *mixer, void * arg) { + snd_config_t * routeConfig = arg; + AFB_API_DEBUG(mixer->api, "%s... route config", __func__); + snd_config_delete(routeConfig); + snd_config_update(); +} + + typedef struct { const char *uid; const char *cardid; @@ -31,6 +39,7 @@ typedef struct { int ccount; int port; bool isPcmPlug; + unsigned int quirks; } ChannelCardPortT; STATIC int CardChannelByUid(SoftMixerT *mixer, const char *uid, ChannelCardPortT *response) { @@ -59,6 +68,7 @@ STATIC int CardChannelByUid(SoftMixerT *mixer, const char *uid, ChannelCardPortT response->cardidx = pcm->sndcard->cid.cardidx; response->pcmplug_params = pcm->sndcard->cid.pcmplug_params; response->isPcmPlug= pcm->isPcmPlug; + response->quirks = pcm->quirks; found = true; break; } @@ -79,7 +89,7 @@ OnErrorExit: } PUBLIC AlsaPcmCtlT* AlsaCreateRoute(SoftMixerT *mixer, AlsaSndZoneT *zone, int open) { - snd_config_t *routeConfig, *elemConfig, *slaveConfig, *tableConfig, *pcmConfig; + snd_config_t *routeConfig = NULL, *elemConfig, *slaveConfig, *tableConfig, *pcmConfig; int error = 0; ChannelCardPortT slave, channelCardPort; AlsaPcmCtlT *pcmRoute = NULL; @@ -151,15 +161,21 @@ PUBLIC AlsaPcmCtlT* AlsaCreateRoute(SoftMixerT *mixer, AlsaSndZoneT *zone, int o pcmRoute->isPcmPlug = true; } + pcmRoute->quirks = slave.quirks; + // temporary store to enable multiple channel to route to the same port snd_config_t **cports = alloca(zone->nbSinks * sizeof (void*)); memset(cports, 0, zone->nbSinks * sizeof (void*)); - int zcount = 0; + int portCount = 0; // We create 1st ttable to retrieve sndcard slave and channel count (void)snd_config_make_compound(&tableConfig, "ttable", 0); + // used physical ports + bool targets[16]; + memset(targets, 0, sizeof(targets)); + cds_list_for_each_entry(channel, &zone->sinks.list, list) { AFB_ApiDebug(mixer->api, "%s: zone->sink channel %s ", __func__, channel->uid); @@ -180,12 +196,17 @@ PUBLIC AlsaPcmCtlT* AlsaCreateRoute(SoftMixerT *mixer, AlsaSndZoneT *zone, int o int target = channelCardPort.port; int port = channel->port; + if (!targets[target]) { + zone->physicalChannelCount++; + targets[target] = true; + } + double volume = 1.0; // currently only support 100% // if channel entry does not exist into ttable create it now if (!cports[port]) { - char channelS[4]; // 999 channel should be more than enough + char channelS[4]; // 999 channels should be more than enough snprintf(channelS, sizeof (channelS), "%d", port); error = snd_config_make_compound(&cports[port], channelS, 0); @@ -201,7 +222,7 @@ PUBLIC AlsaPcmCtlT* AlsaCreateRoute(SoftMixerT *mixer, AlsaSndZoneT *zone, int o } } - zcount++; + portCount++; // ttable require target port as a table and volume as a value char targetS[4]; @@ -227,8 +248,10 @@ PUBLIC AlsaPcmCtlT* AlsaCreateRoute(SoftMixerT *mixer, AlsaSndZoneT *zone, int o } // update zone with route channel count and sndcard params - pcmRoute->ccount = zcount; - zone->ccount=zcount; + pcmRoute->ccount = portCount; + zone->ccount=portCount; + + AFB_API_DEBUG(mixer->api, "%s: ZONE has %d ports and %d hardware channels", __func__, zone->ccount, zone->physicalChannelCount); // refresh global alsalib config and create PCM top config snd_config_update(); @@ -275,7 +298,8 @@ PUBLIC AlsaPcmCtlT* AlsaCreateRoute(SoftMixerT *mixer, AlsaSndZoneT *zone, int o goto fail; } - zone->routeConfig = routeConfig; + pcmRoute->private_data = routeConfig; + pcmRoute->private_data_clean = routeConfigClean; // Debug config & pcm AFB_ApiNotice(mixer->api, "%s: zone(%s) DONE", __func__, zone->uid); |