diff options
author | Max Kellermann <max@duempel.org> | 2014-08-26 10:51:47 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-08-26 10:52:17 +0200 |
commit | 9da88eec3e60e1e34d13d1a8cfe53f25fec4505a (patch) | |
tree | 1748be39b923f2e5192fe782da5430ee2d98351f /src | |
parent | f10d9996d25a224defdb2e474aef0b0a54438720 (diff) |
decoder/mad: move duplicate code to RecoverFrameError()
Diffstat (limited to 'src')
-rw-r--r-- | src/decoder/plugins/MadDecoderPlugin.cxx | 36 |
1 files changed, 16 insertions, 20 deletions
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; |