Commit 52bb03e1 authored by Max Kellermann's avatar Max Kellermann

decoder/mad: eliminate redundant error handling from DecodeNextFrame()

Much of that is not possible when mad_header_decode() has already been called.
parent a90685d6
...@@ -388,8 +388,6 @@ RecoverFrameError(const struct mad_stream &stream) noexcept ...@@ -388,8 +388,6 @@ RecoverFrameError(const struct mad_stream &stream) noexcept
{ {
if (MAD_RECOVERABLE(stream.error)) if (MAD_RECOVERABLE(stream.error))
return MadDecoderAction::SKIP; return MadDecoderAction::SKIP;
else if (stream.error == MAD_ERROR_BUFLEN)
return MadDecoderAction::CONT;
FormatWarning(mad_domain, FormatWarning(mad_domain,
"unrecoverable frame level error: %s", "unrecoverable frame level error: %s",
...@@ -405,6 +403,9 @@ MadDecoder::DecodeNextFrameHeader(Tag *tag) noexcept ...@@ -405,6 +403,9 @@ MadDecoder::DecodeNextFrameHeader(Tag *tag) noexcept
return MadDecoderAction::BREAK; return MadDecoderAction::BREAK;
if (mad_header_decode(&frame.header, &stream)) { if (mad_header_decode(&frame.header, &stream)) {
if (stream.error == MAD_ERROR_BUFLEN)
return MadDecoderAction::CONT;
if (stream.error == MAD_ERROR_LOSTSYNC && stream.this_frame) { if (stream.error == MAD_ERROR_LOSTSYNC && stream.this_frame) {
signed long tagsize = id3_tag_query(stream.this_frame, signed long tagsize = id3_tag_query(stream.this_frame,
stream.bufend - stream.bufend -
...@@ -438,23 +439,8 @@ MadDecoder::DecodeNextFrameHeader(Tag *tag) noexcept ...@@ -438,23 +439,8 @@ MadDecoder::DecodeNextFrameHeader(Tag *tag) noexcept
MadDecoderAction MadDecoderAction
MadDecoder::DecodeNextFrame() noexcept MadDecoder::DecodeNextFrame() noexcept
{ {
if ((stream.buffer == nullptr || stream.error == MAD_ERROR_BUFLEN) && if (mad_frame_decode(&frame, &stream))
!FillBuffer())
return MadDecoderAction::BREAK;
if (mad_frame_decode(&frame, &stream)) {
if (stream.error == MAD_ERROR_LOSTSYNC) {
signed long tagsize = id3_tag_query(stream.this_frame,
stream.bufend -
stream.this_frame);
if (tagsize > 0) {
mad_stream_skip(&stream, tagsize);
return MadDecoderAction::CONT;
}
}
return RecoverFrameError(stream); return RecoverFrameError(stream);
}
return MadDecoderAction::OK; return MadDecoderAction::OK;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment