Rémi Bernon : windows.gaming.input: Use IUnknown invoker instead of IInspectable and add a parameter.
Alexandre Julliard
julliard at winehq.org
Thu May 5 15:56:02 CDT 2022
Module: wine
Branch: master
Commit: 7b3a669ee3978f854d468b119a23d6ea4d302272
URL: https://source.winehq.org/git/wine.git/?a=commit;h=7b3a669ee3978f854d468b119a23d6ea4d302272
Author: Rémi Bernon <rbernon at codeweavers.com>
Date: Fri Apr 29 11:59:37 2022 +0200
windows.gaming.input: Use IUnknown invoker instead of IInspectable and add a parameter.
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/windows.gaming.input/async.c | 18 +++++++++++-------
dlls/windows.gaming.input/force_feedback.c | 18 +++++++++---------
dlls/windows.gaming.input/private.h | 4 ++--
3 files changed, 22 insertions(+), 18 deletions(-)
diff --git a/dlls/windows.gaming.input/async.c b/dlls/windows.gaming.input/async.c
index f21e749cee6..1426b3d8481 100644
--- a/dlls/windows.gaming.input/async.c
+++ b/dlls/windows.gaming.input/async.c
@@ -37,7 +37,8 @@ struct async_info
async_operation_callback callback;
TP_WORK *async_run_work;
- IInspectable *invoker;
+ IUnknown *invoker;
+ IUnknown *param;
CRITICAL_SECTION cs;
IWineAsyncOperationCompletedHandler *handler;
@@ -95,7 +96,8 @@ static ULONG WINAPI async_impl_Release( IWineAsyncInfoImpl *iface )
{
if (impl->handler && impl->handler != HANDLER_NOT_SET) IWineAsyncOperationCompletedHandler_Release( impl->handler );
IAsyncInfo_Close( &impl->IAsyncInfo_iface );
- IInspectable_Release( impl->invoker );
+ if (impl->param) IUnknown_Release( impl->param );
+ if (impl->invoker) IUnknown_Release( impl->invoker );
DeleteCriticalSection( &impl->cs );
free( impl );
}
@@ -302,7 +304,7 @@ static void CALLBACK async_info_callback( TP_CALLBACK_INSTANCE *instance, void *
PROPVARIANT result;
HRESULT hr;
- hr = impl->callback( impl->invoker, &result );
+ hr = impl->callback( impl->invoker, impl->param, &result );
EnterCriticalSection( &impl->cs );
if (impl->status != Closed) impl->status = FAILED(hr) ? Error : Completed;
@@ -327,7 +329,7 @@ static void CALLBACK async_info_callback( TP_CALLBACK_INSTANCE *instance, void *
PropVariantClear( &result );
}
-static HRESULT async_info_create( IInspectable *invoker, async_operation_callback callback,
+static HRESULT async_info_create( IUnknown *invoker, IUnknown *param, async_operation_callback callback,
IInspectable *outer, IWineAsyncInfoImpl **out )
{
struct async_info *impl;
@@ -344,7 +346,9 @@ static HRESULT async_info_create( IInspectable *invoker, async_operation_callbac
if (!(impl->async_run_work = CreateThreadpoolWork( async_info_callback, &impl->IWineAsyncInfoImpl_iface, NULL )))
return HRESULT_FROM_WIN32( GetLastError() );
- IInspectable_AddRef( (impl->invoker = invoker) );
+ if ((impl->invoker = invoker)) IUnknown_AddRef( impl->invoker );
+ if ((impl->param = param)) IUnknown_AddRef( impl->param );
+
InitializeCriticalSection( &impl->cs );
impl->cs.DebugInfo->Spare[0] = (DWORD_PTR)( __FILE__ ": async_info.cs" );
@@ -473,7 +477,7 @@ static const struct IAsyncOperation_booleanVtbl async_bool_vtbl =
async_bool_GetResults,
};
-HRESULT async_operation_boolean_create( IInspectable *invoker, async_operation_callback callback,
+HRESULT async_operation_boolean_create( IUnknown *invoker, IUnknown *param, async_operation_callback callback,
IAsyncOperation_boolean **out )
{
struct async_bool *impl;
@@ -484,7 +488,7 @@ HRESULT async_operation_boolean_create( IInspectable *invoker, async_operation_c
impl->IAsyncOperation_boolean_iface.lpVtbl = &async_bool_vtbl;
impl->ref = 1;
- if (FAILED(hr = async_info_create( invoker, callback, (IInspectable *)&impl->IAsyncOperation_boolean_iface, &impl->IWineAsyncInfoImpl_inner )) ||
+ if (FAILED(hr = async_info_create( invoker, param, callback, (IInspectable *)&impl->IAsyncOperation_boolean_iface, &impl->IWineAsyncInfoImpl_inner )) ||
FAILED(hr = IWineAsyncInfoImpl_Start( impl->IWineAsyncInfoImpl_inner )))
{
if (impl->IWineAsyncInfoImpl_inner) IWineAsyncInfoImpl_Release( impl->IWineAsyncInfoImpl_inner );
diff --git a/dlls/windows.gaming.input/force_feedback.c b/dlls/windows.gaming.input/force_feedback.c
index 667c6d8d81b..3fdcc636bbd 100644
--- a/dlls/windows.gaming.input/force_feedback.c
+++ b/dlls/windows.gaming.input/force_feedback.c
@@ -212,9 +212,9 @@ static HRESULT WINAPI motor_StopAllEffects( IForceFeedbackMotor *iface )
return IDirectInputDevice8_SendForceFeedbackCommand( impl->device, DISFFC_STOPALL );
}
-static HRESULT WINAPI motor_try_disable_async( IInspectable *iface, PROPVARIANT *result )
+static HRESULT WINAPI motor_try_disable_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result )
{
- struct motor *impl = impl_from_IForceFeedbackMotor( (IForceFeedbackMotor *)iface );
+ struct motor *impl = impl_from_IForceFeedbackMotor( (IForceFeedbackMotor *)invoker );
HRESULT hr;
hr = IDirectInputDevice8_SendForceFeedbackCommand( impl->device, DISFFC_SETACTUATORSOFF );
@@ -227,12 +227,12 @@ static HRESULT WINAPI motor_try_disable_async( IInspectable *iface, PROPVARIANT
static HRESULT WINAPI motor_TryDisableAsync( IForceFeedbackMotor *iface, IAsyncOperation_boolean **async_op )
{
TRACE( "iface %p, async_op %p.\n", iface, async_op );
- return async_operation_boolean_create( (IInspectable *)iface, motor_try_disable_async, async_op );
+ return async_operation_boolean_create( (IUnknown *)iface, NULL, motor_try_disable_async, async_op );
}
-static HRESULT WINAPI motor_try_enable_async( IInspectable *iface, PROPVARIANT *result )
+static HRESULT WINAPI motor_try_enable_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result )
{
- struct motor *impl = impl_from_IForceFeedbackMotor( (IForceFeedbackMotor *)iface );
+ struct motor *impl = impl_from_IForceFeedbackMotor( (IForceFeedbackMotor *)invoker );
HRESULT hr;
hr = IDirectInputDevice8_SendForceFeedbackCommand( impl->device, DISFFC_SETACTUATORSON );
@@ -245,12 +245,12 @@ static HRESULT WINAPI motor_try_enable_async( IInspectable *iface, PROPVARIANT *
static HRESULT WINAPI motor_TryEnableAsync( IForceFeedbackMotor *iface, IAsyncOperation_boolean **async_op )
{
TRACE( "iface %p, async_op %p.\n", iface, async_op );
- return async_operation_boolean_create( (IInspectable *)iface, motor_try_enable_async, async_op );
+ return async_operation_boolean_create( (IUnknown *)iface, NULL, motor_try_enable_async, async_op );
}
-static HRESULT WINAPI motor_try_reset_async( IInspectable *iface, PROPVARIANT *result )
+static HRESULT WINAPI motor_try_reset_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result )
{
- struct motor *impl = impl_from_IForceFeedbackMotor( (IForceFeedbackMotor *)iface );
+ struct motor *impl = impl_from_IForceFeedbackMotor( (IForceFeedbackMotor *)invoker );
HRESULT hr;
hr = IDirectInputDevice8_SendForceFeedbackCommand( impl->device, DISFFC_RESET );
@@ -263,7 +263,7 @@ static HRESULT WINAPI motor_try_reset_async( IInspectable *iface, PROPVARIANT *r
static HRESULT WINAPI motor_TryResetAsync( IForceFeedbackMotor *iface, IAsyncOperation_boolean **async_op )
{
TRACE( "iface %p, async_op %p.\n", iface, async_op );
- return async_operation_boolean_create( (IInspectable *)iface, motor_try_reset_async, async_op );
+ return async_operation_boolean_create( (IUnknown *)iface, NULL, motor_try_reset_async, async_op );
}
static HRESULT WINAPI motor_TryUnloadEffectAsync( IForceFeedbackMotor *iface, IForceFeedbackEffect *effect,
diff --git a/dlls/windows.gaming.input/private.h b/dlls/windows.gaming.input/private.h
index 63c9c262f7a..68f6bdcf5b6 100644
--- a/dlls/windows.gaming.input/private.h
+++ b/dlls/windows.gaming.input/private.h
@@ -67,8 +67,8 @@ extern void event_handlers_notify( struct list *list, IInspectable *element );
extern HRESULT force_feedback_motor_create( IDirectInputDevice8W *device, IForceFeedbackMotor **out );
-typedef HRESULT (WINAPI *async_operation_callback)( IInspectable *invoker, PROPVARIANT *result );
-extern HRESULT async_operation_boolean_create( IInspectable *invoker, async_operation_callback callback,
+typedef HRESULT (WINAPI *async_operation_callback)( IUnknown *invoker, IUnknown *param, PROPVARIANT *result );
+extern HRESULT async_operation_boolean_create( IUnknown *invoker, IUnknown *param, async_operation_callback callback,
IAsyncOperation_boolean **out );
#define DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from, iface_mem, expr ) \
More information about the wine-cvs
mailing list