aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-01-05 00:05:57 +0100
committerMax Kellermann <max@duempel.org>2013-01-05 02:40:33 +0100
commit1a8ef3cdab39234e91fe9d91dad2ae004e4537dc (patch)
tree128f25b72f61ff2e7a2a3fb1f292b57ad27b9061 /src
parent7be33eba489825d3a36f3ccbb3571002fcc06c0b (diff)
downloadmpd-1a8ef3cdab39234e91fe9d91dad2ae004e4537dc.tar.gz
mpd-1a8ef3cdab39234e91fe9d91dad2ae004e4537dc.tar.xz
mpd-1a8ef3cdab39234e91fe9d91dad2ae004e4537dc.zip
filter/ReplayGain: add method _set_mode()
Push the new mode to the filter instead of accessing global variables through replay_gain_get_real_mode().
Diffstat (limited to 'src')
-rw-r--r--src/Main.cxx2
-rw-r--r--src/OutputAll.cxx7
-rw-r--r--src/OutputControl.cxx9
-rw-r--r--src/OutputControl.hxx6
-rw-r--r--src/PlayerCommands.cxx4
-rw-r--r--src/ReplayGainConfig.cxx5
-rw-r--r--src/filter/replay_gain_filter_plugin.c28
-rw-r--r--src/filter/replay_gain_filter_plugin.h3
-rw-r--r--src/output_all.h4
-rw-r--r--src/replay_gain_config.h2
10 files changed, 56 insertions, 14 deletions
diff --git a/src/Main.cxx b/src/Main.cxx
index 7f56d83a4..a8f6d55ee 100644
--- a/src/Main.cxx
+++ b/src/Main.cxx
@@ -480,6 +480,8 @@ int mpd_main(int argc, char *argv[])
return EXIT_FAILURE;
}
+ audio_output_all_set_replay_gain_mode(replay_gain_get_real_mode(g_playlist.queue.random));
+
success = config_get_bool(CONF_AUTO_UPDATE, false);
#ifdef ENABLE_INOTIFY
if (success && mapper_has_music_directory())
diff --git a/src/OutputAll.cxx b/src/OutputAll.cxx
index d211cdce4..9c65ddcae 100644
--- a/src/OutputAll.cxx
+++ b/src/OutputAll.cxx
@@ -273,6 +273,13 @@ audio_output_all_update(void)
return ret;
}
+void
+audio_output_all_set_replay_gain_mode(enum replay_gain_mode mode)
+{
+ for (unsigned i = 0; i < num_audio_outputs; ++i)
+ audio_output_set_replay_gain_mode(audio_outputs[i], mode);
+}
+
bool
audio_output_all_play(struct music_chunk *chunk, GError **error_r)
{
diff --git a/src/OutputControl.cxx b/src/OutputControl.cxx
index 36e80a014..7cc2814de 100644
--- a/src/OutputControl.cxx
+++ b/src/OutputControl.cxx
@@ -27,6 +27,7 @@ extern "C" {
#include "mixer_control.h"
#include "mixer_plugin.h"
#include "notify.h"
+#include "filter/replay_gain_filter_plugin.h"
}
#include "filter_plugin.h"
@@ -96,6 +97,14 @@ ao_lock_command(struct audio_output *ao, enum audio_output_command cmd)
}
void
+audio_output_set_replay_gain_mode(struct audio_output *ao,
+ enum replay_gain_mode mode)
+{
+ if (ao->replay_gain_filter != NULL)
+ replay_gain_filter_set_mode(ao->replay_gain_filter, mode);
+}
+
+void
audio_output_enable(struct audio_output *ao)
{
if (ao->thread == NULL) {
diff --git a/src/OutputControl.hxx b/src/OutputControl.hxx
index 90769180f..cf906d2f0 100644
--- a/src/OutputControl.hxx
+++ b/src/OutputControl.hxx
@@ -20,6 +20,8 @@
#ifndef MPD_OUTPUT_CONTROL_HXX
#define MPD_OUTPUT_CONTROL_HXX
+#include "replay_gain_info.h"
+
#include <glib.h>
#include <stddef.h>
@@ -36,6 +38,10 @@ audio_output_quark(void)
return g_quark_from_static_string("audio_output");
}
+void
+audio_output_set_replay_gain_mode(struct audio_output *ao,
+ enum replay_gain_mode mode);
+
/**
* Enables the device.
*/
diff --git a/src/PlayerCommands.cxx b/src/PlayerCommands.cxx
index a9cde7fd5..2bd6fc4e6 100644
--- a/src/PlayerCommands.cxx
+++ b/src/PlayerCommands.cxx
@@ -31,6 +31,7 @@ extern "C" {
#include "audio_format.h"
#include "volume.h"
#include "replay_gain_config.h"
+#include "output_all.h"
}
#include "PlayerControl.hxx"
@@ -280,6 +281,7 @@ handle_random(Client *client, G_GNUC_UNUSED int argc, char *argv[])
return COMMAND_RETURN_ERROR;
playlist_set_random(&client->playlist, client->player_control, status);
+ audio_output_all_set_replay_gain_mode(replay_gain_get_real_mode(client->playlist.queue.random));
return COMMAND_RETURN_OK;
}
@@ -386,6 +388,8 @@ handle_replay_gain_mode(Client *client,
return COMMAND_RETURN_ERROR;
}
+ audio_output_all_set_replay_gain_mode(replay_gain_get_real_mode(client->playlist.queue.random));
+
return COMMAND_RETURN_OK;
}
diff --git a/src/ReplayGainConfig.cxx b/src/ReplayGainConfig.cxx
index 4d3e2f29d..d3af332ce 100644
--- a/src/ReplayGainConfig.cxx
+++ b/src/ReplayGainConfig.cxx
@@ -136,14 +136,15 @@ void replay_gain_global_init(void)
replay_gain_limit = config_get_bool(CONF_REPLAYGAIN_LIMIT, DEFAULT_REPLAYGAIN_LIMIT);
}
-enum replay_gain_mode replay_gain_get_real_mode(void)
+enum replay_gain_mode
+replay_gain_get_real_mode(bool random_mode)
{
enum replay_gain_mode rgm;
rgm = replay_gain_mode;
if (rgm == REPLAY_GAIN_AUTO)
- rgm = g_playlist.queue.random ? REPLAY_GAIN_TRACK : REPLAY_GAIN_ALBUM;
+ rgm = random_mode ? REPLAY_GAIN_TRACK : REPLAY_GAIN_ALBUM;
return rgm;
}
diff --git a/src/filter/replay_gain_filter_plugin.c b/src/filter/replay_gain_filter_plugin.c
index 583a09f90..9fd3cbc07 100644
--- a/src/filter/replay_gain_filter_plugin.c
+++ b/src/filter/replay_gain_filter_plugin.c
@@ -119,7 +119,7 @@ replay_gain_filter_init(G_GNUC_UNUSED const struct config_param *param,
filter_init(&filter->filter, &replay_gain_filter_plugin);
filter->mixer = NULL;
- filter->mode = replay_gain_get_real_mode();
+ filter->mode = REPLAY_GAIN_OFF;
replay_gain_info_init(&filter->info);
filter->volume = PCM_VOLUME_1;
@@ -164,16 +164,6 @@ replay_gain_filter_filter(struct filter *_filter,
(struct replay_gain_filter *)_filter;
bool success;
void *dest;
- enum replay_gain_mode rg_mode;
-
- /* check if the mode has been changed since the last call */
- rg_mode = replay_gain_get_real_mode();
-
- if (filter->mode != rg_mode) {
- g_debug("replay gain mode has changed %d->%d\n", filter->mode, rg_mode);
- filter->mode = rg_mode;
- replay_gain_filter_update(filter);
- }
*dest_size_r = src_size;
@@ -243,3 +233,19 @@ replay_gain_filter_set_info(struct filter *_filter,
replay_gain_filter_update(filter);
}
+
+void
+replay_gain_filter_set_mode(struct filter *_filter, enum replay_gain_mode mode)
+{
+ struct replay_gain_filter *filter =
+ (struct replay_gain_filter *)_filter;
+
+ if (mode == filter->mode)
+ /* no change */
+ return;
+
+ g_debug("replay gain mode has changed %d->%d\n", filter->mode, mode);
+
+ filter->mode = mode;
+ replay_gain_filter_update(filter);
+}
diff --git a/src/filter/replay_gain_filter_plugin.h b/src/filter/replay_gain_filter_plugin.h
index 45b738e40..da2df9d6a 100644
--- a/src/filter/replay_gain_filter_plugin.h
+++ b/src/filter/replay_gain_filter_plugin.h
@@ -47,4 +47,7 @@ void
replay_gain_filter_set_info(struct filter *filter,
const struct replay_gain_info *info);
+void
+replay_gain_filter_set_mode(struct filter *filter, enum replay_gain_mode mode);
+
#endif
diff --git a/src/output_all.h b/src/output_all.h
index 00864c9ba..becf4b695 100644
--- a/src/output_all.h
+++ b/src/output_all.h
@@ -26,6 +26,7 @@
#ifndef OUTPUT_ALL_H
#define OUTPUT_ALL_H
+#include "replay_gain_info.h"
#include "gerror.h"
#include <stdbool.h>
@@ -102,6 +103,9 @@ audio_output_all_close(void);
void
audio_output_all_release(void);
+void
+audio_output_all_set_replay_gain_mode(enum replay_gain_mode mode);
+
/**
* Enqueue a #music_chunk object for playing, i.e. pushes it to a
* #music_pipe.
diff --git a/src/replay_gain_config.h b/src/replay_gain_config.h
index 18747cef2..2bf4f32f2 100644
--- a/src/replay_gain_config.h
+++ b/src/replay_gain_config.h
@@ -50,6 +50,6 @@ replay_gain_set_mode_string(const char *p);
* Returns the "real" mode according to the "auto" setting"
*/
enum replay_gain_mode
-replay_gain_get_real_mode(void);
+replay_gain_get_real_mode(bool random_mode);
#endif