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
This commit is contained in:
Wim Taymans 2020-11-25 12:35:33 +01:00
parent 38fcc64e1f
commit b055b9de25

View file

@ -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;