summaryrefslogtreecommitdiffstats
path: root/plugins/alsa/alsa-api-streams.c
diff options
context:
space:
mode:
authorMark Farrugia <mark.farrugia@fiberdyne.com.au>2019-01-29 11:35:44 +1100
committerMark Farrugia <mark.farrugia@fiberdyne.com.au>2019-02-10 23:56:47 +0000
commitb6aec989e0620322250b033bf339db7868d117d3 (patch)
treed47fb0d5b6647100be034ca4ca0a91be7efe710b /plugins/alsa/alsa-api-streams.c
parentca4b8d63bb92f0a72c31107605bca0ab78855ce0 (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 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 <mark.farrugia@fiberdyne.com.au>
Diffstat (limited to 'plugins/alsa/alsa-api-streams.c')
-rw-r--r--plugins/alsa/alsa-api-streams.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/plugins/alsa/alsa-api-streams.c b/plugins/alsa/alsa-api-streams.c
index 6b743e2..f7149cc 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_ApiDebug(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);
@@ -488,7 +497,7 @@ STATIC int CreateOneStream(SoftMixerT *mixer, const char * uid, AlsaStreamAudioT
}
}
- // create a dedicated verb for this stream
+ // create a dedicated verb for this stream
apiHandleT *apiHandle = calloc(1, sizeof (apiHandleT));
if (apiHandle == NULL) {
SOFTMIXER_NOMEM(mixer->api);