diff options
author | Chris Robinson <[email protected]> | 2020-02-17 00:32:22 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-02-17 00:32:22 -0800 |
commit | a221f8671e8e1424d623222d64f0555c51342525 (patch) | |
tree | 48f6f398f311fcf6862c7e29aabe63b9e70db1b1 /al | |
parent | ccc6da0a5bb691987b95ec7f7b6c8a7cda13b7da (diff) |
Prevent queueing a callback buffer
Also prevent setting it on multiple sources
Diffstat (limited to 'al')
-rw-r--r-- | al/source.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/al/source.cpp b/al/source.cpp index 27f4cbbc..bc850a6d 100644 --- a/al/source.cpp +++ b/al/source.cpp @@ -1159,13 +1159,15 @@ bool SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp prop, const a SETERR_RETURN(Context, AL_INVALID_VALUE, false, "Invalid buffer ID %u", static_cast<ALuint>(values[0])); - if(buffer && buffer->MappedAccess != 0 && - !(buffer->MappedAccess&AL_MAP_PERSISTENT_BIT_SOFT)) + if(buffer && buffer->MappedAccess && !(buffer->MappedAccess&AL_MAP_PERSISTENT_BIT_SOFT)) SETERR_RETURN(Context, AL_INVALID_OPERATION, false, "Setting non-persistently mapped buffer %u", buffer->id); + else if(buffer && buffer->Callback && ReadRef(buffer->ref) != 0) + SETERR_RETURN(Context, AL_INVALID_OPERATION, false, + "Setting already-set callback buffer %u", buffer->id); else { - ALenum state = GetSourceState(Source, GetSourceVoice(Source, Context)); + const ALenum state{GetSourceState(Source, GetSourceVoice(Source, Context))}; if(state == AL_PLAYING || state == AL_PAUSED) SETERR_RETURN(Context, AL_INVALID_OPERATION, false, "Setting buffer on playing or paused source %u", Source->id); @@ -3098,6 +3100,11 @@ START_API_FUNC context->setError(AL_INVALID_NAME, "Queueing invalid buffer ID %u", buffers[i]); goto buffer_error; } + if(buffer && buffer->Callback) + { + context->setError(AL_INVALID_OPERATION, "Queueing callback buffer %u", buffers[i]); + goto buffer_error; + } if(!BufferListStart) { |