upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/shims/gameinput.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/shims/gameinput.cpp')
-rw-r--r--runtime/shims/gameinput.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/runtime/shims/gameinput.cpp b/runtime/shims/gameinput.cpp
index 69707f75a..440337d61 100644
--- a/runtime/shims/gameinput.cpp
+++ b/runtime/shims/gameinput.cpp
@@ -763,6 +763,9 @@ public:
763 void sync(Device* device, uint64_t now, bool muted); 763 void sync(Device* device, uint64_t now, bool muted);
764 // Poll thread, on unplug: the SDL device went with the pad, so forget its effect id without touching SDL. 764 // Poll thread, on unplug: the SDL device went with the pad, so forget its effect id without touching SDL.
765 void orphan(); 765 void orphan();
766 // Poll thread, under g().mu: a reference unless the title's last Release already ran (the destructor then waits
767 // for g().mu to unlink the effect, so it is still in the device's list but must not be used or revived).
768 bool add_ref_if_live() { return rt::gameinput::add_ref_if_live(refs_); }
766 769
767private: 770private:
768 std::atomic<ULONG> refs_{1}; 771 std::atomic<ULONG> refs_{1};
@@ -1399,10 +1402,11 @@ void apply_effects(Device* d, uint64_t now) {
1399 { 1402 {
1400 std::lock_guard lock(s.mu); 1403 std::lock_guard lock(s.mu);
1401 live.reserve(d->effects.size()); 1404 live.reserve(d->effects.size());
1402 for (ForceFeedbackEffect* e : d->effects) { // referenced: the title may release one while this runs 1405 // Referenced: the title may release one while this runs. An effect whose count already reached 0 is being
1403 e->AddRef(); 1406 // destroyed (its destructor waits for this lock to unlink it); a plain AddRef revived it, and this loop's own
1404 live.push_back(e); 1407 // Release below freed it a second time.
1405 } 1408 for (ForceFeedbackEffect* e : d->effects)
1409 if (e->add_ref_if_live()) live.push_back(e);
1406 retire.swap(d->retired); 1410 retire.swap(d->retired);
1407 motor_gain = d->motor_gain; 1411 motor_gain = d->motor_gain;
1408 muted = !s.config.rumble; 1412 muted = !s.config.rumble;