diff options
author | Mark Farrugia <mark.farrugia@fiberdyne.com.au> | 2019-02-12 12:11:26 +1100 |
---|---|---|
committer | Mark Farrugia <mark.farrugia@fiberdyne.com.au> | 2019-02-12 12:12:38 +1100 |
commit | d5ac69750d6d16c88ee009e0106bfd6eeffaa695 (patch) | |
tree | 56026a1dc912f49d76ebc24fa3c27b2c9a7e82dd /plugins/alsa/alsa-api-streams.c | |
parent | d5cc09d1ef5c58bb8d34e3a47c391a10d8b48181 (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-streams.c')
-rw-r--r-- | plugins/alsa/alsa-api-streams.c | 23 |
1 files changed, 16 insertions, 7 deletions
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 <avirt/avirt.h> #include <string.h> #include <stdbool.h> @@ -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); |