aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/mpcdec_decoder_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2010-02-14 20:36:31 +0100
committerMax Kellermann <max@duempel.org>2010-02-17 07:22:44 +0100
commit5e0117b4441f257fcb1aab48b42a787567ebcbe6 (patch)
tree7233b273814def640145276f1a46d45b8cf274e4 /src/decoder/mpcdec_decoder_plugin.c
parentc05e6a1275621421eb0a7c3112b0401fa458841e (diff)
downloadmpd-5e0117b4441f257fcb1aab48b42a787567ebcbe6.tar.gz
mpd-5e0117b4441f257fcb1aab48b42a787567ebcbe6.tar.xz
mpd-5e0117b4441f257fcb1aab48b42a787567ebcbe6.zip
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.
Diffstat (limited to 'src/decoder/mpcdec_decoder_plugin.c')
-rw-r--r--src/decoder/mpcdec_decoder_plugin.c15
1 files changed, 7 insertions, 8 deletions
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,