diff options
author | Max Kellermann <max@duempel.org> | 2014-02-05 00:02:02 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-02-05 00:02:02 +0100 |
commit | e8938b1069739eca2bd2f27705c1c7783e834e59 (patch) | |
tree | 482330dbf228c12a60c9a401f0428cc4e292e234 /src | |
parent | 4a283330394fd2e1541a03bd312e5fadf54aa055 (diff) | |
download | mpd-e8938b1069739eca2bd2f27705c1c7783e834e59.tar.gz mpd-e8938b1069739eca2bd2f27705c1c7783e834e59.tar.xz mpd-e8938b1069739eca2bd2f27705c1c7783e834e59.zip |
MixerPlugin: add EventLoop& init() parameter
Diffstat (limited to '')
-rw-r--r-- | src/Main.cxx | 3 | ||||
-rw-r--r-- | src/mixer/MixerControl.cxx | 5 | ||||
-rw-r--r-- | src/mixer/MixerControl.hxx | 3 | ||||
-rw-r--r-- | src/mixer/MixerPlugin.hxx | 4 | ||||
-rw-r--r-- | src/mixer/plugins/AlsaMixerPlugin.cxx | 13 | ||||
-rw-r--r-- | src/mixer/plugins/OssMixerPlugin.cxx | 3 | ||||
-rw-r--r-- | src/mixer/plugins/PulseMixerPlugin.cxx | 3 | ||||
-rw-r--r-- | src/mixer/plugins/RoarMixerPlugin.cxx | 3 | ||||
-rw-r--r-- | src/mixer/plugins/SoftwareMixerPlugin.cxx | 2 | ||||
-rw-r--r-- | src/mixer/plugins/WinmmMixerPlugin.cxx | 3 | ||||
-rw-r--r-- | src/output/Init.cxx | 15 | ||||
-rw-r--r-- | src/output/Internal.hxx | 3 | ||||
-rw-r--r-- | src/output/MultipleOutputs.cxx | 10 | ||||
-rw-r--r-- | src/output/MultipleOutputs.hxx | 3 |
14 files changed, 44 insertions, 29 deletions
diff --git a/src/Main.cxx b/src/Main.cxx index 1bee66ca8..a4f01dba8 100644 --- a/src/Main.cxx +++ b/src/Main.cxx @@ -476,7 +476,8 @@ int mpd_main(int argc, char *argv[]) initialize_decoder_and_player(); volume_init(); initAudioConfig(); - instance->partition->outputs.Configure(instance->partition->pc); + instance->partition->outputs.Configure(*main_loop, + instance->partition->pc); client_manager_init(); replay_gain_global_init(); diff --git a/src/mixer/MixerControl.cxx b/src/mixer/MixerControl.cxx index bdf6fcc2b..d64ff2c8e 100644 --- a/src/mixer/MixerControl.cxx +++ b/src/mixer/MixerControl.cxx @@ -25,7 +25,8 @@ #include <assert.h> Mixer * -mixer_new(const struct mixer_plugin *plugin, void *ao, +mixer_new(EventLoop &event_loop, + const mixer_plugin *plugin, void *ao, const config_param ¶m, Error &error) { @@ -33,7 +34,7 @@ mixer_new(const struct mixer_plugin *plugin, void *ao, assert(plugin != nullptr); - mixer = plugin->init(ao, param, error); + mixer = plugin->init(event_loop, ao, param, error); assert(mixer == nullptr || mixer->IsPlugin(*plugin)); diff --git a/src/mixer/MixerControl.hxx b/src/mixer/MixerControl.hxx index 3f8e11e86..8ffc683f4 100644 --- a/src/mixer/MixerControl.hxx +++ b/src/mixer/MixerControl.hxx @@ -27,11 +27,12 @@ class Error; class Mixer; +class EventLoop; struct mixer_plugin; struct config_param; Mixer * -mixer_new(const mixer_plugin *plugin, void *ao, +mixer_new(EventLoop &event_loop, const mixer_plugin *plugin, void *ao, const config_param ¶m, Error &error); diff --git a/src/mixer/MixerPlugin.hxx b/src/mixer/MixerPlugin.hxx index 2df0d809e..79ba378a0 100644 --- a/src/mixer/MixerPlugin.hxx +++ b/src/mixer/MixerPlugin.hxx @@ -29,6 +29,7 @@ struct config_param; class Mixer; +class EventLoop; class Error; struct mixer_plugin { @@ -41,7 +42,8 @@ struct mixer_plugin { * nullptr to ignore errors * @return a mixer object, or nullptr on error */ - Mixer *(*init)(void *ao, const config_param ¶m, + Mixer *(*init)(EventLoop &event_loop, void *ao, + const config_param ¶m, Error &error); /** diff --git a/src/mixer/plugins/AlsaMixerPlugin.cxx b/src/mixer/plugins/AlsaMixerPlugin.cxx index a15820fc7..6e99cfa3e 100644 --- a/src/mixer/plugins/AlsaMixerPlugin.cxx +++ b/src/mixer/plugins/AlsaMixerPlugin.cxx @@ -21,7 +21,6 @@ #include "mixer/MixerInternal.hxx" #include "output/OutputAPI.hxx" #include "GlobalEvents.hxx" -#include "Main.hxx" #include "event/MultiSocketMonitor.hxx" #include "event/DeferredMonitor.hxx" #include "event/Loop.hxx" @@ -62,6 +61,8 @@ private: }; class AlsaMixer final : public Mixer { + EventLoop &event_loop; + const char *device; const char *control; unsigned int index; @@ -75,7 +76,8 @@ class AlsaMixer final : public Mixer { AlsaMixerMonitor *monitor; public: - AlsaMixer():Mixer(alsa_mixer_plugin) {} + AlsaMixer(EventLoop &_event_loop) + :Mixer(alsa_mixer_plugin), event_loop(_event_loop) {} void Configure(const config_param ¶m); bool Setup(Error &error); @@ -162,10 +164,11 @@ AlsaMixer::Configure(const config_param ¶m) } static Mixer * -alsa_mixer_init(gcc_unused void *ao, const config_param ¶m, +alsa_mixer_init(EventLoop &event_loop, gcc_unused void *ao, + const config_param ¶m, gcc_unused Error &error) { - AlsaMixer *am = new AlsaMixer(); + AlsaMixer *am = new AlsaMixer(event_loop); am->Configure(param); return am; @@ -237,7 +240,7 @@ AlsaMixer::Setup(Error &error) snd_mixer_elem_set_callback(elem, alsa_mixer_elem_callback); - monitor = new AlsaMixerMonitor(*main_loop, handle); + monitor = new AlsaMixerMonitor(event_loop, handle); return true; } diff --git a/src/mixer/plugins/OssMixerPlugin.cxx b/src/mixer/plugins/OssMixerPlugin.cxx index 095ace015..96dade06e 100644 --- a/src/mixer/plugins/OssMixerPlugin.cxx +++ b/src/mixer/plugins/OssMixerPlugin.cxx @@ -96,7 +96,8 @@ OssMixer::Configure(const config_param ¶m, Error &error) } static Mixer * -oss_mixer_init(gcc_unused void *ao, const config_param ¶m, +oss_mixer_init(gcc_unused EventLoop &event_loop, gcc_unused void *ao, + const config_param ¶m, Error &error) { OssMixer *om = new OssMixer(); diff --git a/src/mixer/plugins/PulseMixerPlugin.cxx b/src/mixer/plugins/PulseMixerPlugin.cxx index 4df88d06b..636656081 100644 --- a/src/mixer/plugins/PulseMixerPlugin.cxx +++ b/src/mixer/plugins/PulseMixerPlugin.cxx @@ -143,7 +143,8 @@ pulse_mixer_on_change(PulseMixer *pm, } static Mixer * -pulse_mixer_init(void *ao, gcc_unused const config_param ¶m, +pulse_mixer_init(gcc_unused EventLoop &event_loop, void *ao, + gcc_unused const config_param ¶m, Error &error) { PulseOutput *po = (PulseOutput *)ao; diff --git a/src/mixer/plugins/RoarMixerPlugin.cxx b/src/mixer/plugins/RoarMixerPlugin.cxx index 958688cd7..ce0462520 100644 --- a/src/mixer/plugins/RoarMixerPlugin.cxx +++ b/src/mixer/plugins/RoarMixerPlugin.cxx @@ -34,7 +34,8 @@ struct RoarMixer final : public Mixer { }; static Mixer * -roar_mixer_init(void *ao, gcc_unused const config_param ¶m, +roar_mixer_init(gcc_unused EventLoop &event_loop, void *ao, + gcc_unused const config_param ¶m, gcc_unused Error &error) { return new RoarMixer((RoarOutput *)ao); diff --git a/src/mixer/plugins/SoftwareMixerPlugin.cxx b/src/mixer/plugins/SoftwareMixerPlugin.cxx index 67ddee1a4..e5d4ba5ca 100644 --- a/src/mixer/plugins/SoftwareMixerPlugin.cxx +++ b/src/mixer/plugins/SoftwareMixerPlugin.cxx @@ -67,7 +67,7 @@ struct SoftwareMixer final : public Mixer { }; static Mixer * -software_mixer_init(gcc_unused void *ao, +software_mixer_init(gcc_unused EventLoop &event_loop, gcc_unused void *ao, gcc_unused const config_param ¶m, gcc_unused Error &error) { diff --git a/src/mixer/plugins/WinmmMixerPlugin.cxx b/src/mixer/plugins/WinmmMixerPlugin.cxx index 093a026a9..c040b19fd 100644 --- a/src/mixer/plugins/WinmmMixerPlugin.cxx +++ b/src/mixer/plugins/WinmmMixerPlugin.cxx @@ -55,7 +55,8 @@ winmm_volume_encode(int volume) } static Mixer * -winmm_mixer_init(void *ao, gcc_unused const config_param ¶m, +winmm_mixer_init(gcc_unused EventLoop &event_loop, void *ao, + gcc_unused const config_param ¶m, gcc_unused Error &error) { assert(ao != nullptr); diff --git a/src/output/Init.cxx b/src/output/Init.cxx index 372bb4276..a983ff7c8 100644 --- a/src/output/Init.cxx +++ b/src/output/Init.cxx @@ -112,7 +112,7 @@ audio_output_mixer_type(const config_param ¶m) } static Mixer * -audio_output_load_mixer(AudioOutput *ao, +audio_output_load_mixer(EventLoop &event_loop, AudioOutput *ao, const config_param ¶m, const struct mixer_plugin *plugin, Filter &filter_chain, @@ -129,10 +129,10 @@ audio_output_load_mixer(AudioOutput *ao, if (plugin == nullptr) return nullptr; - return mixer_new(plugin, ao, param, error); + return mixer_new(event_loop, plugin, ao, param, error); case MIXER_TYPE_SOFTWARE: - mixer = mixer_new(&software_mixer_plugin, nullptr, + mixer = mixer_new(event_loop, &software_mixer_plugin, nullptr, config_param(), IgnoreError()); assert(mixer != nullptr); @@ -211,7 +211,8 @@ AudioOutput::Configure(const config_param ¶m, Error &error) } static bool -audio_output_setup(AudioOutput *ao, const config_param ¶m, +audio_output_setup(EventLoop &event_loop, AudioOutput *ao, + const config_param ¶m, Error &error) { @@ -241,7 +242,7 @@ audio_output_setup(AudioOutput *ao, const config_param ¶m, /* set up the mixer */ Error mixer_error; - ao->mixer = audio_output_load_mixer(ao, param, + ao->mixer = audio_output_load_mixer(event_loop, ao, param, ao->plugin.mixer_plugin, *ao->filter, mixer_error); if (ao->mixer == nullptr && mixer_error.IsDefined()) @@ -277,7 +278,7 @@ audio_output_setup(AudioOutput *ao, const config_param ¶m, } AudioOutput * -audio_output_new(const config_param ¶m, +audio_output_new(EventLoop &event_loop, const config_param ¶m, PlayerControl &pc, Error &error) { @@ -316,7 +317,7 @@ audio_output_new(const config_param ¶m, if (ao == nullptr) return nullptr; - if (!audio_output_setup(ao, param, error)) { + if (!audio_output_setup(event_loop, ao, param, error)) { ao_plugin_finish(ao); return nullptr; } diff --git a/src/output/Internal.hxx b/src/output/Internal.hxx index a443d0642..9b08a9228 100644 --- a/src/output/Internal.hxx +++ b/src/output/Internal.hxx @@ -32,6 +32,7 @@ class Error; class Filter; class MusicPipe; +class EventLoop; struct music_chunk; struct config_param; struct PlayerControl; @@ -422,7 +423,7 @@ private: extern struct notify audio_output_client_notify; AudioOutput * -audio_output_new(const config_param ¶m, +audio_output_new(EventLoop &event_loop, const config_param ¶m, PlayerControl &pc, Error &error); diff --git a/src/output/MultipleOutputs.cxx b/src/output/MultipleOutputs.cxx index 66390f24d..a65fb73c0 100644 --- a/src/output/MultipleOutputs.cxx +++ b/src/output/MultipleOutputs.cxx @@ -50,10 +50,10 @@ MultipleOutputs::~MultipleOutputs() } static AudioOutput * -LoadOutput(PlayerControl &pc, const config_param ¶m) +LoadOutput(EventLoop &event_loop, PlayerControl &pc, const config_param ¶m) { Error error; - AudioOutput *output = audio_output_new(param, pc, error); + AudioOutput *output = audio_output_new(event_loop, param, pc, error); if (output == nullptr) { if (param.line > 0) FormatFatalError("line %i: %s", @@ -67,12 +67,12 @@ LoadOutput(PlayerControl &pc, const config_param ¶m) } void -MultipleOutputs::Configure(PlayerControl &pc) +MultipleOutputs::Configure(EventLoop &event_loop, PlayerControl &pc) { const config_param *param = nullptr; while ((param = config_get_next_param(CONF_AUDIO_OUTPUT, param)) != nullptr) { - auto output = LoadOutput(pc, *param); + auto output = LoadOutput(event_loop, pc, *param); if (FindByName(output->name) != nullptr) FormatFatalError("output devices with identical " "names: %s", output->name); @@ -83,7 +83,7 @@ MultipleOutputs::Configure(PlayerControl &pc) if (outputs.empty()) { /* auto-detect device */ const config_param empty; - auto output = LoadOutput(pc, empty); + auto output = LoadOutput(event_loop, pc, empty); outputs.push_back(output); } } diff --git a/src/output/MultipleOutputs.hxx b/src/output/MultipleOutputs.hxx index 7790f83a4..4fe1aa4f1 100644 --- a/src/output/MultipleOutputs.hxx +++ b/src/output/MultipleOutputs.hxx @@ -37,6 +37,7 @@ struct AudioFormat; class MusicBuffer; class MusicPipe; +class EventLoop; struct music_chunk; struct PlayerControl; struct AudioOutput; @@ -72,7 +73,7 @@ public: MultipleOutputs(); ~MultipleOutputs(); - void Configure(PlayerControl &pc); + void Configure(EventLoop &event_loop, PlayerControl &pc); /** * Returns the total number of audio output devices, including |