LibMedia: Handle EOF as end of stream in FFmpegLoader
We were dealing with EOF by returning a generic I/O error, but Audio::Loader requires us to return empty chunks at the end of stream.
This commit is contained in:
parent
c6d0075796
commit
70b3936188
Notes:
github-actions[bot]
2024-10-14 16:05:41 +00:00
Author: https://github.com/gmta Commit: https://github.com/LadybirdBrowser/ladybird/commit/70b39361883 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1787
1 changed files with 6 additions and 2 deletions
|
@ -260,8 +260,12 @@ ErrorOr<Vector<FixedArray<Sample>>, LoaderError> FFmpegLoaderPlugin::load_chunks
|
|||
|
||||
do {
|
||||
// Obtain a packet
|
||||
if (av_read_frame(m_format_context, m_packet) < 0)
|
||||
auto read_frame_error = av_read_frame(m_format_context, m_packet);
|
||||
if (read_frame_error < 0) {
|
||||
if (read_frame_error == AVERROR_EOF)
|
||||
break;
|
||||
return LoaderError { LoaderError::Category::IO, "Failed to read frame" };
|
||||
}
|
||||
if (m_packet->stream_index != m_audio_stream->index) {
|
||||
av_packet_unref(m_packet);
|
||||
continue;
|
||||
|
@ -278,7 +282,7 @@ ErrorOr<Vector<FixedArray<Sample>>, LoaderError> FFmpegLoaderPlugin::load_chunks
|
|||
if (receive_frame_error == AVERROR(EAGAIN))
|
||||
continue;
|
||||
if (receive_frame_error == AVERROR_EOF)
|
||||
return Error::from_errno(EOF);
|
||||
break;
|
||||
return LoaderError { LoaderError::Category::IO, "Failed to receive frame" };
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue