diff options
author | Max Kellermann <max@duempel.org> | 2009-11-10 21:42:15 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-11-10 21:42:15 +0100 |
commit | b6a2ffd3d761c05fd7cd7fecfe470307b6a5ed15 (patch) | |
tree | adad8c48fe7476b3cb9a47eb5888225830b302c6 /src/decoder | |
parent | 6a5f4651a12cfb624e723835b0c37f38ffb4ec64 (diff) | |
download | mpd-b6a2ffd3d761c05fd7cd7fecfe470307b6a5ed15.tar.gz mpd-b6a2ffd3d761c05fd7cd7fecfe470307b6a5ed15.tar.xz mpd-b6a2ffd3d761c05fd7cd7fecfe470307b6a5ed15.zip |
decoder/flac: added function flac_data_deinit()
Clean up tag and replay_gain_info there.
Diffstat (limited to 'src/decoder')
-rw-r--r-- | src/decoder/_flac_common.c | 10 | ||||
-rw-r--r-- | src/decoder/_flac_common.h | 3 | ||||
-rw-r--r-- | src/decoder/flac_plugin.c | 11 | ||||
-rw-r--r-- | src/decoder/oggflac_plugin.c | 19 |
4 files changed, 26 insertions, 17 deletions
diff --git a/src/decoder/_flac_common.c b/src/decoder/_flac_common.c index 2eaeb2449..578e73263 100644 --- a/src/decoder/_flac_common.c +++ b/src/decoder/_flac_common.c @@ -40,6 +40,16 @@ flac_data_init(struct flac_data *data, struct decoder * decoder, data->tag = NULL; } +void +flac_data_deinit(struct flac_data *data) +{ + if (data->replay_gain_info != NULL) + replay_gain_info_free(data->replay_gain_info); + + if (data->tag != NULL) + tag_free(data->tag); +} + static void flac_find_float_comment(const FLAC__StreamMetadata *block, const char *cmnt, float *fl, bool *found_r) diff --git a/src/decoder/_flac_common.h b/src/decoder/_flac_common.h index 68de7e969..0169e3027 100644 --- a/src/decoder/_flac_common.h +++ b/src/decoder/_flac_common.h @@ -162,6 +162,9 @@ void flac_data_init(struct flac_data *data, struct decoder * decoder, struct input_stream *input_stream); +void +flac_data_deinit(struct flac_data *data); + void flac_metadata_common_cb(const FLAC__StreamMetadata * block, struct flac_data *data); diff --git a/src/decoder/flac_plugin.c b/src/decoder/flac_plugin.c index 9692ba49f..73d82a65c 100644 --- a/src/decoder/flac_plugin.c +++ b/src/decoder/flac_plugin.c @@ -485,10 +485,7 @@ flac_decode_internal(struct decoder * decoder, } fail: - if (data.replay_gain_info) - replay_gain_info_free(data.replay_gain_info); - - tag_free(data.tag); + flac_data_deinit(&data); if (flac_dec) flac_delete(flac_dec); @@ -670,8 +667,7 @@ fail: if (pathname) g_free(pathname); - if (data.replay_gain_info) - replay_gain_info_free(data.replay_gain_info); + flac_data_deinit(&data); if (flac_dec) flac_delete(flac_dec); @@ -793,8 +789,7 @@ flac_filedecode_internal(struct decoder* decoder, } fail: - if (data.replay_gain_info) - replay_gain_info_free(data.replay_gain_info); + flac_data_deinit(&data); if (flac_dec) flac_delete(flac_dec); diff --git a/src/decoder/oggflac_plugin.c b/src/decoder/oggflac_plugin.c index fedfdcb48..0c9b881b6 100644 --- a/src/decoder/oggflac_plugin.c +++ b/src/decoder/oggflac_plugin.c @@ -29,11 +29,8 @@ #include <assert.h> #include <unistd.h> -static void oggflac_cleanup(struct flac_data *data, - OggFLAC__SeekableStreamDecoder * decoder) +static void oggflac_cleanup(OggFLAC__SeekableStreamDecoder * decoder) { - if (data->replay_gain_info) - replay_gain_info_free(data->replay_gain_info); if (decoder) OggFLAC__seekable_stream_decoder_delete(decoder); } @@ -264,6 +261,7 @@ oggflac_tag_dup(const char *file) struct input_stream input_stream; OggFLAC__SeekableStreamDecoder *decoder; struct flac_data data; + struct tag *tag; if (!input_stream_open(&input_stream, file)) return NULL; @@ -280,15 +278,17 @@ oggflac_tag_dup(const char *file) * data.tag will be set or unset, that's all we care about */ decoder = full_decoder_init_and_read_metadata(&data, 1); - oggflac_cleanup(&data, decoder); + oggflac_cleanup(decoder); input_stream_close(&input_stream); - if (!tag_is_defined(data.tag)) { - tag_free(data.tag); + if (tag_is_defined(data.tag)) { + tag = data.tag; data.tag = NULL; } - return data.tag; + flac_data_deinit(&data); + + return tag; } static void @@ -344,7 +344,8 @@ oggflac_decode(struct decoder * mpd_decoder, struct input_stream *input_stream) } fail: - oggflac_cleanup(&data, decoder); + oggflac_cleanup(decoder); + flac_data_deinit(&data); } static const char *const oggflac_suffixes[] = { "ogg", "oga", NULL }; |