aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/alsa/alsa-api-streams.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/alsa/alsa-api-streams.c')
-rw-r--r--plugins/alsa/alsa-api-streams.c45
1 files changed, 25 insertions, 20 deletions
diff --git a/plugins/alsa/alsa-api-streams.c b/plugins/alsa/alsa-api-streams.c
index f7149cc..e3d7bf9 100644
--- a/plugins/alsa/alsa-api-streams.c
+++ b/plugins/alsa/alsa-api-streams.c
@@ -263,7 +263,7 @@ STATIC int CreateOneStream(SoftMixerT *mixer, const char * uid, AlsaStreamAudioT
} else {
// if capture UID is not present in loop search on known sources
- AFB_ApiDebug(mixer->api,"%s: %s not found in loop, look in sources", __func__, uid);
+ AFB_ApiDebug(mixer->api,"%s: %s not found in loop, look in sources", __func__, stream->source);
AlsaSndCtlT *sourceDev = ApiSourceFindSubdev(mixer, stream->source);
if (sourceDev) {
@@ -278,12 +278,20 @@ STATIC int CreateOneStream(SoftMixerT *mixer, const char * uid, AlsaStreamAudioT
__func__, uid, captureDev->pcmplug_params, sourceDev->cid.cardid);
} else {
AFB_ApiError(mixer->api,
- "%s: mixer=%s stream=%s not found in loops/sources",
- __func__, mixer->uid, stream->uid);
+ "%s: mixer=%s stream=%s: %s not found in loops/sources",
+ __func__, mixer->uid, stream->uid, stream->source);
goto OnErrorExit;
}
}
+ 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) {
@@ -417,7 +425,7 @@ STATIC int CreateOneStream(SoftMixerT *mixer, const char * uid, AlsaStreamAudioT
if ((zone->params->rate != stream->params->rate) ||
(zone->params->format != stream->params->format)) {
AFB_ApiNotice(mixer->api,
- "%s: Instanciate a RATE CONVERTER (stream [rate %d,%s(%d),%d channels], zone [rate %d,%s(%d), %d channels])",
+ "%s: Instantiate a RATE CONVERTER (stream [rate %d,%s(%d),%d channels], zone [rate %d,%s(%d), %d channels])",
__func__,
stream->params->rate,
stream->params->formatString,
@@ -445,8 +453,9 @@ STATIC int CreateOneStream(SoftMixerT *mixer, const char * uid, AlsaStreamAudioT
}
streamPcm->isPcmPlug = zone->isPcmPlug;
+ streamPcm->quirks = zone->quirks;
- AFB_ApiDebug(mixer->api, "%s: Opening PCM PLAYBACK name %s", __func__, playbackName);
+ AFB_ApiDebug(mixer->api, "%s: Opening PCM PLAYBACK name %s (quirks=0x%x)", __func__, playbackName, streamPcm->quirks);
// everything is now ready to open playback pcm in BLOCKING mode this time
error = snd_pcm_open(&streamPcm->handle, playbackName, SND_PCM_STREAM_PLAYBACK, 0 /* will block*/ );
@@ -531,7 +540,7 @@ STATIC int CreateOneStream(SoftMixerT *mixer, const char * uid, AlsaStreamAudioT
AFB_ApiNotice(mixer->api,
"%s: mixer=%s stream=%s CREATED",
__func__, mixer->uid, stream->uid);
-
+done:
return 0;
OnErrorExit:
@@ -667,6 +676,9 @@ static void streamDestroy(SoftMixerT * mixer, void * arg) {
int error = 0;
AFB_ApiDebug(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_ApiDebug(mixer->api, "%s: failed to remove verb %s", __func__, stream->uid);
@@ -674,19 +686,7 @@ static void streamDestroy(SoftMixerT * mixer, void * arg) {
AlsaPcmCopyStop(mixer, stream->copy);
- if (stream->softvolConfig) {
- AFB_ApiDebug(mixer->api, "%s... %s delete softvol config", __func__, stream->uid);
- snd_config_delete(stream->softvolConfig);
- snd_config_update();
- stream->softvolConfig = NULL;
- }
-
- if (stream->rateConfig) {
- AFB_ApiDebug(mixer->api, "%s... %s delete rate config", __func__, stream->uid);
- snd_config_delete(stream->rateConfig);
- snd_config_update();
- stream->rateConfig = NULL;
- }
+freemem:
free((char*)stream->uid);
free((char*)stream->playback);
@@ -743,6 +743,8 @@ PUBLIC int ApiStreamAttach(SoftMixerT *mixer, AFB_ReqT request, const char * uid
AFB_ReqFailF(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;
@@ -765,7 +767,10 @@ PUBLIC int ApiStreamAttach(SoftMixerT *mixer, AFB_ReqT request, const char * uid
"%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: