amstream: Implement AMAudioData::SetBuffer.
Signed-off-by: Anton Baskanov <baskanov@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
6010ebb22f
commit
d4db4bfd72
|
@ -32,6 +32,7 @@ typedef struct {
|
|||
LONG ref;
|
||||
DWORD size;
|
||||
BYTE *data;
|
||||
BOOL data_owned;
|
||||
DWORD actual_data;
|
||||
} AMAudioDataImpl;
|
||||
|
||||
|
@ -75,7 +76,14 @@ static ULONG WINAPI IAudioDataImpl_Release(IAudioData* iface)
|
|||
TRACE("(%p)->(): new ref = %u\n", iface, This->ref);
|
||||
|
||||
if (!ref)
|
||||
{
|
||||
if (This->data_owned)
|
||||
{
|
||||
CoTaskMemFree(This->data);
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
}
|
||||
|
||||
return ref;
|
||||
}
|
||||
|
@ -83,9 +91,35 @@ static ULONG WINAPI IAudioDataImpl_Release(IAudioData* iface)
|
|||
/*** IMemoryData methods ***/
|
||||
static HRESULT WINAPI IAudioDataImpl_SetBuffer(IAudioData* iface, DWORD size, BYTE *data, DWORD flags)
|
||||
{
|
||||
FIXME("(%p)->(%u,%p,%x): stub\n", iface, size, data, flags);
|
||||
AMAudioDataImpl *This = impl_from_IAudioData(iface);
|
||||
|
||||
return E_NOTIMPL;
|
||||
TRACE("(%p)->(%u,%p,%x)\n", iface, size, data, flags);
|
||||
|
||||
if (!size)
|
||||
{
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
if (This->data_owned)
|
||||
{
|
||||
CoTaskMemFree(This->data);
|
||||
This->data_owned = FALSE;
|
||||
}
|
||||
|
||||
This->size = size;
|
||||
This->data = data;
|
||||
|
||||
if (!This->data)
|
||||
{
|
||||
This->data = CoTaskMemAlloc(This->size);
|
||||
This->data_owned = TRUE;
|
||||
if (!This->data)
|
||||
{
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IAudioDataImpl_GetInfo(IAudioData* iface, DWORD *length, BYTE **data, DWORD *actual_data)
|
||||
|
|
|
@ -650,6 +650,53 @@ out_unknown:
|
|||
IUnknown_Release(unknown);
|
||||
}
|
||||
|
||||
static void test_audiodata_set_buffer(void)
|
||||
{
|
||||
IUnknown *unknown = create_audio_data();
|
||||
IAudioData *audio_data = NULL;
|
||||
BYTE buffer[100] = {0};
|
||||
DWORD length = 0;
|
||||
BYTE *data = NULL;
|
||||
|
||||
HRESULT result;
|
||||
|
||||
result = IUnknown_QueryInterface(unknown, &IID_IAudioData, (void **)&audio_data);
|
||||
if (FAILED(result))
|
||||
{
|
||||
/* test_audiodata_query_interface handles this case */
|
||||
skip("No IAudioData\n");
|
||||
goto out_unknown;
|
||||
}
|
||||
|
||||
result = IAudioData_SetBuffer(audio_data, 100, NULL, 0);
|
||||
ok(S_OK == result, "got 0x%08x\n", result);
|
||||
|
||||
data = (BYTE *)0xdeadbeef;
|
||||
length = 0xdeadbeef;
|
||||
result = IAudioData_GetInfo(audio_data, &length, &data, NULL);
|
||||
ok(S_OK == result, "got 0x%08x\n", result);
|
||||
ok(100 == length, "got %u\n", length);
|
||||
ok(NULL != data, "got %p\n", data);
|
||||
|
||||
result = IAudioData_SetBuffer(audio_data, 0, buffer, 0);
|
||||
ok(E_INVALIDARG == result, "got 0x%08x\n", result);
|
||||
|
||||
result = IAudioData_SetBuffer(audio_data, sizeof(buffer), buffer, 0);
|
||||
ok(S_OK == result, "got 0x%08x\n", result);
|
||||
|
||||
data = (BYTE *)0xdeadbeef;
|
||||
length = 0xdeadbeef;
|
||||
result = IAudioData_GetInfo(audio_data, &length, &data, NULL);
|
||||
ok(S_OK == result, "got 0x%08x\n", result);
|
||||
ok(sizeof(buffer) == length, "got %u\n", length);
|
||||
ok(buffer == data, "got %p\n", data);
|
||||
|
||||
IAudioData_Release(audio_data);
|
||||
|
||||
out_unknown:
|
||||
IUnknown_Release(unknown);
|
||||
}
|
||||
|
||||
START_TEST(amstream)
|
||||
{
|
||||
HANDLE file;
|
||||
|
@ -670,6 +717,7 @@ START_TEST(amstream)
|
|||
|
||||
test_audiodata_query_interface();
|
||||
test_audiodata_get_info();
|
||||
test_audiodata_set_buffer();
|
||||
|
||||
CoUninitialize();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue