From: Rémi Bernon rbernon@codeweavers.com
--- dlls/dmusic/dmusic_private.h | 2 +- dlls/dmusic/download.c | 15 +++++++++++++-- dlls/dmusic/port.c | 11 +++++++---- dlls/dmusic/tests/dmusic.c | 16 +++++++--------- 4 files changed, 28 insertions(+), 16 deletions(-)
diff --git a/dlls/dmusic/dmusic_private.h b/dlls/dmusic/dmusic_private.h index d2157288a02..03c1e6970ee 100644 --- a/dlls/dmusic/dmusic_private.h +++ b/dlls/dmusic/dmusic_private.h @@ -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 diff --git a/dlls/dmusic/download.c b/dlls/dmusic/download.c index 9c3f0d6b0cd..1417a7b3efc 100644 --- a/dlls/dmusic/download.c +++ b/dlls/dmusic/download.c @@ -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,7 +100,7 @@ static const IDirectMusicDownloadVtbl download_vtbl = download_GetBuffer, };
-HRESULT download_create(IDirectMusicDownload **ret_iface) +HRESULT download_create(DWORD size, IDirectMusicDownload **ret_iface) { struct download *download;
@@ -98,6 +108,7 @@ HRESULT download_create(IDirectMusicDownload **ret_iface) if (!(download = calloc(1, sizeof(*download)))) 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; diff --git a/dlls/dmusic/port.c b/dlls/dmusic/port.c index 7cc30b525c1..95144a6d905 100644 --- a/dlls/dmusic/port.c +++ b/dlls/dmusic/port.c @@ -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) diff --git a/dlls/dmusic/tests/dmusic.c b/dlls/dmusic/tests/dmusic.c index 05568208fee..8cfcc11ffd8 100644 --- a/dlls/dmusic/tests/dmusic.c +++ b/dlls/dmusic/tests/dmusic.c @@ -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); }