Make numVBlanks atomic

The WebSocket debugger reads it from its own thread (input.buttons.press counts
down frames against it) while the CPU thread bumps it.

Note the input subscriber and broadcaster need no other changes for thread
safety: __CtrlUpdateButtons, __CtrlSetAnalogXY, __CtrlPeekButtons and
__CtrlPeekAnalog all take ctrlMutex internally, so routing them through
Core_RunOnCPUThread() would only add a blocking round trip.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9
This commit is contained in:
Henrik RydgårdandClaude Opus 5 committed 2026-08-17 13:11:16 +02:00
1 parent 8858c8ec58
commit 14e8ba8486
1 file changed
+4 -1
+4 -1
View File
@@ -15,6 +15,7 @@
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include <atomic>
#include <algorithm>
#include <cmath>
#include <mutex>
@@ -41,7 +42,9 @@ typedef std::pair<FlipCallback, void *> FlipListener;
static std::vector<FlipListener> flipListeners;
static uint64_t frameStartTicks;
static int numVBlanks;
// Atomic because the WebSocket debugger reads it from its own thread (input.buttons.press uses
// it to count down frames) while the CPU thread bumps it.
static std::atomic<int> numVBlanks;
// hCount is computed now.
static int vCount;
// The "AccumulatedHcount" can be adjusted, this is the base.