summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Bultel <thierry.bultel@iot.bzh>2018-09-07 15:52:28 +0200
committerThierry Bultel <thierry.bultel@iot.bzh>2018-09-07 15:52:28 +0200
commit168e9288f1ff147d9aaa6064c3cc0308fd214a6a (patch)
treefa9213e3c95ce974dd5d4e6196b9405cd0494e7d
parent80deafbe1bfb87c3a5e9f547c9491afd210e736a (diff)
dmix: used device when in name of slave
When a sound card has multiple devices, it is invalid to set the slave name of the dmix as "hw:cardname" because alsa does not know which device to use. The fix consists in using the device number, when it is given. Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
-rw-r--r--plugins/alsa/alsa-plug-dmix.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/plugins/alsa/alsa-plug-dmix.c b/plugins/alsa/alsa-plug-dmix.c
index df525cb..3c6d62e 100644
--- a/plugins/alsa/alsa-plug-dmix.c
+++ b/plugins/alsa/alsa-plug-dmix.c
@@ -27,19 +27,37 @@ ALSA_PLUG_PROTO(dmix);
PUBLIC AlsaPcmCtlT* AlsaCreateDmix(SoftMixerT *mixer, const char* pcmName, AlsaSndPcmT *pcmSlave, int open) {
- snd_config_t *dmixConfig, *slaveConfig, *elemConfig, *pcmConfig;
+ snd_config_t *dmixConfig = NULL, *slaveConfig = NULL, *elemConfig = NULL, *pcmConfig=NULL;
AlsaPcmCtlT *pcmPlug= calloc(1,sizeof(AlsaPcmCtlT));
AlsaSndCtlT *sndSlave=pcmSlave->sndcard;
pcmPlug->cid.cardid=pcmName;
+ char * fullPcmName = NULL;
int error=0;
- AFB_ApiInfo(mixer->api, "%s: %s, slave %s, cardid %s\n", __func__, pcmName, pcmSlave->uid, pcmSlave->sndcard->cid.cardid);
+ AFB_ApiInfo(mixer->api, "%s: %s, slave %s, cardid %s (dev %d, subdev %d)\n",
+ __func__,
+ pcmName,
+ pcmSlave->uid,
+ sndSlave->cid.cardid,
+ sndSlave->cid.device,
+ sndSlave->cid.subdev
+ );
+
+ error = asprintf(&fullPcmName,"%s,%d,%d", sndSlave->cid.cardid, sndSlave->cid.device, sndSlave->cid.subdev);
+ if (error == -1) {
+ AFB_ApiError(mixer->api,
+ "%s: Insufficient memory",
+ __func__);
+ goto OnErrorExit;
+ }
- error += snd_config_top(&dmixConfig);
+ error = snd_config_top(&dmixConfig);
if (error) goto OnErrorExit;
- error += snd_config_set_id (dmixConfig, pcmPlug->cid.cardid);
+
+ error += snd_config_set_id (dmixConfig, pcmName);
if (error) goto OnErrorExit;
+
error += snd_config_imake_string(&elemConfig, "type", "dmix");
if (error) goto OnErrorExit;
error += snd_config_add(dmixConfig, elemConfig);
@@ -51,7 +69,7 @@ PUBLIC AlsaPcmCtlT* AlsaCreateDmix(SoftMixerT *mixer, const char* pcmName, AlsaS
error += snd_config_make_compound(&slaveConfig, "slave", 0);
if (error) goto OnErrorExit;
- error += snd_config_imake_string(&elemConfig, "pcm", sndSlave->cid.cardid);
+ error += snd_config_imake_string(&elemConfig, "pcm", fullPcmName);
if (error) goto OnErrorExit;
error += snd_config_add(slaveConfig, elemConfig);
if (error) goto OnErrorExit;
@@ -105,8 +123,12 @@ PUBLIC AlsaPcmCtlT* AlsaCreateDmix(SoftMixerT *mixer, const char* pcmName, AlsaS
return pcmPlug;
OnErrorExit:
+
+ free(fullPcmName);
+
AlsaDumpCtlConfig(mixer, "plug-pcm", pcmConfig, 1);
AlsaDumpCtlConfig(mixer, "plug-dmix", dmixConfig, 1);
+
AFB_ApiNotice(mixer->api, "%s: FAIL", __func__);
return NULL;
}