aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2021-06-14 01:51:04 -0700
committerChris Robinson <[email protected]>2021-06-14 01:51:04 -0700
commit2f16fc190f2d71d7a5a3557fa61bb7a47f8fd701 (patch)
tree8fc9dda6b426e3aff3262c1a1141c869d2a72957 /core
parent9c58ed73d3a91ac67e4d657f42341a51749a5c43 (diff)
Combine some checks
Diffstat (limited to 'core')
-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);