From 46f6e64539f77eb07b2886aaaab358afd72569ce Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Mon, 21 Jan 2013 10:17:49 -0500 Subject: abstract volume/balance output away from ponymix Add a Notifier virtual base class and a CommandLineNotifier implementation which handles output of volume and balance levels after a change. --- pulse.cc | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'pulse.cc') diff --git a/pulse.cc b/pulse.cc index 26f58eb..324c05d 100644 --- a/pulse.cc +++ b/pulse.cc @@ -349,7 +349,13 @@ bool PulseClient::SetMute(Device& device, bool mute) { mainloop_iterate(op); pa_operation_unref(op); - if (success) device.mute_ = mute; + if (success) { + device.mute_ = mute; + if (notifier_.get()) { + notifier_->Notify(mute ? NOTIFY_MUTE : NOTIFY_UNMUTE, + device.volume_percent_, mute); + } + } return success; } @@ -372,7 +378,12 @@ bool PulseClient::SetVolume(Device& device, long volume) { mainloop_iterate(op); pa_operation_unref(op); - if (success) device.update_volume(*cvol); + if (success) { + device.update_volume(*cvol); + if (notifier_.get()) notifier_->Notify(NOTIFY_VOLUME, + device.volume_percent_, + device.mute_); + } return success; } @@ -405,7 +416,12 @@ bool PulseClient::SetBalance(Device& device, long balance) { mainloop_iterate(op); pa_operation_unref(op); - if (success) device.update_volume(*cvol); + if (success) { + device.update_volume(*cvol); + if (notifier_.get()) notifier_->Notify(NOTIFY_BALANCE, + device.balance_, + false); + } return success; } @@ -544,6 +560,10 @@ void PulseClient::remove_device(Device& device) { devlist->end()); } +void PulseClient::EnableNotifications(Notifier* notifier) { + notifier_.reset(notifier); +} + // // Cards // -- cgit v1.2.3