[Scummvm-git-logs] scummvm master -> 9b976515ee259dfca7b199e286d4bfbb7cdc3868
lephilousophe
noreply at scummvm.org
Sun Oct 11 11:06:35 UTC 2026
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
9b976515ee ANDROID: Clear our internal buffer when flushing Oboe buffers
Commit: 9b976515ee259dfca7b199e286d4bfbb7cdc3868
https://github.com/scummvm/scummvm/commit/9b976515ee259dfca7b199e286d4bfbb7cdc3868
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2026-10-11T13:03:27+02:00
Commit Message:
ANDROID: Clear our internal buffer when flushing Oboe buffers
Without this, when silence is produced the buffer stays full and that
triggers a restart of the stream and then pausing again in a loop.
Changed paths:
backends/mixer/android/android-mixer.cpp
backends/mixer/android/ringbuffer.h
diff --git a/backends/mixer/android/android-mixer.cpp b/backends/mixer/android/android-mixer.cpp
index 61a57afe21c..6545993e442 100644
--- a/backends/mixer/android/android-mixer.cpp
+++ b/backends/mixer/android/android-mixer.cpp
@@ -438,7 +438,7 @@ void *AndroidMixerManagerImpl::audioThreadFunc(void *arg) {
#ifdef OBOE_DEBUG
if (n > 0) {
- LOGD("Requested mix of %zu frames and got %zu%s - Buffer size: %d / %d", req, n, silence ? " S" : "", stream->getBufferSizeInFrames(), stream->getBufferCapacityInFrames());
+ LOGD("Requested mix of %zu frames and got %zu%s - Buffer size: %d / %d - Status: %zu + %zu", req, n, silence ? " S" : "", stream->getBufferSizeInFrames(), stream->getBufferCapacityInFrames(), this_->_underflows.load(std::memory_order_acquire), silence_count);
}
#endif
@@ -449,6 +449,9 @@ void *AndroidMixerManagerImpl::audioThreadFunc(void *arg) {
LOGD("Silence %zu+%zu: pausing audio stream", underflows, silence_count);
stream->pause();
stream->requestFlush();
+ // also flush our internal buffer full of silence
+ // we can call flush as we are paused and flushing (onAudioReady is not called)
+ this_->_buffer->flush();
}
}
diff --git a/backends/mixer/android/ringbuffer.h b/backends/mixer/android/ringbuffer.h
index afd9ba6b8fa..4b629ee62e7 100644
--- a/backends/mixer/android/ringbuffer.h
+++ b/backends/mixer/android/ringbuffer.h
@@ -180,6 +180,26 @@ public:
_write.store(pending_write, std::memory_order_release);
}
+ /*
+ * Make the buffer empty.
+ *
+ * Called from the producer side.
+ * NO consume MUST be ongoing.
+ */
+ void flush() {
+ size_t write = _write.load(std::memory_order_relaxed);
+ size_t read = _read.load(std::memory_order_acquire);
+ assert(_pending_write == write);
+
+ // This check may succeed while the other thread is consuming
+ // This is an imperfect failsafe
+ assert(_pending_read == read);
+
+ _last.store(read, std::memory_order_relaxed);
+ _pending_write = read;
+ _write.store(read, std::memory_order_release);
+ }
+
/*
* Try to consume at most n elements.
* If there is less than n elements (or if the buffer is not contiguous), adjusts n to the real count.
More information about the Scummvm-git-logs
mailing list