Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions plugins/linux-alsa/alsa-input.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");

Expand Down Expand Up @@ -154,6 +156,8 @@ void alsa_destroy(void *vptr)
{
struct alsa_data *data = vptr;

data->shutdown = true;

if (data->handle)
_alsa_close(data);

Expand Down Expand Up @@ -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;

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

Expand Down Expand Up @@ -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;

Expand Down