Skip to content

Commit

Permalink
audio: don't block on lock in ao_read_data
Browse files Browse the repository at this point in the history
ao_read_data() is used by pull AOs potentially from threads managed by
external libraries.  These threads can be sensitive to blocking.
For example the pipewire ao is using a realtime thread for the
callbacks.
  • Loading branch information
t-8ch committed Oct 16, 2023
1 parent 9f1a9d6 commit f2301d5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion audio/out/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ int ao_read_data(struct ao *ao, void **data, int samples, int64_t out_time_us)
struct buffer_state *p = ao->buffer_state;
assert(!ao->driver->write);

pthread_mutex_lock(&p->lock);
if (pthread_mutex_trylock(&p->lock))
return 0;

int pos = read_buffer(ao, data, samples, &(bool){0});

Expand Down

0 comments on commit f2301d5

Please sign in to comment.