mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
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:
committed by
Tim Flynn
parent
c6d0075796
commit
70b3936188
@@ -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" };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user