summaryrefslogtreecommitdiffstats
path: root/plugins/alsa
diff options
context:
space:
mode:
authorThierry Bultel <thierry.bultel@iot.bzh>2018-09-07 16:13:55 +0200
committerThierry Bultel <thierry.bultel@iot.bzh>2018-09-07 16:13:55 +0200
commit9c0aa9f3073a37e961a90a973b8d007685c9e184 (patch)
tree7b4f9778a75958cff3c04b71af303992505629b2 /plugins/alsa
parent168e9288f1ff147d9aaa6064c3cc0308fd214a6a (diff)
fixed crash upon misconfiguration of capture/playback devices
The null pcmplug case was not correctly handled in various places. Also fixed some typos in the log Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
Diffstat (limited to 'plugins/alsa')
-rw-r--r--plugins/alsa/alsa-api-mixer.c14
-rw-r--r--plugins/alsa/alsa-api-streams.c9
-rw-r--r--plugins/alsa/alsa-core-ctl.c2
-rw-r--r--plugins/alsa/alsa-core-pcm.c8
-rw-r--r--plugins/alsa/alsa-utils-bypath.c2
-rw-r--r--plugins/alsa/alsa-utils-dump.c5
6 files changed, 24 insertions, 16 deletions
diff --git a/plugins/alsa/alsa-api-mixer.c b/plugins/alsa/alsa-api-mixer.c
index c4b016c..07bcf12 100644
--- a/plugins/alsa/alsa-api-mixer.c
+++ b/plugins/alsa/alsa-api-mixer.c
@@ -641,13 +641,15 @@ OnErrorExit:
static void MixerBluezAlsaDevVerb(AFB_ReqT request) {
SoftMixerT *mixer = (SoftMixerT*) afb_req_get_vcbdata(request);
-
+ char * interface = NULL, *device = NULL, *profile = NULL;
json_object *argsJ = afb_req_json(request);
- json_object *responseJ = json_object_new_object();
+ int error;
- char * interface = NULL, *device = NULL, *profile = NULL;
+ if (!json_object_is_type(argsJ,json_type_null)) {
+ goto parsed;
+ }
- int error;
+ json_object *responseJ = json_object_new_object();
error = wrap_json_unpack(argsJ, "{ss,ss,ss !}"
, "interface", &interface
@@ -663,8 +665,8 @@ static void MixerBluezAlsaDevVerb(AFB_ReqT request) {
goto OnErrorExit;
}
- printf("%s: interface %s, device %s, profile %s\n", __func__, interface, device, profile);
-
+parsed:
+ printf("%s: interface %s, device %s, profile %s\n", __func__, interface, device, profile);
error = alsa_bluez_set_device(interface, device, profile);
if (error) {
AFB_ReqFailF(request,
diff --git a/plugins/alsa/alsa-api-streams.c b/plugins/alsa/alsa-api-streams.c
index c06a7d4..07d86d1 100644
--- a/plugins/alsa/alsa-api-streams.c
+++ b/plugins/alsa/alsa-api-streams.c
@@ -212,6 +212,7 @@ STATIC int CreateOneStream(SoftMixerT *mixer, const char * uid, AlsaStreamAudioT
captureDev->cardidx = loop->sndcard->cid.cardidx;
captureDev->device = loop->capture;
captureDev->subdev = loopDev->index;
+ captureDev->pcmplug_params = NULL;
captureCard = loop->sndcard;
AFB_ApiInfo(mixer->api,
@@ -246,7 +247,7 @@ STATIC int CreateOneStream(SoftMixerT *mixer, const char * uid, AlsaStreamAudioT
capturePcm->mute = stream->mute;
- AFB_ApiInfo(mixer->api,"%s: PCM opened !\n", __func__);
+ AFB_ApiInfo(mixer->api,"%s: PCM opened !", __func__);
// Registry capturePcm PCM for active/pause event
if (loopDev && loopDev->numid) {
@@ -296,7 +297,7 @@ STATIC int CreateOneStream(SoftMixerT *mixer, const char * uid, AlsaStreamAudioT
if (asprintf(&runName, "pause-%s", stream->uid) == -1)
goto OnErrorExit;
- AFB_ApiInfo(mixer->api,"%s: create mute control !\n", __func__);
+ AFB_ApiInfo(mixer->api,"%s: create mute control...", __func__);
pauseNumid = AlsaCtlCreateControl(mixer, captureCard, runName, 1, 0, 1, 1, stream->mute);
if (pauseNumid <= 0) {
@@ -304,7 +305,7 @@ STATIC int CreateOneStream(SoftMixerT *mixer, const char * uid, AlsaStreamAudioT
goto OnErrorExit;
}
- AFB_ApiInfo(mixer->api,"%s: register mute control !", __func__);
+ AFB_ApiInfo(mixer->api,"%s: register mute control...", __func__);
// Registry stop/play as a pause/resume control
error = AlsaCtlRegister(mixer, captureCard, capturePcm, FONTEND_NUMID_PAUSE, pauseNumid);
@@ -373,7 +374,7 @@ STATIC int CreateOneStream(SoftMixerT *mixer, const char * uid, AlsaStreamAudioT
error = snd_pcm_open(&streamPcm->handle, playbackName, SND_PCM_STREAM_PLAYBACK, 0 /* will block*/ );
if (error) {
AFB_ApiError(mixer->api,
- "%s: mixer=%s stream=%s fail to open capturePcm=%s error=%s",
+ "%s: mixer=%s stream=%s fail to open playback PCM=%s; error=%s",
__func__, mixer->uid, stream->uid, streamPcm->cid.cardid, snd_strerror(error));
goto OnErrorExit;
}
diff --git a/plugins/alsa/alsa-core-ctl.c b/plugins/alsa/alsa-core-ctl.c
index 01e560f..7a0c476 100644
--- a/plugins/alsa/alsa-core-ctl.c
+++ b/plugins/alsa/alsa-core-ctl.c
@@ -639,7 +639,7 @@ OnErrorExit:
PUBLIC int AlsaCtlRegister(SoftMixerT *mixer, AlsaSndCtlT *sndcard, AlsaPcmCtlT *pcmdev, RegistryNumidT type, int numid) {
int index;
- AFB_ApiInfo(mixer->api,"%s: %d!\n", __func__, numid);
+ AFB_ApiInfo(mixer->api,"%s: registered ID %d.", __func__, numid);
for (index = 0; index < sndcard->rcount; index++) {
if (!sndcard->registry[index]) break;
diff --git a/plugins/alsa/alsa-core-pcm.c b/plugins/alsa/alsa-core-pcm.c
index 50e1384..1205a81 100644
--- a/plugins/alsa/alsa-core-pcm.c
+++ b/plugins/alsa/alsa-core-pcm.c
@@ -781,15 +781,15 @@ PUBLIC int AlsaPcmCopy(SoftMixerT *mixer, AlsaStreamAudioT *stream, AlsaPcmCtlT
/// start a thread for writing
if ((error = pthread_create(&cHandle->wthread, NULL, &readThreadEntry, cHandle)) < 0) {
AFB_ApiError(mixer->api,
- "%s Fail create waiting thread pcmIn=%s err=%d",
- __func__, ALSA_PCM_UID(pcmIn->handle, string), error);
+ "%s Fail create write thread pcmOut=%s err=%d",
+ __func__, ALSA_PCM_UID(pcmOut->handle, string), error);
goto OnErrorExit;
}
// start a thread for reading
if ((error = pthread_create(&cHandle->rthread, NULL, &writeThreadEntry, cHandle)) < 0) {
AFB_ApiError(mixer->api,
- "%s Fail create waiting thread pcmIn=%s err=%d",
+ "%s Fail create read thread pcmIn=%s err=%d",
__func__, ALSA_PCM_UID(pcmIn->handle, string), error);
goto OnErrorExit;
}
@@ -809,7 +809,7 @@ PUBLIC int AlsaPcmCopy(SoftMixerT *mixer, AlsaStreamAudioT *stream, AlsaPcmCtlT
if (error) {
AFB_ApiWarning(mixer->api,
"%s: Failed to increase stream write thread priority pcmIn=%s err=%s",
- __func__, ALSA_PCM_UID(pcmIn->handle, string), strerror(error));
+ __func__, ALSA_PCM_UID(pcmOut->handle, string), strerror(error));
}
return 0;
diff --git a/plugins/alsa/alsa-utils-bypath.c b/plugins/alsa/alsa-utils-bypath.c
index 4c258c2..2427e9f 100644
--- a/plugins/alsa/alsa-utils-bypath.c
+++ b/plugins/alsa/alsa-utils-bypath.c
@@ -94,7 +94,7 @@ PUBLIC AlsaPcmCtlT *AlsaByPathOpenPcm(SoftMixerT *mixer, AlsaDevInfoT *pcmDev, s
AFB_ApiInfo(mixer->api,
"%s OPEN PCM '%s', direction %s",
- __func__, pcmCtl->cid.cardid, direction==SND_PCM_STREAM_PLAYBACK?"playback":"capture");
+ __func__, pcmDev->cardid, direction==SND_PCM_STREAM_PLAYBACK?"playback":"capture");
error = snd_pcm_open(&pcmCtl->handle, pcmCtl->cid.cardid, direction, SND_PCM_NONBLOCK);
if (error < 0) {
diff --git a/plugins/alsa/alsa-utils-dump.c b/plugins/alsa/alsa-utils-dump.c
index 28ed83a..3007563 100644
--- a/plugins/alsa/alsa-utils-dump.c
+++ b/plugins/alsa/alsa-utils-dump.c
@@ -182,6 +182,11 @@ PUBLIC void AlsaDumpElemConfig(SoftMixerT *mixer, const char* info, const char*
PUBLIC void AlsaDumpCtlConfig(SoftMixerT *mixer, const char* info, snd_config_t *config, int indent) {
snd_config_iterator_t it, next;
+ if (!config) {
+ AFB_ApiNotice(mixer->api,"%s (%s): no config", __func__, info);
+ return;
+ }
+
// hugly hack to get minimalist indentation
char *pretty = alloca(indent + 1);