aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2013-08-22 23:34:11 -0400
committerDave Reisner <dreisner@archlinux.org>2013-08-22 23:34:11 -0400
commit11b85e55db3f6ed29a040b53041a4aa9cf1a10df (patch)
tree6702e426d6e97ff997a3f24b7b31e71da80ca1f7
parentab16b8a89c399c513a7fba8e0bc68f0e700cfd2c (diff)
downloadmirror-ponymix-11b85e55db3f6ed29a040b53041a4aa9cf1a10df.tar.gz
mirror-ponymix-11b85e55db3f6ed29a040b53041a4aa9cf1a10df.tar.bz2
mirror-ponymix-11b85e55db3f6ed29a040b53041a4aa9cf1a10df.zip
notify: Create a NullNotifier as the default notifier
This notifier is boring. It does nothing.
-rw-r--r--notify.h6
-rw-r--r--pulse.cc17
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;