summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrzej Rybczak <andrzej@rybczak.net>2020-12-17 22:48:48 +0100
committerAndrzej Rybczak <andrzej@rybczak.net>2020-12-17 22:48:48 +0100
commitfa2bca9311d63c92dc366ecc6772c5b6dbf30bd2 (patch)
tree3a3823924b8150c92d5d7840272dc6ff871f2baf /src
parentfb886f687014e22b2fe1477da855be5201063ea8 (diff)
Don't run volume changing actions if there is no mixer
Diffstat (limited to 'src')
-rw-r--r--src/actions.cpp15
-rw-r--r--src/actions.h3
2 files changed, 18 insertions, 0 deletions
diff --git a/src/actions.cpp b/src/actions.cpp
index f07feab6..9d6392ea 100644
--- a/src/actions.cpp
+++ b/src/actions.cpp
@@ -621,11 +621,21 @@ void SlaveScreen::run()
drawHeader();
}
+bool VolumeUp::canBeRun()
+{
+ return Status::State::volume() >= 0;
+}
+
void VolumeUp::run()
{
Mpd.ChangeVolume(static_cast<int>(Config.volume_change_step));
}
+bool VolumeDown::canBeRun()
+{
+ return Status::State::volume() >= 0;
+}
+
void VolumeDown::run()
{
Mpd.ChangeVolume(-static_cast<int>(Config.volume_change_step));
@@ -1356,6 +1366,11 @@ void SetCrossfade::run()
Mpd.SetCrossfade(crossfade);
}
+bool SetVolume::canBeRun()
+{
+ return Status::State::volume() >= 0;
+}
+
void SetVolume::run()
{
using Global::wFooter;
diff --git a/src/actions.h b/src/actions.h
index 809e94ee..153f1bad 100644
--- a/src/actions.h
+++ b/src/actions.h
@@ -428,6 +428,7 @@ struct VolumeUp: BaseAction
VolumeUp(): BaseAction(Type::VolumeUp, "volume_up") { }
private:
+ virtual bool canBeRun() override;
virtual void run() override;
};
@@ -436,6 +437,7 @@ struct VolumeDown: BaseAction
VolumeDown(): BaseAction(Type::VolumeDown, "volume_down") { }
private:
+ virtual bool canBeRun() override;
virtual void run() override;
};
@@ -791,6 +793,7 @@ struct SetVolume: BaseAction
SetVolume(): BaseAction(Type::SetVolume, "set_volume") { }
private:
+ virtual bool canBeRun() override;
virtual void run() override;
};