diff options
author | Max Kellermann <max@musicpd.org> | 2021-08-06 17:53:24 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2021-08-06 17:53:45 +0200 |
commit | ad6e303047397a9ef6cf9790e309f1cf438f21c8 (patch) | |
tree | e68afd3e2b5ff06bc9c9c9d060e0223d94157398 | |
parent | b0e95388554eeef78e3e3c4c6eb401b297b7603b (diff) |
mixer/alsa: move code to GetNormalizedVolume()
-rw-r--r-- | src/mixer/plugins/AlsaMixerPlugin.cxx | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/mixer/plugins/AlsaMixerPlugin.cxx b/src/mixer/plugins/AlsaMixerPlugin.cxx index 9d264993a..23b641cca 100644 --- a/src/mixer/plugins/AlsaMixerPlugin.cxx +++ b/src/mixer/plugins/AlsaMixerPlugin.cxx @@ -95,6 +95,13 @@ public: void Close() noexcept override; int GetVolume() override; void SetVolume(unsigned volume) override; + +private: + [[gnu::pure]] + double GetNormalizedVolume() const noexcept { + return get_normalized_playback_volume(elem, + SND_MIXER_SCHN_FRONT_LEFT); + } }; static constexpr Domain alsa_mixer_domain("alsa_mixer"); @@ -273,7 +280,7 @@ AlsaMixer::GetVolume() throw FormatRuntimeError("snd_mixer_handle_events() failed: %s", snd_strerror(err)); - return lround(100 * get_normalized_playback_volume(elem, SND_MIXER_SCHN_FRONT_LEFT)); + return lround(100 * GetNormalizedVolume()); } void @@ -281,7 +288,7 @@ AlsaMixer::SetVolume(unsigned volume) { assert(handle != nullptr); - double cur = get_normalized_playback_volume(elem, SND_MIXER_SCHN_FRONT_LEFT); + double cur = GetNormalizedVolume(); int delta = volume - lround(100.*cur); int err = set_normalized_playback_volume(elem, cur + 0.01*delta, delta); if (err < 0) |