diff options
author | Thomas Weißschuh <thomas@t-8ch.de> | 2023-10-15 19:09:34 +0200 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2023-10-20 21:33:46 +0200 |
commit | ae908a70cecebb2cac8354a3b4d8967af847bd3e (patch) | |
tree | 695a1b07ac1491e47ac05ee4d871a716893f9b68 /audio/out/buffer.c | |
parent | dd13412986e52671b1e19c6c7ddb81593b5d211f (diff) | |
download | mpv-ae908a70cecebb2cac8354a3b4d8967af847bd3e.tar.bz2 mpv-ae908a70cecebb2cac8354a3b4d8967af847bd3e.tar.xz |
audio: don't block on lock in ao_read_data
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.
Diffstat (limited to 'audio/out/buffer.c')
-rw-r--r-- | audio/out/buffer.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/audio/out/buffer.c b/audio/out/buffer.c index c0457ba279..e23e4cf108 100644 --- a/audio/out/buffer.c +++ b/audio/out/buffer.c @@ -184,7 +184,8 @@ int ao_read_data(struct ao *ao, void **data, int samples, int64_t out_time_ns) 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}); |