summaryrefslogtreecommitdiffstats
path: root/plugins/alsa/alsa-api-streams.c
diff options
context:
space:
mode:
authorThierry Bultel <thierry.bultel@iot.bzh>2019-02-13 11:44:02 +0100
committerThierry Bultel <thierry.bultel@iot.bzh>2019-02-18 15:51:30 +0100
commitc0c670aab4d1cb87f7f49031ec8728d6f1701fe3 (patch)
treefb89a17dbc2513e7e80e965f6f8e9246efabe675 /plugins/alsa/alsa-api-streams.c
parentedeccfc0d062117bdb74c86044e197372ca25885 (diff)
alsa-api-pcm: added an 'optional' parameter
This adds a boolean 'optional' parameter for both playback and capture devices. When the device is not detected, the stream(s) that use is are not created, without leading to the exit of the softmixer. Change-Id: I3effbd61bfe1d1d4a7cde573354b9db791f759cc 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.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/plugins/alsa/alsa-api-streams.c b/plugins/alsa/alsa-api-streams.c
index 43485b4..92e00c0 100644
--- a/plugins/alsa/alsa-api-streams.c
+++ b/plugins/alsa/alsa-api-streams.c
@@ -284,6 +284,14 @@ STATIC int CreateOneStream(SoftMixerT *mixer, const char * uid, AlsaStreamAudioT
}
}
+ stream->optional = captureCard->optional;
+
+ if (!captureCard->ctl && captureCard->optional) {
+ stream->noHwDetected = true;
+ AFB_API_INFO(mixer->api,"%s: no detected capture device", __func__);
+ goto done;
+ }
+
// check PCM is valid and get its full name
AlsaPcmCtlT *capturePcm = AlsaByPathOpenPcmCtl(mixer, captureDev, SND_PCM_STREAM_CAPTURE);
if (!capturePcm) {
@@ -532,7 +540,7 @@ STATIC int CreateOneStream(SoftMixerT *mixer, const char * uid, AlsaStreamAudioT
AFB_API_NOTICE(mixer->api,
"%s: mixer=%s stream=%s CREATED",
__func__, mixer->uid, stream->uid);
-
+done:
return 0;
OnErrorExit:
@@ -668,6 +676,9 @@ static void streamDestroy(SoftMixerT * mixer, void * arg) {
int error = 0;
AFB_API_DEBUG(mixer->api, "%s... %s", __func__, stream->uid);
+ if (stream->noHwDetected)
+ goto freemem;
+
error = afb_api_del_verb(mixer->api, stream->uid, (void**)stream->verbApiHandle);
if (error) {
AFB_API_DEBUG(mixer->api, "%s: failed to remove verb %s", __func__, stream->uid);
@@ -675,6 +686,7 @@ static void streamDestroy(SoftMixerT * mixer, void * arg) {
AlsaPcmCopyStop(mixer, stream->copy);
+freemem:
if (stream->softvolConfig) {
AFB_API_DEBUG(mixer->api, "%s... %s delete softvol config", __func__, stream->uid);
snd_config_delete(stream->softvolConfig);
@@ -744,6 +756,8 @@ PUBLIC int ApiStreamAttach(SoftMixerT *mixer, afb_req_t request, const char * ui
afb_req_fail_f(request, "bad-stream", "mixer=%s invalid stream= %s", mixer->uid, json_object_get_string(argsJ));
goto fail;
}
+ if (newStream->noHwDetected)
+ AlsaMixerTransactionObjectDelete(mixer->transaction, newStream, true);
break;
@@ -766,7 +780,10 @@ PUBLIC int ApiStreamAttach(SoftMixerT *mixer, afb_req_t request, const char * ui
"%s: mixer=%s invalid stream= %s",
__func__, mixer->uid, json_object_get_string(streamJ));
goto fail;
- }
+ }
+ if (newStream->noHwDetected)
+ AlsaMixerTransactionObjectDelete(mixer->transaction, newStream, true);
+
}
break;
default: