From 631baa7120a72ad2d6b2d0586fff68ee0f6fc0dd Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 10 Jul 2016 21:53:47 +0200 Subject: [PATCH] decoder/flac: eliminate redundant FlacDecoder attributes --- src/decoder/plugins/FlacCommon.cxx | 13 ++++++------- src/decoder/plugins/FlacCommon.hxx | 3 --- src/decoder/plugins/FlacDecoderPlugin.cxx | 6 +++--- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/decoder/plugins/FlacCommon.cxx b/src/decoder/plugins/FlacCommon.cxx index 6c833cc64..b70b87f81 100644 --- a/src/decoder/plugins/FlacCommon.cxx +++ b/src/decoder/plugins/FlacCommon.cxx @@ -33,8 +33,7 @@ FlacDecoder::FlacDecoder(Decoder &_decoder, InputStream &_input_stream) :FlacInput(_input_stream, &_decoder), initialized(false), unsupported(false), - position(0), - decoder(_decoder), input_stream(_input_stream) + position(0) { } @@ -83,8 +82,8 @@ FlacDecoder::Initialize(unsigned sample_rate, unsigned bits_per_sample, audio_format.sample_rate) : SignedSongTime::Negative(); - decoder_initialized(decoder, audio_format, - input_stream.IsSeekable(), + decoder_initialized(*GetDecoder(), audio_format, + GetInputStream().IsSeekable(), duration); initialized = true; @@ -119,9 +118,9 @@ void flac_metadata_common_cb(const FLAC__StreamMetadata * block, case FLAC__METADATA_TYPE_VORBIS_COMMENT: if (flac_parse_replay_gain(rgi, block->data.vorbis_comment)) - decoder_replay_gain(data->decoder, &rgi); + decoder_replay_gain(*data->GetDecoder(), &rgi); - decoder_mixramp(data->decoder, + decoder_mixramp(*data->GetDecoder(), flac_parse_mixramp(block->data.vorbis_comment)); data->tag = flac_vorbis_comments_to_tag(&block->data.vorbis_comment); @@ -172,7 +171,7 @@ flac_common_write(FlacDecoder *data, const FLAC__Frame * frame, unsigned bit_rate = nbytes * 8 * frame->header.sample_rate / (1000 * frame->header.blocksize); - auto cmd = decoder_data(data->decoder, data->input_stream, + auto cmd = decoder_data(*data->GetDecoder(), data->GetInputStream(), buffer, buffer_size, bit_rate); switch (cmd) { diff --git a/src/decoder/plugins/FlacCommon.hxx b/src/decoder/plugins/FlacCommon.hxx index ec5a9b08a..6e86faaa5 100644 --- a/src/decoder/plugins/FlacCommon.hxx +++ b/src/decoder/plugins/FlacCommon.hxx @@ -60,9 +60,6 @@ struct FlacDecoder : public FlacInput { */ FLAC__uint64 position; - Decoder &decoder; - InputStream &input_stream; - Tag tag; FlacDecoder(Decoder &decoder, InputStream &input_stream); diff --git a/src/decoder/plugins/FlacDecoderPlugin.cxx b/src/decoder/plugins/FlacDecoderPlugin.cxx index aa8b12dcd..f66a85467 100644 --- a/src/decoder/plugins/FlacDecoderPlugin.cxx +++ b/src/decoder/plugins/FlacDecoderPlugin.cxx @@ -146,7 +146,7 @@ flac_decoder_initialize(FlacDecoder *data, FLAC__StreamDecoder *sd) return true; } - if (data->input_stream.IsSeekable()) + if (data->GetInputStream().IsSeekable()) /* allow the workaround below only for nonseekable streams*/ return false; @@ -160,12 +160,12 @@ flac_decoder_initialize(FlacDecoder *data, FLAC__StreamDecoder *sd) static void flac_decoder_loop(FlacDecoder *data, FLAC__StreamDecoder *flac_dec) { - Decoder &decoder = data->decoder; + Decoder &decoder = *data->GetDecoder(); while (true) { DecoderCommand cmd; if (!data->tag.IsEmpty()) { - cmd = decoder_tag(data->decoder, data->input_stream, + cmd = decoder_tag(decoder, data->GetInputStream(), std::move(data->tag)); data->tag.Clear(); } else