alsa: clear output and log file after doing alsa API

Also be a bit more careful when the handles are NULL.
This commit is contained in:
Wim Taymans 2026-05-06 16:05:30 +02:00
parent 91755950dd
commit eadaa2608a

View file

@ -1068,7 +1068,7 @@ int spa_alsa_init(struct state *state, const struct spa_dict *info)
int spa_alsa_clear(struct state *state)
{
int err;
int err = 0;
struct state *follower;
spa_list_remove(&state->link);
@ -1094,10 +1094,6 @@ int spa_alsa_clear(struct state *state)
state->card = NULL;
state->card_index = SPA_ID_INVALID;
if ((err = snd_output_close(state->output)) < 0)
spa_log_warn(state->log, "output close failed: %s", snd_strerror(err));
fclose(state->log_file);
free(state->tag[0]);
free(state->tag[1]);
@ -1121,6 +1117,13 @@ int spa_alsa_clear(struct state *state)
}
}
if (state->output) {
if ((err = snd_output_close(state->output)) < 0)
spa_log_warn(state->log, "output close failed: %s", snd_strerror(err));
}
if (state->log_file)
fclose(state->log_file);
spa_clear_ptr(state->alsa_chmap, free);
return err;