dplayx: Move the lock into the DirectPlay object.

This commit is contained in:
Michael Stefaniuc 2013-03-29 16:48:24 +01:00 committed by Alexandre Julliard
parent 878ea7d9ea
commit 526851f5df
3 changed files with 10 additions and 41 deletions

View File

@ -227,33 +227,6 @@ static inline IDirectPlayImpl *impl_from_IDirectPlay4( 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 )
{
IDirectPlay2AImpl *This = lpDP;
@ -418,8 +391,10 @@ HRESULT DP_CreateInterface
}
/* 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 );
return S_OK;
@ -427,8 +402,6 @@ HRESULT DP_CreateInterface
/* Initialize failed, destroy it */
DP_DestroyDirectPlay2( This );
DP_DestroyIUnknown( This );
HeapFree( GetProcessHeap(), 0, This );
*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
of the last interface */
DP_DestroyDirectPlay2( This );
DP_DestroyIUnknown( This );
This->lock.DebugInfo->Spare[0] = 0;
DeleteCriticalSection( &This->lock );
HeapFree( GetProcessHeap(), 0, This );
}

View File

@ -31,11 +31,6 @@ extern HRESULT DPL_EnumAddress( LPDPENUMADDRESSCALLBACK lpEnumAddressCallback,
LPCVOID lpAddress, DWORD dwAddressSize,
LPVOID lpContext ) DECLSPEC_HIDDEN;
typedef struct tagDirectPlayIUnknownData
{
CRITICAL_SECTION DP_lock;
} DirectPlayIUnknownData;
typedef struct tagEnumSessionAsyncCallbackData
{
LPSPINITDATA lpSpData;
@ -190,7 +185,7 @@ typedef struct IDirectPlayImpl
IDirectPlay4A IDirectPlay4A_iface;
IDirectPlay4 IDirectPlay4_iface;
LONG ulInterfaceRef;
DirectPlayIUnknownData *unk;
CRITICAL_SECTION lock;
DirectPlay2Data *dp2;
} IDirectPlayImpl;

View File

@ -171,9 +171,9 @@ HANDLE DP_MSG_BuildAndLinkReplyStruct( IDirectPlay2Impl* This,
lpReplyStructList->replyExpected.dwMsgBodySize = 0;
/* Insert into the message queue while locked */
EnterCriticalSection( &This->unk->DP_lock );
EnterCriticalSection( &This->lock );
DPQ_INSERT( This->dp2->repliesExpected, lpReplyStructList, repliesExpected );
LeaveCriticalSection( &This->unk->DP_lock );
LeaveCriticalSection( &This->lock );
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
* avoid problems.
*/
EnterCriticalSection( &This->unk->DP_lock );
EnterCriticalSection( &This->lock );
DPQ_REMOVE_ENTRY( This->dp2->repliesExpected, repliesExpected, replyExpected.wExpectedReply,
==, wCommandId, lpReplyList );
LeaveCriticalSection( &This->unk->DP_lock );
LeaveCriticalSection( &This->lock );
if( lpReplyList != NULL )
{