From 1f7bdb1b2a19444b5f9394f237a191cb6cd4dc6f Mon Sep 17 00:00:00 2001 From: loki-47-6F-64 Date: Mon, 27 Sep 2021 19:35:06 +0200 Subject: [PATCH] Fix segfault when multiple controllers connected --- sunshine/platform/linux/input.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sunshine/platform/linux/input.cpp b/sunshine/platform/linux/input.cpp index a0d18578..fbdc8133 100644 --- a/sunshine/platform/linux/input.cpp +++ b/sunshine/platform/linux/input.cpp @@ -696,7 +696,13 @@ public: }; inline void rumbleIterate(std::vector &effects, std::vector &polls, std::chrono::milliseconds to) { - auto res = poll(&polls.data()->el, polls.size(), to.count()); + std::vector polls_tmp; + polls_tmp.reserve(polls.size()); + for(auto &poll : polls) { + polls_tmp.emplace_back(poll.el); + } + + auto res = poll(polls_tmp.data(), polls.size(), to.count()); // If timed out if(!res) { @@ -871,7 +877,7 @@ void broadcastRumble(safe::queue_t &rumble_queue_queue) { } if(polls.empty()) { - std::this_thread::sleep_for(50ms); + std::this_thread::sleep_for(250ms); } else { rumbleIterate(effects, polls, 100ms);