From 1330274ffc6f80d5dd768902b09849cf32f329d2 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 4 Jan 2010 20:43:19 +0100 Subject: replay_gain: moved code to replay_gain_info.c --- src/decoder/flac_metadata.c | 2 +- src/decoder_api.c | 1 + src/decoder_api.h | 2 +- src/decoder_thread.c | 1 + src/replay_gain.c | 23 -------------------- src/replay_gain.h | 29 +++---------------------- src/replay_gain_info.c | 48 +++++++++++++++++++++++++++++++++++++++++ src/replay_gain_info.h | 52 +++++++++++++++++++++++++++++++++++++++++++++ src/replay_gain_state.h | 2 +- 9 files changed, 108 insertions(+), 52 deletions(-) create mode 100644 src/replay_gain_info.c create mode 100644 src/replay_gain_info.h (limited to 'src') diff --git a/src/decoder/flac_metadata.c b/src/decoder/flac_metadata.c index f6f64789..b05dca3e 100644 --- a/src/decoder/flac_metadata.c +++ b/src/decoder/flac_metadata.c @@ -19,7 +19,7 @@ #include "config.h" #include "flac_metadata.h" -#include "replay_gain.h" +#include "replay_gain_info.h" #include "tag.h" #include diff --git a/src/decoder_api.c b/src/decoder_api.c index 8e1e22f9..0a4e1d12 100644 --- a/src/decoder_api.c +++ b/src/decoder_api.c @@ -28,6 +28,7 @@ #include "pipe.h" #include "chunk.h" #include "replay_gain_state.h" +#include "replay_gain.h" #include diff --git a/src/decoder_api.h b/src/decoder_api.h index 39e7972d..8fe9dd4e 100644 --- a/src/decoder_api.h +++ b/src/decoder_api.h @@ -31,7 +31,7 @@ #include "decoder_command.h" #include "decoder_plugin.h" #include "input_stream.h" -#include "replay_gain.h" +#include "replay_gain_info.h" #include "tag.h" #include "audio_format.h" #include "conf.h" diff --git a/src/decoder_thread.c b/src/decoder_thread.c index 625ec46c..d2841436 100644 --- a/src/decoder_thread.c +++ b/src/decoder_thread.c @@ -32,6 +32,7 @@ #include "path.h" #include "uri.h" #include "replay_gain_state.h" +#include "replay_gain.h" #include diff --git a/src/replay_gain.c b/src/replay_gain.c index 3537a96e..d5ac55eb 100644 --- a/src/replay_gain.c +++ b/src/replay_gain.c @@ -127,26 +127,3 @@ void replay_gain_global_init(void) replay_gain_missing_preamp = pow(10, f / 20.0); } } - -struct replay_gain_info *replay_gain_info_new(void) -{ - struct replay_gain_info *ret = g_new(struct replay_gain_info, 1); - - for (unsigned i = 0; i < G_N_ELEMENTS(ret->tuples); ++i) { - ret->tuples[i].gain = 0.0; - ret->tuples[i].peak = 0.0; - } - - return ret; -} - -struct replay_gain_info * -replay_gain_info_dup(const struct replay_gain_info *src) -{ - return g_memdup(src, sizeof(*src)); -} - -void replay_gain_info_free(struct replay_gain_info *info) -{ - g_free(info); -} diff --git a/src/replay_gain.h b/src/replay_gain.h index c27e2be0..8241aab8 100644 --- a/src/replay_gain.h +++ b/src/replay_gain.h @@ -23,38 +23,15 @@ #ifndef MPD_REPLAY_GAIN_H #define MPD_REPLAY_GAIN_H -#include +#include "check.h" +#include "replay_gain_info.h" -enum replay_gain_mode { - REPLAY_GAIN_OFF = -1, - REPLAY_GAIN_ALBUM, - REPLAY_GAIN_TRACK, -}; +#include extern enum replay_gain_mode replay_gain_mode; extern float replay_gain_preamp; extern float replay_gain_missing_preamp; -struct replay_gain_tuple { - float gain; - float peak; -}; - -struct replay_gain_info { - struct replay_gain_tuple tuples[2]; -}; - -struct replay_gain_info * -replay_gain_info_new(void); - -/** - * Duplicate a #replay_gain_info object. - */ -struct replay_gain_info * -replay_gain_info_dup(const struct replay_gain_info *src); - -void replay_gain_info_free(struct replay_gain_info *info); - void replay_gain_global_init(void); /** diff --git a/src/replay_gain_info.c b/src/replay_gain_info.c new file mode 100644 index 00000000..676394c0 --- /dev/null +++ b/src/replay_gain_info.c @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2003-2010 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "config.h" +#include "replay_gain_info.h" + +#include + +struct replay_gain_info * +replay_gain_info_new(void) +{ + struct replay_gain_info *ret = g_new(struct replay_gain_info, 1); + + for (unsigned i = 0; i < G_N_ELEMENTS(ret->tuples); ++i) { + ret->tuples[i].gain = 0.0; + ret->tuples[i].peak = 0.0; + } + + return ret; +} + +struct replay_gain_info * +replay_gain_info_dup(const struct replay_gain_info *src) +{ + return g_memdup(src, sizeof(*src)); +} + +void +replay_gain_info_free(struct replay_gain_info *info) +{ + g_free(info); +} diff --git a/src/replay_gain_info.h b/src/replay_gain_info.h new file mode 100644 index 00000000..51a167ce --- /dev/null +++ b/src/replay_gain_info.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2003-2010 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef MPD_REPLAY_GAIN_INFO_H +#define MPD_REPLAY_GAIN_INFO_H + +#include "check.h" + +enum replay_gain_mode { + REPLAY_GAIN_OFF = -1, + REPLAY_GAIN_ALBUM, + REPLAY_GAIN_TRACK, +}; + +struct replay_gain_tuple { + float gain; + float peak; +}; + +struct replay_gain_info { + struct replay_gain_tuple tuples[2]; +}; + +struct replay_gain_info * +replay_gain_info_new(void); + +/** + * Duplicate a #replay_gain_info object. + */ +struct replay_gain_info * +replay_gain_info_dup(const struct replay_gain_info *src); + +void +replay_gain_info_free(struct replay_gain_info *info); + +#endif diff --git a/src/replay_gain_state.h b/src/replay_gain_state.h index 7fa47609..bf687aa0 100644 --- a/src/replay_gain_state.h +++ b/src/replay_gain_state.h @@ -21,7 +21,7 @@ #define MPD_REPLAY_GAIN_STATE_H #include "check.h" -#include "replay_gain.h" +#include "replay_gain_info.h" #include -- cgit v1.2.3