diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-15 23:56:43 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-15 23:56:43 +0100 |
| commit | 5c7feffd3749ce4b355d0db6334cf39ca94d8d82 (patch) | |
| tree | 7105aea12d0367208a37777cf53b348f35a66dad /src/audio/backend/miniaudio_backend.h | |
| parent | e21127a3fc4797805d49ae2d95fc7ed6f94ac456 (diff) | |
perf(audio): smooth playback time and RMS-based peak at 60Hz
Interpolates audio playback time between callbacks using CLOCK_MONOTONIC
for smooth 60Hz updates instead of coarse 8-10Hz steps.
Replaces artificial peak decay with true RMS calculation over 50ms
window. Ring buffer computes RMS directly on internal buffer without
copies for efficiency.
All backends updated with get_callback_state() interface for time
interpolation. Tests passing (34/34).
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'src/audio/backend/miniaudio_backend.h')
| -rw-r--r-- | src/audio/backend/miniaudio_backend.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/audio/backend/miniaudio_backend.h b/src/audio/backend/miniaudio_backend.h index eb9019c..435496c 100644 --- a/src/audio/backend/miniaudio_backend.h +++ b/src/audio/backend/miniaudio_backend.h @@ -18,6 +18,7 @@ class MiniaudioBackend : public AudioBackend { void start() override; void shutdown() override; float get_realtime_peak() override; + void get_callback_state(double* out_time, int64_t* out_samples) override; // Get the underlying miniaudio device (for internal use) ma_device* get_device() { @@ -32,6 +33,10 @@ class MiniaudioBackend : public AudioBackend { // Updated in audio_callback when samples are read from ring buffer static volatile float realtime_peak_; + // Smooth playback time interpolation (updated in callback) + static volatile double last_callback_time_; // Absolute CLOCK_MONOTONIC time + static volatile int64_t last_callback_samples_; + // Static callback required by miniaudio C API static void audio_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount); |
