diff options
author | Max Kellermann <max@duempel.org> | 2010-02-14 20:36:31 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2010-02-17 07:22:44 +0100 |
commit | 5e0117b4441f257fcb1aab48b42a787567ebcbe6 (patch) | |
tree | 7233b273814def640145276f1a46d45b8cf274e4 /src/decoder/wavpack_decoder_plugin.c | |
parent | c05e6a1275621421eb0a7c3112b0401fa458841e (diff) | |
download | mpd-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/wavpack_decoder_plugin.c')
-rw-r--r-- | src/decoder/wavpack_decoder_plugin.c | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/src/decoder/wavpack_decoder_plugin.c b/src/decoder/wavpack_decoder_plugin.c index ec0bc5d8d..efed98851 100644 --- a/src/decoder/wavpack_decoder_plugin.c +++ b/src/decoder/wavpack_decoder_plugin.c @@ -256,13 +256,13 @@ wavpack_tag_float(WavpackContext *wpc, const char *key, float *value_r) return true; } -static struct replay_gain_info * -wavpack_replaygain(WavpackContext *wpc) +static bool +wavpack_replaygain(struct replay_gain_info *replay_gain_info, + WavpackContext *wpc) { - struct replay_gain_info *replay_gain_info; bool found = false; - replay_gain_info = replay_gain_info_new(); + replay_gain_info_init(replay_gain_info); found |= wavpack_tag_float( wpc, "replaygain_track_gain", @@ -281,13 +281,7 @@ wavpack_replaygain(WavpackContext *wpc) &replay_gain_info->tuples[REPLAY_GAIN_ALBUM].peak ); - if (found) { - return replay_gain_info; - } - - replay_gain_info_free(replay_gain_info); - - return NULL; + return found; } /* @@ -554,7 +548,6 @@ wavpack_filedecode(struct decoder *decoder, const char *fname) { char error[ERRORLEN]; WavpackContext *wpc; - struct replay_gain_info *replay_gain_info; wpc = WavpackOpenFileInput( fname, error, @@ -568,11 +561,9 @@ wavpack_filedecode(struct decoder *decoder, const char *fname) return; } - replay_gain_info = wavpack_replaygain(wpc); - if (replay_gain_info != NULL) { - decoder_replay_gain(decoder, replay_gain_info); - replay_gain_info_free(replay_gain_info); - } + struct replay_gain_info replay_gain_info; + if (wavpack_replaygain(&replay_gain_info, wpc)) + decoder_replay_gain(decoder, &replay_gain_info); wavpack_decode(decoder, wpc, true); |