aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends
diff options
context:
space:
mode:
Diffstat (limited to 'Alc/backends')
-rw-r--r--Alc/backends/jack.c14
1 files changed, 14 insertions, 0 deletions
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);