diff options
Diffstat (limited to '')
-rw-r--r-- | src/mixer/plugins/AlsaMixerPlugin.cxx | 22 | ||||
-rw-r--r-- | src/mixer/plugins/OssMixerPlugin.cxx | 6 | ||||
-rw-r--r-- | src/mixer/plugins/PulseMixerPlugin.cxx | 15 | ||||
-rw-r--r-- | src/mixer/plugins/RoarMixerPlugin.cxx | 9 | ||||
-rw-r--r-- | src/mixer/plugins/SoftwareMixerPlugin.cxx | 7 | ||||
-rw-r--r-- | src/mixer/plugins/WinmmMixerPlugin.cxx | 7 |
6 files changed, 40 insertions, 26 deletions
diff --git a/src/mixer/plugins/AlsaMixerPlugin.cxx b/src/mixer/plugins/AlsaMixerPlugin.cxx index 26007fef3..cd787182a 100644 --- a/src/mixer/plugins/AlsaMixerPlugin.cxx +++ b/src/mixer/plugins/AlsaMixerPlugin.cxx @@ -19,8 +19,8 @@ #include "config.h" #include "mixer/MixerInternal.hxx" +#include "mixer/Listener.hxx" #include "output/OutputAPI.hxx" -#include "GlobalEvents.hxx" #include "event/MultiSocketMonitor.hxx" #include "event/DeferredMonitor.hxx" #include "event/Loop.hxx" @@ -76,8 +76,9 @@ class AlsaMixer final : public Mixer { AlsaMixerMonitor *monitor; public: - AlsaMixer(EventLoop &_event_loop) - :Mixer(alsa_mixer_plugin), event_loop(_event_loop) {} + AlsaMixer(EventLoop &_event_loop, MixerListener &_listener) + :Mixer(alsa_mixer_plugin, _listener), + event_loop(_event_loop) {} virtual ~AlsaMixer(); @@ -142,10 +143,15 @@ AlsaMixerMonitor::DispatchSockets() */ static int -alsa_mixer_elem_callback(gcc_unused snd_mixer_elem_t *elem, unsigned mask) +alsa_mixer_elem_callback(snd_mixer_elem_t *elem, unsigned mask) { - if (mask & SND_CTL_EVENT_MASK_VALUE) - GlobalEvents::Emit(GlobalEvents::MIXER); + AlsaMixer &mixer = *(AlsaMixer *) + snd_mixer_elem_get_callback_private(elem); + + if (mask & SND_CTL_EVENT_MASK_VALUE) { + int volume = mixer.GetVolume(IgnoreError()); + mixer.listener.OnMixerVolumeChanged(mixer, volume); + } return 0; } @@ -168,10 +174,11 @@ AlsaMixer::Configure(const config_param ¶m) static Mixer * alsa_mixer_init(EventLoop &event_loop, gcc_unused AudioOutput &ao, + MixerListener &listener, const config_param ¶m, gcc_unused Error &error) { - AlsaMixer *am = new AlsaMixer(event_loop); + AlsaMixer *am = new AlsaMixer(event_loop, listener); am->Configure(param); return am; @@ -236,6 +243,7 @@ AlsaMixer::Setup(Error &error) snd_mixer_selem_get_playback_volume_range(elem, &volume_min, &volume_max); + snd_mixer_elem_set_callback_private(elem, this); snd_mixer_elem_set_callback(elem, alsa_mixer_elem_callback); monitor = new AlsaMixerMonitor(event_loop, handle); diff --git a/src/mixer/plugins/OssMixerPlugin.cxx b/src/mixer/plugins/OssMixerPlugin.cxx index 939fe0824..6615c7022 100644 --- a/src/mixer/plugins/OssMixerPlugin.cxx +++ b/src/mixer/plugins/OssMixerPlugin.cxx @@ -49,7 +49,8 @@ class OssMixer final : public Mixer { int volume_control; public: - OssMixer():Mixer(oss_mixer_plugin) {} + OssMixer(MixerListener &_listener) + :Mixer(oss_mixer_plugin, _listener) {} bool Configure(const config_param ¶m, Error &error); @@ -98,10 +99,11 @@ OssMixer::Configure(const config_param ¶m, Error &error) static Mixer * oss_mixer_init(gcc_unused EventLoop &event_loop, gcc_unused AudioOutput &ao, + MixerListener &listener, const config_param ¶m, Error &error) { - OssMixer *om = new OssMixer(); + OssMixer *om = new OssMixer(listener); if (!om->Configure(param, error)) { delete om; diff --git a/src/mixer/plugins/PulseMixerPlugin.cxx b/src/mixer/plugins/PulseMixerPlugin.cxx index b838de689..0a765bf68 100644 --- a/src/mixer/plugins/PulseMixerPlugin.cxx +++ b/src/mixer/plugins/PulseMixerPlugin.cxx @@ -20,8 +20,8 @@ #include "config.h" #include "PulseMixerPlugin.hxx" #include "mixer/MixerInternal.hxx" +#include "mixer/Listener.hxx" #include "output/plugins/PulseOutputPlugin.hxx" -#include "GlobalEvents.hxx" #include "util/Error.hxx" #include "util/Domain.hxx" #include "Log.hxx" @@ -41,9 +41,9 @@ class PulseMixer final : public Mixer { struct pa_cvolume volume; public: - PulseMixer(PulseOutput &_output) - :Mixer(pulse_mixer_plugin), - output(_output), online(false) + PulseMixer(PulseOutput &_output, MixerListener &_listener) + :Mixer(pulse_mixer_plugin, _listener), + output(_output), online(false) { } @@ -75,7 +75,7 @@ PulseMixer::Offline() online = false; - GlobalEvents::Emit(GlobalEvents::MIXER); + listener.OnMixerVolumeChanged(*this, -1); } inline void @@ -92,7 +92,7 @@ PulseMixer::VolumeCallback(const pa_sink_input_info *i, int eol) online = true; volume = i->volume; - GlobalEvents::Emit(GlobalEvents::MIXER); + listener.OnMixerVolumeChanged(*this, GetVolume(IgnoreError())); } /** @@ -165,11 +165,12 @@ pulse_mixer_on_change(PulseMixer &pm, static Mixer * pulse_mixer_init(gcc_unused EventLoop &event_loop, AudioOutput &ao, + MixerListener &listener, gcc_unused const config_param ¶m, gcc_unused Error &error) { PulseOutput &po = (PulseOutput &)ao; - PulseMixer *pm = new PulseMixer(po); + PulseMixer *pm = new PulseMixer(po, listener); pulse_output_set_mixer(po, *pm); diff --git a/src/mixer/plugins/RoarMixerPlugin.cxx b/src/mixer/plugins/RoarMixerPlugin.cxx index 7c2a25dfb..8e198478d 100644 --- a/src/mixer/plugins/RoarMixerPlugin.cxx +++ b/src/mixer/plugins/RoarMixerPlugin.cxx @@ -29,9 +29,9 @@ class RoarMixer final : public Mixer { RoarOutput &self; public: - RoarMixer(RoarOutput &_output) - :Mixer(roar_mixer_plugin), - self(_output) {} + RoarMixer(RoarOutput &_output, MixerListener &_listener) + :Mixer(roar_mixer_plugin, _listener), + self(_output) {} /* virtual methods from class Mixer */ virtual bool Open(gcc_unused Error &error) override { @@ -47,10 +47,11 @@ public: static Mixer * roar_mixer_init(gcc_unused EventLoop &event_loop, AudioOutput &ao, + MixerListener &listener, gcc_unused const config_param ¶m, gcc_unused Error &error) { - return new RoarMixer((RoarOutput &)ao); + return new RoarMixer((RoarOutput &)ao, listener); } int diff --git a/src/mixer/plugins/SoftwareMixerPlugin.cxx b/src/mixer/plugins/SoftwareMixerPlugin.cxx index 78f0769ab..0cde682f6 100644 --- a/src/mixer/plugins/SoftwareMixerPlugin.cxx +++ b/src/mixer/plugins/SoftwareMixerPlugin.cxx @@ -52,8 +52,8 @@ class SoftwareMixer final : public Mixer { unsigned volume; public: - SoftwareMixer() - :Mixer(software_mixer_plugin), + SoftwareMixer(MixerListener &_listener) + :Mixer(software_mixer_plugin, _listener), filter(CreateVolumeFilter()), owns_filter(true), volume(100) @@ -86,10 +86,11 @@ public: static Mixer * software_mixer_init(gcc_unused EventLoop &event_loop, gcc_unused AudioOutput &ao, + MixerListener &listener, gcc_unused const config_param ¶m, gcc_unused Error &error) { - return new SoftwareMixer(); + return new SoftwareMixer(listener); } bool diff --git a/src/mixer/plugins/WinmmMixerPlugin.cxx b/src/mixer/plugins/WinmmMixerPlugin.cxx index 6b81fa095..e0436011a 100644 --- a/src/mixer/plugins/WinmmMixerPlugin.cxx +++ b/src/mixer/plugins/WinmmMixerPlugin.cxx @@ -34,8 +34,8 @@ class WinmmMixer final : public Mixer { WinmmOutput &output; public: - WinmmMixer(WinmmOutput &_output) - :Mixer(winmm_mixer_plugin), + WinmmMixer(WinmmOutput &_output, MixerListener &_listener) + :Mixer(winmm_mixer_plugin, _listener), output(_output) { } @@ -68,10 +68,11 @@ winmm_volume_encode(int volume) static Mixer * winmm_mixer_init(gcc_unused EventLoop &event_loop, AudioOutput &ao, + MixerListener &listener, gcc_unused const config_param ¶m, gcc_unused Error &error) { - return new WinmmMixer((WinmmOutput &)ao); + return new WinmmMixer((WinmmOutput &)ao, listener); } int |