From 7cbf77c2b64f6559e4fb4b2d1b0701190c37efc6 Mon Sep 17 00:00:00 2001 From: Isaac <> Date: Tue, 24 Dec 2024 14:42:59 +0800 Subject: [PATCH] Return EOF when fetchedCount == 0 --- .../MediaPlayer/Sources/FFMpegMediaFrameSourceContext.swift | 4 ++++ .../MediaPlayer/Sources/UniversalSoftwareVideoSource.swift | 3 +++ 2 files changed, 7 insertions(+) diff --git a/submodules/MediaPlayer/Sources/FFMpegMediaFrameSourceContext.swift b/submodules/MediaPlayer/Sources/FFMpegMediaFrameSourceContext.swift index 2557ff8ca2..152f2270b8 100644 --- a/submodules/MediaPlayer/Sources/FFMpegMediaFrameSourceContext.swift +++ b/submodules/MediaPlayer/Sources/FFMpegMediaFrameSourceContext.swift @@ -184,6 +184,10 @@ private func readPacketCallback(userData: UnsafeMutableRawPointer?, buffer: Unsa } fetchedCount = Int32(fetchedData.count) context.readingOffset += Int64(fetchedCount) + + if fetchedCount == 0 { + return FFMPEG_CONSTANT_AVERROR_EOF + } } if context.closed { diff --git a/submodules/MediaPlayer/Sources/UniversalSoftwareVideoSource.swift b/submodules/MediaPlayer/Sources/UniversalSoftwareVideoSource.swift index 4fd2366c7f..f6800ae681 100644 --- a/submodules/MediaPlayer/Sources/UniversalSoftwareVideoSource.swift +++ b/submodules/MediaPlayer/Sources/UniversalSoftwareVideoSource.swift @@ -70,6 +70,9 @@ private func readPacketCallback(userData: UnsafeMutableRawPointer?, buffer: Unsa } let fetchedCount = Int32(fetchedData.count) context.readingOffset += Int64(fetchedCount) + if fetchedCount == 0 { + return FFMPEG_CONSTANT_AVERROR_EOF + } return fetchedCount } else { return FFMPEG_CONSTANT_AVERROR_EOF