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:
parent
a90685d6cf
commit
52bb03e136
|
@ -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
|
||||||
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
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue