winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
October 2021
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
2 participants
1165 discussions
Start a n
N
ew thread
Rémi Bernon : dinput: Call hid_joystick_enum_device directly in JoyConfig8Impl_GetConfig.
by Alexandre Julliard
26 Oct '21
26 Oct '21
Module: wine Branch: master Commit: bbff12381ed841dc84c982d9a830801b727e8d18 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=bbff12381ed841dc84c982d9…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Tue Oct 26 09:17:31 2021 +0200 dinput: Call hid_joystick_enum_device directly in JoyConfig8Impl_GetConfig. Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/dinput/dinput_main.c | 41 ++++++++++------------------------------- dlls/dinput/dinput_private.h | 11 ----------- dlls/dinput/joystick_hid.c | 7 ------- dlls/dinput/keyboard.c | 6 ------ dlls/dinput/mouse.c | 6 ------ 5 files changed, 10 insertions(+), 61 deletions(-) diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c index 745fdafa920..bc033a1baca 100644 --- a/dlls/dinput/dinput_main.c +++ b/dlls/dinput/dinput_main.c @@ -74,13 +74,6 @@ static inline IDirectInputDeviceImpl *impl_from_IDirectInputDevice8W(IDirectInpu return CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8W_iface); } -static const struct dinput_device *dinput_devices[] = -{ - &mouse_device, - &keyboard_device, - &joystick_hid_device, -}; - HINSTANCE DINPUT_instance; static HWND di_em_win; @@ -927,10 +920,11 @@ static HRESULT WINAPI JoyConfig8Impl_DeleteType(IDirectInputJoyConfig8 *iface, L static HRESULT WINAPI JoyConfig8Impl_GetConfig(IDirectInputJoyConfig8 *iface, UINT id, LPDIJOYCONFIG info, DWORD flags) { + DIDEVICEINSTANCEW instance = {.dwSize = sizeof(DIDEVICEINSTANCEW)}; IDirectInputImpl *di = impl_from_IDirectInputJoyConfig8(iface); + unsigned int i = 0; UINT found = 0; - int i, j; - HRESULT r; + HRESULT hr; FIXME("(%p)->(%d, %p, 0x%08x): semi-stub!\n", iface, id, info, flags); @@ -941,29 +935,14 @@ static HRESULT WINAPI JoyConfig8Impl_GetConfig(IDirectInputJoyConfig8 *iface, UI X(DIJC_CALLOUT) #undef X - /* Enumerate all joysticks in order */ - for (i = 0; i < ARRAY_SIZE(dinput_devices); i++) + do { - if (!dinput_devices[i]->enum_device) continue; - - for (j = 0, r = S_OK; SUCCEEDED(r); j++) - { - DIDEVICEINSTANCEW dev; - dev.dwSize = sizeof(dev); - if ((r = dinput_devices[i]->enum_device(DI8DEVCLASS_GAMECTRL, 0, &dev, di->dwVersion, j)) == S_OK) - { - /* Only take into account the chosen id */ - if (found == id) - { - if (flags & DIJC_GUIDINSTANCE) - info->guidInstance = dev.guidInstance; - - return DI_OK; - } - found += 1; - } - } - } + hr = hid_joystick_enum_device( DI8DEVCLASS_GAMECTRL, 0, &instance, di->dwVersion, i++ ); + if (hr != DI_OK) continue; + if (flags & DIJC_GUIDINSTANCE) info->guidInstance = instance.guidInstance; + /* Only take into account the chosen id */ + if (found++ == id) return DI_OK; + } while (SUCCEEDED(hr)); return DIERR_NOMOREITEMS; } diff --git a/dlls/dinput/dinput_private.h b/dlls/dinput/dinput_private.h index e9b40bb95b6..461af021a30 100644 --- a/dlls/dinput/dinput_private.h +++ b/dlls/dinput/dinput_private.h @@ -52,13 +52,6 @@ struct IDirectInputImpl extern const IDirectInput7AVtbl dinput7_a_vtbl DECLSPEC_HIDDEN; extern const IDirectInput8AVtbl dinput8_a_vtbl DECLSPEC_HIDDEN; -/* Function called by all devices that Wine supports */ -struct dinput_device { - const char *name; - HRESULT (*enum_device)(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id); - HRESULT (*create_device)(IDirectInputImpl *dinput, REFGUID rguid, IDirectInputDevice8W **out); -}; - extern HRESULT mouse_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *instance, DWORD version, int index ); extern HRESULT mouse_create_device( IDirectInputImpl *dinput, const GUID *guid, IDirectInputDevice8W **out ); extern HRESULT keyboard_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *instance, DWORD version, int index ); @@ -72,10 +65,6 @@ struct DevicePlayer { struct list entry; }; -extern const struct dinput_device mouse_device DECLSPEC_HIDDEN; -extern const struct dinput_device keyboard_device DECLSPEC_HIDDEN; -extern const struct dinput_device joystick_hid_device DECLSPEC_HIDDEN; - extern void dinput_hooks_acquire_device(LPDIRECTINPUTDEVICE8W iface); extern void dinput_hooks_unacquire_device(LPDIRECTINPUTDEVICE8W iface); extern int dinput_mouse_hook( IDirectInputDevice8W *iface, WPARAM wparam, LPARAM lparam ); diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 3419fed7d79..4632109a35b 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -1867,13 +1867,6 @@ failed: return hr; } -const struct dinput_device joystick_hid_device = -{ - "Wine HID joystick driver", - hid_joystick_enum_device, - hid_joystick_create_device, -}; - static HRESULT WINAPI hid_joystick_effect_QueryInterface( IDirectInputEffect *iface, REFIID iid, void **out ) { TRACE( "iface %p, iid %s, out %p\n", iface, debugstr_guid( iid ), out ); diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c index 3b8f52b38f2..a6032cbd0a4 100644 --- a/dlls/dinput/keyboard.c +++ b/dlls/dinput/keyboard.c @@ -204,12 +204,6 @@ HRESULT keyboard_create_device( IDirectInputImpl *dinput, const GUID *guid, IDir return DI_OK; } -const struct dinput_device keyboard_device = { - "Wine keyboard driver", - keyboard_enum_device, - keyboard_create_device -}; - static HRESULT keyboard_poll( IDirectInputDevice8W *iface ) { check_dinput_events(); diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c index 325d38c90d3..84b5410bb36 100644 --- a/dlls/dinput/mouse.c +++ b/dlls/dinput/mouse.c @@ -153,12 +153,6 @@ HRESULT mouse_create_device( IDirectInputImpl *dinput, const GUID *guid, IDirect return DI_OK; } -const struct dinput_device mouse_device = { - "Wine mouse driver", - mouse_enum_device, - mouse_create_device -}; - /****************************************************************************** * SysMouseA (DInput Mouse support) */
1
0
0
0
Rémi Bernon : dinput: Call hid_joystick_enum_device directly in EnumDevicesBySemantics.
by Alexandre Julliard
26 Oct '21
26 Oct '21
Module: wine Branch: master Commit: 5726c77faa5962504632f1e19813588dedcfc692 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=5726c77faa5962504632f1e1…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Tue Oct 26 09:17:30 2021 +0200 dinput: Call hid_joystick_enum_device directly in EnumDevicesBySemantics. Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/dinput/dinput_main.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c index ffa78be2fb5..745fdafa920 100644 --- a/dlls/dinput/dinput_main.c +++ b/dlls/dinput/dinput_main.c @@ -762,7 +762,8 @@ static HRESULT WINAPI IDirectInput8WImpl_EnumDevicesBySemantics( DIDEVICEINSTANCEW didevi; LPDIRECTINPUTDEVICE8W lpdid; DWORD callbackFlags; - int i, j; + unsigned int i = 0; + HRESULT hr; int device_count = 0; int remain; DIDEVICEINSTANCEW *didevis = 0; @@ -772,28 +773,17 @@ static HRESULT WINAPI IDirectInput8WImpl_EnumDevicesBySemantics( didevi.dwSize = sizeof(didevi); - /* Enumerate all the joysticks */ - for (i = 0; i < ARRAY_SIZE(dinput_devices); i++) + do { - HRESULT enumSuccess; - - if (!dinput_devices[i]->enum_device) continue; - - for (j = 0, enumSuccess = S_OK; SUCCEEDED(enumSuccess); j++) + hr = hid_joystick_enum_device( DI8DEVCLASS_GAMECTRL, DIEDFL_ATTACHEDONLY | dwFlags, &didevi, This->dwVersion, i++ ); + if (hr != DI_OK) continue; + if (should_enumerate_device( ptszUserName, dwFlags, &This->device_players, &didevi.guidInstance )) { - TRACE(" - checking device %u ('%s')\n", i, dinput_devices[i]->name); - - /* Default behavior is to enumerate attached game controllers */ - enumSuccess = dinput_devices[i]->enum_device(DI8DEVCLASS_GAMECTRL, DIEDFL_ATTACHEDONLY | dwFlags, &didevi, This->dwVersion, j); - if (enumSuccess == S_OK && - should_enumerate_device(ptszUserName, dwFlags, &This->device_players, &didevi.guidInstance)) - { - device_count++; - didevis = realloc( didevis, sizeof(DIDEVICEINSTANCEW) * device_count ); - didevis[device_count-1] = didevi; - } + device_count++; + didevis = realloc( didevis, sizeof(DIDEVICEINSTANCEW) * device_count ); + didevis[device_count - 1] = didevi; } - } + } while (SUCCEEDED(hr)); remain = device_count; /* Add keyboard and mouse to remaining device count */
1
0
0
0
Rémi Bernon : dinput: Call *_create_device directly in IDirectInput7WImpl_CreateDeviceEx.
by Alexandre Julliard
26 Oct '21
26 Oct '21
Module: wine Branch: master Commit: a83e6db3531012c60c6d8f72193e7661666b2b57 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=a83e6db3531012c60c6d8f72…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Tue Oct 26 09:17:29 2021 +0200 dinput: Call *_create_device directly in IDirectInput7WImpl_CreateDeviceEx. Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/dinput/dinput_main.c | 21 +++++++-------------- dlls/dinput/dinput_private.h | 3 +++ dlls/dinput/joystick_hid.c | 2 +- dlls/dinput/keyboard.c | 2 +- dlls/dinput/mouse.c | 2 +- 5 files changed, 13 insertions(+), 17 deletions(-) diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c index bee919cebff..ffa78be2fb5 100644 --- a/dlls/dinput/dinput_main.c +++ b/dlls/dinput/dinput_main.c @@ -610,7 +610,6 @@ static HRESULT WINAPI IDirectInput7WImpl_CreateDeviceEx( IDirectInput7W *iface, { IDirectInputImpl *impl = impl_from_IDirectInput7W( iface ); IDirectInputDevice8W *device; - unsigned int i; HRESULT hr; TRACE( "iface %p, guid %s, iid %s, out %p, outer %p\n", iface, debugstr_guid( guid ), @@ -622,20 +621,14 @@ static HRESULT WINAPI IDirectInput7WImpl_CreateDeviceEx( IDirectInput7W *iface, if (!guid) return E_POINTER; if (!impl->initialized) return DIERR_NOTINITIALIZED; - /* Loop on all the devices to see if anyone matches the given GUID */ - for (i = 0; i < ARRAY_SIZE(dinput_devices); i++) - { - if (!dinput_devices[i]->create_device) continue; - if (SUCCEEDED(hr = dinput_devices[i]->create_device( impl, guid, &device ))) - { - hr = IDirectInputDevice8_QueryInterface( device, iid, out ); - IDirectInputDevice8_Release( device ); - return hr; - } - } + if (IsEqualGUID( &GUID_SysKeyboard, guid )) hr = keyboard_create_device( impl, guid, &device ); + else if (IsEqualGUID( &GUID_SysMouse, guid )) hr = mouse_create_device( impl, guid, &device ); + else hr = hid_joystick_create_device( impl, guid, &device ); - WARN( "invalid device GUID %s\n", debugstr_guid( guid ) ); - return DIERR_DEVICENOTREG; + if (FAILED(hr)) return hr; + hr = IDirectInputDevice8_QueryInterface( device, iid, out ); + IDirectInputDevice8_Release( device ); + return hr; } static HRESULT WINAPI IDirectInputWImpl_CreateDevice(LPDIRECTINPUT7W iface, REFGUID rguid, diff --git a/dlls/dinput/dinput_private.h b/dlls/dinput/dinput_private.h index 553906e705d..e9b40bb95b6 100644 --- a/dlls/dinput/dinput_private.h +++ b/dlls/dinput/dinput_private.h @@ -60,8 +60,11 @@ struct dinput_device { }; extern HRESULT mouse_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *instance, DWORD version, int index ); +extern HRESULT mouse_create_device( IDirectInputImpl *dinput, const GUID *guid, IDirectInputDevice8W **out ); extern HRESULT keyboard_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *instance, DWORD version, int index ); +extern HRESULT keyboard_create_device( IDirectInputImpl *dinput, const GUID *guid, IDirectInputDevice8W **out ); extern HRESULT hid_joystick_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *instance, DWORD version, int index ); +extern HRESULT hid_joystick_create_device( IDirectInputImpl *dinput, const GUID *guid, IDirectInputDevice8W **out ); struct DevicePlayer { GUID instance_guid; diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 8ce55e67ef2..3419fed7d79 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -1737,7 +1737,7 @@ static BOOL init_pid_caps( struct hid_joystick *impl, struct hid_value_caps *cap return DIENUM_CONTINUE; } -static HRESULT hid_joystick_create_device( IDirectInputImpl *dinput, const GUID *guid, IDirectInputDevice8W **out ) +HRESULT hid_joystick_create_device( IDirectInputImpl *dinput, const GUID *guid, IDirectInputDevice8W **out ) { static const DIPROPHEADER filter = { diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c index 4a3deb161f1..3b8f52b38f2 100644 --- a/dlls/dinput/keyboard.c +++ b/dlls/dinput/keyboard.c @@ -174,7 +174,7 @@ HRESULT keyboard_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *instan return DI_OK; } -static HRESULT keyboard_create_device( IDirectInputImpl *dinput, const GUID *guid, IDirectInputDevice8W **out ) +HRESULT keyboard_create_device( IDirectInputImpl *dinput, const GUID *guid, IDirectInputDevice8W **out ) { SysKeyboardImpl *impl; HRESULT hr; diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c index b120966717e..325d38c90d3 100644 --- a/dlls/dinput/mouse.c +++ b/dlls/dinput/mouse.c @@ -104,7 +104,7 @@ HRESULT mouse_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *instance, return DI_OK; } -static HRESULT mouse_create_device( IDirectInputImpl *dinput, const GUID *guid, IDirectInputDevice8W **out ) +HRESULT mouse_create_device( IDirectInputImpl *dinput, const GUID *guid, IDirectInputDevice8W **out ) { SysMouseImpl *impl; HKEY hkey, appkey;
1
0
0
0
Rémi Bernon : dinput: Canonicalize code style of IDirectInput7WImpl_CreateDeviceEx.
by Alexandre Julliard
26 Oct '21
26 Oct '21
Module: wine Branch: master Commit: 8932f5394714c4552cba55329d09fbf29ae61942 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=8932f5394714c4552cba5532…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Tue Oct 26 09:17:28 2021 +0200 dinput: Canonicalize code style of IDirectInput7WImpl_CreateDeviceEx. Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/dinput/dinput_main.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c index 27fd7fa7364..bee919cebff 100644 --- a/dlls/dinput/dinput_main.c +++ b/dlls/dinput/dinput_main.c @@ -605,38 +605,36 @@ static HRESULT WINAPI IDirectInput2WImpl_FindDevice(LPDIRECTINPUT7W iface, REFGU return DI_OK; } -static HRESULT WINAPI IDirectInput7WImpl_CreateDeviceEx( IDirectInput7W *iface, REFGUID rguid, REFIID riid, - LPVOID *pvOut, LPUNKNOWN lpUnknownOuter ) +static HRESULT WINAPI IDirectInput7WImpl_CreateDeviceEx( IDirectInput7W *iface, const GUID *guid, + const GUID *iid, void **out, IUnknown *outer ) { + IDirectInputImpl *impl = impl_from_IDirectInput7W( iface ); IDirectInputDevice8W *device; - IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); unsigned int i; HRESULT hr; - TRACE( "(%p)->(%s, %s, %p, %p)\n", This, debugstr_guid( rguid ), debugstr_guid( riid ), pvOut, lpUnknownOuter ); - - if (pvOut) - *pvOut = NULL; + TRACE( "iface %p, guid %s, iid %s, out %p, outer %p\n", iface, debugstr_guid( guid ), + debugstr_guid( iid ), out, outer ); - if (!rguid || !pvOut) - return E_POINTER; + if (!out) return E_POINTER; + *out = NULL; - if (!This->initialized) - return DIERR_NOTINITIALIZED; + if (!guid) return E_POINTER; + if (!impl->initialized) return DIERR_NOTINITIALIZED; /* Loop on all the devices to see if anyone matches the given GUID */ for (i = 0; i < ARRAY_SIZE(dinput_devices); i++) { if (!dinput_devices[i]->create_device) continue; - if (SUCCEEDED(hr = dinput_devices[i]->create_device( This, rguid, &device ))) + if (SUCCEEDED(hr = dinput_devices[i]->create_device( impl, guid, &device ))) { - hr = IDirectInputDevice8_QueryInterface( device, riid, pvOut ); + hr = IDirectInputDevice8_QueryInterface( device, iid, out ); IDirectInputDevice8_Release( device ); return hr; } } - WARN("invalid device GUID %s\n", debugstr_guid(rguid)); + WARN( "invalid device GUID %s\n", debugstr_guid( guid ) ); return DIERR_DEVICENOTREG; }
1
0
0
0
Rémi Bernon : dinput: Call *_enum_device directly in IDirectInputWImpl_EnumDevices.
by Alexandre Julliard
26 Oct '21
26 Oct '21
Module: wine Branch: master Commit: 591be9d45690fb2e7dbd84747c522a6ecb73d867 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=591be9d45690fb2e7dbd8474…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Tue Oct 26 09:17:27 2021 +0200 dinput: Call *_enum_device directly in IDirectInputWImpl_EnumDevices. Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/dinput/dinput_main.c | 25 ++++++++++++++----------- dlls/dinput/dinput_private.h | 4 ++++ dlls/dinput/joystick_hid.c | 3 +-- dlls/dinput/keyboard.c | 2 +- dlls/dinput/mouse.c | 2 +- 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c index da790bae36c..27fd7fa7364 100644 --- a/dlls/dinput/dinput_main.c +++ b/dlls/dinput/dinput_main.c @@ -324,7 +324,7 @@ static HRESULT WINAPI IDirectInputWImpl_EnumDevices( IDirectInput7W *iface, DWOR { DIDEVICEINSTANCEW instance = {.dwSize = sizeof(DIDEVICEINSTANCEW)}; IDirectInputImpl *impl = impl_from_IDirectInput7W( iface ); - unsigned int i, j; + unsigned int i = 0; HRESULT hr; TRACE( "iface %p, type %#x, callback %p, context %p, flags %#x\n", iface, type, callback, context, flags ); @@ -339,19 +339,22 @@ static HRESULT WINAPI IDirectInputWImpl_EnumDevices( IDirectInput7W *iface, DWOR if (!impl->initialized) return DIERR_NOTINITIALIZED; - for (i = 0; i < ARRAY_SIZE(dinput_devices); i++) + hr = mouse_enum_device( type, flags, &instance, impl->dwVersion, 0 ); + if (hr == DI_OK && enum_callback_wrapper( callback, &instance, context ) == DIENUM_STOP) + return DI_OK; + hr = keyboard_enum_device( type, flags, &instance, impl->dwVersion, 0 ); + if (hr == DI_OK && enum_callback_wrapper( callback, &instance, context ) == DIENUM_STOP) + return DI_OK; + + do { - if (!dinput_devices[i]->enum_device) continue; - for (j = 0, hr = S_OK; SUCCEEDED(hr); j++) - { - TRACE(" - checking device %u ('%s')\n", i, dinput_devices[i]->name); - hr = dinput_devices[i]->enum_device( type, flags, &instance, impl->dwVersion, j ); - if (hr != S_OK) continue; - if (enum_callback_wrapper( callback, &instance, context ) == DIENUM_STOP) return S_OK; - } + hr = hid_joystick_enum_device( type, flags, &instance, impl->dwVersion, i++ ); + if (hr == DI_OK && enum_callback_wrapper( callback, &instance, context ) == DIENUM_STOP) + return DI_OK; } + while (SUCCEEDED(hr)); - return S_OK; + return DI_OK; } static ULONG WINAPI IDirectInputWImpl_AddRef( IDirectInput7W *iface ) diff --git a/dlls/dinput/dinput_private.h b/dlls/dinput/dinput_private.h index 949e84957d0..553906e705d 100644 --- a/dlls/dinput/dinput_private.h +++ b/dlls/dinput/dinput_private.h @@ -59,6 +59,10 @@ struct dinput_device { HRESULT (*create_device)(IDirectInputImpl *dinput, REFGUID rguid, IDirectInputDevice8W **out); }; +extern HRESULT mouse_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *instance, DWORD version, int index ); +extern HRESULT keyboard_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *instance, DWORD version, int index ); +extern HRESULT hid_joystick_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *instance, DWORD version, int index ); + struct DevicePlayer { GUID instance_guid; WCHAR username[MAX_PATH]; diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 2bd527e7000..8ce55e67ef2 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -1450,8 +1450,7 @@ static HRESULT hid_joystick_device_open( int index, DIDEVICEINSTANCEW *filter, W return DI_OK; } -static HRESULT hid_joystick_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *instance, - DWORD version, int index ) +HRESULT hid_joystick_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *instance, DWORD version, int index ) { HIDD_ATTRIBUTES attrs = {.Size = sizeof(attrs)}; PHIDP_PREPARSED_DATA preparsed; diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c index 35e55be4f4b..4a3deb161f1 100644 --- a/dlls/dinput/keyboard.c +++ b/dlls/dinput/keyboard.c @@ -144,7 +144,7 @@ static DWORD get_keyboard_subtype(void) return dev_subtype; } -static HRESULT keyboard_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *instance, DWORD version, int index ) +HRESULT keyboard_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *instance, DWORD version, int index ) { BYTE subtype = get_keyboard_subtype(); DWORD size; diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c index d871722e0a9..b120966717e 100644 --- a/dlls/dinput/mouse.c +++ b/dlls/dinput/mouse.c @@ -75,7 +75,7 @@ static inline SysMouseImpl *impl_from_IDirectInputDevice8W(IDirectInputDevice8W return CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8W_iface), SysMouseImpl, base); } -static HRESULT mouse_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *instance, DWORD version, int index ) +HRESULT mouse_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *instance, DWORD version, int index ) { DWORD size;
1
0
0
0
Rémi Bernon : dinput: Canonicalize code style of IDirectInputWImpl_EnumDevices.
by Alexandre Julliard
26 Oct '21
26 Oct '21
Module: wine Branch: master Commit: 8c257d0ca87d713214405a387be424751bc5cb53 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=8c257d0ca87d713214405a38…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Tue Oct 26 09:17:26 2021 +0200 dinput: Canonicalize code style of IDirectInputWImpl_EnumDevices. Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/dinput/dinput_main.c | 95 ++++++++++------------------------------------- 1 file changed, 20 insertions(+), 75 deletions(-) diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c index 985dae1ab36..da790bae36c 100644 --- a/dlls/dinput/dinput_main.c +++ b/dlls/dinput/dinput_main.c @@ -270,58 +270,6 @@ HRESULT WINAPI DECLSPEC_HOTPATCH DirectInputCreateW(HINSTANCE hinst, DWORD dwVer return DirectInputCreateEx(hinst, dwVersion, &IID_IDirectInput7W, (LPVOID *)ppDI, punkOuter); } -static const char *_dump_DIDEVTYPE_value(DWORD dwDevType, DWORD dwVersion) -{ - if (dwVersion < 0x0800) { - switch (dwDevType) { - case 0: return "All devices"; - case DIDEVTYPE_MOUSE: return "DIDEVTYPE_MOUSE"; - case DIDEVTYPE_KEYBOARD: return "DIDEVTYPE_KEYBOARD"; - case DIDEVTYPE_JOYSTICK: return "DIDEVTYPE_JOYSTICK"; - case DIDEVTYPE_DEVICE: return "DIDEVTYPE_DEVICE"; - default: return "Unknown"; - } - } else { - switch (dwDevType) { - case DI8DEVCLASS_ALL: return "All devices"; - case DI8DEVCLASS_POINTER: return "DI8DEVCLASS_POINTER"; - case DI8DEVCLASS_KEYBOARD: return "DI8DEVCLASS_KEYBOARD"; - case DI8DEVCLASS_DEVICE: return "DI8DEVCLASS_DEVICE"; - case DI8DEVCLASS_GAMECTRL: return "DI8DEVCLASS_GAMECTRL"; - default: return "Unknown"; - } - } -} - -static void _dump_EnumDevices_dwFlags(DWORD dwFlags) -{ - if (TRACE_ON(dinput)) { - unsigned int i; - static const struct { - DWORD mask; - const char *name; - } flags[] = { -#define FE(x) { x, #x} - FE(DIEDFL_ALLDEVICES), - FE(DIEDFL_ATTACHEDONLY), - FE(DIEDFL_FORCEFEEDBACK), - FE(DIEDFL_INCLUDEALIASES), - FE(DIEDFL_INCLUDEPHANTOMS), - FE(DIEDFL_INCLUDEHIDDEN) -#undef FE - }; - TRACE(" flags: "); - if (dwFlags == 0) { - TRACE("DIEDFL_ALLDEVICES\n"); - return; - } - for (i = 0; i < ARRAY_SIZE(flags); i++) - if (flags[i].mask & dwFlags) - TRACE("%s ",flags[i].name); - } - TRACE("\n"); -} - static DWORD diactionformat_priorityW(LPDIACTIONFORMATW lpdiaf, DWORD genre) { int i; @@ -371,38 +319,35 @@ __ASM_GLOBAL_FUNC( enum_callback_wrapper, /****************************************************************************** * IDirectInputW_EnumDevices */ -static HRESULT WINAPI IDirectInputWImpl_EnumDevices( - LPDIRECTINPUT7W iface, DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback, - LPVOID pvRef, DWORD dwFlags) +static HRESULT WINAPI IDirectInputWImpl_EnumDevices( IDirectInput7W *iface, DWORD type, LPDIENUMDEVICESCALLBACKW callback, + void *context, DWORD flags ) { - IDirectInputImpl *This = impl_from_IDirectInput7W( iface ); - DIDEVICEINSTANCEW devInstance; - unsigned int i; - int j; - HRESULT r; + DIDEVICEINSTANCEW instance = {.dwSize = sizeof(DIDEVICEINSTANCEW)}; + IDirectInputImpl *impl = impl_from_IDirectInput7W( iface ); + unsigned int i, j; + HRESULT hr; - TRACE("(this=%p,0x%04x '%s',%p,%p,0x%04x)\n", - This, dwDevType, _dump_DIDEVTYPE_value(dwDevType, This->dwVersion), - lpCallback, pvRef, dwFlags); - _dump_EnumDevices_dwFlags(dwFlags); + TRACE( "iface %p, type %#x, callback %p, context %p, flags %#x\n", iface, type, callback, context, flags ); - if (!lpCallback || - dwFlags & ~(DIEDFL_ATTACHEDONLY | DIEDFL_FORCEFEEDBACK | DIEDFL_INCLUDEALIASES | DIEDFL_INCLUDEPHANTOMS | DIEDFL_INCLUDEHIDDEN) || - (dwDevType > DI8DEVCLASS_GAMECTRL && dwDevType < DI8DEVTYPE_DEVICE) || dwDevType > DI8DEVTYPE_SUPPLEMENTAL) + if (!callback) return DIERR_INVALIDPARAM; + + if ((type > DI8DEVCLASS_GAMECTRL && type < DI8DEVTYPE_DEVICE) || type > DI8DEVTYPE_SUPPLEMENTAL) + return DIERR_INVALIDPARAM; + if (flags & ~(DIEDFL_ATTACHEDONLY|DIEDFL_FORCEFEEDBACK|DIEDFL_INCLUDEALIASES|DIEDFL_INCLUDEPHANTOMS|DIEDFL_INCLUDEHIDDEN)) return DIERR_INVALIDPARAM; - if (!This->initialized) + if (!impl->initialized) return DIERR_NOTINITIALIZED; - for (i = 0; i < ARRAY_SIZE(dinput_devices); i++) { + for (i = 0; i < ARRAY_SIZE(dinput_devices); i++) + { if (!dinput_devices[i]->enum_device) continue; - for (j = 0, r = S_OK; SUCCEEDED(r); j++) { - devInstance.dwSize = sizeof(devInstance); + for (j = 0, hr = S_OK; SUCCEEDED(hr); j++) + { TRACE(" - checking device %u ('%s')\n", i, dinput_devices[i]->name); - r = dinput_devices[i]->enum_device(dwDevType, dwFlags, &devInstance, This->dwVersion, j); - if (r == S_OK) - if (enum_callback_wrapper(lpCallback, &devInstance, pvRef) == DIENUM_STOP) - return S_OK; + hr = dinput_devices[i]->enum_device( type, flags, &instance, impl->dwVersion, j ); + if (hr != S_OK) continue; + if (enum_callback_wrapper( callback, &instance, context ) == DIENUM_STOP) return S_OK; } }
1
0
0
0
Rémi Bernon : dinput8/tests: Relax test results for 3 buttons mouse.
by Alexandre Julliard
26 Oct '21
26 Oct '21
Module: wine Branch: master Commit: 2c95bb37047c5ebd3ac0591b8463184add47524a URL:
https://source.winehq.org/git/wine.git/?a=commit;h=2c95bb37047c5ebd3ac0591b…
Author: Rémi Bernon <rbernon(a)codeweavers.com> Date: Tue Oct 26 09:15:34 2021 +0200 dinput8/tests: Relax test results for 3 buttons mouse. Wine-Bug:
https://bugs.winehq.org/show_bug.cgi?id=51913
Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/dinput8/tests/device.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dlls/dinput8/tests/device.c b/dlls/dinput8/tests/device.c index 4492170673e..3cad4ce256c 100644 --- a/dlls/dinput8/tests/device.c +++ b/dlls/dinput8/tests/device.c @@ -1278,7 +1278,7 @@ static void test_mouse_info(void) todo_wine check_member( caps, expect_caps, "%#x", dwDevType ); check_member( caps, expect_caps, "%d", dwAxes ); - check_member( caps, expect_caps, "%d", dwButtons ); + ok( caps.dwButtons == 3 || caps.dwButtons == 5, "got dwButtons %d, expected 3 or 5\n", caps.dwButtons ); check_member( caps, expect_caps, "%d", dwPOVs ); check_member( caps, expect_caps, "%d", dwFFSamplePeriod ); check_member( caps, expect_caps, "%d", dwFFMinTimeResolution ); @@ -1384,7 +1384,8 @@ static void test_mouse_info(void) res = 0; hr = IDirectInputDevice8_EnumObjects( device, check_object_count, &res, DIDFT_AXIS | DIDFT_PSHBUTTON ); ok( hr == DI_OK, "EnumObjects returned %#x\n", hr ); - ok( res == 8, "got %u expected %u\n", res, 8 ); + ok( res == 3 + caps.dwButtons, "got %u expected %u\n", res, 3 + caps.dwButtons ); + check_objects_params.expect_count = 3 + caps.dwButtons; hr = IDirectInputDevice8_EnumObjects( device, check_objects, &check_objects_params, DIDFT_ALL ); ok( hr == DI_OK, "EnumObjects returned %#x\n", hr ); ok( check_objects_params.index >= check_objects_params.expect_count, "missing %u objects\n",
1
0
0
0
Huw Davies : wmc: Remove struct and enum typedefs.
by Alexandre Julliard
26 Oct '21
26 Oct '21
Module: wine Branch: master Commit: be59553410bf41acd193640f96891174ffb42c85 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=be59553410bf41acd193640f…
Author: Huw Davies <huw(a)codeweavers.com> Date: Tue Oct 26 08:17:08 2021 +0100 wmc: Remove struct and enum typedefs. This has the side effect of fixing the build on macOS after commit 2c1b8153630. Signed-off-by: Huw Davies <huw(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- tools/wmc/lang.c | 8 ++-- tools/wmc/lang.h | 6 +-- tools/wmc/mcl.c | 16 ++++---- tools/wmc/mcy.y | 103 +++++++++++++++++++++++++-------------------------- tools/wmc/po.c | 20 +++++----- tools/wmc/wmc.h | 10 ++--- tools/wmc/wmctypes.h | 52 +++++++++++++------------- tools/wmc/write.c | 24 ++++++------ 8 files changed, 119 insertions(+), 120 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=be59553410bf41acd193…
1
0
0
0
Zebediah Figura : winegstreamer: Implement IWMProfile::GetStreamCount().
by Alexandre Julliard
26 Oct '21
26 Oct '21
Module: wine Branch: master Commit: 87e4c289e46701c6f582e95c330eefb6fc5ec68a URL:
https://source.winehq.org/git/wine.git/?a=commit;h=87e4c289e46701c6f582e95c…
Author: Zebediah Figura <zfigura(a)codeweavers.com> Date: Mon Oct 25 18:52:13 2021 -0500 winegstreamer: Implement IWMProfile::GetStreamCount(). Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winegstreamer/gst_private.h | 2 ++ dlls/winegstreamer/wm_reader.c | 10 ++++++++-- dlls/wmvcore/tests/wmvcore.c | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h index caa449956bf..86ddc3c85c8 100644 --- a/dlls/winegstreamer/gst_private.h +++ b/dlls/winegstreamer/gst_private.h @@ -129,6 +129,8 @@ struct wm_reader bool read_thread_shutdown; struct wg_parser *wg_parser; + WORD stream_count; + const struct wm_reader_ops *ops; }; diff --git a/dlls/winegstreamer/wm_reader.c b/dlls/winegstreamer/wm_reader.c index 163eebf8c55..689d2232b73 100644 --- a/dlls/winegstreamer/wm_reader.c +++ b/dlls/winegstreamer/wm_reader.c @@ -188,12 +188,16 @@ static HRESULT WINAPI profile_SetDescription(IWMProfile3 *iface, const WCHAR *de static HRESULT WINAPI profile_GetStreamCount(IWMProfile3 *iface, DWORD *count) { - FIXME("iface %p, count %p, stub!\n", iface, count); + struct wm_reader *reader = impl_from_IWMProfile3(iface); + + TRACE("reader %p, count %p.\n", reader, count); if (!count) return E_INVALIDARG; - *count = 0; + EnterCriticalSection(&reader->cs); + *count = reader->stream_count; + LeaveCriticalSection(&reader->cs); return S_OK; } @@ -853,6 +857,8 @@ HRESULT wm_reader_open_stream(struct wm_reader *reader, IStream *stream) goto out_shutdown_thread; } + reader->stream_count = wg_parser_get_stream_count(reader->wg_parser); + LeaveCriticalSection(&reader->cs); return S_OK; diff --git a/dlls/wmvcore/tests/wmvcore.c b/dlls/wmvcore/tests/wmvcore.c index 61c3504e69c..ad58f53d552 100644 --- a/dlls/wmvcore/tests/wmvcore.c +++ b/dlls/wmvcore/tests/wmvcore.c @@ -459,7 +459,7 @@ static void test_sync_reader_streaming(void) count = 0xdeadbeef; hr = IWMProfile_GetStreamCount(profile, &count); ok(hr == S_OK, "Got hr %#x.\n", hr); - todo_wine ok(count == 2, "Got count %u.\n", count); + ok(count == 2, "Got count %u.\n", count); count = 0xdeadbeef; hr = IWMSyncReader_GetOutputCount(reader, &count);
1
0
0
0
Zebediah Figura : winegstreamer: Create a winegstreamer parser object in wm_reader_open_stream().
by Alexandre Julliard
26 Oct '21
26 Oct '21
Module: wine Branch: master Commit: 51b6d45503e5849f28cce1a9aa9b7d3dba9de0fe URL:
https://source.winehq.org/git/wine.git/?a=commit;h=51b6d45503e5849f28cce1a9…
Author: Zebediah Figura <zfigura(a)codeweavers.com> Date: Mon Oct 25 18:52:12 2021 -0500 winegstreamer: Create a winegstreamer parser object in wm_reader_open_stream(). Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winegstreamer/gst_private.h | 3 ++ dlls/winegstreamer/wm_reader.c | 113 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 115 insertions(+), 1 deletion(-) diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h index a07195a4a1e..caa449956bf 100644 --- a/dlls/winegstreamer/gst_private.h +++ b/dlls/winegstreamer/gst_private.h @@ -125,6 +125,9 @@ struct wm_reader CRITICAL_SECTION cs; IStream *source_stream; + HANDLE read_thread; + bool read_thread_shutdown; + struct wg_parser *wg_parser; const struct wm_reader_ops *ops; }; diff --git a/dlls/winegstreamer/wm_reader.c b/dlls/winegstreamer/wm_reader.c index e5c2d2a9789..163eebf8c55 100644 --- a/dlls/winegstreamer/wm_reader.c +++ b/dlls/winegstreamer/wm_reader.c @@ -20,6 +20,68 @@ WINE_DEFAULT_DEBUG_CHANNEL(wmvcore); +static DWORD CALLBACK read_thread(void *arg) +{ + struct wm_reader *reader = arg; + IStream *stream = reader->source_stream; + size_t buffer_size = 4096; + uint64_t file_size; + STATSTG stat; + void *data; + + if (!(data = malloc(buffer_size))) + return 0; + + IStream_Stat(stream, &stat, STATFLAG_NONAME); + file_size = stat.cbSize.QuadPart; + + TRACE("Starting read thread for reader %p.\n", reader); + + while (!reader->read_thread_shutdown) + { + LARGE_INTEGER stream_offset; + uint64_t offset; + ULONG ret_size; + uint32_t size; + HRESULT hr; + + if (!wg_parser_get_next_read_offset(reader->wg_parser, &offset, &size)) + continue; + + if (offset >= file_size) + size = 0; + else if (offset + size >= file_size) + size = file_size - offset; + + if (!size) + { + wg_parser_push_data(reader->wg_parser, data, 0); + continue; + } + + if (!array_reserve(&data, &buffer_size, size, 1)) + { + free(data); + return 0; + } + + ret_size = 0; + + stream_offset.QuadPart = offset; + if (SUCCEEDED(hr = IStream_Seek(stream, stream_offset, STREAM_SEEK_SET, NULL))) + hr = IStream_Read(stream, data, size, &ret_size); + if (FAILED(hr)) + ERR("Failed to read %u bytes at offset %I64u, hr %#x.\n", size, offset, hr); + else if (ret_size != size) + ERR("Unexpected short read: requested %u bytes, got %u.\n", size, ret_size); + wg_parser_push_data(reader->wg_parser, SUCCEEDED(hr) ? data : NULL, ret_size); + } + + free(data); + TRACE("Reader is shutting down; exiting.\n"); + return 0; +} + static struct wm_reader *impl_from_IWMProfile3(IWMProfile3 *iface) { return CONTAINING_RECORD(iface, struct wm_reader, IWMProfile3_iface); @@ -761,13 +823,53 @@ static const IWMReaderTimecodeVtbl timecode_vtbl = HRESULT wm_reader_open_stream(struct wm_reader *reader, IStream *stream) { + struct wg_parser *wg_parser; + STATSTG stat; + HRESULT hr; + + if (FAILED(hr = IStream_Stat(stream, &stat, STATFLAG_NONAME))) + { + ERR("Failed to stat stream, hr %#x.\n", hr); + return hr; + } + + if (!(wg_parser = wg_parser_create(WG_PARSER_DECODEBIN, false))) + return E_OUTOFMEMORY; + EnterCriticalSection(&reader->cs); + reader->wg_parser = wg_parser; IStream_AddRef(reader->source_stream = stream); + reader->read_thread_shutdown = false; + if (!(reader->read_thread = CreateThread(NULL, 0, read_thread, reader, 0, NULL))) + { + hr = E_OUTOFMEMORY; + goto out_destroy_parser; + } - LeaveCriticalSection(&reader->cs); + if (FAILED(hr = wg_parser_connect(reader->wg_parser, stat.cbSize.QuadPart))) + { + ERR("Failed to connect parser, hr %#x.\n", hr); + goto out_shutdown_thread; + } + LeaveCriticalSection(&reader->cs); return S_OK; + +out_shutdown_thread: + reader->read_thread_shutdown = true; + WaitForSingleObject(reader->read_thread, INFINITE); + CloseHandle(reader->read_thread); + reader->read_thread = NULL; + +out_destroy_parser: + wg_parser_destroy(reader->wg_parser); + reader->wg_parser = NULL; + IStream_Release(reader->source_stream); + reader->source_stream = NULL; + + LeaveCriticalSection(&reader->cs); + return hr; } HRESULT wm_reader_close(struct wm_reader *reader) @@ -780,6 +882,15 @@ HRESULT wm_reader_close(struct wm_reader *reader) return NS_E_INVALID_REQUEST; } + wg_parser_disconnect(reader->wg_parser); + + reader->read_thread_shutdown = true; + WaitForSingleObject(reader->read_thread, INFINITE); + CloseHandle(reader->read_thread); + reader->read_thread = NULL; + + wg_parser_destroy(reader->wg_parser); + reader->wg_parser = NULL; IStream_Release(reader->source_stream); reader->source_stream = NULL;
1
0
0
0
← Newer
1
...
15
16
17
18
19
20
21
...
117
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
Results per page:
10
25
50
100
200