summaryrefslogtreecommitdiffstats
path: root/plugins/alsa/alsa-api-streams.c
diff options
context:
space:
mode:
authorThierry Bultel <thierry.bultel@iot.bzh>2018-07-11 17:50:44 +0200
committerThierry Bultel <thierry.bultel@iot.bzh>2018-07-11 17:50:44 +0200
commit283bf0a4ab7dbd6f4393f6a1b4ef5a201ee92f62 (patch)
treed0ece00821901244465ef5fb3694389430db3085 /plugins/alsa/alsa-api-streams.c
parentafd9f87786fe0cc3070ec976b89399603112c845 (diff)
stops the read/write loop when the stream is muted
when the stream is muted (due to the configuration, or due to a HAL request), the read/write loop is stopped. The benefit is that muting will work with capture devices that do not implement the mute in their driver. The inconvenient of stopping the read loop is that it has made appear an unexpected side-effect: the poll on capture does not trig for further incoming frames. The workaround is to completely close, then reopen and configure the capture PCM. Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
Diffstat (limited to 'plugins/alsa/alsa-api-streams.c')
-rw-r--r--plugins/alsa/alsa-api-streams.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/plugins/alsa/alsa-api-streams.c b/plugins/alsa/alsa-api-streams.c
index dab7748..cf54d91 100644
--- a/plugins/alsa/alsa-api-streams.c
+++ b/plugins/alsa/alsa-api-streams.c
@@ -20,6 +20,7 @@
#include "alsa-softmixer.h"
#include <string.h>
+#include <stdbool.h>
// Set stream volume control in %
#define VOL_CONTROL_MAX 100
@@ -56,6 +57,7 @@ STATIC void StreamApiVerbCB(AFB_ReqT request) {
, "volume", &volumeJ
, "ramp", &rampJ
);
+
if (error) {
AFB_ReqFailF(request, "syntax-error", "Missing 'close|mute|volume|verbose' args=%s", json_object_get_string(argsJ));
goto OnErrorExit;
@@ -82,9 +84,9 @@ STATIC void StreamApiVerbCB(AFB_ReqT request) {
}
if (doMute != -1) {
- error = AlsaCtlNumidSetLong(mixer, handle->sndcard, handle->stream->mute, !mute);
+ error = AlsaCtlNumidSetLong(mixer, handle->sndcard, handle->stream->mute, doMute);
if (error) {
- AFB_ReqFailF(request, "StreamApiVerbCB", "Fail to set stream volume numid=%d value=%d", handle->stream->volume, !mute);
+ AFB_ReqFailF(request, "StreamApiVerbCB", "Fail to set stream volume numid=%d value=%d", handle->stream->volume, !doMute);
goto OnErrorExit;
}
@@ -194,8 +196,8 @@ STATIC int CreateOneStream(SoftMixerT *mixer, const char * uid, AlsaStreamAudioT
char *volName = NULL;
AFB_ApiInfo(mixer->api,
- "%s, stream %s %s, source %s, sink %s\n",
- __func__,uid, stream->uid, stream->source, stream->sink);
+ "%s, stream %s %s, source %s, sink %s, mute %d",
+ __func__,uid, stream->uid, stream->source, stream->sink, stream->mute);
loopDev = ApiLoopFindSubdev(mixer, stream->uid, stream->source, &loop);
if (loopDev) {
@@ -236,6 +238,8 @@ STATIC int CreateOneStream(SoftMixerT *mixer, const char * uid, AlsaStreamAudioT
AlsaPcmCtlT *capturePcm = AlsaByPathOpenPcm(mixer, captureDev, SND_PCM_STREAM_CAPTURE);
if (!capturePcm) goto OnErrorExit;
+ capturePcm->mute = stream->mute;
+
// Registry capturePcm PCM for active/pause event
if (loopDev && loopDev->numid) {
error = AlsaCtlRegister(mixer, captureCard, capturePcm, FONTEND_NUMID_RUN, loopDev->numid);