Commit 907b8eebc312ce395be14b797caa604e7ff76f01

Sam Lantinga 2021-01-14T23:49:16

Make sure the HIDAPI device is locked when closing it, in case there is rumble pending that didn't complete

1
2
3
4
5
6
7
8
9
10
11
12
13
14
diff --git a/src/joystick/hidapi/SDL_hidapijoystick.c b/src/joystick/hidapi/SDL_hidapijoystick.c
index 121913f..f3d5f39 100644
--- a/src/joystick/hidapi/SDL_hidapijoystick.c
+++ b/src/joystick/hidapi/SDL_hidapijoystick.c
@@ -1221,7 +1221,9 @@ HIDAPI_JoystickClose(SDL_Joystick * joystick)
             SDL_LockMutex(device->dev_lock);
         }
 
+        SDL_LockMutex(device->dev_lock);
         device->driver->CloseJoystick(device, joystick);
+        SDL_UnlockMutex(device->dev_lock);
 
         SDL_free(joystick->hwdata);
         joystick->hwdata = NULL;