diff options
author | Chris Robinson <[email protected]> | 2022-02-14 04:18:48 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2022-02-14 04:18:48 -0800 |
commit | e0f87c44c0fe320b1d6ad706033459d27e06a458 (patch) | |
tree | 1974f52b87b6797e11a26b7b48497772b4e5c709 /al | |
parent | f9ed6f85c89a8ee194a56449eafbdcb311abd534 (diff) |
Don't access a playing voice's mFlags outside of the mixer thread
It's updated asynchronously, and it's non-atomic, so it's unsafe to even read
since the mixer thread may be modifying it.
Diffstat (limited to 'al')
-rw-r--r-- | al/source.cpp | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/al/source.cpp b/al/source.cpp index 9817674f..4e3fb3b5 100644 --- a/al/source.cpp +++ b/al/source.cpp @@ -427,7 +427,7 @@ al::optional<VoicePos> GetSampleOffset(al::deque<ALbufferQueueItem> &BufferList, BufferFmt = item.mBuffer; if(BufferFmt) break; } - if(!BufferFmt) + if(!BufferFmt || BufferFmt->mCallback) return al::nullopt; /* Get sample frame offset */ @@ -477,7 +477,7 @@ al::optional<VoicePos> GetSampleOffset(al::deque<ALbufferQueueItem> &BufferList, if(item.mSampleLen > offset-totalBufferLen) { /* Offset is in this buffer */ - return al::make_optional(VoicePos{offset-totalBufferLen, frac, &item}); + return VoicePos{offset-totalBufferLen, frac, &item}; } totalBufferLen += item.mSampleLen; } @@ -1283,9 +1283,6 @@ void SetSourcefv(ALsource *Source, ALCcontext *Context, SourceProp prop, if(Voice *voice{GetSourceVoice(Source, Context)}) { - if(voice->mFlags.test(VoiceIsCallback)) - SETERR_RETURN(Context, AL_INVALID_VALUE,, - "Source offset for callback is invalid"); auto vpos = GetSampleOffset(Source->mQueue, prop, values[0]); if(!vpos) SETERR_RETURN(Context, AL_INVALID_VALUE,, "Invalid offset"); @@ -1506,9 +1503,6 @@ void SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp prop, if(Voice *voice{GetSourceVoice(Source, Context)}) { - if(voice->mFlags.test(VoiceIsCallback)) - SETERR_RETURN(Context, AL_INVALID_VALUE,, - "Source offset for callback is invalid"); auto vpos = GetSampleOffset(Source->mQueue, prop, values[0]); if(!vpos) SETERR_RETURN(Context, AL_INVALID_VALUE,, "Invalid source offset"); |