Commit 1b33b1d5 authored by Christian Costa's avatar Christian Costa Committed by Alexandre Julliard

dmusic: Pass creation parameters to DMUSIC_CreateDirectMusicBufferImpl then…

dmusic: Pass creation parameters to DMUSIC_CreateDirectMusicBufferImpl then allocate data buffer and set format accordingly.
parent 209bc696
......@@ -53,6 +53,7 @@ static ULONG WINAPI IDirectMusicBufferImpl_Release (LPDIRECTMUSICBUFFER iface) {
TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
if (!refCount) {
HeapFree(GetProcessHeap(), 0, This->data);
HeapFree(GetProcessHeap(), 0, This);
}
......@@ -159,17 +160,37 @@ static const IDirectMusicBufferVtbl DirectMusicBuffer_Vtbl = {
IDirectMusicBufferImpl_SetUsedBytes
};
/* for ClassFactory */
HRESULT WINAPI DMUSIC_CreateDirectMusicBufferImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) {
IDirectMusicBufferImpl* dmbuff;
HRESULT WINAPI DMUSIC_CreateDirectMusicBufferImpl(LPDMUS_BUFFERDESC desc, LPVOID* ret_iface)
{
IDirectMusicBufferImpl* dmbuffer;
HRESULT hr;
dmbuff = HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicBufferImpl));
if (NULL == dmbuff) {
*ppobj = NULL;
TRACE("(%p, %p)\n", desc, ret_iface);
*ret_iface = NULL;
dmbuffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectMusicBufferImpl));
if (!dmbuffer)
return E_OUTOFMEMORY;
dmbuffer->lpVtbl = &DirectMusicBuffer_Vtbl;
dmbuffer->ref = 0; /* Will be inited by QueryInterface */
memcpy(&dmbuffer->format, &desc->guidBufferFormat, sizeof(GUID));
dmbuffer->size = (desc->cbBuffer + 3) & ~3; /* Buffer size must be multiple of 4 bytes */
dmbuffer->data = HeapAlloc(GetProcessHeap(), 0, dmbuffer->size);
if (!dmbuffer->data) {
HeapFree(GetProcessHeap(), 0, dmbuffer);
return E_OUTOFMEMORY;
}
dmbuff->lpVtbl = &DirectMusicBuffer_Vtbl;
dmbuff->ref = 0; /* will be inited by QueryInterface */
return IDirectMusicBufferImpl_QueryInterface ((LPDIRECTMUSICBUFFER)dmbuff, lpcGUID, ppobj);
hr = IDirectMusicBufferImpl_QueryInterface((LPDIRECTMUSICBUFFER)dmbuffer, &IID_IDirectMusicBuffer, ret_iface);
if (FAILED(hr))
{
HeapFree(GetProcessHeap(), 0, dmbuffer->data);
HeapFree(GetProcessHeap(), 0, dmbuffer);
}
return hr;
}
......@@ -165,7 +165,7 @@ static HRESULT WINAPI IDirectMusic8Impl_CreateMusicBuffer(LPDIRECTMUSIC8 iface,
if (!pBufferDesc || !ppBuffer)
return E_POINTER;
return DMUSIC_CreateDirectMusicBufferImpl(&IID_IDirectMusicBuffer, (LPVOID)ppBuffer, NULL);
return DMUSIC_CreateDirectMusicBufferImpl(pBufferDesc, (LPVOID)ppBuffer);
}
static HRESULT WINAPI IDirectMusic8Impl_CreatePort(LPDIRECTMUSIC8 iface, REFCLSID rclsidPort, LPDMUS_PORTPARAMS pPortParams, LPDIRECTMUSICPORT* ppPort, LPUNKNOWN pUnkOuter)
......
......@@ -75,13 +75,16 @@ typedef struct DMUSIC_PRIVATE_CHANNEL_GROUP_ {
/*****************************************************************************
* ClassFactory
*/
/* CLSID */
extern HRESULT WINAPI DMUSIC_CreateDirectMusicImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
extern HRESULT WINAPI DMUSIC_CreateDirectMusicBufferImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
extern HRESULT WINAPI DMUSIC_CreateDirectMusicCollectionImpl(LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
/* Internal */
extern HRESULT WINAPI DMUSIC_CreateDirectMusicBufferImpl(LPDMUS_BUFFERDESC desc, LPVOID* ret_iface) DECLSPEC_HIDDEN;
extern HRESULT WINAPI DMUSIC_CreateDirectMusicDownloadedInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
extern HRESULT WINAPI DMUSIC_CreateDirectMusicDownloadImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
extern HRESULT WINAPI DMUSIC_CreateReferenceClockImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
extern HRESULT WINAPI DMUSIC_CreateDirectMusicCollectionImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
extern HRESULT WINAPI DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter) DECLSPEC_HIDDEN;
/*****************************************************************************
......@@ -107,6 +110,9 @@ struct IDirectMusicBufferImpl {
LONG ref;
/* IDirectMusicBufferImpl fields */
GUID format;
DWORD size;
LPBYTE data;
};
/*****************************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment