From d5ac69750d6d16c88ee009e0106bfd6eeffaa695 Mon Sep 17 00:00:00 2001 From: Mark Farrugia Date: Tue, 12 Feb 2019 12:11:26 +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 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 --- plugins/alsa/alsa-api-streams.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'plugins/alsa/alsa-api-streams.c') diff --git a/plugins/alsa/alsa-api-streams.c b/plugins/alsa/alsa-api-streams.c index c1fb749..edf506e 100644 --- a/plugins/alsa/alsa-api-streams.c +++ b/plugins/alsa/alsa-api-streams.c @@ -19,6 +19,7 @@ #define _GNU_SOURCE // needed for vasprintf #include "alsa-softmixer.h" +#include #include #include @@ -231,6 +232,7 @@ STATIC int CreateOneStream(SoftMixerT *mixer, const char * uid, AlsaStreamAudioT char *volName = NULL; int pauseNumid = 0; int volNumid = 0; + int device, subdev; AFB_API_DEBUG(mixer->api, "NEW STREAM stream %s %s, source %s, sink %s, mute %d", @@ -238,12 +240,20 @@ STATIC int CreateOneStream(SoftMixerT *mixer, const char * uid, AlsaStreamAudioT loopDev = ApiLoopFindSubdev(mixer, stream->uid, stream->source, &loop); if (loopDev) { + if (loop->avirt) { + device = loopDev->index; + subdev = 0; + } else { // loop->avirt == false + device = loop->capture; + subdev = loopDev->index; + } + // create a valid PCM reference and try to open it. captureDev->devpath = NULL; captureDev->cardid = NULL; captureDev->cardidx = loop->sndcard->cid.cardidx; - captureDev->device = loop->capture; - captureDev->subdev = loopDev->index; + captureDev->device = device; + captureDev->subdev = subdev; captureDev->pcmplug_params = NULL; captureCard = loop->sndcard; @@ -476,11 +486,10 @@ STATIC int CreateOneStream(SoftMixerT *mixer, const char * uid, AlsaStreamAudioT } if (loop) { - if (asprintf((char**) &stream->source, "hw:%d,%d,%d", captureDev->cardidx, loop->playback, capturePcm->cid.subdev) == -1) { - SOFTMIXER_NOMEM(mixer->api); - goto OnErrorExit; - } - + int device = (loop->avirt) ? captureDev->device + : loop->playback; + if (asprintf((char**) &stream->source, "hw:%d,%d,%d", captureDev->cardidx, device, capturePcm->cid.subdev) == -1) + goto OnErrorExit; } else { if (asprintf((char**) &stream->source, "hw:%d,%d,%d", captureDev->cardidx, captureDev->device, captureDev->subdev) == -1) { SOFTMIXER_NOMEM(mixer->api); -- cgit 1.2.3-korg