diff options
author | Max Kellermann <max@duempel.org> | 2016-07-08 23:03:49 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2016-07-08 23:03:49 +0200 |
commit | ed3bc4ab632305a54c41377b10e70991b2aeb003 (patch) | |
tree | 6520da1581b2b369e919a4687419a5395205d559 | |
parent | 68064f1aa60d30febc69557b982057bb404e4e5e (diff) |
decoder/flac: move code to FlacInitAndDecode()
-rw-r--r-- | src/decoder/plugins/FlacDecoderPlugin.cxx | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/src/decoder/plugins/FlacDecoderPlugin.cxx b/src/decoder/plugins/FlacDecoderPlugin.cxx index 35bb041f0..0990899d1 100644 --- a/src/decoder/plugins/FlacDecoderPlugin.cxx +++ b/src/decoder/plugins/FlacDecoderPlugin.cxx @@ -261,6 +261,24 @@ stream_init(FLAC__StreamDecoder *flac_dec, struct flac_data *data, bool is_ogg) : stream_init_flac(flac_dec, data); } +static bool +FlacInitAndDecode(struct flac_data &data, FLAC__StreamDecoder *sd, bool is_ogg) +{ + auto init_status = stream_init(sd, &data, is_ogg); + if (init_status != FLAC__STREAM_DECODER_INIT_STATUS_OK) { + LogWarning(flac_domain, + FLAC__StreamDecoderInitStatusString[init_status]); + return false; + } + + bool result = flac_decoder_initialize(&data, sd); + if (result) + flac_decoder_loop(&data, sd); + + FLAC__stream_decoder_finish(sd); + return result; +} + static void flac_decode_internal(Decoder &decoder, InputStream &input_stream, @@ -274,24 +292,8 @@ flac_decode_internal(Decoder &decoder, struct flac_data data(decoder, input_stream); - FLAC__StreamDecoderInitStatus status = - stream_init(flac_dec, &data, is_ogg); - if (status != FLAC__STREAM_DECODER_INIT_STATUS_OK) { - FLAC__stream_decoder_delete(flac_dec); - LogWarning(flac_domain, - FLAC__StreamDecoderInitStatusString[status]); - return; - } - - if (!flac_decoder_initialize(&data, flac_dec)) { - FLAC__stream_decoder_finish(flac_dec); - FLAC__stream_decoder_delete(flac_dec); - return; - } - - flac_decoder_loop(&data, flac_dec); + FlacInitAndDecode(data, flac_dec, is_ogg); - FLAC__stream_decoder_finish(flac_dec); FLAC__stream_decoder_delete(flac_dec); } |