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

Much of that is not possible when mad_header_decode() has already been
called.
This commit is contained in:
Max Kellermann 2019-08-03 12:55:48 +02:00
parent a90685d6cf
commit 52bb03e136

View File

@ -388,8 +388,6 @@ RecoverFrameError(const struct mad_stream &stream) noexcept
{
if (MAD_RECOVERABLE(stream.error))
return MadDecoderAction::SKIP;
else if (stream.error == MAD_ERROR_BUFLEN)
return MadDecoderAction::CONT;
FormatWarning(mad_domain,
"unrecoverable frame level error: %s",
@ -405,6 +403,9 @@ MadDecoder::DecodeNextFrameHeader(Tag *tag) noexcept
return MadDecoderAction::BREAK;
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) {
signed long tagsize = id3_tag_query(stream.this_frame,
stream.bufend -
@ -438,23 +439,8 @@ MadDecoder::DecodeNextFrameHeader(Tag *tag) noexcept
MadDecoderAction
MadDecoder::DecodeNextFrame() noexcept
{
if ((stream.buffer == nullptr || stream.error == MAD_ERROR_BUFLEN) &&
!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;
}
}
if (mad_frame_decode(&frame, &stream))
return RecoverFrameError(stream);
}
return MadDecoderAction::OK;
}