From 11b85e55db3f6ed29a040b53041a4aa9cf1a10df Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Thu, 22 Aug 2013 23:34:11 -0400 Subject: notify: Create a NullNotifier as the default notifier This notifier is boring. It does nothing. --- notify.h | 6 ++++++ pulse.cc | 17 ++++++----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/notify.h b/notify.h index 10423ee..69e8730 100644 --- a/notify.h +++ b/notify.h @@ -23,6 +23,12 @@ class Notifier { bool initialized_; }; +class NullNotifier : public Notifier { + public: + virtual ~NullNotifier() {} + virtual void Notify(enum NotificationType, long, bool) {} +}; + class CommandLineNotifier : public Notifier { public: virtual ~CommandLineNotifier() {} diff --git a/pulse.cc b/pulse.cc index 233dfc2..e95dd53 100644 --- a/pulse.cc +++ b/pulse.cc @@ -98,7 +98,8 @@ static int xstrtol(const char *str, long *out) { PulseClient::PulseClient(string client_name) : client_name_(client_name), volume_range_(0, 150), - balance_range_(-100, 100) { + balance_range_(-100, 100), + notifier_(new NullNotifier) { enum pa_context_state state = PA_CONTEXT_CONNECTING; pa_proplist* proplist = pa_proplist_new(); @@ -345,10 +346,8 @@ bool PulseClient::SetMute(Device& device, bool mute) { if (success) { device.mute_ = mute; - if (notifier_.get()) { - notifier_->Notify(mute ? NOTIFY_MUTE : NOTIFY_UNMUTE, - device.volume_percent_, mute); - } + notifier_->Notify(mute ? NOTIFY_MUTE : NOTIFY_UNMUTE, + device.volume_percent_, mute); } return success; @@ -374,9 +373,7 @@ bool PulseClient::SetVolume(Device& device, long volume) { if (success) { device.update_volume(*cvol); - if (notifier_.get()) notifier_->Notify(NOTIFY_VOLUME, - device.volume_percent_, - device.mute_); + notifier_->Notify(NOTIFY_VOLUME, device.volume_percent_, device.mute_); } return success; @@ -412,9 +409,7 @@ bool PulseClient::SetBalance(Device& device, long balance) { if (success) { device.update_volume(*cvol); - if (notifier_.get()) notifier_->Notify(NOTIFY_BALANCE, - device.balance_, - false); + notifier_->Notify(NOTIFY_BALANCE, device.balance_, false); } return success; -- cgit v1.2.3