dmusic: Simplify the creation of a DirectMusic8 object.
Also lock/unlock the module only on creation/destruction of the object.
This commit is contained in:
parent
d82e2935e4
commit
096bfbd214
|
@ -61,8 +61,6 @@ static ULONG WINAPI IDirectMusic8Impl_AddRef(LPDIRECTMUSIC8 iface)
|
|||
|
||||
TRACE("(%p)->(): new ref = %u\n", This, ref);
|
||||
|
||||
DMUSIC_LockModule();
|
||||
|
||||
return ref;
|
||||
}
|
||||
|
||||
|
@ -78,9 +76,8 @@ static ULONG WINAPI IDirectMusic8Impl_Release(LPDIRECTMUSIC8 iface)
|
|||
HeapFree(GetProcessHeap(), 0, This->system_ports);
|
||||
HeapFree(GetProcessHeap(), 0, This->ppPorts);
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
}
|
||||
|
||||
DMUSIC_UnlockModule();
|
||||
}
|
||||
|
||||
return ref;
|
||||
}
|
||||
|
@ -417,7 +414,7 @@ HRESULT WINAPI DMUSIC_CreateDirectMusicImpl(LPCGUID riid, LPVOID* ret_iface, LPU
|
|||
return E_OUTOFMEMORY;
|
||||
|
||||
dmusic->IDirectMusic8_iface.lpVtbl = &DirectMusic8_Vtbl;
|
||||
dmusic->ref = 0; /* Will be inited by QueryInterface */
|
||||
dmusic->ref = 1;
|
||||
dmusic->pMasterClock = NULL;
|
||||
dmusic->ppPorts = NULL;
|
||||
dmusic->nrofports = 0;
|
||||
|
@ -427,14 +424,11 @@ HRESULT WINAPI DMUSIC_CreateDirectMusicImpl(LPCGUID riid, LPVOID* ret_iface, LPU
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret = IDirectMusic8Impl_QueryInterface(&dmusic->IDirectMusic8_iface, riid, ret_iface);
|
||||
if (FAILED(ret)) {
|
||||
IReferenceClock_Release(&dmusic->pMasterClock->IReferenceClock_iface);
|
||||
HeapFree(GetProcessHeap(), 0, dmusic);
|
||||
return ret;
|
||||
}
|
||||
|
||||
create_system_ports_list(dmusic);
|
||||
|
||||
return S_OK;
|
||||
DMUSIC_LockModule();
|
||||
ret = IDirectMusic8Impl_QueryInterface(&dmusic->IDirectMusic8_iface, riid, ret_iface);
|
||||
IDirectMusic8Impl_Release(&dmusic->IDirectMusic8_iface);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue