Signed-off-by: Anton Baskanov baskanov@gmail.com --- dlls/amstream/tests/amstream.c | 890 ++++++++++++++++----------------- 1 file changed, 445 insertions(+), 445 deletions(-)
diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index aeedb62b00..feb195140e 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -711,6 +711,279 @@ static void check_enum_stream_(int line, IAMMultiMediaStream *mmstream, } }
+struct testfilter +{ + struct strmbase_filter filter; + struct strmbase_source source; + IMediaSeeking IMediaSeeking_iface; + LONGLONG current_position; + LONGLONG stop_position; + HRESULT get_duration_hr; + HRESULT set_positions_hr; +}; + +static inline struct testfilter *impl_from_BaseFilter(struct strmbase_filter *iface) +{ + return CONTAINING_RECORD(iface, struct testfilter, filter); +} + +static struct strmbase_pin *testfilter_get_pin(struct strmbase_filter *iface, unsigned int index) +{ + struct testfilter *filter = impl_from_BaseFilter(iface); + if (!index) + return &filter->source.pin; + return NULL; +} + +static void testfilter_destroy(struct strmbase_filter *iface) +{ + struct testfilter *filter = impl_from_BaseFilter(iface); + strmbase_source_cleanup(&filter->source); + strmbase_filter_cleanup(&filter->filter); +} + +static HRESULT testfilter_init_stream(struct strmbase_filter *iface) +{ + struct testfilter *filter = impl_from_BaseFilter(iface); + + BaseOutputPinImpl_Active(&filter->source); + return S_OK; +} + +static HRESULT testfilter_cleanup_stream(struct strmbase_filter *iface) +{ + struct testfilter *filter = impl_from_BaseFilter(iface); + + BaseOutputPinImpl_Inactive(&filter->source); + return S_OK; +} + +static const struct strmbase_filter_ops testfilter_ops = +{ + .filter_get_pin = testfilter_get_pin, + .filter_destroy = testfilter_destroy, + .filter_init_stream = testfilter_init_stream, + .filter_cleanup_stream = testfilter_cleanup_stream, +}; + +static inline struct testfilter *impl_from_base_pin(struct strmbase_pin *iface) +{ + return CONTAINING_RECORD(iface, struct testfilter, source.pin); +} + +static HRESULT testsource_query_interface(struct strmbase_pin *iface, REFIID iid, void **out) +{ + struct testfilter *filter = impl_from_base_pin(iface); + + if (IsEqualGUID(iid, &IID_IMediaSeeking) && filter->IMediaSeeking_iface.lpVtbl) + *out = &filter->IMediaSeeking_iface; + else + return E_NOINTERFACE; + + IUnknown_AddRef((IUnknown *)*out); + + return S_OK; +} + +static HRESULT WINAPI testsource_DecideBufferSize(struct strmbase_source *iface, + IMemAllocator *alloc, ALLOCATOR_PROPERTIES *requested) +{ + ALLOCATOR_PROPERTIES actual; + + if (!requested->cbAlign) + requested->cbAlign = 1; + + if (requested->cbBuffer < 4096) + requested->cbBuffer = 4096; + + if (!requested->cBuffers) + requested->cBuffers = 2; + + return IMemAllocator_SetProperties(alloc, requested, &actual); +} + +static const struct strmbase_source_ops testsource_ops = +{ + .base.pin_query_interface = testsource_query_interface, + .pfnAttemptConnection = BaseOutputPinImpl_AttemptConnection, + .pfnDecideBufferSize = testsource_DecideBufferSize, + .pfnDecideAllocator = BaseOutputPinImpl_DecideAllocator, +}; + +static void testfilter_init(struct testfilter *filter) +{ + static const GUID clsid = {0xabacab}; + memset(filter, 0, sizeof(*filter)); + strmbase_filter_init(&filter->filter, NULL, &clsid, &testfilter_ops); + strmbase_source_init(&filter->source, &filter->filter, L"", &testsource_ops); + filter->stop_position = 0x8000000000000000ULL; +} + +static inline struct testfilter *impl_from_IMediaSeeking(IMediaSeeking *iface) +{ + return CONTAINING_RECORD(iface, struct testfilter, IMediaSeeking_iface); +} + +static HRESULT WINAPI testsource_seeking_QueryInterface(IMediaSeeking *iface, REFIID iid, void **out) +{ + struct testfilter *filter = impl_from_IMediaSeeking(iface); + return IBaseFilter_QueryInterface(&filter->filter.IBaseFilter_iface, iid, out); +} + +static ULONG WINAPI testsource_seeking_AddRef(IMediaSeeking *iface) +{ + struct testfilter *filter = impl_from_IMediaSeeking(iface); + return IBaseFilter_AddRef(&filter->filter.IBaseFilter_iface); +} + +static ULONG WINAPI testsource_seeking_Release(IMediaSeeking *iface) +{ + struct testfilter *filter = impl_from_IMediaSeeking(iface); + return IBaseFilter_Release(&filter->filter.IBaseFilter_iface); +} + +static HRESULT WINAPI testsource_seeking_GetCapabilities(IMediaSeeking *iface, DWORD *capabilities) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testsource_seeking_CheckCapabilities(IMediaSeeking *iface, DWORD *capabilities) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testsource_seeking_IsFormatSupported(IMediaSeeking *iface, const GUID *format) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testsource_seeking_QueryPreferredFormat(IMediaSeeking *iface, GUID *format) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testsource_seeking_GetTimeFormat(IMediaSeeking *iface, GUID *format) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testsource_seeking_IsUsingTimeFormat(IMediaSeeking *iface, const GUID *format) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testsource_seeking_SetTimeFormat(IMediaSeeking *iface, const GUID *format) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testsource_seeking_GetDuration(IMediaSeeking *iface, LONGLONG *duration) +{ + struct testfilter *filter = impl_from_IMediaSeeking(iface); + + if (SUCCEEDED(filter->get_duration_hr)) + *duration = 0x8000000000000000ULL; + + return filter->get_duration_hr; +} + +static HRESULT WINAPI testsource_seeking_GetStopPosition(IMediaSeeking *iface, LONGLONG *stop) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testsource_seeking_GetCurrentPosition(IMediaSeeking *iface, LONGLONG *current) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testsource_seeking_ConvertTimeFormat(IMediaSeeking *iface, LONGLONG *target, + const GUID *target_format, LONGLONG source, const GUID *source_format) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testsource_seeking_SetPositions(IMediaSeeking *iface, LONGLONG *current_ptr, DWORD current_flags, + LONGLONG *stop_ptr, DWORD stop_flags) +{ + struct testfilter *filter = impl_from_IMediaSeeking(iface); + + if (SUCCEEDED(filter->set_positions_hr)) + { + if (current_ptr) + filter->current_position = *current_ptr; + + if (stop_ptr) + filter->stop_position = *stop_ptr; + } + + return filter->set_positions_hr; +} + +static HRESULT WINAPI testsource_seeking_GetPositions(IMediaSeeking *iface, LONGLONG *current, LONGLONG *stop) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testsource_seeking_GetAvailable(IMediaSeeking *iface, LONGLONG *earliest, LONGLONG *latest) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testsource_seeking_SetRate(IMediaSeeking *iface, double rate) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testsource_seeking_GetRate(IMediaSeeking *iface, double *rate) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static HRESULT WINAPI testsource_seeking_GetPreroll(IMediaSeeking *iface, LONGLONG *preroll) +{ + ok(0, "Unexpected call.\n"); + return E_NOTIMPL; +} + +static const IMediaSeekingVtbl testsource_seeking_vtbl = +{ + testsource_seeking_QueryInterface, + testsource_seeking_AddRef, + testsource_seeking_Release, + testsource_seeking_GetCapabilities, + testsource_seeking_CheckCapabilities, + testsource_seeking_IsFormatSupported, + testsource_seeking_QueryPreferredFormat, + testsource_seeking_GetTimeFormat, + testsource_seeking_IsUsingTimeFormat, + testsource_seeking_SetTimeFormat, + testsource_seeking_GetDuration, + testsource_seeking_GetStopPosition, + testsource_seeking_GetCurrentPosition, + testsource_seeking_ConvertTimeFormat, + testsource_seeking_SetPositions, + testsource_seeking_GetPositions, + testsource_seeking_GetAvailable, + testsource_seeking_SetRate, + testsource_seeking_GetRate, + testsource_seeking_GetPreroll, +}; + #define check_get_stream(a,b,c,d) check_get_stream_(__LINE__,a,b,c,d) static void check_get_stream_(int line, IAMMultiMediaStream *mmstream, IMediaStreamFilter *filter, const GUID *mspid, IMediaStream *expect) @@ -2186,171 +2459,51 @@ static void test_IDirectDrawStreamSample(void)
error: if (ddraw_stream) - IDirectDrawMediaStream_Release(ddraw_stream); - if (stream) - IMediaStream_Release(stream); - - release_directdraw(); - IAMMultiMediaStream_Release(mmstream); -} - -static IUnknown *create_audio_data(void) -{ - IUnknown *audio_data = NULL; - HRESULT result = CoCreateInstance(&CLSID_AMAudioData, NULL, CLSCTX_INPROC_SERVER, - &IID_IUnknown, (void **)&audio_data); - ok(S_OK == result, "got 0x%08x\n", result); - return audio_data; -} - -static void test_audiodata_query_interface(void) -{ - IUnknown *unknown = create_audio_data(); - IMemoryData *memory_data = NULL; - IAudioData *audio_data = NULL; - - HRESULT result; - - result = IUnknown_QueryInterface(unknown, &IID_IMemoryData, (void **)&memory_data); - ok(E_NOINTERFACE == result, "got 0x%08x\n", result); - - result = IUnknown_QueryInterface(unknown, &IID_IAudioData, (void **)&audio_data); - ok(S_OK == result, "got 0x%08x\n", result); - if (S_OK == result) - { - result = IAudioData_QueryInterface(audio_data, &IID_IMemoryData, (void **)&memory_data); - ok(E_NOINTERFACE == result, "got 0x%08x\n", result); - - IAudioData_Release(audio_data); - } - - IUnknown_Release(unknown); -} - -static void test_audiodata_get_info(void) -{ - IUnknown *unknown = create_audio_data(); - IAudioData *audio_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_GetInfo(audio_data, NULL, NULL, NULL); - ok(MS_E_NOTINIT == result, "got 0x%08x\n", result); - - IAudioData_Release(audio_data); - -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); + IDirectDrawMediaStream_Release(ddraw_stream); + if (stream) + IMediaStream_Release(stream);
- IAudioData_Release(audio_data); + release_directdraw(); + IAMMultiMediaStream_Release(mmstream); +}
-out_unknown: - IUnknown_Release(unknown); +static IUnknown *create_audio_data(void) +{ + IUnknown *audio_data = NULL; + HRESULT result = CoCreateInstance(&CLSID_AMAudioData, NULL, CLSCTX_INPROC_SERVER, + &IID_IUnknown, (void **)&audio_data); + ok(S_OK == result, "got 0x%08x\n", result); + return audio_data; }
-static void test_audiodata_set_actual(void) +static void test_audiodata_query_interface(void) { IUnknown *unknown = create_audio_data(); + IMemoryData *memory_data = NULL; IAudioData *audio_data = NULL; - BYTE buffer[100] = {0}; - DWORD actual_data = 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_SetActual(audio_data, 0); - ok(S_OK == result, "got 0x%08x\n", result); - - result = IAudioData_SetBuffer(audio_data, sizeof(buffer), buffer, 0); - ok(S_OK == result, "got 0x%08x\n", result); - - result = IAudioData_SetActual(audio_data, sizeof(buffer) + 1); - ok(E_INVALIDARG == result, "got 0x%08x\n", result); - - result = IAudioData_SetActual(audio_data, sizeof(buffer)); - ok(S_OK == result, "got 0x%08x\n", result); - - actual_data = 0xdeadbeef; - result = IAudioData_GetInfo(audio_data, NULL, NULL, &actual_data); - ok(S_OK == result, "got 0x%08x\n", result); - ok(sizeof(buffer) == actual_data, "got %u\n", actual_data); - - result = IAudioData_SetActual(audio_data, 0); - ok(S_OK == result, "got 0x%08x\n", result); + result = IUnknown_QueryInterface(unknown, &IID_IMemoryData, (void **)&memory_data); + ok(E_NOINTERFACE == result, "got 0x%08x\n", result);
- actual_data = 0xdeadbeef; - result = IAudioData_GetInfo(audio_data, NULL, NULL, &actual_data); + result = IUnknown_QueryInterface(unknown, &IID_IAudioData, (void **)&audio_data); ok(S_OK == result, "got 0x%08x\n", result); - ok(0 == actual_data, "got %u\n", actual_data); + if (S_OK == result) + { + result = IAudioData_QueryInterface(audio_data, &IID_IMemoryData, (void **)&memory_data); + ok(E_NOINTERFACE == result, "got 0x%08x\n", result);
- IAudioData_Release(audio_data); + IAudioData_Release(audio_data); + }
-out_unknown: IUnknown_Release(unknown); }
-static void test_audiodata_get_format(void) +static void test_audiodata_get_info(void) { IUnknown *unknown = create_audio_data(); IAudioData *audio_data = NULL; - WAVEFORMATEX wave_format = {0};
HRESULT result;
@@ -2362,25 +2515,8 @@ static void test_audiodata_get_format(void) goto out_unknown; }
- result = IAudioData_GetFormat(audio_data, NULL); - ok(E_POINTER == result, "got 0x%08x\n", result); - - wave_format.wFormatTag = 0xdead; - wave_format.nChannels = 0xdead; - wave_format.nSamplesPerSec = 0xdeadbeef; - wave_format.nAvgBytesPerSec = 0xdeadbeef; - wave_format.nBlockAlign = 0xdead; - wave_format.wBitsPerSample = 0xdead; - wave_format.cbSize = 0xdead; - result = IAudioData_GetFormat(audio_data, &wave_format); - ok(S_OK == result, "got 0x%08x\n", result); - ok(WAVE_FORMAT_PCM == wave_format.wFormatTag, "got %u\n", wave_format.wFormatTag); - ok(1 == wave_format.nChannels, "got %u\n", wave_format.nChannels); - ok(11025 == wave_format.nSamplesPerSec, "got %u\n", wave_format.nSamplesPerSec); - ok(22050 == wave_format.nAvgBytesPerSec, "got %u\n", wave_format.nAvgBytesPerSec); - ok(2 == wave_format.nBlockAlign, "got %u\n", wave_format.nBlockAlign); - ok(16 == wave_format.wBitsPerSample, "got %u\n", wave_format.wBitsPerSample); - ok(0 == wave_format.cbSize, "got %u\n", wave_format.cbSize); + result = IAudioData_GetInfo(audio_data, NULL, NULL, NULL); + ok(MS_E_NOTINIT == result, "got 0x%08x\n", result);
IAudioData_Release(audio_data);
@@ -2388,11 +2524,13 @@ out_unknown: IUnknown_Release(unknown); }
-static void test_audiodata_set_format(void) +static void test_audiodata_set_buffer(void) { IUnknown *unknown = create_audio_data(); IAudioData *audio_data = NULL; - WAVEFORMATPCMEX wave_format = {{0}}; + BYTE buffer[100] = {0}; + DWORD length = 0; + BYTE *data = NULL;
HRESULT result;
@@ -2404,328 +2542,190 @@ static void test_audiodata_set_format(void) goto out_unknown; }
- result = IAudioData_SetFormat(audio_data, NULL); - ok(E_POINTER == result, "got 0x%08x\n", result); + result = IAudioData_SetBuffer(audio_data, 100, NULL, 0); + ok(S_OK == 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); + 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);
- 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); + result = IAudioData_SetBuffer(audio_data, sizeof(buffer), buffer, 0); 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); + data = (BYTE *)0xdeadbeef; + length = 0xdeadbeef; + result = IAudioData_GetInfo(audio_data, &length, &data, NULL); 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); + ok(sizeof(buffer) == length, "got %u\n", length); + ok(buffer == data, "got %p\n", data);
IAudioData_Release(audio_data);
-out_unknown: - IUnknown_Release(unknown); -} - -struct testfilter -{ - struct strmbase_filter filter; - struct strmbase_source source; - IMediaSeeking IMediaSeeking_iface; - LONGLONG current_position; - LONGLONG stop_position; - HRESULT get_duration_hr; - HRESULT set_positions_hr; -}; - -static inline struct testfilter *impl_from_BaseFilter(struct strmbase_filter *iface) -{ - return CONTAINING_RECORD(iface, struct testfilter, filter); -} - -static struct strmbase_pin *testfilter_get_pin(struct strmbase_filter *iface, unsigned int index) -{ - struct testfilter *filter = impl_from_BaseFilter(iface); - if (!index) - return &filter->source.pin; - return NULL; -} - -static void testfilter_destroy(struct strmbase_filter *iface) -{ - struct testfilter *filter = impl_from_BaseFilter(iface); - strmbase_source_cleanup(&filter->source); - strmbase_filter_cleanup(&filter->filter); -} - -static HRESULT testfilter_init_stream(struct strmbase_filter *iface) -{ - struct testfilter *filter = impl_from_BaseFilter(iface); - - BaseOutputPinImpl_Active(&filter->source); - return S_OK; -} - -static HRESULT testfilter_cleanup_stream(struct strmbase_filter *iface) -{ - struct testfilter *filter = impl_from_BaseFilter(iface); - - BaseOutputPinImpl_Inactive(&filter->source); - return S_OK; -} - -static const struct strmbase_filter_ops testfilter_ops = -{ - .filter_get_pin = testfilter_get_pin, - .filter_destroy = testfilter_destroy, - .filter_init_stream = testfilter_init_stream, - .filter_cleanup_stream = testfilter_cleanup_stream, -}; - -static inline struct testfilter *impl_from_base_pin(struct strmbase_pin *iface) -{ - return CONTAINING_RECORD(iface, struct testfilter, source.pin); -} - -static HRESULT testsource_query_interface(struct strmbase_pin *iface, REFIID iid, void **out) -{ - struct testfilter *filter = impl_from_base_pin(iface); - - if (IsEqualGUID(iid, &IID_IMediaSeeking) && filter->IMediaSeeking_iface.lpVtbl) - *out = &filter->IMediaSeeking_iface; - else - return E_NOINTERFACE; - - IUnknown_AddRef((IUnknown *)*out); - - return S_OK; -} - -static HRESULT WINAPI testsource_DecideBufferSize(struct strmbase_source *iface, - IMemAllocator *alloc, ALLOCATOR_PROPERTIES *requested) -{ - ALLOCATOR_PROPERTIES actual; - - if (!requested->cbAlign) - requested->cbAlign = 1; - - if (requested->cbBuffer < 4096) - requested->cbBuffer = 4096; - - if (!requested->cBuffers) - requested->cBuffers = 2; - - return IMemAllocator_SetProperties(alloc, requested, &actual); -} - -static const struct strmbase_source_ops testsource_ops = -{ - .base.pin_query_interface = testsource_query_interface, - .pfnAttemptConnection = BaseOutputPinImpl_AttemptConnection, - .pfnDecideBufferSize = testsource_DecideBufferSize, - .pfnDecideAllocator = BaseOutputPinImpl_DecideAllocator, -}; - -static void testfilter_init(struct testfilter *filter) -{ - static const GUID clsid = {0xabacab}; - memset(filter, 0, sizeof(*filter)); - strmbase_filter_init(&filter->filter, NULL, &clsid, &testfilter_ops); - strmbase_source_init(&filter->source, &filter->filter, L"", &testsource_ops); - filter->stop_position = 0x8000000000000000ULL; -} - -static inline struct testfilter *impl_from_IMediaSeeking(IMediaSeeking *iface) -{ - return CONTAINING_RECORD(iface, struct testfilter, IMediaSeeking_iface); +out_unknown: + IUnknown_Release(unknown); }
-static HRESULT WINAPI testsource_seeking_QueryInterface(IMediaSeeking *iface, REFIID iid, void **out) +static void test_audiodata_set_actual(void) { - struct testfilter *filter = impl_from_IMediaSeeking(iface); - return IBaseFilter_QueryInterface(&filter->filter.IBaseFilter_iface, iid, out); -} + IUnknown *unknown = create_audio_data(); + IAudioData *audio_data = NULL; + BYTE buffer[100] = {0}; + DWORD actual_data = 0;
-static ULONG WINAPI testsource_seeking_AddRef(IMediaSeeking *iface) -{ - struct testfilter *filter = impl_from_IMediaSeeking(iface); - return IBaseFilter_AddRef(&filter->filter.IBaseFilter_iface); -} + HRESULT result;
-static ULONG WINAPI testsource_seeking_Release(IMediaSeeking *iface) -{ - struct testfilter *filter = impl_from_IMediaSeeking(iface); - return IBaseFilter_Release(&filter->filter.IBaseFilter_iface); -} + 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; + }
-static HRESULT WINAPI testsource_seeking_GetCapabilities(IMediaSeeking *iface, DWORD *capabilities) -{ - ok(0, "Unexpected call.\n"); - return E_NOTIMPL; -} + result = IAudioData_SetActual(audio_data, 0); + ok(S_OK == result, "got 0x%08x\n", result);
-static HRESULT WINAPI testsource_seeking_CheckCapabilities(IMediaSeeking *iface, DWORD *capabilities) -{ - ok(0, "Unexpected call.\n"); - return E_NOTIMPL; -} + result = IAudioData_SetBuffer(audio_data, sizeof(buffer), buffer, 0); + ok(S_OK == result, "got 0x%08x\n", result);
-static HRESULT WINAPI testsource_seeking_IsFormatSupported(IMediaSeeking *iface, const GUID *format) -{ - ok(0, "Unexpected call.\n"); - return E_NOTIMPL; -} + result = IAudioData_SetActual(audio_data, sizeof(buffer) + 1); + ok(E_INVALIDARG == result, "got 0x%08x\n", result);
-static HRESULT WINAPI testsource_seeking_QueryPreferredFormat(IMediaSeeking *iface, GUID *format) -{ - ok(0, "Unexpected call.\n"); - return E_NOTIMPL; -} + result = IAudioData_SetActual(audio_data, sizeof(buffer)); + ok(S_OK == result, "got 0x%08x\n", result);
-static HRESULT WINAPI testsource_seeking_GetTimeFormat(IMediaSeeking *iface, GUID *format) -{ - ok(0, "Unexpected call.\n"); - return E_NOTIMPL; -} + actual_data = 0xdeadbeef; + result = IAudioData_GetInfo(audio_data, NULL, NULL, &actual_data); + ok(S_OK == result, "got 0x%08x\n", result); + ok(sizeof(buffer) == actual_data, "got %u\n", actual_data);
-static HRESULT WINAPI testsource_seeking_IsUsingTimeFormat(IMediaSeeking *iface, const GUID *format) -{ - ok(0, "Unexpected call.\n"); - return E_NOTIMPL; -} + result = IAudioData_SetActual(audio_data, 0); + ok(S_OK == result, "got 0x%08x\n", result);
-static HRESULT WINAPI testsource_seeking_SetTimeFormat(IMediaSeeking *iface, const GUID *format) -{ - ok(0, "Unexpected call.\n"); - return E_NOTIMPL; + actual_data = 0xdeadbeef; + result = IAudioData_GetInfo(audio_data, NULL, NULL, &actual_data); + ok(S_OK == result, "got 0x%08x\n", result); + ok(0 == actual_data, "got %u\n", actual_data); + + IAudioData_Release(audio_data); + +out_unknown: + IUnknown_Release(unknown); }
-static HRESULT WINAPI testsource_seeking_GetDuration(IMediaSeeking *iface, LONGLONG *duration) +static void test_audiodata_get_format(void) { - struct testfilter *filter = impl_from_IMediaSeeking(iface); + IUnknown *unknown = create_audio_data(); + IAudioData *audio_data = NULL; + WAVEFORMATEX wave_format = {0};
- if (SUCCEEDED(filter->get_duration_hr)) - *duration = 0x8000000000000000ULL; + HRESULT result;
- return filter->get_duration_hr; -} + 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; + }
-static HRESULT WINAPI testsource_seeking_GetStopPosition(IMediaSeeking *iface, LONGLONG *stop) -{ - ok(0, "Unexpected call.\n"); - return E_NOTIMPL; -} + result = IAudioData_GetFormat(audio_data, NULL); + ok(E_POINTER == result, "got 0x%08x\n", result);
-static HRESULT WINAPI testsource_seeking_GetCurrentPosition(IMediaSeeking *iface, LONGLONG *current) -{ - ok(0, "Unexpected call.\n"); - return E_NOTIMPL; -} + wave_format.wFormatTag = 0xdead; + wave_format.nChannels = 0xdead; + wave_format.nSamplesPerSec = 0xdeadbeef; + wave_format.nAvgBytesPerSec = 0xdeadbeef; + wave_format.nBlockAlign = 0xdead; + wave_format.wBitsPerSample = 0xdead; + wave_format.cbSize = 0xdead; + result = IAudioData_GetFormat(audio_data, &wave_format); + ok(S_OK == result, "got 0x%08x\n", result); + ok(WAVE_FORMAT_PCM == wave_format.wFormatTag, "got %u\n", wave_format.wFormatTag); + ok(1 == wave_format.nChannels, "got %u\n", wave_format.nChannels); + ok(11025 == wave_format.nSamplesPerSec, "got %u\n", wave_format.nSamplesPerSec); + ok(22050 == wave_format.nAvgBytesPerSec, "got %u\n", wave_format.nAvgBytesPerSec); + ok(2 == wave_format.nBlockAlign, "got %u\n", wave_format.nBlockAlign); + ok(16 == wave_format.wBitsPerSample, "got %u\n", wave_format.wBitsPerSample); + ok(0 == wave_format.cbSize, "got %u\n", wave_format.cbSize);
-static HRESULT WINAPI testsource_seeking_ConvertTimeFormat(IMediaSeeking *iface, LONGLONG *target, - const GUID *target_format, LONGLONG source, const GUID *source_format) -{ - ok(0, "Unexpected call.\n"); - return E_NOTIMPL; + IAudioData_Release(audio_data); + +out_unknown: + IUnknown_Release(unknown); }
-static HRESULT WINAPI testsource_seeking_SetPositions(IMediaSeeking *iface, LONGLONG *current_ptr, DWORD current_flags, - LONGLONG *stop_ptr, DWORD stop_flags) +static void test_audiodata_set_format(void) { - struct testfilter *filter = impl_from_IMediaSeeking(iface); + IUnknown *unknown = create_audio_data(); + IAudioData *audio_data = NULL; + WAVEFORMATPCMEX wave_format = {{0}};
- if (SUCCEEDED(filter->set_positions_hr)) - { - if (current_ptr) - filter->current_position = *current_ptr; + HRESULT result;
- if (stop_ptr) - filter->stop_position = *stop_ptr; + 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; }
- return filter->set_positions_hr; -} + result = IAudioData_SetFormat(audio_data, NULL); + ok(E_POINTER == result, "got 0x%08x\n", result);
-static HRESULT WINAPI testsource_seeking_GetPositions(IMediaSeeking *iface, LONGLONG *current, LONGLONG *stop) -{ - ok(0, "Unexpected call.\n"); - return E_NOTIMPL; -} + 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);
-static HRESULT WINAPI testsource_seeking_GetAvailable(IMediaSeeking *iface, LONGLONG *earliest, LONGLONG *latest) -{ - ok(0, "Unexpected call.\n"); - return E_NOTIMPL; -} + 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);
-static HRESULT WINAPI testsource_seeking_SetRate(IMediaSeeking *iface, double rate) -{ - ok(0, "Unexpected call.\n"); - return E_NOTIMPL; -} + 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);
-static HRESULT WINAPI testsource_seeking_GetRate(IMediaSeeking *iface, double *rate) -{ - ok(0, "Unexpected call.\n"); - return E_NOTIMPL; -} + IAudioData_Release(audio_data);
-static HRESULT WINAPI testsource_seeking_GetPreroll(IMediaSeeking *iface, LONGLONG *preroll) -{ - ok(0, "Unexpected call.\n"); - return E_NOTIMPL; +out_unknown: + IUnknown_Release(unknown); }
-static const IMediaSeekingVtbl testsource_seeking_vtbl = -{ - testsource_seeking_QueryInterface, - testsource_seeking_AddRef, - testsource_seeking_Release, - testsource_seeking_GetCapabilities, - testsource_seeking_CheckCapabilities, - testsource_seeking_IsFormatSupported, - testsource_seeking_QueryPreferredFormat, - testsource_seeking_GetTimeFormat, - testsource_seeking_IsUsingTimeFormat, - testsource_seeking_SetTimeFormat, - testsource_seeking_GetDuration, - testsource_seeking_GetStopPosition, - testsource_seeking_GetCurrentPosition, - testsource_seeking_ConvertTimeFormat, - testsource_seeking_SetPositions, - testsource_seeking_GetPositions, - testsource_seeking_GetAvailable, - testsource_seeking_SetRate, - testsource_seeking_GetRate, - testsource_seeking_GetPreroll, -}; - struct testclock { IReferenceClock IReferenceClock_iface;