Don't run volume changing actions if there is no mixer

This commit is contained in:
Andrzej Rybczak
2020-12-17 22:48:48 +01:00
parent fb886f6870
commit fa2bca9311
3 changed files with 19 additions and 0 deletions

View File

@@ -26,6 +26,7 @@
synchronization attempts.
* Support gstreamer's udpsink as a data source for visualization (Mopidy).
* Deprecate `visualizer_fifo_path` in favor of `visualizer_data_source`.
* Don't run volume changing actions if there is no mixer.
# ncmpcpp-0.8.2 (2018-04-11)
* Help screen: fixed display of EoF keycode

View File

@@ -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;

View File

@@ -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;
};