diff options
-rw-r--r-- | plugins/alsa/alsa-api-loop.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/plugins/alsa/alsa-api-loop.c b/plugins/alsa/alsa-api-loop.c index 8cf0c4e..e5e6af5 100644 --- a/plugins/alsa/alsa-api-loop.c +++ b/plugins/alsa/alsa-api-loop.c @@ -235,6 +235,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; @@ -302,8 +303,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); @@ -334,9 +333,7 @@ STATIC AlsaSndLoopT *AttachOneLoop(SoftMixerT *mixer, const char *uid, json_obje AFB_ApiNotice(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)) { @@ -363,7 +360,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(); @@ -381,17 +378,18 @@ STATIC AlsaSndLoopT *AttachOneLoop(SoftMixerT *mixer, const char *uid, json_obje return loop; -fail_loop_subdev: { +fail_loop_subdev: AFB_ApiDebug(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: |