Skip to content

Commit 46a3ce5

Browse files
author
Maciej Makowski
committed
fix: minor fix
1 parent 42a3aca commit 46a3ce5

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

packages/react-native-audio-api/common/cpp/audioapi/core/sources/AudioBufferStreamSourceNode.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,18 +112,20 @@ void AudioBufferStreamSourceNode::processWithPitchCorrection(
112112

113113
playbackRateBus_->zero();
114114

115-
auto framesNeededToStretch =
116-
static_cast<int>(playbackRate * static_cast<float>(framesToProcess));
117-
118115
updatePlaybackInfo(
119-
playbackRateBus_, framesNeededToStretch, startOffset, offsetLength);
116+
processingBus, framesToProcess, startOffset, offsetLength);
120117

121118
if (playbackRate == 0.0f || (!isPlaying() && !isStopScheduled())) {
122119
processingBus->zero();
123120
return;
124121
}
125122

126-
processWithoutInterpolation(playbackRateBus_, startOffset, offsetLength);
123+
auto framesNeededToStretch =
124+
static_cast<int>(playbackRate * static_cast<float>(framesToProcess));
125+
auto stretchedStartOffset = static_cast<size_t>(static_cast<float>(startOffset) * playbackRate);
126+
auto stretchedOffsetLength = static_cast<size_t>(static_cast<float>(offsetLength) * playbackRate);
127+
128+
processWithoutInterpolation(playbackRateBus_, stretchedStartOffset, stretchedOffsetLength);
127129

128130
stretch_->process(
129131
playbackRateBus_.get()[0],

0 commit comments

Comments
 (0)