diff --git a/include/adapters/pulseaudio.hpp b/include/adapters/pulseaudio.hpp index c7602613..3d372848 100644 --- a/include/adapters/pulseaudio.hpp +++ b/include/adapters/pulseaudio.hpp @@ -74,7 +74,7 @@ class pulseaudio { string s_name; uint32_t m_index{0}; - pa_volume_t max_volume{PA_VOLUME_UI_MAX}; + pa_volume_t m_max_volume{PA_VOLUME_UI_MAX}; }; POLYBAR_NS_END diff --git a/src/adapters/pulseaudio.cpp b/src/adapters/pulseaudio.cpp index 284d47a3..5ec13d32 100644 --- a/src/adapters/pulseaudio.cpp +++ b/src/adapters/pulseaudio.cpp @@ -6,7 +6,7 @@ POLYBAR_NS /** * Construct pulseaudio object */ -pulseaudio::pulseaudio(const logger& logger, string&& sink_name, bool m_max_volume) : m_log(logger), spec_s_name(sink_name) { +pulseaudio::pulseaudio(const logger& logger, string&& sink_name, bool max_volume) : m_log(logger), spec_s_name(sink_name) { m_mainloop = pa_threaded_mainloop_new(); if (!m_mainloop) { throw pulseaudio_error("Could not create pulseaudio threaded mainloop."); @@ -64,7 +64,7 @@ pulseaudio::pulseaudio(const logger& logger, string&& sink_name, bool m_max_volu m_log.trace("pulseaudio: using sink %s", s_name); } - max_volume = m_max_volume ? PA_VOLUME_UI_MAX : PA_VOLUME_NORM; + m_max_volume = max_volume ? PA_VOLUME_UI_MAX : PA_VOLUME_NORM; auto event_types = static_cast(PA_SUBSCRIPTION_MASK_SINK | PA_SUBSCRIPTION_MASK_SERVER); op = pa_context_subscribe(m_context, event_types, simple_callback, this); @@ -175,7 +175,7 @@ void pulseaudio::inc_volume(int delta_perc) { pa_threaded_mainloop_lock(m_mainloop); pa_volume_t vol = math_util::percentage_to_value(abs(delta_perc), PA_VOLUME_NORM); if (delta_perc > 0) { - if (pa_cvolume_max(&cv) + vol <= max_volume) { + if (pa_cvolume_max(&cv) + vol <= m_max_volume) { pa_cvolume_inc(&cv, vol); } else { m_log.warn("pulseaudio: maximum volume reached");