From c297b51a6ea070f16bc6044fda01da5b37aa1cbd Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 7 Feb 2015 10:09:01 -0800 Subject: [PATCH] Add a note to the JACK backend about a (minor) race condition --- Alc/backends/jack.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Alc/backends/jack.c b/Alc/backends/jack.c index 75ced9c4..57f129fc 100644 --- a/Alc/backends/jack.c +++ b/Alc/backends/jack.c @@ -289,6 +289,20 @@ static int ALCjackPlayback_mixerProc(void *arg) { ALuint todo, len1, len2; + /* NOTE: Unfortunately, there is an unavoidable race condition here. + * It's possible for the process() method to run, updating the read + * pointer and signaling the condition variable, in between the mixer + * loop checking the write size and waiting for the condition variable. + * This will cause the mixer loop to wait until the *next* process() + * invocation, most likely writing silence for it. + * + * However, this should only happen if the mixer is running behind + * anyway (as ideally we'll be asleep in alcnd_wait by the time the + * process() method is invoked), so this behavior is not unwarranted. + * It's unfortunate since it'll be wasting time sleeping that could be + * used to catch up, but there's no way around it without blocking in + * the process() method. + */ if(ll_ringbuffer_write_space(self->Ring) < device->UpdateSize) { alcnd_wait(&self->Cond, &STATIC_CAST(ALCbackend,self)->mMutex); -- 2.11.4.GIT