dplayx: Add a separate refcount for IDirectPlayLobby2A.

This commit is contained in:
Michael Stefaniuc 2013-04-17 22:12:53 +02:00 committed by Alexandre Julliard
parent 2314df86df
commit 4d9882572c
2 changed files with 158 additions and 3 deletions

View File

@ -74,10 +74,11 @@ typedef struct IDirectPlayLobbyImpl
{
IDirectPlayLobby IDirectPlayLobby_iface;
IDirectPlayLobbyA IDirectPlayLobbyA_iface;
IDirectPlayLobby2A IDirectPlayLobby2A_iface;
IDirectPlayLobby3 IDirectPlayLobby3_iface;
IDirectPlayLobby3A IDirectPlayLobby3A_iface;
LONG numIfaces; /* "in use interfaces" refcount */
LONG ref, refA, ref3, ref3A;
LONG ref, refA, ref2A, ref3, ref3A;
CRITICAL_SECTION lock;
DirectPlayLobbyData* dpl;
} IDirectPlayLobbyImpl;
@ -92,6 +93,11 @@ static inline IDirectPlayLobbyImpl *impl_from_IDirectPlayLobbyA( IDirectPlayLobb
return CONTAINING_RECORD( iface, IDirectPlayLobbyImpl, IDirectPlayLobbyA_iface );
}
static inline IDirectPlayLobbyImpl *impl_from_IDirectPlayLobby2A( IDirectPlayLobby2A *iface )
{
return CONTAINING_RECORD( iface, IDirectPlayLobbyImpl, IDirectPlayLobby2A_iface );
}
static inline IDirectPlayLobbyImpl *impl_from_IDirectPlayLobby3( IDirectPlayLobby3 *iface )
{
return CONTAINING_RECORD( iface, IDirectPlayLobbyImpl, IDirectPlayLobby3_iface );
@ -156,6 +162,13 @@ static HRESULT WINAPI IDirectPlayLobbyImpl_QueryInterface( IDirectPlayLobby *ifa
return IDirectPlayLobby_QueryInterface( &This->IDirectPlayLobby3_iface, riid, ppv );
}
static HRESULT WINAPI IDirectPlayLobby2AImpl_QueryInterface( IDirectPlayLobby2A *iface, REFIID riid,
void **ppv )
{
IDirectPlayLobbyImpl *This = impl_from_IDirectPlayLobby2A( iface );
return IDirectPlayLobby_QueryInterface( &This->IDirectPlayLobby3_iface, riid, ppv );
}
static HRESULT WINAPI IDirectPlayLobby3AImpl_QueryInterface( IDirectPlayLobby3A *iface, REFIID riid,
void **ppv )
{
@ -191,7 +204,7 @@ static HRESULT WINAPI IDirectPlayLobby3Impl_QueryInterface( IDirectPlayLobby3 *i
else if ( IsEqualGUID( &IID_IDirectPlayLobby2A, riid ) )
{
TRACE( "(%p)->(IID_IDirectPlayLobby2A %p)\n", This, ppv );
*ppv = &This->IDirectPlayLobby3A_iface;
*ppv = &This->IDirectPlayLobby2A_iface;
}
else if ( IsEqualGUID( &IID_IDirectPlayLobby3, riid ) )
{
@ -240,6 +253,19 @@ static ULONG WINAPI IDirectPlayLobbyImpl_AddRef( IDirectPlayLobby *iface )
return ref;
}
static ULONG WINAPI IDirectPlayLobby2AImpl_AddRef(IDirectPlayLobby2A *iface)
{
IDirectPlayLobbyImpl *This = impl_from_IDirectPlayLobby2A( iface );
ULONG ref = InterlockedIncrement( &This->ref2A );
TRACE( "(%p) ref2A=%d\n", This, ref );
if ( ref == 1 )
InterlockedIncrement( &This->numIfaces );
return ref;
}
static ULONG WINAPI IDirectPlayLobby3AImpl_AddRef(IDirectPlayLobby3A *iface)
{
IDirectPlayLobbyImpl *This = impl_from_IDirectPlayLobby3A( iface );
@ -292,6 +318,19 @@ static ULONG WINAPI IDirectPlayLobbyImpl_Release( IDirectPlayLobby *iface )
return ref;
}
static ULONG WINAPI IDirectPlayLobby2AImpl_Release(IDirectPlayLobby2A *iface)
{
IDirectPlayLobbyImpl *This = impl_from_IDirectPlayLobby2A( iface );
ULONG ref = InterlockedDecrement( &This->ref2A );
TRACE( "(%p) ref2A=%d\n", This, ref );
if ( !ref && !InterlockedDecrement( &This->numIfaces ) )
dplobby_destroy( This );
return ref;
}
static ULONG WINAPI IDirectPlayLobby3AImpl_Release(IDirectPlayLobby3A *iface)
{
IDirectPlayLobbyImpl *This = impl_from_IDirectPlayLobby3A( iface );
@ -419,6 +458,13 @@ static HRESULT WINAPI IDirectPlayLobbyImpl_Connect( IDirectPlayLobby *iface, DWO
return IDirectPlayLobby_Connect( &This->IDirectPlayLobby3_iface, flags, dp, unk );
}
static HRESULT WINAPI IDirectPlayLobby2AImpl_Connect( IDirectPlayLobby2A *iface, DWORD flags,
IDirectPlay2A **dp, IUnknown *unk )
{
IDirectPlayLobbyImpl *This = impl_from_IDirectPlayLobby2A( iface );
return IDirectPlayLobby_Connect( &This->IDirectPlayLobby3A_iface, flags, dp, unk );
}
static HRESULT WINAPI IDirectPlayLobby3AImpl_Connect( IDirectPlayLobby3A *iface, DWORD flags,
IDirectPlay2A **dp, IUnknown *unk)
{
@ -458,6 +504,14 @@ static HRESULT WINAPI IDirectPlayLobbyImpl_CreateAddress( IDirectPlayLobby *ifac
datasize, address, addrsize );
}
static HRESULT WINAPI IDirectPlayLobby2AImpl_CreateAddress( IDirectPlayLobby2A *iface, REFGUID sp,
REFGUID datatype, const void *data, DWORD datasize, void *address, DWORD *addrsize )
{
IDirectPlayLobbyImpl *This = impl_from_IDirectPlayLobby2A( iface );
return IDirectPlayLobby_CreateAddress( &This->IDirectPlayLobby3A_iface, sp, datatype, data,
datasize, address, addrsize );
}
static HRESULT WINAPI IDirectPlayLobby3AImpl_CreateAddress( IDirectPlayLobby3A *iface,
REFGUID guidSP, REFGUID guidDataType, const void *lpData, DWORD dwDataSize, void *lpAddress,
DWORD *lpdwAddressSize )
@ -527,6 +581,14 @@ static HRESULT WINAPI IDirectPlayLobbyImpl_EnumAddress( IDirectPlayLobby *iface,
context );
}
static HRESULT WINAPI IDirectPlayLobby2AImpl_EnumAddress( IDirectPlayLobby2A *iface,
LPDPENUMADDRESSCALLBACK enumaddrcb, const void *address, DWORD size, void *context )
{
IDirectPlayLobbyImpl *This = impl_from_IDirectPlayLobby2A( iface );
return IDirectPlayLobby_EnumAddress( &This->IDirectPlayLobby3A_iface, enumaddrcb, address, size,
context );
}
static HRESULT WINAPI IDirectPlayLobby3AImpl_EnumAddress( IDirectPlayLobby3A *iface,
LPDPENUMADDRESSCALLBACK lpEnumAddressCallback, const void *lpAddress, DWORD dwAddressSize,
void *lpContext )
@ -602,6 +664,14 @@ static HRESULT WINAPI IDirectPlayLobbyImpl_EnumAddressTypes( IDirectPlayLobby *i
context, flags );
}
static HRESULT WINAPI IDirectPlayLobby2AImpl_EnumAddressTypes( IDirectPlayLobby2A *iface,
LPDPLENUMADDRESSTYPESCALLBACK enumaddrtypecb, REFGUID sp, void *context, DWORD flags )
{
IDirectPlayLobbyImpl *This = impl_from_IDirectPlayLobby2A( iface );
return IDirectPlayLobby_EnumAddressTypes( &This->IDirectPlayLobby3A_iface, enumaddrtypecb, sp,
context, flags );
}
static HRESULT WINAPI IDirectPlayLobby3AImpl_EnumAddressTypes( IDirectPlayLobby3A *iface,
LPDPLENUMADDRESSTYPESCALLBACK lpEnumAddressTypeCallback, REFGUID guidSP, void *lpContext,
DWORD dwFlags )
@ -764,6 +834,14 @@ static HRESULT WINAPI IDirectPlayLobbyImpl_EnumLocalApplications( IDirectPlayLob
context, flags );
}
static HRESULT WINAPI IDirectPlayLobby2AImpl_EnumLocalApplications( IDirectPlayLobby2A *iface,
LPDPLENUMLOCALAPPLICATIONSCALLBACK enumlocalappcb, void *context, DWORD flags )
{
IDirectPlayLobbyImpl *This = impl_from_IDirectPlayLobby2A( iface );
return IDirectPlayLobby_EnumLocalApplications( &This->IDirectPlayLobby3A_iface, enumlocalappcb,
context, flags );
}
static HRESULT WINAPI IDirectPlayLobby3AImpl_EnumLocalApplications( IDirectPlayLobby3A *iface,
LPDPLENUMLOCALAPPLICATIONSCALLBACK lpEnumLocalAppCallback, void *lpContext, DWORD dwFlags )
{
@ -879,6 +957,14 @@ static HRESULT WINAPI IDirectPlayLobbyImpl_GetConnectionSettings( IDirectPlayLob
size );
}
static HRESULT WINAPI IDirectPlayLobby2AImpl_GetConnectionSettings( IDirectPlayLobby2A *iface,
DWORD appid, void *data, DWORD *size )
{
IDirectPlayLobbyImpl *This = impl_from_IDirectPlayLobby2A( iface );
return IDirectPlayLobby_GetConnectionSettings( &This->IDirectPlayLobby3A_iface, appid, data,
size );
}
static HRESULT WINAPI IDirectPlayLobby3AImpl_GetConnectionSettings( IDirectPlayLobby3A *iface,
DWORD dwAppID, void *lpData, DWORD *lpdwDataSize )
{
@ -941,6 +1027,14 @@ static HRESULT WINAPI IDirectPlayLobbyImpl_ReceiveLobbyMessage( IDirectPlayLobby
msgflags, data, size );
}
static HRESULT WINAPI IDirectPlayLobby2AImpl_ReceiveLobbyMessage( IDirectPlayLobby2A *iface,
DWORD flags, DWORD appid, DWORD *msgflags, void *data, DWORD *size )
{
IDirectPlayLobbyImpl *This = impl_from_IDirectPlayLobby2A( iface );
return IDirectPlayLobby_ReceiveLobbyMessage( &This->IDirectPlayLobby3A_iface, flags, appid,
msgflags, data, size );
}
static HRESULT WINAPI IDirectPlayLobby3AImpl_ReceiveLobbyMessage( IDirectPlayLobby3A *iface,
DWORD dwFlags, DWORD dwAppID, DWORD *lpdwMessageFlags, void *lpData,
DWORD *lpdwDataSize )
@ -1122,6 +1216,14 @@ static HRESULT WINAPI IDirectPlayLobbyImpl_RunApplication( IDirectPlayLobby *ifa
event );
}
static HRESULT WINAPI IDirectPlayLobby2AImpl_RunApplication( IDirectPlayLobby2A *iface, DWORD flags,
DWORD *appid, DPLCONNECTION *conn, HANDLE event )
{
IDirectPlayLobbyImpl *This = impl_from_IDirectPlayLobby2A( iface );
return IDirectPlayLobby_RunApplication( &This->IDirectPlayLobby3A_iface, flags, appid, conn,
event );
}
static HRESULT WINAPI IDirectPlayLobby3AImpl_RunApplication( IDirectPlayLobby3A *iface,
DWORD dwFlags, DWORD *lpdwAppID, DPLCONNECTION *lpConn, HANDLE hReceiveEvent )
{
@ -1278,6 +1380,14 @@ static HRESULT WINAPI IDirectPlayLobbyImpl_SendLobbyMessage( IDirectPlayLobby *i
size );
}
static HRESULT WINAPI IDirectPlayLobby2AImpl_SendLobbyMessage( IDirectPlayLobby2A *iface,
DWORD flags, DWORD appid, void *data, DWORD size )
{
IDirectPlayLobbyImpl *This = impl_from_IDirectPlayLobby2A( iface );
return IDirectPlayLobby_SendLobbyMessage( &This->IDirectPlayLobby3A_iface, flags, appid, data,
size );
}
static HRESULT WINAPI IDirectPlayLobby3AImpl_SendLobbyMessage( IDirectPlayLobby3A *iface,
DWORD flags, DWORD appid, void *data, DWORD size )
{
@ -1345,6 +1455,14 @@ static HRESULT WINAPI IDirectPlayLobbyImpl_SetConnectionSettings( IDirectPlayLob
appid, conn );
}
static HRESULT WINAPI IDirectPlayLobby2AImpl_SetConnectionSettings( IDirectPlayLobby2A *iface,
DWORD flags, DWORD appid, DPLCONNECTION *conn )
{
IDirectPlayLobbyImpl *This = impl_from_IDirectPlayLobby2A( iface );
return IDirectPlayLobby_SetConnectionSettings( &This->IDirectPlayLobby3A_iface, flags,
appid, conn );
}
static HRESULT WINAPI IDirectPlayLobby3AImpl_SetConnectionSettings( IDirectPlayLobby3A *iface,
DWORD dwFlags, DWORD dwAppID, DPLCONNECTION *lpConn )
{
@ -1394,6 +1512,14 @@ static HRESULT WINAPI IDirectPlayLobbyImpl_SetLobbyMessageEvent( IDirectPlayLobb
event );
}
static HRESULT WINAPI IDirectPlayLobby2AImpl_SetLobbyMessageEvent( IDirectPlayLobby2A *iface,
DWORD flags, DWORD appid, HANDLE event )
{
IDirectPlayLobbyImpl *This = impl_from_IDirectPlayLobby2A( iface );
return IDirectPlayLobby_SetLobbyMessageEvent( &This->IDirectPlayLobby3A_iface, flags, appid,
event );
}
static HRESULT WINAPI IDirectPlayLobby3AImpl_SetLobbyMessageEvent( IDirectPlayLobby3A *iface,
DWORD flags, DWORD appid, HANDLE event )
{
@ -1410,6 +1536,14 @@ static HRESULT WINAPI IDirectPlayLobby3Impl_SetLobbyMessageEvent( IDirectPlayLob
/* DPL 2 methods */
static HRESULT WINAPI IDirectPlayLobby2AImpl_CreateCompoundAddress( IDirectPlayLobby2A *iface,
const DPCOMPOUNDADDRESSELEMENT *elements, DWORD count, void *address, DWORD *size )
{
IDirectPlayLobbyImpl *This = impl_from_IDirectPlayLobby2A( iface );
return IDirectPlayLobby_CreateCompoundAddress( &This->IDirectPlayLobby3A_iface, elements,
count, address, size );
}
static HRESULT WINAPI IDirectPlayLobby3Impl_CreateCompoundAddress( IDirectPlayLobby3 *iface,
const DPCOMPOUNDADDRESSELEMENT *lpElements, DWORD dwElementCount, void *lpAddress,
DWORD *lpdwAddressSize )
@ -1708,6 +1842,25 @@ static const IDirectPlayLobbyVtbl dpl_vt =
IDirectPlayLobbyImpl_SetLobbyMessageEvent
};
static const IDirectPlayLobby2Vtbl dpl2A_vt =
{
IDirectPlayLobby2AImpl_QueryInterface,
IDirectPlayLobby2AImpl_AddRef,
IDirectPlayLobby2AImpl_Release,
IDirectPlayLobby2AImpl_Connect,
IDirectPlayLobby2AImpl_CreateAddress,
IDirectPlayLobby2AImpl_EnumAddress,
IDirectPlayLobby2AImpl_EnumAddressTypes,
IDirectPlayLobby2AImpl_EnumLocalApplications,
IDirectPlayLobby2AImpl_GetConnectionSettings,
IDirectPlayLobby2AImpl_ReceiveLobbyMessage,
IDirectPlayLobby2AImpl_RunApplication,
IDirectPlayLobby2AImpl_SendLobbyMessage,
IDirectPlayLobby2AImpl_SetConnectionSettings,
IDirectPlayLobby2AImpl_SetLobbyMessageEvent,
IDirectPlayLobby2AImpl_CreateCompoundAddress
};
static const IDirectPlayLobby3Vtbl dpl3A_vt =
{
IDirectPlayLobby3AImpl_QueryInterface,
@ -1768,11 +1921,13 @@ HRESULT dplobby_create( REFIID riid, void **ppv )
obj->IDirectPlayLobby_iface.lpVtbl = &dpl_vt;
obj->IDirectPlayLobbyA_iface.lpVtbl = &dplA_vt;
obj->IDirectPlayLobby2A_iface.lpVtbl = &dpl2A_vt;
obj->IDirectPlayLobby3_iface.lpVtbl = &dpl3_vt;
obj->IDirectPlayLobby3A_iface.lpVtbl = &dpl3A_vt;
obj->numIfaces = 1;
obj->ref = 0;
obj->refA = 0;
obj->ref2A = 0;
obj->ref3 = 1;
obj->ref3A = 0;

View File

@ -6511,7 +6511,7 @@ static void test_COM_dplobby(void)
hr = IDirectPlayLobby_QueryInterface(dpl, &IID_IDirectPlayLobby3A, (void**)&dpl3A);
ok(hr == S_OK, "QueryInterface for IID_IDirectPlayLobby3A failed: %08x\n", hr);
refcount = IDirectPlayLobby_AddRef(dpl3A);
todo_wine ok(refcount == 2, "refcount == %u, expected 2\n", refcount);
ok(refcount == 2, "refcount == %u, expected 2\n", refcount);
IDirectPlayLobby_Release(dpl3A);
/* IDirectPlayLobby and IUnknown share a refcount */