From 4b080f7610265e5dd2c846b4efdd70832a0a2d1f Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Wed, 19 Jan 2022 00:25:52 +1100 Subject: [PATCH] [client] audio: don't lock when consuming frames from the buffer --- client/src/audio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/src/audio.c b/client/src/audio.c index 8381e46a..abcba588 100644 --- a/client/src/audio.c +++ b/client/src/audio.c @@ -133,8 +133,6 @@ void playbackStopNL(void) static int playbackPullFrames(uint8_t ** data, int frames) { - LG_LOCK(audio.playback.lock); - if (audio.playback.buffer) *data = ringbuffer_consume(audio.playback.buffer, &frames); else @@ -142,9 +140,11 @@ static int playbackPullFrames(uint8_t ** data, int frames) if (audio.playback.state == STREAM_STATE_DRAIN && ringbuffer_getCount(audio.playback.buffer) == 0) + { + LG_LOCK(audio.playback.lock); playbackStopNL(); - - LG_UNLOCK(audio.playback.lock); + LG_UNLOCK(audio.playback.lock); + } return frames; }