summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/alsa/alsa-api-loop.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/plugins/alsa/alsa-api-loop.c b/plugins/alsa/alsa-api-loop.c
index c9456f2..7949c63 100644
--- a/plugins/alsa/alsa-api-loop.c
+++ b/plugins/alsa/alsa-api-loop.c
@@ -236,6 +236,7 @@ static void freeSubdev(SoftMixerT* mixer, AlsaLoopSubdevT * subdev) {
STATIC AlsaSndLoopT *AttachOneLoop(SoftMixerT *mixer, const char *uid, json_object *argsJ, json_object *streamsJ) {
+ AlsaLoopSubdevT * subdev;
json_object *subdevsJ = NULL, *devicesJ = NULL;
int error;
@@ -303,8 +304,6 @@ STATIC AlsaSndLoopT *AttachOneLoop(SoftMixerT *mixer, const char *uid, json_obje
}
}
- AlsaLoopSubdevT * subdev;
-
switch (json_object_get_type(subdevsJ)) {
case json_type_object:
subdev = ProcessOneSubdev(mixer, loop, subdevsJ);
@@ -335,9 +334,7 @@ STATIC AlsaSndLoopT *AttachOneLoop(SoftMixerT *mixer, const char *uid, json_obje
AFB_API_NOTICE(mixer->api, "nbStreams: %d max.streams: %d", mixer->nbStreams, mixer->max.streams);
if (mixer->nbStreams >= mixer->max.streams)
- goto fail_snd_card_ctl;
-
- AlsaLoopSubdevT * subdev;
+ goto fail_snd_card;
// Create AVIRT streams
switch (json_object_get_type(streamsJ)) {
@@ -364,7 +361,7 @@ STATIC AlsaSndLoopT *AttachOneLoop(SoftMixerT *mixer, const char *uid, json_obje
break;
}
default:
- goto fail_snd_card_ctl;
+ goto fail_snd_card;
}
snd_avirt_card_seal();
@@ -382,17 +379,18 @@ STATIC AlsaSndLoopT *AttachOneLoop(SoftMixerT *mixer, const char *uid, json_obje
return loop;
-fail_loop_subdev: {
+fail_loop_subdev:
AFB_API_DEBUG(mixer->api, "%s cleanup", __func__);
- AlsaLoopSubdevT * subdev, *tmp;
+ AlsaLoopSubdevT *tmp;
cds_list_for_each_entry_safe(subdev, tmp, &loop->subdevs.list, list) {
cds_list_del(&subdev->list);
freeSubdev(mixer, subdev);
}
-}
fail_snd_card_ctl:
- snd_ctl_close(loop->sndcard->ctl);
+ /* in the case of avirt, loop->sndcard->ctl may be NULL */
+ if (loop->sndcard->ctl)
+ snd_ctl_close(loop->sndcard->ctl);
fail_snd_card:
free(loop->sndcard);
fail_loop: