diff options
| author | Calvin Morrison <calvin@pobox.com> | 2026-05-24 21:56:18 -0400 |
|---|---|---|
| committer | Calvin Morrison <calvin@pobox.com> | 2026-05-24 21:56:18 -0400 |
| commit | ccff0eb51fa2ae2b94d2a6297f45519a12e07def (patch) | |
| tree | de546a55f294d13edd94eb3476532232a96b4665 /src | |
| parent | 883dd1fa7c3fa1cde131071bfabf757f04ce13de (diff) | |
fix issue slavek reported with peak lagging due to buffer and some other stuff. fixed
Diffstat (limited to 'src')
| -rw-r--r-- | src/model/pulsedevice.cpp | 16 | ||||
| -rw-r--r-- | src/ui/levelmeter.cpp | 2 |
2 files changed, 15 insertions, 3 deletions
diff --git a/src/model/pulsedevice.cpp b/src/model/pulsedevice.cpp index f91ace6..616cf23 100644 --- a/src/model/pulsedevice.cpp +++ b/src/model/pulsedevice.cpp @@ -82,7 +82,15 @@ void PulseDevice::update( const TQString &name, int volume, bool muted, m_channels = channels ? channels : 2; m_pan = pan; - if ( m_monitorName.isEmpty() && !monitorName.isEmpty() ) { + if ( !monitorName.isEmpty() && monitorName != m_monitorName ) { + if ( m_monitorStream && m_mainloop ) { + pa_threaded_mainloop_lock( m_mainloop ); + pa_stream_set_read_callback( m_monitorStream, 0, 0 ); + pa_stream_disconnect( m_monitorStream ); + pa_stream_unref( m_monitorStream ); + pa_threaded_mainloop_unlock( m_mainloop ); + m_monitorStream = 0; + } m_monitorName = monitorName; if ( m_context ) startMonitoring(); } @@ -107,6 +115,9 @@ void PulseDevice::resumeMonitoring() { if ( !m_monitorStream || !m_mainloop ) return; pa_threaded_mainloop_lock( m_mainloop ); + const void *data; size_t nbytes; + while ( pa_stream_peek( m_monitorStream, &data, &nbytes ) == 0 && nbytes > 0 ) + pa_stream_drop( m_monitorStream ); pa_stream_set_read_callback( m_monitorStream, monitorReadCb, this ); pa_threaded_mainloop_unlock( m_mainloop ); } @@ -138,7 +149,8 @@ void PulseDevice::startMonitoring() pa_buffer_attr attr; memset( &attr, 0xff, sizeof(attr) ); - attr.fragsize = sizeof(float); + attr.fragsize = sizeof(float); + attr.maxlength = sizeof(float) * 8; pa_stream_connect_record( m_monitorStream, m_monitorName.utf8().data(), &attr, diff --git a/src/ui/levelmeter.cpp b/src/ui/levelmeter.cpp index 906ef20..f0512c7 100644 --- a/src/ui/levelmeter.cpp +++ b/src/ui/levelmeter.cpp @@ -29,7 +29,7 @@ void LevelMeter::setLevel( float level ) if ( display > m_level ) m_level = m_level * 0.3f + display * 0.7f; // fast attack, not instant else { - m_level *= 0.925f; // slow decay ~1.5s to floor at 20Hz + m_level *= 0.85f; // decay ~0.7s to floor at 20Hz if ( m_level < 0.001f ) m_level = 0.0f; } update(); |
