Commit 9da88eec authored by Max Kellermann's avatar Max Kellermann

decoder/mad: move duplicate code to RecoverFrameError()

parent f10d9996
...@@ -410,6 +410,20 @@ id3_tag_query(const void *p0, size_t length) ...@@ -410,6 +410,20 @@ id3_tag_query(const void *p0, size_t length)
} }
#endif /* !HAVE_ID3TAG */ #endif /* !HAVE_ID3TAG */
static enum mp3_action
RecoverFrameError(struct mad_stream &stream)
{
if (MAD_RECOVERABLE(stream.error))
return DECODE_SKIP;
else if (stream.error == MAD_ERROR_BUFLEN)
return DECODE_CONT;
FormatWarning(mad_domain,
"unrecoverable frame level error: %s",
mad_stream_errorstr(&stream));
return DECODE_BREAK;
}
enum mp3_action enum mp3_action
MadDecoder::DecodeNextFrameHeader(Tag **tag) MadDecoder::DecodeNextFrameHeader(Tag **tag)
{ {
...@@ -433,16 +447,7 @@ MadDecoder::DecodeNextFrameHeader(Tag **tag) ...@@ -433,16 +447,7 @@ MadDecoder::DecodeNextFrameHeader(Tag **tag)
} }
} }
if (MAD_RECOVERABLE(stream.error)) return RecoverFrameError(stream);
return DECODE_SKIP;
else if (stream.error == MAD_ERROR_BUFLEN)
return DECODE_CONT;
else {
FormatWarning(mad_domain,
"unrecoverable frame level error: %s",
mad_stream_errorstr(&stream));
return DECODE_BREAK;
}
} }
enum mad_layer new_layer = frame.header.layer; enum mad_layer new_layer = frame.header.layer;
...@@ -479,16 +484,7 @@ MadDecoder::DecodeNextFrame() ...@@ -479,16 +484,7 @@ MadDecoder::DecodeNextFrame()
} }
} }
if (MAD_RECOVERABLE(stream.error)) return RecoverFrameError(stream);
return DECODE_SKIP;
else if (stream.error == MAD_ERROR_BUFLEN)
return DECODE_CONT;
else {
FormatWarning(mad_domain,
"unrecoverable frame level error: %s",
mad_stream_errorstr(&stream));
return DECODE_BREAK;
}
} }
return DECODE_OK; return DECODE_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