diff options
Diffstat (limited to 'runtime/shims/gameinput.cpp')
| -rw-r--r-- | runtime/shims/gameinput.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/runtime/shims/gameinput.cpp b/runtime/shims/gameinput.cpp index e020d0728..896310ef0 100644 --- a/runtime/shims/gameinput.cpp +++ b/runtime/shims/gameinput.cpp | |||
| @@ -779,6 +779,9 @@ public: | |||
| 779 | void sync(Device* device, uint64_t now, bool muted); | 779 | void sync(Device* device, uint64_t now, bool muted); |
| 780 | // Poll thread, on unplug: the SDL device went with the pad, so forget its effect id without touching SDL. | 780 | // Poll thread, on unplug: the SDL device went with the pad, so forget its effect id without touching SDL. |
| 781 | void orphan(); | 781 | void orphan(); |
| 782 | // Poll thread, under g().mu: a reference unless the title's last Release already ran (the destructor then waits | ||
| 783 | // for g().mu to unlink the effect, so it is still in the device's list but must not be used or revived). | ||
| 784 | bool add_ref_if_live() { return rt::gameinput::add_ref_if_live(refs_); } | ||
| 782 | 785 | ||
| 783 | private: | 786 | private: |
| 784 | std::atomic<ULONG> refs_{1}; | 787 | std::atomic<ULONG> refs_{1}; |
| @@ -1490,10 +1493,11 @@ void apply_effects(Device* d, uint64_t now) { | |||
| 1490 | { | 1493 | { |
| 1491 | std::lock_guard lock(s.mu); | 1494 | std::lock_guard lock(s.mu); |
| 1492 | live.reserve(d->effects.size()); | 1495 | live.reserve(d->effects.size()); |
| 1493 | for (ForceFeedbackEffect* e : d->effects) { // referenced: the title may release one while this runs | 1496 | // Referenced: the title may release one while this runs. An effect whose count already reached 0 is being |
| 1494 | e->AddRef(); | 1497 | // destroyed (its destructor waits for this lock to unlink it); a plain AddRef revived it, and this loop's own |
| 1495 | live.push_back(e); | 1498 | // Release below freed it a second time. |
| 1496 | } | 1499 | for (ForceFeedbackEffect* e : d->effects) |
| 1500 | if (e->add_ref_if_live()) live.push_back(e); | ||
| 1497 | retire.swap(d->retired); | 1501 | retire.swap(d->retired); |
| 1498 | motor_gain = d->motor_gain; | 1502 | motor_gain = d->motor_gain; |
| 1499 | muted = !s.config.rumble; | 1503 | muted = !s.config.rumble; |