aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/alsa/alsa-api-mixer.c
diff options
context:
space:
mode:
authorMark Farrugia <mark.farrugia@fiberdyne.com.au>2019-02-12 12:11:26 +1100
committerMark Farrugia <mark.farrugia@fiberdyne.com.au>2019-02-12 12:12:38 +1100
commitd5ac69750d6d16c88ee009e0106bfd6eeffaa695 (patch)
tree56026a1dc912f49d76ebc24fa3c27b2c9a7e82dd /plugins/alsa/alsa-api-mixer.c
parentd5cc09d1ef5c58bb8d34e3a47c391a10d8b48181 (diff)
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 snd-avirt drivers are installed in AGL by default as of 6.99.2. The existing snd-aloop configuration is not broken by this change. Change-Id: I827636656c109a7393ad77997e05069a2462ea46 Signed-off-by: Mark Farrugia <mark.farrugia@fiberdyne.com.au>
Diffstat (limited to 'plugins/alsa/alsa-api-mixer.c')
-rw-r--r--plugins/alsa/alsa-api-mixer.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/plugins/alsa/alsa-api-mixer.c b/plugins/alsa/alsa-api-mixer.c
index e892b2f..ebb8c25 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_req_t request) {
mixer->transaction = transaction;
- AFB_API_INFO(mixer->api, "%s set LOOPS", __func__);
-
- if (loopsJ) {
- error = ApiLoopAttach(mixer, request, uid, loopsJ);
- if (error) goto fail;
- }
-
AFB_API_INFO(mixer->api, "%s set PLAYBACKS", __func__);
if (playbacksJ) {
@@ -616,6 +612,16 @@ STATIC void MixerAttachVerb(afb_req_t request) {
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_API_INFO(mixer->api, "%s set LOOPS/AVIRT", __func__);
+ error = ApiLoopAttach(mixer, request, uid,
+ ((loopsJ) ? loopsJ : LoopsJ), streamsJ);
+ if (error) goto fail_loop;
+ }
+
AFB_API_INFO(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) {