amstream: Implement AMAudioData::SetFormat.

Signed-off-by: Anton Baskanov <baskanov@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Anton Baskanov 2016-07-28 21:59:56 +06:00 committed by Alexandre Julliard
parent fa542355e9
commit d283051b6b
2 changed files with 85 additions and 2 deletions

View File

@ -185,9 +185,23 @@ static HRESULT WINAPI IAudioDataImpl_GetFormat(IAudioData* iface, WAVEFORMATEX *
static HRESULT WINAPI IAudioDataImpl_SetFormat(IAudioData* iface, const WAVEFORMATEX *wave_format)
{
FIXME("(%p)->(%p): stub\n", iface, wave_format);
AMAudioDataImpl *This = impl_from_IAudioData(iface);
return E_NOTIMPL;
TRACE("(%p)->(%p)\n", iface, wave_format);
if (!wave_format)
{
return E_POINTER;
}
if (WAVE_FORMAT_PCM != wave_format->wFormatTag)
{
return E_INVALIDARG;
}
This->wave_format = *wave_format;
return S_OK;
}
static const struct IAudioDataVtbl AudioData_Vtbl =

View File

@ -25,6 +25,9 @@
#include "uuids.h"
#include "amstream.h"
#include "vfwmsgs.h"
#include "mmreg.h"
#include "ks.h"
#include "ksmedia.h"
#define EXPECT_REF(obj,ref) _expect_ref((IUnknown*)obj, ref, __LINE__)
static void _expect_ref(IUnknown* obj, ULONG ref, int line)
@ -787,6 +790,71 @@ out_unknown:
IUnknown_Release(unknown);
}
static void test_audiodata_set_format(void)
{
IUnknown *unknown = create_audio_data();
IAudioData *audio_data = NULL;
WAVEFORMATPCMEX wave_format = {{0}};
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_SetFormat(audio_data, NULL);
ok(E_POINTER == result, "got 0x%08x\n", result);
wave_format.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
wave_format.Format.nChannels = 2;
wave_format.Format.nSamplesPerSec = 44100;
wave_format.Format.nAvgBytesPerSec = 176400;
wave_format.Format.nBlockAlign = 4;
wave_format.Format.wBitsPerSample = 16;
wave_format.Format.cbSize = 22;
wave_format.Samples.wValidBitsPerSample = 16;
wave_format.dwChannelMask = KSAUDIO_SPEAKER_STEREO;
wave_format.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
result = IAudioData_SetFormat(audio_data, &wave_format.Format);
ok(E_INVALIDARG == result, "got 0x%08x\n", result);
wave_format.Format.wFormatTag = WAVE_FORMAT_PCM;
wave_format.Format.nChannels = 2;
wave_format.Format.nSamplesPerSec = 44100;
wave_format.Format.nAvgBytesPerSec = 176400;
wave_format.Format.nBlockAlign = 4;
wave_format.Format.wBitsPerSample = 16;
wave_format.Format.cbSize = 0;
result = IAudioData_SetFormat(audio_data, &wave_format.Format);
ok(S_OK == result, "got 0x%08x\n", result);
wave_format.Format.wFormatTag = 0xdead;
wave_format.Format.nChannels = 0xdead;
wave_format.Format.nSamplesPerSec = 0xdeadbeef;
wave_format.Format.nAvgBytesPerSec = 0xdeadbeef;
wave_format.Format.nBlockAlign = 0xdead;
wave_format.Format.wBitsPerSample = 0xdead;
wave_format.Format.cbSize = 0xdead;
result = IAudioData_GetFormat(audio_data, &wave_format.Format);
ok(S_OK == result, "got 0x%08x\n", result);
ok(WAVE_FORMAT_PCM == wave_format.Format.wFormatTag, "got %u\n", wave_format.Format.wFormatTag);
ok(2 == wave_format.Format.nChannels, "got %u\n", wave_format.Format.nChannels);
ok(44100 == wave_format.Format.nSamplesPerSec, "got %u\n", wave_format.Format.nSamplesPerSec);
ok(176400 == wave_format.Format.nAvgBytesPerSec, "got %u\n", wave_format.Format.nAvgBytesPerSec);
ok(4 == wave_format.Format.nBlockAlign, "got %u\n", wave_format.Format.nBlockAlign);
ok(16 == wave_format.Format.wBitsPerSample, "got %u\n", wave_format.Format.wBitsPerSample);
ok(0 == wave_format.Format.cbSize, "got %u\n", wave_format.Format.cbSize);
IAudioData_Release(audio_data);
out_unknown:
IUnknown_Release(unknown);
}
START_TEST(amstream)
{
HANDLE file;
@ -810,6 +878,7 @@ START_TEST(amstream)
test_audiodata_set_buffer();
test_audiodata_set_actual();
test_audiodata_get_format();
test_audiodata_set_format();
CoUninitialize();
}