diff --git a/plugins/linux-alsa/alsa-input.c b/plugins/linux-alsa/alsa-input.c index cb6d79dce9920d..4e28201a9884c2 100644 --- a/plugins/linux-alsa/alsa-input.c +++ b/plugins/linux-alsa/alsa-input.c @@ -51,6 +51,7 @@ struct alsa_data { os_event_t *abort_event; volatile bool listen; volatile bool reopen; + volatile bool shutdown; /* alsa */ snd_pcm_t *handle; @@ -123,6 +124,7 @@ void *alsa_create(obs_data_t *settings, obs_source_t *source) data->reopen = false; data->listen_thread = 0; data->reopen_thread = 0; + data->shutdown = false; const char *device = obs_data_get_string(settings, "device_id"); @@ -154,6 +156,8 @@ void alsa_destroy(void *vptr) { struct alsa_data *data = vptr; + data->shutdown = true; + if (data->handle) _alsa_close(data); @@ -342,6 +346,9 @@ bool _alsa_try_open(struct alsa_data *data) { _alsa_stop_reopen(data); + if (data->shutdown) + return false; + if (_alsa_open(data)) return true; @@ -352,6 +359,9 @@ bool _alsa_try_open(struct alsa_data *data) bool _alsa_open(struct alsa_data *data) { + if (data->shutdown) + return false; + pthread_attr_t attr; int err; @@ -501,6 +511,9 @@ bool _alsa_configure(struct alsa_data *data) void _alsa_start_reopen(struct alsa_data *data) { + if (data->shutdown) + return; + pthread_attr_t attr; int err;