@@ -48,63 +48,62 @@ auto Program::create() -> void {
48
48
auto Program::emulatorRunLoop (uintptr_t ) -> void {
49
49
thread::setName (" dev.ares.worker" );
50
50
while (!_quitting) {
51
- {
52
- lock_guard<recursive_mutex> lock (programMutex);
53
- if (!loaded || !emulator) {
54
- usleep (20 * 1000 );
55
- continue ;
56
- }
57
-
58
- if (emulator && nall::GDB::server.isHalted ()) {
59
- ruby::audio.clear ();
60
- nall::GDB::server.updateLoop (); // sleeps internally
61
- continue ;
62
- }
63
-
64
- bool defocused = driverSettings.inputDefocusPause .checked () && !ruby::video.fullScreen () && !presentation.focused ();
51
+ // Allow other threads to access the program mutex
52
+ usleep (1 );
53
+
54
+ lock_guard<recursive_mutex> lock (programMutex);
55
+ if (!loaded || !emulator) {
56
+ usleep (20 * 1000 );
57
+ continue ;
58
+ }
65
59
66
- if (!emulator || (paused && !program.requestFrameAdvance ) || defocused) {
67
- ruby::audio.clear ();
68
- nall::GDB::server.updateLoop ();
69
- usleep (20 * 1000 );
70
- continue ;
71
- }
60
+ if (emulator && nall::GDB::server.isHalted ()) {
61
+ ruby::audio.clear ();
62
+ nall::GDB::server.updateLoop (); // sleeps internally
63
+ continue ;
64
+ }
72
65
73
- rewindRun ();
66
+ bool defocused = driverSettings. inputDefocusPause . checked () && !ruby::video. fullScreen () && !presentation. focused ();
74
67
68
+ if (!emulator || (paused && !program.requestFrameAdvance ) || defocused) {
69
+ ruby::audio.clear ();
75
70
nall::GDB::server.updateLoop ();
71
+ usleep (20 * 1000 );
72
+ continue ;
73
+ }
76
74
77
- program.requestFrameAdvance = false ;
78
- if (!runAhead || fastForwarding || rewinding) {
79
- emulator->root ->run ();
80
- } else {
81
- ares::setRunAhead (true );
82
- emulator->root ->run ();
83
- auto state = emulator->root ->serialize (false );
84
- ares::setRunAhead (false );
85
- emulator->root ->run ();
86
- state.setReading ();
87
- emulator->root ->unserialize (state);
88
- }
75
+ rewindRun ();
76
+
77
+ nall::GDB::server.updateLoop ();
78
+
79
+ program.requestFrameAdvance = false ;
80
+ if (!runAhead || fastForwarding || rewinding) {
81
+ emulator->root ->run ();
82
+ } else {
83
+ ares::setRunAhead (true );
84
+ emulator->root ->run ();
85
+ auto state = emulator->root ->serialize (false );
86
+ ares::setRunAhead (false );
87
+ emulator->root ->run ();
88
+ state.setReading ();
89
+ emulator->root ->unserialize (state);
90
+ }
89
91
90
- nall::GDB::server.updateLoop ();
92
+ nall::GDB::server.updateLoop ();
91
93
92
- if (settings.general .autoSaveMemory ) {
93
- static u64 previousTime = chrono::timestamp ();
94
- u64 currentTime = chrono::timestamp ();
95
- if (currentTime - previousTime >= 30 ) {
96
- previousTime = currentTime;
97
- emulator->save ();
98
- }
94
+ if (settings.general .autoSaveMemory ) {
95
+ static u64 previousTime = chrono::timestamp ();
96
+ u64 currentTime = chrono::timestamp ();
97
+ if (currentTime - previousTime >= 30 ) {
98
+ previousTime = currentTime;
99
+ emulator->save ();
99
100
}
101
+ }
100
102
101
- if (emulator->latch .changed ) {
102
- emulator->latch .changed = false ;
103
- _needsResize = true ;
104
- }
103
+ if (emulator->latch .changed ) {
104
+ emulator->latch .changed = false ;
105
+ _needsResize = true ;
105
106
}
106
- // Allow other threads to access the program mutex
107
- usleep (1 );
108
107
}
109
108
}
110
109
0 commit comments