diff options
| author | Calvin Morrison <calvin@pobox.com> | 2026-05-17 10:14:22 -0400 |
|---|---|---|
| committer | Calvin Morrison <calvin@pobox.com> | 2026-05-17 10:14:22 -0400 |
| commit | 311b69c14203860ab6d98bd11633eea287c8f04e (patch) | |
| tree | bad243b12d3e5935af1cf4c214bd39e90a984b94 /src/model/pulsedevice.cpp | |
| parent | 83ff745b43ebda7b33c52ac1a80a1408c59bfa70 (diff) | |
cleanups
Diffstat (limited to 'src/model/pulsedevice.cpp')
| -rw-r--r-- | src/model/pulsedevice.cpp | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/src/model/pulsedevice.cpp b/src/model/pulsedevice.cpp index 2f0adb1..f91ace6 100644 --- a/src/model/pulsedevice.cpp +++ b/src/model/pulsedevice.cpp @@ -213,14 +213,8 @@ static pa_cvolume buildCVolume( uint8_t channels, pa_volume_t vol, int pan ) // ---- write back to PA ------------------------------------------------------- -void PulseDevice::setVolume( int v ) +void PulseDevice::pushCVolume( const pa_cvolume &cv ) { - if ( !m_context ) return; - v = v < 0 ? 0 : v > 100 ? 100 : v; - m_volume = v; - emit volumeChanged( v ); - - pa_cvolume cv = buildCVolume( m_channels, percentToPA(v), m_pan ); pa_threaded_mainloop_lock( m_mainloop ); pa_operation *op = 0; switch ( m_category ) { @@ -233,24 +227,22 @@ void PulseDevice::setVolume( int v ) pa_threaded_mainloop_unlock( m_mainloop ); } +void PulseDevice::setVolume( int v ) +{ + if ( !m_context ) return; + v = v < 0 ? 0 : v > 100 ? 100 : v; + m_volume = v; + emit volumeChanged( v ); + pushCVolume( buildCVolume( m_channels, percentToPA(v), m_pan ) ); +} + void PulseDevice::setPan( int p ) { if ( !m_context ) return; p = p < -50 ? -50 : p > 50 ? 50 : p; m_pan = p; emit panChanged( p ); - - pa_cvolume cv = buildCVolume( m_channels, percentToPA(m_volume), p ); - pa_threaded_mainloop_lock( m_mainloop ); - pa_operation *op = 0; - switch ( m_category ) { - case Output: op = pa_context_set_sink_volume_by_index( m_context, m_paIndex, &cv, 0, 0 ); break; - case Input: op = pa_context_set_source_volume_by_index( m_context, m_paIndex, &cv, 0, 0 ); break; - case Playback: op = pa_context_set_sink_input_volume( m_context, m_paIndex, &cv, 0, 0 ); break; - case Recording: op = pa_context_set_source_output_volume( m_context, m_paIndex, &cv, 0, 0 ); break; - } - if ( op ) pa_operation_unref( op ); - pa_threaded_mainloop_unlock( m_mainloop ); + pushCVolume( buildCVolume( m_channels, percentToPA(m_volume), p ) ); } void PulseDevice::setMuted( bool m ) |
