aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/alsa/alsa-plug-dmix.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/alsa/alsa-plug-dmix.c')
-rw-r--r--plugins/alsa/alsa-plug-dmix.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/plugins/alsa/alsa-plug-dmix.c b/plugins/alsa/alsa-plug-dmix.c
index 3d67410..e28d009 100644
--- a/plugins/alsa/alsa-plug-dmix.c
+++ b/plugins/alsa/alsa-plug-dmix.c
@@ -28,14 +28,16 @@ ALSA_PLUG_PROTO(dmix);
PUBLIC AlsaPcmInfoT* AlsaCreateDmix(CtlSourceT *source, const char* pcmName, AlsaPcmInfoT *pcmSlave) {
snd_config_t *dmixConfig, *slaveConfig, *elemConfig, *pcmConfig;
- AlsaPcmInfoT *pcmPlug= malloc(sizeof(AlsaPcmInfoT));
- pcmPlug->devid= pcmName;
+ AlsaPcmInfoT *pcmPlug= calloc(1,sizeof(AlsaPcmInfoT));
+ pcmPlug->uid= strdup(pcmName);
+ pcmPlug->cardid=pcmPlug->uid;
+
int error=0;
// refresh global alsalib config and create PCM top config
snd_config_update();
error += snd_config_top(&dmixConfig);
- error += snd_config_set_id (dmixConfig, pcmPlug->devid);
+ error += snd_config_set_id (dmixConfig, pcmPlug->cardid);
error += snd_config_imake_string(&elemConfig, "type", "dmix");
error += snd_config_add(dmixConfig, elemConfig);
error += snd_config_imake_integer(&elemConfig, "ipc_key", uniqueIpcIndex++);
@@ -43,7 +45,11 @@ PUBLIC AlsaPcmInfoT* AlsaCreateDmix(CtlSourceT *source, const char* pcmName, Als
if (error) goto OnErrorExit;
error += snd_config_make_compound(&slaveConfig, "slave", 0);
- error += snd_config_imake_string(&elemConfig, "pcm", pcmSlave->devid);
+ error += snd_config_imake_string(&elemConfig, "pcm", pcmSlave->cardid);
+ if (pcmSlave->params.rate) {
+ error += snd_config_add(slaveConfig, elemConfig);
+ error += snd_config_imake_integer(&elemConfig, "rate", pcmSlave->params.rate);
+ }
error += snd_config_add(slaveConfig, elemConfig);
if (error) goto OnErrorExit;
@@ -51,26 +57,27 @@ PUBLIC AlsaPcmInfoT* AlsaCreateDmix(CtlSourceT *source, const char* pcmName, Als
error += snd_config_add(dmixConfig, slaveConfig);
if (error) goto OnErrorExit;
- error = _snd_pcm_dmix_open(&pcmPlug->handle, pcmPlug->devid, snd_config, dmixConfig, SND_PCM_STREAM_PLAYBACK , SND_PCM_NONBLOCK);
+ error = _snd_pcm_dmix_open(&pcmPlug->handle, pcmPlug->cardid, snd_config, dmixConfig, SND_PCM_STREAM_PLAYBACK , SND_PCM_NONBLOCK);
if (error) {
- AFB_ApiError(source->api, "AlsaCreateDmix: fail to create DMIX=%s SLAVE=%s", pcmPlug->devid, pcmSlave->devid);
+ AFB_ApiError(source->api, "AlsaCreateDmix: fail to create Dmix=%s Slave=%s Error=%s", pcmPlug->cardid, pcmSlave->cardid, snd_strerror(error));
goto OnErrorExit;
}
error += snd_config_search(snd_config, "pcm", &pcmConfig);
error += snd_config_add(pcmConfig, dmixConfig);
if (error) {
- AFB_ApiError(source->api, "AlsaCreateDmix: fail to add configDMIX=%s", pcmPlug->devid);
+ AFB_ApiError(source->api, "AlsaCreateDmix: fail to add configDMIX=%s", pcmPlug->cardid);
goto OnErrorExit;
}
// Debug config & pcm
- AlsaDumpCtlConfig (source, dmixConfig, 1);
- //AlsaDumpPcmInfo(source, pcmPlug->handle, pcmPlug->devid);
- AFB_ApiNotice(source->api, "AlsaCreateDmix: %s done", pcmPlug->devid);
+ AlsaDumpCtlConfig (source, "plug-dmix", dmixConfig, 1);
+ //AlsaDumpPcmInfo(source, pcmPlug->handle, pcmPlug->cardid);
+ AFB_ApiNotice(source->api, "AlsaCreateDmix: %s done\n", pcmPlug->cardid);
return pcmPlug;
OnErrorExit:
- AFB_ApiNotice(source->api, "AlsaCreateDmix: OnErrorExit");
+ AlsaDumpCtlConfig(source, "plug-dmix", dmixConfig, 1);
+ AFB_ApiNotice(source->api, "AlsaCreateDmix: OnErrorExit\n");
return NULL;
} \ No newline at end of file