[vlc-commits] coreaudio: replace TPCircularBuffer by os_unfair_lock and a block chain

Thomas Guillem git at videolan.org
Thu Jun 21 16:56:53 CEST 2018


vlc/vlc-3.0 | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Mar 12 13:58:28 2018 +0100| [a50e1a3238bbb5f1db8fdec5834974b62bee9cdb] | committer: Thomas Guillem

coreaudio: replace TPCircularBuffer by os_unfair_lock and a block chain

Remove the usage of TPCircularBuffer and multiple atomic variables that start
to make this code way too complicated. Replace it by os_unfair_lock and a block
chain.

os_unfair_lock is a safe spinlock that waits in the kernel in case of thread
contention.

Fallback to pthread_mutex_t if os_unfair_lock is not availaible (before macOS
10.12 / iOS 10.0).

The unfairness of this new lock is not an issue here since both locking threads
(the render callback and the VLC DecoderThread calling aout_DecPlay) will be
automatically paced (and will let the other thread take the lock). Indeed, the
render thread need a sample every 22 or 88ms, and the DecoderThread will wait
for the decoder, wait in the decoder lock, or wait from the aout if the FIFO is
full.

(cherry picked from commit 9bb14edac43e3bf7c4a96b02e3f920f7f7efeb6c)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=a50e1a3238bbb5f1db8fdec5834974b62bee9cdb
---

 modules/audio_output/Makefile.am        |   6 +-
 modules/audio_output/TPCircularBuffer.c | 115 -----------
 modules/audio_output/TPCircularBuffer.h | 175 -----------------
 modules/audio_output/coreaudio_common.c | 335 ++++++++++++++++++++------------
 modules/audio_output/coreaudio_common.h |  30 ++-
 5 files changed, 238 insertions(+), 423 deletions(-)

Diff:   http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commitdiff;h=a50e1a3238bbb5f1db8fdec5834974b62bee9cdb


More information about the vlc-commits mailing list