[PATCH] joy.cpl: Fix high CPU load in FF test window

Tim Schumacher timschumi at gmx.de
Sat May 18 17:43:17 CDT 2019


If no effects are in the effects list, the loop in ff_input_thread
is immediately restarted, skipping the poll interval. This causes an
incredibly high refresh rate, which maxes out at least one CPU core.

Move the Sleep call to the top of the loop, so that it is always done,
no matter if there are effects listed or not.

Additionally, this fixes a race condition that crashes the program
when the thread is closed.

Signed-off-by: Tim Schumacher <timschumi at gmx.de>
---
 dlls/joy.cpl/main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/dlls/joy.cpl/main.c b/dlls/joy.cpl/main.c
index 32dfad0eb5..9768917641 100644
--- a/dlls/joy.cpl/main.c
+++ b/dlls/joy.cpl/main.c
@@ -677,6 +677,8 @@ static DWORD WINAPI ff_input_thread(void *param)
         DWORD flags = DIEP_AXES | DIEP_DIRECTION | DIEP_NORESTART;
         RECT r;

+        Sleep(TEST_POLL_TIME);
+
         /* Skip this if we have no effects */
         if (joy->num_effects == 0 || chosen_effect < 0) continue;

@@ -701,8 +703,6 @@ static DWORD WINAPI ff_input_thread(void *param)
                 IDirectInputEffect_Start(joy->effects[chosen_effect].effect, 1, 0);
                 break;
             }
-
-        Sleep(TEST_POLL_TIME);
     }

     return 0;
--
2.21.0




More information about the wine-devel mailing list