Skip to content

Commit

Permalink
fix: correct buffer lengths on real ios devices (#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
michalsek authored Dec 10, 2024
1 parent ef4327d commit 7fd138a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ void AudioDestinationNode::renderAudio(
}

context_->getNodeManager()->preProcessGraph();

destinationBus->zero();

AudioBus *processedBus = processAudio(destinationBus, numFrames);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ std::shared_ptr<AudioBuffer> BaseAudioContext::decodeAudioDataSource(
#endif

std::function<void(AudioBus *, int)> BaseAudioContext::renderAudio() {
if (isClosed()) {
if (!isRunning()) {
return [](AudioBus *, int) {};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ - (int)getBufferSizeInFrames
// which is safer to base our internal AudioBus sizes.
// Buut no documentation => no guarantee :)
// If something is crackling when it should play silence, start here 📻
return (int)(self.audioSession.preferredIOBufferDuration * self.audioSession.sampleRate);
double maxBufferDuration = fmax(0.02, fmax(self.audioSession.IOBufferDuration, self.audioSession.preferredIOBufferDuration));
return (int)(maxBufferDuration * self.audioSession.sampleRate + 1);
}

- (void)start
Expand Down

0 comments on commit 7fd138a

Please sign in to comment.