Commit 30df87af authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

dmusic: Implement IDirectMusicPortDownload_AllocateBuffer.

parent 45f61965
......@@ -99,7 +99,7 @@ extern HRESULT DMUSIC_CreateDirectMusicBufferImpl(LPDMUS_BUFFERDESC desc, LPVOID
extern HRESULT DMUSIC_CreateReferenceClockImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
extern HRESULT DMUSIC_CreateDirectMusicInstrumentImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
extern HRESULT download_create(IDirectMusicDownload **ret_iface);
extern HRESULT download_create(DWORD size, IDirectMusicDownload **ret_iface);
/*****************************************************************************
* IDirectMusic8Impl implementation structure
......
......@@ -27,8 +27,13 @@ struct download
{
IDirectMusicDownload IDirectMusicDownload_iface;
LONG ref;
DWORD size;
BYTE data[];
};
C_ASSERT(sizeof(struct download) == offsetof(struct download, data[0]));
static inline struct download *impl_from_IDirectMusicDownload(IDirectMusicDownload *iface)
{
return CONTAINING_RECORD(iface, struct download, IDirectMusicDownload_iface);
......@@ -77,7 +82,12 @@ static ULONG WINAPI download_Release(IDirectMusicDownload *iface)
static HRESULT WINAPI download_GetBuffer(IDirectMusicDownload *iface, void **buffer, DWORD *size)
{
FIXME("(%p, %p, %p): stub\n", iface, buffer, size);
struct download *This = impl_from_IDirectMusicDownload(iface);
TRACE("(%p, %p, %p)\n", iface, buffer, size);
*buffer = This->data;
*size = This->size;
return S_OK;
}
......@@ -90,14 +100,15 @@ static const IDirectMusicDownloadVtbl download_vtbl =
download_GetBuffer,
};
HRESULT download_create(IDirectMusicDownload **ret_iface)
HRESULT download_create(DWORD size, IDirectMusicDownload **ret_iface)
{
struct download *download;
*ret_iface = NULL;
if (!(download = calloc(1, sizeof(*download)))) return E_OUTOFMEMORY;
if (!(download = malloc(offsetof(struct download, data[size])))) return E_OUTOFMEMORY;
download->IDirectMusicDownload_iface.lpVtbl = &download_vtbl;
download->ref = 1;
download->size = size;
TRACE("Created DirectMusicDownload %p\n", download);
*ret_iface = &download->IDirectMusicDownload_iface;
......
......@@ -584,17 +584,20 @@ static HRESULT WINAPI synth_port_download_GetBuffer(IDirectMusicPortDownload *if
if (!IDMDownload)
return E_POINTER;
return download_create(IDMDownload);
return download_create(0, IDMDownload);
}
static HRESULT WINAPI synth_port_download_AllocateBuffer(IDirectMusicPortDownload *iface, DWORD size,
IDirectMusicDownload **IDMDownload)
IDirectMusicDownload **download)
{
struct synth_port *This = synth_from_IDirectMusicPortDownload(iface);
FIXME("(%p/%p, %lu, %p): stub\n", iface, This, size, IDMDownload);
TRACE("(%p/%p, %lu, %p)\n", iface, This, size, download);
return S_OK;
if (!download) return E_POINTER;
if (!size) return E_INVALIDARG;
return download_create(size, download);
}
static HRESULT WINAPI synth_port_download_GetDLId(IDirectMusicPortDownload *iface, DWORD *first, DWORD count)
......
......@@ -1065,9 +1065,9 @@ static void test_port_download(void)
/* AllocateBuffer use the exact requested size */
hr = IDirectMusicPortDownload_AllocateBuffer(port, 0, NULL);
todo_wine ok(hr == E_POINTER, "got %#lx\n", hr);
ok(hr == E_POINTER, "got %#lx\n", hr);
hr = IDirectMusicPortDownload_AllocateBuffer(port, 0, &download);
todo_wine ok(hr == E_INVALIDARG, "got %#lx\n", hr);
ok(hr == E_INVALIDARG, "got %#lx\n", hr);
hr = IDirectMusicPortDownload_AllocateBuffer(port, 1, &download);
ok(hr == S_OK, "got %#lx\n", hr);
......@@ -1075,8 +1075,8 @@ static void test_port_download(void)
buffer = invalid_ptr;
hr = IDirectMusicDownload_GetBuffer(download, (void **)&buffer, &size);
ok(hr == S_OK, "got %#lx\n", hr);
todo_wine ok(size == 1, "got %#lx\n", size);
todo_wine ok(buffer != invalid_ptr, "got %p\n", buffer);
ok(size == 1, "got %#lx\n", size);
ok(buffer != invalid_ptr, "got %p\n", buffer);
IDirectMusicDownload_Release(download);
/* GetDLId allocates the given number of slots and returns only the first */
......@@ -1107,14 +1107,13 @@ static void test_port_download(void)
download = invalid_ptr;
hr = IDirectMusicPortDownload_AllocateBuffer(port, sizeof(struct wave_download), &download);
ok(hr == S_OK, "got %#lx\n", hr);
todo_wine ok(download != invalid_ptr, "got %p\n", download);
if (download == invalid_ptr) goto skip_tests;
ok(download != invalid_ptr, "got %p\n", download);
size = 0xdeadbeef;
wave_download = invalid_ptr;
hr = IDirectMusicDownload_GetBuffer(download, (void **)&wave_download, &size);
ok(hr == S_OK, "got %#lx\n", hr);
todo_wine ok(size == sizeof(struct wave_download), "got %#lx\n", size);
todo_wine ok(wave_download != invalid_ptr, "got %p\n", wave_download);
ok(size == sizeof(struct wave_download), "got %#lx\n", size);
ok(wave_download != invalid_ptr, "got %p\n", wave_download);
wave_download->info.cbSize = sizeof(struct wave_download);
wave_download->info.dwDLId = 2;
wave_download->info.dwDLType = 0;
......@@ -1172,7 +1171,6 @@ static void test_port_download(void)
IDirectMusicDownload_Release(download);
skip_tests:
IDirectMusicPortDownload_Release(port);
}
......
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