diff options
| author | Calvin Morrison <calvin@pobox.com> | 2026-05-17 09:44:33 -0400 |
|---|---|---|
| committer | Calvin Morrison <calvin@pobox.com> | 2026-05-17 09:44:33 -0400 |
| commit | 83ff745b43ebda7b33c52ac1a80a1408c59bfa70 (patch) | |
| tree | 3383f8d54d0523b3ed812957a56e70cb59a01b08 /src/model/pulsedevice.cpp | |
| parent | 5ccdfbc97811847611ee366848aa4b4b767bd656 (diff) | |
for the pulse peak streams do nothing if windows aren't open to reduce cpu
Diffstat (limited to 'src/model/pulsedevice.cpp')
| -rw-r--r-- | src/model/pulsedevice.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/model/pulsedevice.cpp b/src/model/pulsedevice.cpp index d79ee8e..2f0adb1 100644 --- a/src/model/pulsedevice.cpp +++ b/src/model/pulsedevice.cpp @@ -95,6 +95,22 @@ void PulseDevice::update( const TQString &name, int volume, bool muted, // ---- peak monitoring -------------------------------------------------------- +void PulseDevice::pauseMonitoring() +{ + if ( !m_monitorStream || !m_mainloop ) return; + pa_threaded_mainloop_lock( m_mainloop ); + pa_stream_set_read_callback( m_monitorStream, 0, 0 ); + pa_threaded_mainloop_unlock( m_mainloop ); +} + +void PulseDevice::resumeMonitoring() +{ + if ( !m_monitorStream || !m_mainloop ) return; + pa_threaded_mainloop_lock( m_mainloop ); + pa_stream_set_read_callback( m_monitorStream, monitorReadCb, this ); + pa_threaded_mainloop_unlock( m_mainloop ); +} + void PulseDevice::startMonitoring() { if ( !m_context || !m_mainloop || m_monitorName.isEmpty() || m_monitorStream ) @@ -102,7 +118,7 @@ void PulseDevice::startMonitoring() pa_sample_spec spec; spec.format = PA_SAMPLE_FLOAT32NE; - spec.rate = 25; + spec.rate = 20; spec.channels = 1; pa_threaded_mainloop_lock( m_mainloop ); @@ -112,7 +128,8 @@ void PulseDevice::startMonitoring() m_monitorStream = pa_stream_new_with_proplist( m_context, "tmix-peak", &spec, 0, props ); pa_proplist_free( props ); if ( m_monitorStream ) { - pa_stream_set_read_callback( m_monitorStream, monitorReadCb, this ); + if ( !m_model || m_model->levelsActive() ) + pa_stream_set_read_callback( m_monitorStream, monitorReadCb, this ); // For sink inputs, filter peak detection to just this stream. // Source outputs don't support pa_stream_set_monitor_stream; they connect to the source directly. |
