aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2016-05-28 06:23:55 -0700
committerChris Robinson <[email protected]>2016-05-28 06:23:55 -0700
commit4b8aa9caf11b35d0b670bdba05132357e580a71c (patch)
treeb5bf4307172036ca44d5bc9e1889f3f9c0ffae94 /OpenAL32
parent9025e42afd9f5c518d6e30167bcb4b1d6a6beee8 (diff)
Avoid the mixer lock when getting the plain source offset
i.e. without the latency
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/alSource.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c
index 8a07cf13..a15b169f 100644
--- a/OpenAL32/alSource.c
+++ b/OpenAL32/alSource.c
@@ -51,7 +51,7 @@ static ALvoid InitSourceParams(ALsource *Source);
static ALvoid DeinitSource(ALsource *source);
static ALint64 GetSourceSampleOffset(ALsource *Source, ALCdevice *device, ALuint64 *clocktime);
static ALdouble GetSourceSecOffset(ALsource *Source, ALCdevice *device, ALuint64 *clocktime);
-static ALdouble GetSourceOffset(ALsource *Source, ALenum name);
+static ALdouble GetSourceOffset(ALsource *Source, ALenum name, ALCdevice *device);
static ALboolean GetSampleOffset(ALsource *Source, ALuint *offset, ALuint *frac);
typedef enum SourceProp {
@@ -1056,9 +1056,7 @@ static ALboolean GetSourcedv(ALsource *Source, ALCcontext *Context, SourceProp p
case AL_SEC_OFFSET:
case AL_SAMPLE_OFFSET:
case AL_BYTE_OFFSET:
- LockContext(Context);
- *values = GetSourceOffset(Source, prop);
- UnlockContext(Context);
+ *values = GetSourceOffset(Source, prop, device);
return AL_TRUE;
case AL_CONE_OUTER_GAINHF:
@@ -3146,7 +3144,7 @@ static ALdouble GetSourceSecOffset(ALsource *Source, ALCdevice *device, ALuint64
* (Bytes, Samples or Seconds). The offset is relative to the start of the
* queue (not the start of the current buffer).
*/
-static ALdouble GetSourceOffset(ALsource *Source, ALenum name)
+static ALdouble GetSourceOffset(ALsource *Source, ALenum name, ALCdevice *device)
{
const ALbufferlistitem *BufferList;
const ALbufferlistitem *Current;
@@ -3155,6 +3153,7 @@ static ALdouble GetSourceOffset(ALsource *Source, ALenum name)
ALuint readPos, readPosFrac;
ALuint totalBufferLen;
ALdouble offset = 0.0;
+ ALuint refcount;
ReadLock(&Source->queue_lock);
if(Source->state != AL_PLAYING && Source->state != AL_PAUSED)
@@ -3163,13 +3162,18 @@ static ALdouble GetSourceOffset(ALsource *Source, ALenum name)
return 0.0;
}
- /* NOTE: This is the offset into the *current* buffer, so add the length of
- * any played buffers */
totalBufferLen = 0;
- readPos = ATOMIC_LOAD(&Source->position);
- readPosFrac = ATOMIC_LOAD(&Source->position_fraction, almemory_order_relaxed);
- BufferList = ATOMIC_LOAD(&Source->queue, almemory_order_relaxed);
- Current = ATOMIC_LOAD(&Source->current_buffer, almemory_order_relaxed);
+ do {
+ while(((refcount=ReadRef(&device->MixCount))&1))
+ althrd_yield();
+ /* NOTE: This is the offset into the *current* buffer, so add the length of
+ * any played buffers */
+ readPos = ATOMIC_LOAD(&Source->position, almemory_order_relaxed);
+ readPosFrac = ATOMIC_LOAD(&Source->position_fraction, almemory_order_relaxed);
+ BufferList = ATOMIC_LOAD(&Source->queue, almemory_order_relaxed);
+ Current = ATOMIC_LOAD(&Source->current_buffer, almemory_order_relaxed);
+ } while(refcount != ReadRef(&device->MixCount));
+
while(BufferList != NULL)
{
const ALbuffer *buffer;