summaryrefslogtreecommitdiffstats
path: root/plugins/alsa/alsa-plug-rate.c
diff options
context:
space:
mode:
authorThierry Bultel <thierry.bultel@iot.bzh>2019-02-13 11:59:45 +0100
committerThierry Bultel <thierry.bultel@iot.bzh>2019-02-18 15:51:30 +0100
commit297aa8309743d570b801e917f637937c0fc904c7 (patch)
tree85d41c16bc9d84410ad96a7a66ebadae9bcd9692 /plugins/alsa/alsa-plug-rate.c
parentc0c670aab4d1cb87f7f49031ec8728d6f1701fe3 (diff)
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 <thierry.bultel@iot.bzh>
Diffstat (limited to 'plugins/alsa/alsa-plug-rate.c')
-rw-r--r--plugins/alsa/alsa-plug-rate.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/plugins/alsa/alsa-plug-rate.c b/plugins/alsa/alsa-plug-rate.c
index ef7c335..00ad3d4 100644
--- a/plugins/alsa/alsa-plug-rate.c
+++ b/plugins/alsa/alsa-plug-rate.c
@@ -23,6 +23,13 @@
ALSA_PLUG_PROTO(rate);
+static void rateConfigClean(SoftMixerT *mixer, void * arg) {
+ snd_config_t * rateConfig = arg;
+ AFB_API_DEBUG(mixer->api, "%s... rate config", __func__);
+ snd_config_delete(rateConfig);
+ snd_config_update();
+}
+
PUBLIC AlsaPcmCtlT* AlsaCreateRate(SoftMixerT *mixer, AlsaStreamAudioT * stream, const char* pcmName, AlsaPcmCtlT *pcmSlave, AlsaPcmHwInfoT *params, int open) {
snd_config_t *rateConfig, *slaveConfig, *elemConfig, *pcmConfig;
@@ -71,8 +78,6 @@ PUBLIC AlsaPcmCtlT* AlsaCreateRate(SoftMixerT *mixer, AlsaStreamAudioT * stream,
goto OnErrorExit;
}
- stream->rateConfig = rateConfig;
-
if (open) error = _snd_pcm_rate_open(&pcmPlug->handle, pcmPlug->cid.cardid, snd_config, rateConfig, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);
if (error) {
AFB_API_ERROR(mixer->api,
@@ -81,6 +86,9 @@ PUBLIC AlsaPcmCtlT* AlsaCreateRate(SoftMixerT *mixer, AlsaStreamAudioT * stream,
goto OnErrorExit;
}
+ pcmPlug->private_data = rateConfig;
+ pcmPlug->private_data_clean = rateConfigClean;
+
// Debug config & pcm
//AlsaDumpCtlConfig(mixer, "plug-rate", pcmConfig, 1);
AlsaDumpCtlConfig (mixer, "plug-rate", rateConfig, 1);