From 5e0117b4441f257fcb1aab48b42a787567ebcbe6 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 14 Feb 2010 20:36:31 +0100 Subject: replay_gain_info: allocate the struct statically Don't allocate each replay_gain_info object on the heap. Those objects who held a pointer now store a full replay_gain_info object. This reduces the number of allocations and heap fragmentation. --- src/decoder/mpcdec_decoder_plugin.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/decoder/mpcdec_decoder_plugin.c') diff --git a/src/decoder/mpcdec_decoder_plugin.c b/src/decoder/mpcdec_decoder_plugin.c index 92f0cad84..e41ae779d 100644 --- a/src/decoder/mpcdec_decoder_plugin.c +++ b/src/decoder/mpcdec_decoder_plugin.c @@ -154,7 +154,6 @@ mpcdec_decode(struct decoder *mpd_decoder, struct input_stream *is) long bit_rate = 0; mpc_uint32_t vbr_update_acc; mpc_uint32_t vbr_update_bits; - struct replay_gain_info *replay_gain_info = NULL; enum decoder_command cmd = DECODE_COMMAND_NONE; data.is = is; @@ -205,13 +204,13 @@ mpcdec_decode(struct decoder *mpd_decoder, struct input_stream *is) return; } - replay_gain_info = replay_gain_info_new(); - replay_gain_info->tuples[REPLAY_GAIN_ALBUM].gain = info.gain_album * 0.01; - replay_gain_info->tuples[REPLAY_GAIN_ALBUM].peak = info.peak_album / 32767.0; - replay_gain_info->tuples[REPLAY_GAIN_TRACK].gain = info.gain_title * 0.01; - replay_gain_info->tuples[REPLAY_GAIN_TRACK].peak = info.peak_title / 32767.0; - decoder_replay_gain(mpd_decoder, replay_gain_info); - replay_gain_info_free(replay_gain_info); + struct replay_gain_info replay_gain_info; + replay_gain_info_init(&replay_gain_info); + replay_gain_info.tuples[REPLAY_GAIN_ALBUM].gain = info.gain_album * 0.01; + replay_gain_info.tuples[REPLAY_GAIN_ALBUM].peak = info.peak_album / 32767.0; + replay_gain_info.tuples[REPLAY_GAIN_TRACK].gain = info.gain_title * 0.01; + replay_gain_info.tuples[REPLAY_GAIN_TRACK].peak = info.peak_title / 32767.0; + decoder_replay_gain(mpd_decoder, &replay_gain_info); decoder_initialized(mpd_decoder, &audio_format, is->seekable, -- cgit v1.2.3