From 43df82896d8535f99233b4d3ab35a744b07871e0 Mon Sep 17 00:00:00 2001 From: Thierry Bultel Date: Wed, 20 Feb 2019 12:24:41 +0100 Subject: loops/avirt: forget saved loops after creation avirt needs a backup of loops, before creating the streams. However, this breaks software dynamic streams such as those of of type bluez-alsa, because the logic was re-calling the loop creation at each call of the 'attach' verb. The fix simply consists in forgetting the saved loops once they are created Bug-AGL: SPEC-2387 Change-Id: I63f492b89233bed12de583de6e1077ac1c9c3ccf Signed-off-by: Thierry Bultel --- plugins/alsa/alsa-api-loop.c | 11 ++++++----- plugins/alsa/alsa-api-mixer.c | 6 +++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/plugins/alsa/alsa-api-loop.c b/plugins/alsa/alsa-api-loop.c index bc3c62a..a4b19f5 100644 --- a/plugins/alsa/alsa-api-loop.c +++ b/plugins/alsa/alsa-api-loop.c @@ -445,10 +445,12 @@ PUBLIC int ApiLoopAttach(SoftMixerT *mixer, AFB_ReqT request, const char * uid, AlsaSndLoopT * newLoop = NULL; + AFB_API_INFO(mixer->api, "%s: %s", __func__, json_object_get_string(argsJ)); + if (mixer->nbLoops >= mixer->max.loops) { - AFB_IfReqFailF(mixer, request, "too-small", "mixer=%s hal=%s max loop=%d", mixer->uid, uid, mixer->max.loops); + AFB_IfReqFailF(mixer, request, "too many loops", "mixer=%s hal=%s max loop=%d", mixer->uid, uid, mixer->max.loops); goto fail; - } + } switch (json_object_get_type(argsJ)) { size_t count; @@ -464,14 +466,14 @@ PUBLIC int ApiLoopAttach(SoftMixerT *mixer, AFB_ReqT request, const char * uid, count = json_object_array_length(argsJ); if (count > (mixer->max.loops - mixer->nbLoops)) { AFB_IfReqFailF(mixer, request, "too-small", "mixer=%s hal=%s max loop=%d", mixer->uid, uid, mixer->max.loops); - goto fail_loop; + goto fail; } for (int idx = 0; idx < count; idx++) { json_object *loopJ = json_object_array_get_idx(argsJ, idx); newLoop = loopCreate(mixer, uid, loopJ, streamsJ); if (newLoop == NULL) { - goto fail_loop; + goto fail; } } break; @@ -482,7 +484,6 @@ PUBLIC int ApiLoopAttach(SoftMixerT *mixer, AFB_ReqT request, const char * uid, return 0; -fail_loop: fail: return -1; } diff --git a/plugins/alsa/alsa-api-mixer.c b/plugins/alsa/alsa-api-mixer.c index c000ea8..15dae20 100644 --- a/plugins/alsa/alsa-api-mixer.c +++ b/plugins/alsa/alsa-api-mixer.c @@ -618,7 +618,11 @@ STATIC void MixerAttachVerb(AFB_ReqT request) { AFB_ApiInfo(mixer->api, "%s set LOOPS/AVIRT", __func__); error = ApiLoopAttach(mixer, request, uid, ((loopsJ) ? loopsJ : LoopsJ), streamsJ); - if (error) goto fail_loop; + if (error) + goto fail; + // Now, forget the saved LoopsJ + if (LoopsJ) + LoopsJ = NULL; } AFB_ApiInfo(mixer->api, "%s set RAMPS", __func__); -- cgit 1.2.3-korg