From b07e69620e1aca7ffcd9fb02a0fd2b62d81f58c2 Mon Sep 17 00:00:00 2001 From: axel10 Date: Fri, 22 May 2026 16:50:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86flac?= =?UTF-8?q?=E6=92=AD=E6=94=BE=E5=88=B0=E6=9C=AB=E5=B0=BE=E4=B8=8D=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=81=9C=E6=AD=A2=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/CSFBAudioEngine/Decoders/SFBFLACDecoder.mm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Sources/CSFBAudioEngine/Decoders/SFBFLACDecoder.mm b/Sources/CSFBAudioEngine/Decoders/SFBFLACDecoder.mm index 0ec8dd53..352f779c 100644 --- a/Sources/CSFBAudioEngine/Decoders/SFBFLACDecoder.mm +++ b/Sources/CSFBAudioEngine/Decoders/SFBFLACDecoder.mm @@ -446,6 +446,16 @@ - (BOOL)decodeIntoBuffer:(AVAudioPCMBuffer *)buffer frameLength:(AVAudioFrameCou return YES; } + if (_streamInfo.total_samples > 0) { + if (_framePosition >= static_cast(_streamInfo.total_samples)) { + return YES; + } + const auto framesRemaining = _streamInfo.total_samples - static_cast(_framePosition); + if (framesRemaining < frameLength) { + frameLength = static_cast(framesRemaining); + } + } + AVAudioFrameCount framesProcessed = 0; for (;;) { @@ -501,6 +511,7 @@ - (BOOL)seekToFrame:(AVAudioFramePosition)frame error:(NSError **)error { } _framePosition = frame; + _frameBuffer.frameLength = 0; return YES; }