mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-15 05:41:19 +00:00
dmusic: Implement IDirectMusicPortDownload_AllocateBuffer.
This commit is contained in:
parent
45f61965dc
commit
30df87af09
|
@ -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_CreateReferenceClockImpl (LPCGUID lpcGUID, LPVOID* ppobj, LPUNKNOWN pUnkOuter);
|
||||||
extern HRESULT DMUSIC_CreateDirectMusicInstrumentImpl (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
|
* IDirectMusic8Impl implementation structure
|
||||||
|
|
|
@ -27,8 +27,13 @@ struct download
|
||||||
{
|
{
|
||||||
IDirectMusicDownload IDirectMusicDownload_iface;
|
IDirectMusicDownload IDirectMusicDownload_iface;
|
||||||
LONG ref;
|
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)
|
static inline struct download *impl_from_IDirectMusicDownload(IDirectMusicDownload *iface)
|
||||||
{
|
{
|
||||||
return CONTAINING_RECORD(iface, struct download, 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)
|
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;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
@ -90,14 +100,15 @@ static const IDirectMusicDownloadVtbl download_vtbl =
|
||||||
download_GetBuffer,
|
download_GetBuffer,
|
||||||
};
|
};
|
||||||
|
|
||||||
HRESULT download_create(IDirectMusicDownload **ret_iface)
|
HRESULT download_create(DWORD size, IDirectMusicDownload **ret_iface)
|
||||||
{
|
{
|
||||||
struct download *download;
|
struct download *download;
|
||||||
|
|
||||||
*ret_iface = NULL;
|
*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->IDirectMusicDownload_iface.lpVtbl = &download_vtbl;
|
||||||
download->ref = 1;
|
download->ref = 1;
|
||||||
|
download->size = size;
|
||||||
|
|
||||||
TRACE("Created DirectMusicDownload %p\n", download);
|
TRACE("Created DirectMusicDownload %p\n", download);
|
||||||
*ret_iface = &download->IDirectMusicDownload_iface;
|
*ret_iface = &download->IDirectMusicDownload_iface;
|
||||||
|
|
|
@ -584,17 +584,20 @@ static HRESULT WINAPI synth_port_download_GetBuffer(IDirectMusicPortDownload *if
|
||||||
if (!IDMDownload)
|
if (!IDMDownload)
|
||||||
return E_POINTER;
|
return E_POINTER;
|
||||||
|
|
||||||
return download_create(IDMDownload);
|
return download_create(0, IDMDownload);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI synth_port_download_AllocateBuffer(IDirectMusicPortDownload *iface, DWORD size,
|
static HRESULT WINAPI synth_port_download_AllocateBuffer(IDirectMusicPortDownload *iface, DWORD size,
|
||||||
IDirectMusicDownload **IDMDownload)
|
IDirectMusicDownload **download)
|
||||||
{
|
{
|
||||||
struct synth_port *This = synth_from_IDirectMusicPortDownload(iface);
|
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)
|
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 */
|
/* AllocateBuffer use the exact requested size */
|
||||||
hr = IDirectMusicPortDownload_AllocateBuffer(port, 0, NULL);
|
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);
|
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);
|
hr = IDirectMusicPortDownload_AllocateBuffer(port, 1, &download);
|
||||||
ok(hr == S_OK, "got %#lx\n", hr);
|
ok(hr == S_OK, "got %#lx\n", hr);
|
||||||
|
@ -1075,8 +1075,8 @@ static void test_port_download(void)
|
||||||
buffer = invalid_ptr;
|
buffer = invalid_ptr;
|
||||||
hr = IDirectMusicDownload_GetBuffer(download, (void **)&buffer, &size);
|
hr = IDirectMusicDownload_GetBuffer(download, (void **)&buffer, &size);
|
||||||
ok(hr == S_OK, "got %#lx\n", hr);
|
ok(hr == S_OK, "got %#lx\n", hr);
|
||||||
todo_wine ok(size == 1, "got %#lx\n", size);
|
ok(size == 1, "got %#lx\n", size);
|
||||||
todo_wine ok(buffer != invalid_ptr, "got %p\n", buffer);
|
ok(buffer != invalid_ptr, "got %p\n", buffer);
|
||||||
IDirectMusicDownload_Release(download);
|
IDirectMusicDownload_Release(download);
|
||||||
|
|
||||||
/* GetDLId allocates the given number of slots and returns only the first */
|
/* 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;
|
download = invalid_ptr;
|
||||||
hr = IDirectMusicPortDownload_AllocateBuffer(port, sizeof(struct wave_download), &download);
|
hr = IDirectMusicPortDownload_AllocateBuffer(port, sizeof(struct wave_download), &download);
|
||||||
ok(hr == S_OK, "got %#lx\n", hr);
|
ok(hr == S_OK, "got %#lx\n", hr);
|
||||||
todo_wine ok(download != invalid_ptr, "got %p\n", download);
|
ok(download != invalid_ptr, "got %p\n", download);
|
||||||
if (download == invalid_ptr) goto skip_tests;
|
|
||||||
size = 0xdeadbeef;
|
size = 0xdeadbeef;
|
||||||
wave_download = invalid_ptr;
|
wave_download = invalid_ptr;
|
||||||
hr = IDirectMusicDownload_GetBuffer(download, (void **)&wave_download, &size);
|
hr = IDirectMusicDownload_GetBuffer(download, (void **)&wave_download, &size);
|
||||||
ok(hr == S_OK, "got %#lx\n", hr);
|
ok(hr == S_OK, "got %#lx\n", hr);
|
||||||
todo_wine ok(size == sizeof(struct wave_download), "got %#lx\n", size);
|
ok(size == sizeof(struct wave_download), "got %#lx\n", size);
|
||||||
todo_wine ok(wave_download != invalid_ptr, "got %p\n", wave_download);
|
ok(wave_download != invalid_ptr, "got %p\n", wave_download);
|
||||||
wave_download->info.cbSize = sizeof(struct wave_download);
|
wave_download->info.cbSize = sizeof(struct wave_download);
|
||||||
wave_download->info.dwDLId = 2;
|
wave_download->info.dwDLId = 2;
|
||||||
wave_download->info.dwDLType = 0;
|
wave_download->info.dwDLType = 0;
|
||||||
|
@ -1172,7 +1171,6 @@ static void test_port_download(void)
|
||||||
|
|
||||||
IDirectMusicDownload_Release(download);
|
IDirectMusicDownload_Release(download);
|
||||||
|
|
||||||
skip_tests:
|
|
||||||
IDirectMusicPortDownload_Release(port);
|
IDirectMusicPortDownload_Release(port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue