aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends/jack.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2015-02-07 10:09:01 -0800
committerChris Robinson <[email protected]>2015-02-07 10:09:01 -0800
commitc297b51a6ea070f16bc6044fda01da5b37aa1cbd (patch)
tree2857a2e96bb5c6af37bff568eef45acf889ebc2d /Alc/backends/jack.c
parentf5dd5c13303f4396e1d03868898ad06d1b73ed4b (diff)
Add a note to the JACK backend about a (minor) race condition
Diffstat (limited to 'Alc/backends/jack.c')
-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);