dplayx: Move the lock into the DirectPlay object.
This commit is contained in:
parent
878ea7d9ea
commit
526851f5df
|
@ -227,33 +227,6 @@ static inline IDirectPlayImpl *impl_from_IDirectPlay4( IDirectPlay4 *iface )
|
||||||
return CONTAINING_RECORD( iface, IDirectPlayImpl, IDirectPlay4_iface );
|
return CONTAINING_RECORD( iface, IDirectPlayImpl, IDirectPlay4_iface );
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL DP_CreateIUnknown( LPVOID lpDP )
|
|
||||||
{
|
|
||||||
IDirectPlay2AImpl *This = lpDP;
|
|
||||||
|
|
||||||
This->unk = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof( *(This->unk) ) );
|
|
||||||
if ( This->unk == NULL )
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
InitializeCriticalSection( &This->unk->DP_lock );
|
|
||||||
This->unk->DP_lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": IDirectPlay2AImpl*->DirectPlayIUnknownData*->DP_lock");
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static BOOL DP_DestroyIUnknown( LPVOID lpDP )
|
|
||||||
{
|
|
||||||
IDirectPlay2AImpl *This = lpDP;
|
|
||||||
|
|
||||||
This->unk->DP_lock.DebugInfo->Spare[0] = 0;
|
|
||||||
DeleteCriticalSection( &This->unk->DP_lock );
|
|
||||||
HeapFree( GetProcessHeap(), 0, This->unk );
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static BOOL DP_CreateDirectPlay2( LPVOID lpDP )
|
static BOOL DP_CreateDirectPlay2( LPVOID lpDP )
|
||||||
{
|
{
|
||||||
IDirectPlay2AImpl *This = lpDP;
|
IDirectPlay2AImpl *This = lpDP;
|
||||||
|
@ -418,8 +391,10 @@ HRESULT DP_CreateInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize it */
|
/* Initialize it */
|
||||||
if ( DP_CreateIUnknown( This ) && DP_CreateDirectPlay2( This ) )
|
if ( DP_CreateDirectPlay2( This ) )
|
||||||
{
|
{
|
||||||
|
InitializeCriticalSection( &This->lock );
|
||||||
|
This->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": IDirectPlayImpl.lock");
|
||||||
IDirectPlayX_AddRef( (LPDIRECTPLAY2A)*ppvObj );
|
IDirectPlayX_AddRef( (LPDIRECTPLAY2A)*ppvObj );
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
@ -427,8 +402,6 @@ HRESULT DP_CreateInterface
|
||||||
|
|
||||||
/* Initialize failed, destroy it */
|
/* Initialize failed, destroy it */
|
||||||
DP_DestroyDirectPlay2( This );
|
DP_DestroyDirectPlay2( This );
|
||||||
DP_DestroyIUnknown( This );
|
|
||||||
|
|
||||||
HeapFree( GetProcessHeap(), 0, This );
|
HeapFree( GetProcessHeap(), 0, This );
|
||||||
|
|
||||||
*ppvObj = NULL;
|
*ppvObj = NULL;
|
||||||
|
@ -483,7 +456,8 @@ static ULONG WINAPI DP_Release( IDirectPlayImpl *This )
|
||||||
/* If we're destroying the object, this must be the last ref
|
/* If we're destroying the object, this must be the last ref
|
||||||
of the last interface */
|
of the last interface */
|
||||||
DP_DestroyDirectPlay2( This );
|
DP_DestroyDirectPlay2( This );
|
||||||
DP_DestroyIUnknown( This );
|
This->lock.DebugInfo->Spare[0] = 0;
|
||||||
|
DeleteCriticalSection( &This->lock );
|
||||||
HeapFree( GetProcessHeap(), 0, This );
|
HeapFree( GetProcessHeap(), 0, This );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,11 +31,6 @@ extern HRESULT DPL_EnumAddress( LPDPENUMADDRESSCALLBACK lpEnumAddressCallback,
|
||||||
LPCVOID lpAddress, DWORD dwAddressSize,
|
LPCVOID lpAddress, DWORD dwAddressSize,
|
||||||
LPVOID lpContext ) DECLSPEC_HIDDEN;
|
LPVOID lpContext ) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
typedef struct tagDirectPlayIUnknownData
|
|
||||||
{
|
|
||||||
CRITICAL_SECTION DP_lock;
|
|
||||||
} DirectPlayIUnknownData;
|
|
||||||
|
|
||||||
typedef struct tagEnumSessionAsyncCallbackData
|
typedef struct tagEnumSessionAsyncCallbackData
|
||||||
{
|
{
|
||||||
LPSPINITDATA lpSpData;
|
LPSPINITDATA lpSpData;
|
||||||
|
@ -190,7 +185,7 @@ typedef struct IDirectPlayImpl
|
||||||
IDirectPlay4A IDirectPlay4A_iface;
|
IDirectPlay4A IDirectPlay4A_iface;
|
||||||
IDirectPlay4 IDirectPlay4_iface;
|
IDirectPlay4 IDirectPlay4_iface;
|
||||||
LONG ulInterfaceRef;
|
LONG ulInterfaceRef;
|
||||||
DirectPlayIUnknownData *unk;
|
CRITICAL_SECTION lock;
|
||||||
DirectPlay2Data *dp2;
|
DirectPlay2Data *dp2;
|
||||||
} IDirectPlayImpl;
|
} IDirectPlayImpl;
|
||||||
|
|
||||||
|
|
|
@ -171,9 +171,9 @@ HANDLE DP_MSG_BuildAndLinkReplyStruct( IDirectPlay2Impl* This,
|
||||||
lpReplyStructList->replyExpected.dwMsgBodySize = 0;
|
lpReplyStructList->replyExpected.dwMsgBodySize = 0;
|
||||||
|
|
||||||
/* Insert into the message queue while locked */
|
/* Insert into the message queue while locked */
|
||||||
EnterCriticalSection( &This->unk->DP_lock );
|
EnterCriticalSection( &This->lock );
|
||||||
DPQ_INSERT( This->dp2->repliesExpected, lpReplyStructList, repliesExpected );
|
DPQ_INSERT( This->dp2->repliesExpected, lpReplyStructList, repliesExpected );
|
||||||
LeaveCriticalSection( &This->unk->DP_lock );
|
LeaveCriticalSection( &This->lock );
|
||||||
|
|
||||||
return lpReplyStructList->replyExpected.hReceipt;
|
return lpReplyStructList->replyExpected.hReceipt;
|
||||||
}
|
}
|
||||||
|
@ -432,10 +432,10 @@ void DP_MSG_ReplyReceived( IDirectPlay2AImpl* This, WORD wCommandId,
|
||||||
/* Find, and immediately remove (to avoid double triggering), the appropriate entry. Call locked to
|
/* Find, and immediately remove (to avoid double triggering), the appropriate entry. Call locked to
|
||||||
* avoid problems.
|
* avoid problems.
|
||||||
*/
|
*/
|
||||||
EnterCriticalSection( &This->unk->DP_lock );
|
EnterCriticalSection( &This->lock );
|
||||||
DPQ_REMOVE_ENTRY( This->dp2->repliesExpected, repliesExpected, replyExpected.wExpectedReply,
|
DPQ_REMOVE_ENTRY( This->dp2->repliesExpected, repliesExpected, replyExpected.wExpectedReply,
|
||||||
==, wCommandId, lpReplyList );
|
==, wCommandId, lpReplyList );
|
||||||
LeaveCriticalSection( &This->unk->DP_lock );
|
LeaveCriticalSection( &This->lock );
|
||||||
|
|
||||||
if( lpReplyList != NULL )
|
if( lpReplyList != NULL )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue