summaryrefslogtreecommitdiffstats
path: root/plugins/alsa/alsa-api-streams.c
diff options
context:
space:
mode:
authorStephane Desneux <stephane.desneux@iot.bzh>2018-12-22 11:51:54 +0100
committerStephane Desneux <stephane.desneux@iot.bzh>2018-12-22 11:51:54 +0100
commitc85fd2f131c73e8c21e05e1ea80b55d6a787dda6 (patch)
tree248aca4a75556e3546a3c89cac43bcffe3ccf634 /plugins/alsa/alsa-api-streams.c
parente0f57e523112e1bc73a04e8615d7a21355f0ce0e (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-api-streams.c')
-rw-r--r--plugins/alsa/alsa-api-streams.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/plugins/alsa/alsa-api-streams.c b/plugins/alsa/alsa-api-streams.c
index e35a8b7..80609bc 100644
--- a/plugins/alsa/alsa-api-streams.c
+++ b/plugins/alsa/alsa-api-streams.c
@@ -196,7 +196,7 @@ static void paramsOverride(SoftMixerT *mixer, AlsaStreamAudioT * destStream, con
if (dest->format != src->format) {
AFB_ApiNotice(mixer->api, "Stream %s overrides format to %d", destStream->uid, src->format);
dest->format = src->format;
- dest->formatS = strdup(src->formatS);
+ strncpy(dest->formatString, src->formatString, SND_FORMAT_STRING_LEN );
}
if (dest->access != src->access) {
@@ -334,11 +334,14 @@ STATIC int CreateOneStream(SoftMixerT *mixer, const char * uid, AlsaStreamAudioT
// create a fake zone for rate converter selection
zone=alloca(sizeof(AlsaSndZoneT));
- zone->uid= playback->uid;
- zone->params = playback->sndcard->params;
+ zone->uid = playback->uid;
+
+ ApiPcmParamsShow(mixer,"PLAYBACK to FAKE ZONE", playback->sndcard->params);
+
+ zone->params = ApiPcmParamsDup(mixer, playback->sndcard->params);
zone->ccount = playback->nbChannels;
- }
+ }
// create mute control and Registry it as pause/resume ctl)
if (asprintf(&runName, "pause-%s", stream->uid) == -1) {
@@ -379,6 +382,9 @@ STATIC int CreateOneStream(SoftMixerT *mixer, const char * uid, AlsaStreamAudioT
AFB_ApiDebug(mixer->api,"%s: create softvol control", __func__);
+ ApiPcmParamsShow(mixer, "Stream ", stream->params);
+ ApiPcmParamsShow(mixer, "Zone", zone->params);
+
// create volume control before softvol pcm is opened
volNumid = AlsaCtlCreateControl(mixer,
captureCard,
@@ -396,14 +402,14 @@ STATIC int CreateOneStream(SoftMixerT *mixer, const char * uid, AlsaStreamAudioT
if ((zone->params->rate != stream->params->rate) ||
(zone->params->format != stream->params->format)) {
AFB_ApiNotice(mixer->api,
- "%s: Instanciate a RATE CONVERTER (stream [%d,%s(%d),%d channels], zone [%d,%s(%d), %d channels])",
+ "%s: Instanciate a RATE CONVERTER (stream [rate %d,%s(%d),%d channels], zone [rate %d,%s(%d), %d channels])",
__func__,
stream->params->rate,
- stream->params->formatS,
+ stream->params->formatString,
stream->params->format,
stream->params->channels,
zone->params->rate,
- zone->params->formatS,
+ zone->params->formatString,
zone->params->format,
zone->params->channels);
@@ -423,9 +429,9 @@ STATIC int CreateOneStream(SoftMixerT *mixer, const char * uid, AlsaStreamAudioT
playbackName = (char*) streamPcm->cid.cardid;
}
- streamPcm->isPcmPlug = zone->isPcmPlug;
+ streamPcm->isPcmPlug = zone->isPcmPlug;
- AFB_ApiDebug(mixer->api, "%s: Opening PCM PLAYBACK name %s", __func__, playbackName);
+ AFB_ApiDebug(mixer->api, "%s: Opening PCM PLAYBACK name %s", __func__, playbackName);
// everything is now ready to open playback pcm in BLOCKING mode this time
error = snd_pcm_open(&streamPcm->handle, playbackName, SND_PCM_STREAM_PLAYBACK, 0 /* will block*/ );