From e355716f6bac57615195333559a746e283e22060 Mon Sep 17 00:00:00 2001 From: Thierry Bultel Date: Wed, 13 Feb 2019 11:59:45 +0100 Subject: pcm plugs: rework the alsa config cleanup The alsa config (for softvol, routes, rate conversion ...) was cleaned up by the owner stream or zone, at their deletion time. This was a mistake, because when the stream or zone creation was not complete, the cleanup of the configuration was not done. Instead of doing that, the config is attached to the plug objects as private data (in the AlsaPcmCtlT structure). Since the AlsaPcmCtlT are always recorded in the creation transaction, it is easy to call the cleaning callback (when it exists) when the transaction is deleted. Change-Id: I952871518a20bfe0be6398887bc747338cf574fb Signed-off-by: Thierry Bultel --- plugins/alsa/alsa-plug-dmix.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'plugins/alsa/alsa-plug-dmix.c') diff --git a/plugins/alsa/alsa-plug-dmix.c b/plugins/alsa/alsa-plug-dmix.c index 9aaf866..bb58a29 100644 --- a/plugins/alsa/alsa-plug-dmix.c +++ b/plugins/alsa/alsa-plug-dmix.c @@ -24,6 +24,13 @@ static int uniqueIpcIndex = 1024; ALSA_PLUG_PROTO(dmix); +static void dmixConfigClean(SoftMixerT *mixer, void * arg) { + snd_config_t * dmixConfig = arg; + AFB_API_DEBUG(mixer->api, "%s... ", __func__); + snd_config_delete(dmixConfig); + snd_config_update(); +} + PUBLIC AlsaPcmCtlT* AlsaCreateDmix(SoftMixerT *mixer, const char* pcmName, AlsaSndPcmT *pcmSlave, int open) { @@ -92,7 +99,7 @@ PUBLIC AlsaPcmCtlT* AlsaCreateDmix(SoftMixerT *mixer, const char* pcmName, AlsaS if (error) goto OnErrorExit; } - /* It is critical to set the right number of channels ... know. + /* It is critical to set the right number of channels ... now. * Trying to set another value later leads to silent failure * */ @@ -121,6 +128,9 @@ PUBLIC AlsaPcmCtlT* AlsaCreateDmix(SoftMixerT *mixer, const char* pcmName, AlsaS goto OnErrorExit; } + pcmPlug->private_data = dmixConfig; + pcmPlug->private_data_clean = dmixConfigClean; + // Debug config & pcm AlsaDumpCtlConfig(mixer, "plug-dmix", dmixConfig, 1); AFB_ApiNotice(mixer->api, "%s: %s done", __func__, pcmPlug->cid.cardid); -- cgit 1.2.3-korg