From 9da88eec3e60e1e34d13d1a8cfe53f25fec4505a Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 26 Aug 2014 10:51:47 +0200 Subject: decoder/mad: move duplicate code to RecoverFrameError() --- src/decoder/plugins/MadDecoderPlugin.cxx | 36 ++++++++++++++------------------ 1 file changed, 16 insertions(+), 20 deletions(-) (limited to 'src/decoder/plugins') diff --git a/src/decoder/plugins/MadDecoderPlugin.cxx b/src/decoder/plugins/MadDecoderPlugin.cxx index 2b82b6221..6bc795309 100644 --- a/src/decoder/plugins/MadDecoderPlugin.cxx +++ b/src/decoder/plugins/MadDecoderPlugin.cxx @@ -410,6 +410,20 @@ id3_tag_query(const void *p0, size_t length) } #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 MadDecoder::DecodeNextFrameHeader(Tag **tag) { @@ -433,16 +447,7 @@ MadDecoder::DecodeNextFrameHeader(Tag **tag) } } - if (MAD_RECOVERABLE(stream.error)) - 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 RecoverFrameError(stream); } enum mad_layer new_layer = frame.header.layer; @@ -479,16 +484,7 @@ MadDecoder::DecodeNextFrame() } } - if (MAD_RECOVERABLE(stream.error)) - 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 RecoverFrameError(stream); } return DECODE_OK; -- cgit v1.2.3