aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/Include/alMain.h14
-rw-r--r--OpenAL32/alSource.c18
2 files changed, 26 insertions, 6 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index b604c547..174210fa 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -204,6 +204,20 @@ AL_API const ALchar* AL_APIENTRY alGetStringiSOFT(ALenum pname, ALsizei index);
#endif
+#ifdef __GNUC__
+/* This helps cast away the const-ness of a pointer without accidentally
+ * changing the pointer type. This is necessary due to Clang's inability to use
+ * atomic_load on a const _Atomic variable.
+ */
+#define CONST_CAST(T, V) __extension__({ \
+ const T _tmp = (V); \
+ (T)_tmp; \
+})
+#else
+#define CONST_CAST(T, V) ((T)(V))
+#endif
+
+
typedef ALint64SOFT ALint64;
typedef ALuint64SOFT ALuint64;
diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c
index 23b4fb5a..f2c4908f 100644
--- a/OpenAL32/alSource.c
+++ b/OpenAL32/alSource.c
@@ -1407,7 +1407,8 @@ static ALboolean GetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp p
while(BufferList && BufferList != Current)
{
played++;
- BufferList = ATOMIC_LOAD(&BufferList->next, almemory_order_relaxed);
+ BufferList = ATOMIC_LOAD(&CONST_CAST(ALbufferlistitem*,BufferList)->next,
+ almemory_order_relaxed);
}
*values = played;
}
@@ -3177,7 +3178,8 @@ static ALint64 GetSourceSampleOffset(ALsource *Source, ALCcontext *context, ALui
{
if(BufferList->buffer)
readPos += (ALuint64)BufferList->buffer->SampleLen << 32;
- BufferList = ATOMIC_LOAD(&BufferList->next, almemory_order_relaxed);
+ BufferList = ATOMIC_LOAD(&CONST_CAST(ALbufferlistitem*,BufferList)->next,
+ almemory_order_relaxed);
}
readPos = minu64(readPos, U64(0x7fffffffffffffff));
}
@@ -3233,13 +3235,15 @@ static ALdouble GetSourceSecOffset(ALsource *Source, ALCcontext *context, ALuint
if(!BufferFmt) BufferFmt = buffer;
readPos += (ALuint64)buffer->SampleLen << FRACTIONBITS;
}
- BufferList = ATOMIC_LOAD(&BufferList->next, almemory_order_relaxed);
+ BufferList = ATOMIC_LOAD(&CONST_CAST(ALbufferlistitem*,BufferList)->next,
+ almemory_order_relaxed);
}
while(BufferList && !BufferFmt)
{
BufferFmt = BufferList->buffer;
- BufferList = ATOMIC_LOAD(&BufferList->next, almemory_order_relaxed);
+ BufferList = ATOMIC_LOAD(&CONST_CAST(ALbufferlistitem*,BufferList)->next,
+ almemory_order_relaxed);
}
assert(BufferFmt != NULL);
@@ -3302,7 +3306,8 @@ static ALdouble GetSourceOffset(ALsource *Source, ALenum name, ALCcontext *conte
totalBufferLen += buffer->SampleLen;
if(!readFin) readPos += buffer->SampleLen;
}
- BufferList = ATOMIC_LOAD(&BufferList->next, almemory_order_relaxed);
+ BufferList = ATOMIC_LOAD(&CONST_CAST(ALbufferlistitem*,BufferList)->next,
+ almemory_order_relaxed);
}
assert(BufferFmt != NULL);
@@ -3421,7 +3426,8 @@ static ALboolean GetSampleOffset(ALsource *Source, ALuint *offset, ALsizei *frac
{
if((BufferFmt=BufferList->buffer) != NULL)
break;
- BufferList = ATOMIC_LOAD(&BufferList->next, almemory_order_relaxed);
+ BufferList = ATOMIC_LOAD(&CONST_CAST(ALbufferlistitem*,BufferList)->next,
+ almemory_order_relaxed);
}
if(!BufferFmt)
{