From 7fb3029e8b32af7cea26404206359e92d14dd21e Mon Sep 17 00:00:00 2001 From: David Madl Date: Sun, 22 Mar 2026 14:28:44 +0100 Subject: [PATCH] chore: improve debug logging of audio lag from stretcher --- app/src/main/cpp/PlaybackEngine.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/cpp/PlaybackEngine.cpp b/app/src/main/cpp/PlaybackEngine.cpp index 9e5d405..f22a607 100644 --- a/app/src/main/cpp/PlaybackEngine.cpp +++ b/app/src/main/cpp/PlaybackEngine.cpp @@ -362,11 +362,18 @@ void MusicProvider::onAudioReady(float *data, int32_t frames) { } if(frames > buf_size_samples) { - LOGE("MusicProvider::onAudioReady() asked for frames=%d but buf_size=%d", frames, buf_size_samples); + LOGE("audio buffer too small! adapt PlaybackEngine::buf_size_samples!! asked for frames=%d but buf_size=%d", frames, buf_size_samples); } // 1. read from oboe into our temp de-interleaved buffer 'buf' - size_t num_frames = std::min((size_t) frames, buf_size_samples); + size_t num_frames_requested = std::min((size_t) frames, buf_size_samples); + size_t num_frames_available = stretcher->available(); + if(num_frames_available < num_frames_requested) { + // this is an audio glitch + // TODO: bubble info upwards, in a counter (so we can collect device-specific glitch stats) + LOGI("stretcher lag: %d requested, %d available", num_frames_requested, num_frames_available); + } + size_t num_frames = std::min(num_frames_available, num_frames_requested); stretcher->retrieve(buf_ptr, num_frames); // 2. convert to add samples to interleaved *data