diff options
author | Stephane Desneux <stephane.desneux@iot.bzh> | 2018-12-22 11:51:54 +0100 |
---|---|---|
committer | Stephane Desneux <stephane.desneux@iot.bzh> | 2018-12-22 11:51:54 +0100 |
commit | c85fd2f131c73e8c21e05e1ea80b55d6a787dda6 (patch) | |
tree | 248aca4a75556e3546a3c89cac43bcffe3ccf634 /plugins/alsa/alsa-utils-bypath.c | |
parent | e0f57e523112e1bc73a04e8615d7a21355f0ce0e (diff) |
Implemented the bug cleanup at application exit
Fixes most memory leaks in softmixer.
The concept of 'transaction' for dynamic streams has
been generalized to the objects created at startup.
The cleanup is done via a handle set through a atexit()
call.
Also added a missing strdup in alsa-api-loop, that fixes
a double free.
Warning, the bluez-alsa PCM are not closed in this
version. This is intentional due to a BUG in the
bluealsa ioplug PCM, that crashes upon close
(pthread_cancel is used to terminate the io_thread
and things get very bad. I have a pending fix for
that, relying on a cancellation pipe, but deeper
testing must be done).
As an effect, only one phone call can be made,
else 4a needs to be restarted
Change-Id: Idb84cafe15f17c0ef02fcc70296d541dc55a2dcf
Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
Signed-off-by: Stephane Desneux <stephane.desneux@iot.bzh>
Diffstat (limited to 'plugins/alsa/alsa-utils-bypath.c')
-rw-r--r-- | plugins/alsa/alsa-utils-bypath.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/plugins/alsa/alsa-utils-bypath.c b/plugins/alsa/alsa-utils-bypath.c index 908d247..49f89e4 100644 --- a/plugins/alsa/alsa-utils-bypath.c +++ b/plugins/alsa/alsa-utils-bypath.c @@ -91,15 +91,18 @@ PUBLIC void AlsaPcmCtlDelete(SoftMixerT* mixer, void * arg) { AlsaPcmCtlT * pcmCtl = (AlsaPcmCtlT *) arg; + AFB_ApiDebug(mixer->api, "%s of %s (plug: %d)", __func__, pcmCtl->name, pcmCtl->isPcmPlug); + if (!pcmCtl->closeAtDeletion) goto done; + // TODO REMOVE THIS ONCE THE BUG IN BLUEZ-ALSA IS CORRECTED. Else Closing it make SIGSEGV if (pcmCtl->isPcmPlug) { - AFB_ApiDebug(mixer->api, "%s: Wont' close '%s' PCM, its slave is a plug", __func__, pcmCtl->cid.cardid); + AFB_ApiDebug(mixer->api, "%s: Wont' close '%s' PCM, it uses is a plug", __func__, pcmCtl->cid.cardid); goto done; } - AFB_ApiDebug(mixer->api, "%s: Closing %s",__func__, pcmCtl->cid.cardid); + AFB_ApiDebug(mixer->api, "%s: Closing %s", __func__, pcmCtl->cid.cardid); error = snd_pcm_close(pcmCtl->handle); if (error) { // It's safe to ignore this error. In case of ioplug PCM, the device may have already disappeared @@ -109,8 +112,13 @@ PUBLIC void AlsaPcmCtlDelete(SoftMixerT* mixer, void * arg) { done: + ApiPcmDelParams(mixer, pcmCtl->params); + free((char*) pcmCtl->cid.cardid); free(pcmCtl); + + AFB_ApiDebug(mixer->api, "%s DONE", __func__); + } PUBLIC AlsaPcmCtlT *AlsaByPathOpenPcmCtl(SoftMixerT *mixer, AlsaDevInfoT *pcmDev, snd_pcm_stream_t direction) { @@ -156,7 +164,6 @@ PUBLIC AlsaPcmCtlT *AlsaByPathOpenPcmCtl(SoftMixerT *mixer, AlsaDevInfoT *pcmDev goto fail_cardid; } - // inherit CID from pcmDev pcmCtl->cid.cardid = pcmDev->cardid; pcmCtl->cid.cardidx = pcmDev->cardidx; @@ -165,6 +172,9 @@ PUBLIC AlsaPcmCtlT *AlsaByPathOpenPcmCtl(SoftMixerT *mixer, AlsaDevInfoT *pcmDev pcmCtl->cid.name=NULL; pcmCtl->cid.longname=NULL; + if (pcmDev->pcmplug_params) + pcmCtl->isPcmPlug = true; + AFB_ApiDebug(mixer->api, "%s OPEN PCM '%s', direction %s", __func__, pcmDev->cardid, direction==SND_PCM_STREAM_PLAYBACK?"playback":"capture"); |