Skip to content

Commit 359f8a4

Browse files
committed
修复部分flac播放到末尾不自动停止的问题
1 parent a72c020 commit 359f8a4

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

Sources/CSFBAudioEngine/Decoders/SFBFLACDecoder.mm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)