aboutsummaryrefslogtreecommitdiffstats
path: root/pulse.cc
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2013-01-21 10:17:49 -0500
committerDave Reisner <dreisner@archlinux.org>2013-01-21 15:49:31 -0500
commit46f6e64539f77eb07b2886aaaab358afd72569ce (patch)
tree0cb0e0555d0ce6fb20d9683cf0ec70e233314b49 /pulse.cc
parent2bdbd84cc41975c7d9855551cecef02ff41c2b2a (diff)
downloadmirror-ponymix-46f6e64539f77eb07b2886aaaab358afd72569ce.tar.gz
mirror-ponymix-46f6e64539f77eb07b2886aaaab358afd72569ce.tar.bz2
mirror-ponymix-46f6e64539f77eb07b2886aaaab358afd72569ce.zip
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.
Diffstat (limited to 'pulse.cc')
-rw-r--r--pulse.cc26
1 files changed, 23 insertions, 3 deletions
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
//