aboutsummaryrefslogtreecommitdiffstats
path: root/core/voice.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/voice.cpp')
-rw-r--r--core/voice.cpp45
1 files changed, 23 insertions, 22 deletions
diff --git a/core/voice.cpp b/core/voice.cpp
index c764a277..e580ef05 100644
--- a/core/voice.cpp
+++ b/core/voice.cpp
@@ -557,28 +557,6 @@ void Voice::mix(const State vstate, ContextBase *Context, const uint SamplesToDo
}
}
- if((mFlags&(VoiceIsCallback|VoiceCallbackStopped)) == VoiceIsCallback && BufferListItem)
- {
- if(SrcBufferSize > mNumCallbackSamples)
- {
- const size_t byteOffset{mNumCallbackSamples*mFrameSize};
- const size_t needBytes{SrcBufferSize*mFrameSize - byteOffset};
-
- const int gotBytes{BufferListItem->mCallback(BufferListItem->mUserData,
- &BufferListItem->mSamples[byteOffset], static_cast<int>(needBytes))};
- if(gotBytes < 0)
- mFlags |= VoiceCallbackStopped;
- else if(static_cast<uint>(gotBytes) < needBytes)
- {
- mFlags |= VoiceCallbackStopped;
- mNumCallbackSamples += static_cast<uint>(static_cast<uint>(gotBytes) /
- mFrameSize);
- }
- else
- mNumCallbackSamples = SrcBufferSize;
- }
- }
-
if UNLIKELY(!BufferListItem)
{
for(auto &chanbuffer : mVoiceSamples)
@@ -604,8 +582,31 @@ void Voice::mix(const State vstate, ContextBase *Context, const uint SamplesToDo
LoadBufferStatic(BufferListItem, BufferLoopItem, DataPosInt, mFmtType, mFmtChannels,
SrcBufferSize, mVoiceSamples);
else if((mFlags&VoiceIsCallback))
+ {
+ if(!(mFlags&VoiceCallbackStopped))
+ {
+ if(SrcBufferSize > mNumCallbackSamples)
+ {
+ const size_t byteOffset{mNumCallbackSamples*mFrameSize};
+ const size_t needBytes{SrcBufferSize*mFrameSize - byteOffset};
+
+ const int gotBytes{BufferListItem->mCallback(BufferListItem->mUserData,
+ &BufferListItem->mSamples[byteOffset], static_cast<int>(needBytes))};
+ if(gotBytes < 0)
+ mFlags |= VoiceCallbackStopped;
+ else if(static_cast<uint>(gotBytes) < needBytes)
+ {
+ mFlags |= VoiceCallbackStopped;
+ mNumCallbackSamples += static_cast<uint>(static_cast<uint>(gotBytes) /
+ mFrameSize);
+ }
+ else
+ mNumCallbackSamples = SrcBufferSize;
+ }
+ }
LoadBufferCallback(BufferListItem, mNumCallbackSamples, mFmtType, mFmtChannels,
SrcBufferSize, mVoiceSamples);
+ }
else
LoadBufferQueue(BufferListItem, BufferLoopItem, DataPosInt, mFmtType, mFmtChannels,
SrcBufferSize, mVoiceSamples);