File tree Expand file tree Collapse file tree
Sources/CSFBAudioEngine/Decoders Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -446,6 +446,16 @@ - (BOOL)decodeIntoBuffer:(AVAudioPCMBuffer *)buffer frameLength:(AVAudioFrameCou
446446 return YES ;
447447 }
448448
449+ if (_streamInfo.total_samples > 0 ) {
450+ if (_framePosition >= static_cast <AVAudioFramePosition>(_streamInfo.total_samples )) {
451+ return YES ;
452+ }
453+ const auto framesRemaining = _streamInfo.total_samples - static_cast <uint64_t >(_framePosition);
454+ if (framesRemaining < frameLength) {
455+ frameLength = static_cast <AVAudioFrameCount>(framesRemaining);
456+ }
457+ }
458+
449459 AVAudioFrameCount framesProcessed = 0 ;
450460
451461 for (;;) {
@@ -501,6 +511,7 @@ - (BOOL)seekToFrame:(AVAudioFramePosition)frame error:(NSError **)error {
501511 }
502512
503513 _framePosition = frame;
514+ _frameBuffer.frameLength = 0 ;
504515 return YES ;
505516}
506517
You can’t perform that action at this time.
0 commit comments