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-route.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'plugins/alsa/alsa-plug-route.c') diff --git a/plugins/alsa/alsa-plug-route.c b/plugins/alsa/alsa-plug-route.c index d3f22a7..df39698 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; @@ -81,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; @@ -279,7 +287,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); -- cgit 1.2.3-korg