From b6aec989e0620322250b033bf339db7868d117d3 Mon Sep 17 00:00:00 2001 From: Mark Farrugia Date: Tue, 29 Jan 2019 11:35:44 +1100 Subject: Add support for AVIRT Leverage the new AVIRT driver for a more secure, more dynamically configurable loopback sound driver. To use, replace the file smixer-4a-default.json with smixer-4a-avirt.json, at /usr/libexec/agl/smixer/etc The existing snd-aloop configuration is not broken by this change. The submodule libavirt is temporary, and will be transformed into a library. Change-Id: I827636656c109a7393ad77997e05069a2462ea46 Signed-off-by: Mark Farrugia --- plugins/alsa/alsa-api-mixer.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'plugins/alsa/alsa-api-mixer.c') diff --git a/plugins/alsa/alsa-api-mixer.c b/plugins/alsa/alsa-api-mixer.c index 6d80b55..328f02e 100644 --- a/plugins/alsa/alsa-api-mixer.c +++ b/plugins/alsa/alsa-api-mixer.c @@ -27,6 +27,9 @@ static struct cds_list_head mixerList; static void MixerDelete(SoftMixerT * mixer); +// AVIRT: temporary loops JSON +static json_object *LoopsJ = NULL; + static void MixerExit() { SoftMixerT *mixer, *tmp; printf("%s !\n", __func__); @@ -575,13 +578,6 @@ STATIC void MixerAttachVerb(AFB_ReqT request) { mixer->transaction = transaction; - AFB_ApiInfo(mixer->api, "%s set LOOPS", __func__); - - if (loopsJ) { - error = ApiLoopAttach(mixer, request, uid, loopsJ); - if (error) goto fail; - } - AFB_ApiInfo(mixer->api, "%s set PLAYBACKS", __func__); if (playbacksJ) { @@ -611,11 +607,21 @@ STATIC void MixerAttachVerb(AFB_ReqT request) { error = ApiZoneAttach(mixer, request, uid, zonesJ); if (error) goto fail_source; - + json_object *resultJ = MixerInfoZones(mixer, zonesJ, 0); json_object_object_add(responseJ, "zone", resultJ); } + // In AVIRT mode, we require both the loops and streams JSON objects to + // construct the loopbacks, so when the loops are set, but the streams + // are not, we need to save the loops until the streams are given to us + if (streamsJ && (loopsJ || LoopsJ)) { + AFB_ApiInfo(mixer->api, "%s set LOOPS/AVIRT", __func__); + error = ApiLoopAttach(mixer, request, uid, + ((loopsJ) ? loopsJ : LoopsJ), streamsJ); + if (error) goto fail_loop; + } + AFB_ApiInfo(mixer->api, "%s set RAMPS", __func__); if (rampsJ) { @@ -657,12 +663,12 @@ fail_ramp: // TODO remove created ramps fail_zone: // TODO remove created zone +fail_loop: + // TODO remove created loops fail_source: // TODO remove created sources fail_sink: // TODO remove created sinks -fail_loop: - // TODO remove created loops fail: if (mixer->transaction) @@ -734,9 +740,14 @@ CTLP_CAPI(MixerAttach, source, argsJ, responseJ) { if (error) goto OnErrorExit; } - if (loopsJ) { - error = ApiLoopAttach(mixer, NULL, uid, loopsJ); + // In AVIRT mode, we require both the loops and streams JSON objects to + // construct the loopbacks, so when the loops are set, but the streams + // are not, we need to save the loops until the streams are given to us + if (loopsJ && streamsJ) { + error = ApiLoopAttach(mixer, NULL, uid, loopsJ, streamsJ); if (error) goto OnErrorExit; + } else { + LoopsJ = loopsJ; } if (zonesJ) { -- cgit 1.2.3-korg