Fixed bug 3561 - Re-acquire device before playing effects if needed.

Mathieu Laurendeau

Check the result of IDirectInputEffect_SetParameters and re-acquire the device to solve concurrency issues.
This commit is contained in:
Sam Lantinga 2017-01-18 11:58:16 -08:00
parent 5cb1ca551f
commit dd007e3fe7

View File

@ -1016,6 +1016,19 @@ SDL_DINPUT_HapticUpdateEffect(SDL_Haptic * haptic, struct haptic_effect *effect,
/* Create the actual effect. */ /* Create the actual effect. */
ret = ret =
IDirectInputEffect_SetParameters(effect->hweffect->ref, &temp, flags); IDirectInputEffect_SetParameters(effect->hweffect->ref, &temp, flags);
if (ret == DIERR_NOTEXCLUSIVEACQUIRED) {
IDirectInputDevice8_Unacquire(haptic->hwdata->device);
ret = IDirectInputDevice8_SetCooperativeLevel(haptic->hwdata->device, SDL_HelperWindow, DISCL_EXCLUSIVE | DISCL_BACKGROUND);
if (SUCCEEDED(ret)) {
ret = DIERR_NOTACQUIRED;
}
}
if (ret == DIERR_INPUTLOST || ret == DIERR_NOTACQUIRED) {
ret = IDirectInputDevice8_Acquire(haptic->hwdata->device);
if (SUCCEEDED(ret)) {
ret = IDirectInputEffect_SetParameters(effect->hweffect->ref, &temp, flags);
}
}
if (FAILED(ret)) { if (FAILED(ret)) {
DI_SetError("Unable to update effect", ret); DI_SetError("Unable to update effect", ret);
goto err_update; goto err_update;