From b055b9de253b468e8ad0a3b208a4c31a5efc91c1 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 25 Nov 2020 12:35:33 +0100 Subject: [PATCH] alsa: Make sure we handle errors in close When a device is removed, close() will error. Warn about this but continue closing our other things including marking the device as closed so that we don't try to close it again later. Fixes #413 --- spa/plugins/alsa/alsa-pcm.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c index 2601b6580..c550c0c76 100644 --- a/spa/plugins/alsa/alsa-pcm.c +++ b/spa/plugins/alsa/alsa-pcm.c @@ -74,11 +74,15 @@ int spa_alsa_close(struct state *state) return 0; spa_log_debug(state->log, NAME" %p: Device '%s' closing", state, state->props.device); - CHECK(snd_pcm_close(state->hndl), "%s: close failed", state->props.device); + if ((err = snd_pcm_close(state->hndl)) < 0) + spa_log_warn(state->log, "%s: close failed: %s", state->props.device, + snd_strerror(err)); - CHECK(snd_output_close(state->output), "output close failed"); + if ((err = snd_output_close(state->output)) < 0) + spa_log_warn(state->log, "output close failed: %s", snd_strerror(err)); spa_system_close(state->data_system, state->timerfd); + state->opened = false; return err;