Commit c93813e1 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

dinput: Call device read_callback while holding the internal CS.

And remove the device from the list of acquired devices if the callback indicates a read error. Signed-off-by: 's avatarRémi Bernon <rbernon@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent bbb68aea
...@@ -1289,11 +1289,11 @@ static LRESULT CALLBACK callwndproc_proc( int code, WPARAM wparam, LPARAM lparam ...@@ -1289,11 +1289,11 @@ static LRESULT CALLBACK callwndproc_proc( int code, WPARAM wparam, LPARAM lparam
static DWORD WINAPI hook_thread_proc(void *param) static DWORD WINAPI hook_thread_proc(void *param)
{ {
static HHOOK kbd_hook, mouse_hook; static HHOOK kbd_hook, mouse_hook;
IDirectInputDeviceImpl *impl; IDirectInputDeviceImpl *impl, *next;
IDirectInputDevice8W *iface;
SIZE_T events_count = 0; SIZE_T events_count = 0;
HANDLE finished_event; HANDLE finished_event;
HANDLE events[128]; HANDLE events[128];
HRESULT hr;
DWORD ret; DWORD ret;
MSG msg; MSG msg;
...@@ -1310,24 +1310,17 @@ static DWORD WINAPI hook_thread_proc(void *param) ...@@ -1310,24 +1310,17 @@ static DWORD WINAPI hook_thread_proc(void *param)
if (ret < events_count) if (ret < events_count)
{ {
iface = NULL;
EnterCriticalSection( &dinput_hook_crit ); EnterCriticalSection( &dinput_hook_crit );
LIST_FOR_EACH_ENTRY( impl, &acquired_device_list, IDirectInputDeviceImpl, entry ) LIST_FOR_EACH_ENTRY_SAFE( impl, next, &acquired_device_list, IDirectInputDeviceImpl, entry )
{ {
if (impl->read_event == events[ret]) if (impl->read_event == events[ret])
{ {
iface = &impl->IDirectInputDevice8W_iface; hr = impl->read_callback( &impl->IDirectInputDevice8W_iface );
IDirectInputDevice8_AddRef( iface ); if (FAILED(hr)) list_remove( &impl->entry );
break; break;
} }
} }
LeaveCriticalSection( &dinput_hook_crit ); LeaveCriticalSection( &dinput_hook_crit );
if (iface)
{
impl->read_callback( iface );
IDirectInputDevice8_Release( iface );
}
} }
while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE ))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment