aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/alsa/alsa-api-sndcards.c4
-rw-r--r--plugins/alsa/alsa-api-sndstreams.c33
-rw-r--r--plugins/alsa/alsa-plug-dmix.c3
-rw-r--r--plugins/alsa/alsa-plug-multi.c3
-rw-r--r--plugins/alsa/alsa-plug-route.c2
-rw-r--r--plugins/alsa/alsa-plug-stream.c3
6 files changed, 29 insertions, 19 deletions
diff --git a/plugins/alsa/alsa-api-sndcards.c b/plugins/alsa/alsa-api-sndcards.c
index d48abd8..e98a294 100644
--- a/plugins/alsa/alsa-api-sndcards.c
+++ b/plugins/alsa/alsa-api-sndcards.c
@@ -75,7 +75,9 @@ STATIC int ProcessOneSndCard(CtlSourceT *source, json_object *sndcardJ, AlsaPcmI
}
// protect each sndcard with a dmix plugin to enable audio-stream mixing
- AlsaPcmInfoT *dmixPcm= AlsaCreateDmix(source, snd->uid, snd);
+ char dmixUid[100];
+ snprintf(dmixUid, sizeof(dmixUid),"Dmix-%s", snd->uid);
+ AlsaPcmInfoT *dmixPcm= AlsaCreateDmix(source, dmixUid, snd);
if (!dmixPcm) {
AFB_ApiError(source->api, "ProcessOneSndCard: sndcard=%s fail to attach dmix plugin", snd->uid);
goto OnErrorExit;
diff --git a/plugins/alsa/alsa-api-sndstreams.c b/plugins/alsa/alsa-api-sndstreams.c
index 9f5d90f..1ee0029 100644
--- a/plugins/alsa/alsa-api-sndstreams.c
+++ b/plugins/alsa/alsa-api-sndstreams.c
@@ -109,10 +109,13 @@ CTLP_LUA2C(snd_streams, source, argsJ, responseJ) {
goto OnErrorExit;
}
- // instantiate stream as a softvol
+ // return stream data to application as a json array
+ *responseJ = json_object_new_array();
+
for (int idx = 0; sndStream[idx].uid != NULL; idx++) {
-
+ json_object *streamJ;
+
// Search for a free loop capture device
AFB_ApiNotice(source->api, "L2C:sndstreams stream=%s Start", (char*)sndStream[idx].uid);
ctlLoop->scount--;
@@ -122,34 +125,42 @@ CTLP_LUA2C(snd_streams, source, argsJ, responseJ) {
}
// Retrieve subdev loop device and open corresponding pcm
- AlsaPcmInfoT *devLoop = &ctlLoop->subdevs[ctlLoop->scount];
- AlsaPcmInfoT *pcmLoop = AlsaByPathOpenPcm(source, devLoop, SND_PCM_STREAM_CAPTURE);
- if (!pcmLoop) goto OnErrorExit;
+ AlsaPcmInfoT *playbackDev = &ctlLoop->subdevs[ctlLoop->scount];
+
+ // capture use the same card/subdev as playback with a different device
+ playbackDev->device= ctlLoop->capture;
+ AlsaPcmInfoT *captureDev = AlsaByPathOpenPcm(source, playbackDev, SND_PCM_STREAM_CAPTURE);
+ if (!captureDev) goto OnErrorExit;
- AlsaPcmInfoT *streamPcm = AlsaCreateStream(source, &sndStream[idx], pcmLoop);
+ AlsaPcmInfoT *streamPcm = AlsaCreateStream(source, &sndStream[idx], captureDev);
if (!streamPcm) {
AFB_ApiError(source->api, "L2C:sndstreams fail to create stream=%s", (char*) sndStream[idx].uid);
goto OnErrorExit;
}
// capture stream inherit channel from targeted zone
- pcmLoop->ccount = streamPcm->ccount;
+ captureDev->ccount = streamPcm->ccount;
sndStream[idx].params.channels=streamPcm->ccount;
// start stream pcm copy
- error = AlsaPcmCopy(source, pcmLoop, streamPcm, &sndStream[idx].params);
+ error = AlsaPcmCopy(source, captureDev, streamPcm, &sndStream[idx].params);
if (error) goto OnErrorExit;
// Registration to event should be done after pcm_start
- if (pcmLoop->numid) {
- error = AlsaCtlRegister(source, pcmLoop, pcmLoop->numid);
+ if (captureDev->numid) {
+ error = AlsaCtlRegister(source, captureDev, captureDev->numid);
if (error) goto OnErrorExit;
}
+ // prepare response for application
+ playbackDev->device= ctlLoop->playback;
+ error = AlsaByPathDevid(source, playbackDev);
+ wrap_json_pack(&streamJ, "{ss ss si}", "uid", sndStream[idx].uid, "alsa", playbackDev->cardid, "numid", captureDev->numid);
+ json_object_array_add(*responseJ,streamJ);
// Debug Alsa Config
//AlsaDumpElemConfig (source, "\n\nAlsa_Config\n------------\n", "pcm");
- AlsaDumpPcmInfo(source, "\n\nPcm_config\n-----------\n", streamPcm->handle);
+ //AlsaDumpPcmInfo(source, "\n\nPcm_config\n-----------\n", streamPcm->handle);
AFB_ApiNotice(source->api, "L2C:sndstreams stream=%s OK\n", (char*) sndStream[idx].uid);
}
diff --git a/plugins/alsa/alsa-plug-dmix.c b/plugins/alsa/alsa-plug-dmix.c
index e28d009..22b5117 100644
--- a/plugins/alsa/alsa-plug-dmix.c
+++ b/plugins/alsa/alsa-plug-dmix.c
@@ -71,8 +71,7 @@ PUBLIC AlsaPcmInfoT* AlsaCreateDmix(CtlSourceT *source, const char* pcmName, Als
}
// Debug config & pcm
- AlsaDumpCtlConfig (source, "plug-dmix", dmixConfig, 1);
- //AlsaDumpPcmInfo(source, pcmPlug->handle, pcmPlug->cardid);
+ //AlsaDumpCtlConfig (source, "plug-dmix", dmixConfig, 1);
AFB_ApiNotice(source->api, "AlsaCreateDmix: %s done\n", pcmPlug->cardid);
return pcmPlug;
diff --git a/plugins/alsa/alsa-plug-multi.c b/plugins/alsa/alsa-plug-multi.c
index d6ef46e..6deca96 100644
--- a/plugins/alsa/alsa-plug-multi.c
+++ b/plugins/alsa/alsa-plug-multi.c
@@ -57,7 +57,7 @@ PUBLIC AlsaPcmInfoT* AlsaCreateMulti(CtlSourceT *source, const char *pcmUid) {
snprintf (idxS, sizeof(idxS), "%d", pcmPlug->ccount++);
// multi does not support to name channels
error += snd_config_make_compound(&bindingConfig,idxS, 0);
- error += snd_config_imake_string(&elemConfig, "slave", sndcard->cardid);
+ error += snd_config_imake_string(&elemConfig, "slave", sndcard->uid);
error += snd_config_add(bindingConfig, elemConfig);
error += snd_config_imake_integer(&elemConfig,"channel", channelIdx);
error += snd_config_add(bindingConfig, elemConfig);
@@ -94,7 +94,6 @@ PUBLIC AlsaPcmInfoT* AlsaCreateMulti(CtlSourceT *source, const char *pcmUid) {
// Debug config & pcm
//AlsaDumpCtlConfig(source, "plug-multi", multiConfig, 1);
- //AlsaDumpPcmInfo(source, pcmPlug->handle, "pcmPlug->handle");
AFB_ApiNotice(source->api, "AlsaCreateMulti: %s done\n", pcmPlug->cardid);
return pcmPlug;
diff --git a/plugins/alsa/alsa-plug-route.c b/plugins/alsa/alsa-plug-route.c
index dc75b56..2c8f3cb 100644
--- a/plugins/alsa/alsa-plug-route.c
+++ b/plugins/alsa/alsa-plug-route.c
@@ -129,7 +129,7 @@ PUBLIC AlsaPcmInfoT* AlsaCreateRoute(CtlSourceT *source, AlsaSndZoneT *zone) {
}
// Debug config & pcm
- AlsaDumpCtlConfig(source, "plug-route", routeConfig, 1);
+ //AlsaDumpCtlConfig(source, "plug-route", routeConfig, 1);
AFB_ApiNotice(source->api, "AlsaCreateRoute:zone(%s) done\n", zone->uid);
return pcmPlug;
diff --git a/plugins/alsa/alsa-plug-stream.c b/plugins/alsa/alsa-plug-stream.c
index fccb309..e0ef69a 100644
--- a/plugins/alsa/alsa-plug-stream.c
+++ b/plugins/alsa/alsa-plug-stream.c
@@ -109,8 +109,7 @@ PUBLIC AlsaPcmInfoT* AlsaCreateStream(CtlSourceT *source, AlsaSndStreamT *stream
}
// Debug config & pcm
- AlsaDumpCtlConfig (source, "plug-stream", streamConfig, 1);
- //AlsaDumpPcmInfo(source, pcmPlug->handle, "pcmPlug->handle");
+ //AlsaDumpCtlConfig (source, "plug-stream", streamConfig, 1);
AFB_ApiNotice(source->api, "AlsaCreateStream:%s(stream) done\n", stream->uid);
return pcmPlug;