diff options
author | Chris Robinson <[email protected]> | 2021-12-18 03:59:32 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2021-12-18 03:59:32 -0800 |
commit | 0a87828b4134e7bde65a8f2e2e2b98519ca891d3 (patch) | |
tree | 5e702fb34cee5ea288d95621a68c949632adbf75 | |
parent | 5bfa7c22fd8693060a809a9e5c3d55b78dae08b1 (diff) |
Don't swallow up buffer callback samples when pausing
-rw-r--r-- | core/voice.cpp | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/core/voice.cpp b/core/voice.cpp index 12df996a..1eb804ac 100644 --- a/core/voice.cpp +++ b/core/voice.cpp @@ -733,18 +733,24 @@ void Voice::mix(const State vstate, ContextBase *Context, const uint SamplesToDo } else if((mFlags&VoiceIsCallback)) { - if(SrcSamplesDone < mNumCallbackSamples) - { - const size_t byteOffset{SrcSamplesDone*mFrameSize}; - const size_t byteEnd{mNumCallbackSamples*mFrameSize}; - al::byte *data{BufferListItem->mSamples}; - std::copy(data+byteOffset, data+byteEnd, data); - mNumCallbackSamples -= SrcSamplesDone; - } - else + /* Don't use up the stored callback samples when stopping (pausing) + * since they'll be replayed when resuming. + */ + if(likely(vstate == Playing)) { - BufferListItem = nullptr; - mNumCallbackSamples = 0; + if(SrcSamplesDone < mNumCallbackSamples) + { + const size_t byteOffset{SrcSamplesDone*mFrameSize}; + const size_t byteEnd{mNumCallbackSamples*mFrameSize}; + al::byte *data{BufferListItem->mSamples}; + std::copy(data+byteOffset, data+byteEnd, data); + mNumCallbackSamples -= SrcSamplesDone; + } + else + { + BufferListItem = nullptr; + mNumCallbackSamples = 0; + } } } else |