Anton Baskanov : quartz/tests: Add tests for MPEG audio decoder source allocator.
Alexandre Julliard
julliard at winehq.org
Mon May 2 16:02:11 CDT 2022
Module: wine
Branch: master
Commit: 7c20724b0d29cee02010a3114575315b9fc9d439
URL: https://source.winehq.org/git/wine.git/?a=commit;h=7c20724b0d29cee02010a3114575315b9fc9d439
Author: Anton Baskanov <baskanov at gmail.com>
Date: Mon May 2 19:28:26 2022 +0700
quartz/tests: Add tests for MPEG audio decoder source allocator.
Signed-off-by: Anton Baskanov <baskanov at gmail.com>
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/quartz/tests/mpegaudio.c | 136 +++++++++++++++++++++++++++++++++++++++++-
1 file changed, 135 insertions(+), 1 deletion(-)
diff --git a/dlls/quartz/tests/mpegaudio.c b/dlls/quartz/tests/mpegaudio.c
index 19765fe5b2b..acbe5f30c11 100644
--- a/dlls/quartz/tests/mpegaudio.c
+++ b/dlls/quartz/tests/mpegaudio.c
@@ -832,6 +832,7 @@ struct testfilter
{
struct strmbase_filter filter;
struct strmbase_source source;
+ struct strmbase_sink sink;
const AM_MEDIA_TYPE *mt;
};
@@ -852,6 +853,7 @@ static void testfilter_destroy(struct strmbase_filter *iface)
{
struct testfilter *filter = impl_from_strmbase_filter(iface);
strmbase_source_cleanup(&filter->source);
+ strmbase_sink_cleanup(&filter->sink);
strmbase_filter_cleanup(&filter->filter);
}
@@ -873,12 +875,31 @@ static const struct strmbase_source_ops testsource_ops =
.pfnDecideAllocator = testsource_DecideAllocator,
};
+static HRESULT testsink_query_interface(struct strmbase_pin *iface, REFIID iid, void **out)
+{
+ struct testfilter *filter = impl_from_strmbase_filter(iface->filter);
+
+ if (IsEqualGUID(iid, &IID_IMemInputPin))
+ *out = &filter->sink.IMemInputPin_iface;
+ else
+ return E_NOINTERFACE;
+
+ IUnknown_AddRef((IUnknown *)*out);
+ return S_OK;
+}
+
+static const struct strmbase_sink_ops testsink_ops =
+{
+ .base.pin_query_interface = testsink_query_interface,
+};
+
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"source", &testsource_ops);
+ strmbase_sink_init(&filter->sink, &filter->filter, L"sink", &testsink_ops, NULL);
}
static void test_sink_allocator(IMemInputPin *input)
@@ -931,10 +952,117 @@ static void test_sink_allocator(IMemInputPin *input)
IMemAllocator_Release(ret_allocator);
}
+static void test_source_allocator(IFilterGraph2 *graph, IMediaControl *control,
+ IPin *sink, IPin *source, struct testfilter *testsource, struct testfilter *testsink)
+{
+ ALLOCATOR_PROPERTIES props, req_props = {2, 30000, 32, 0};
+ IMemAllocator *allocator;
+ IMediaSample *sample;
+ WAVEFORMATEX format;
+ AM_MEDIA_TYPE mt;
+ HRESULT hr;
+
+ hr = IFilterGraph2_ConnectDirect(graph, &testsource->source.pin.IPin_iface, sink, &mp2_mt);
+ ok(hr == S_OK, "Got hr %#lx.\n", hr);
+
+ init_pcm_mt(&mt, &format, 1, 32000, 16);
+ hr = IFilterGraph2_ConnectDirect(graph, source, &testsink->sink.pin.IPin_iface, &mt);
+ ok(hr == S_OK, "Got hr %#lx.\n", hr);
+
+ ok(!!testsink->sink.pAllocator, "Expected an allocator.\n");
+ hr = IMemAllocator_GetProperties(testsink->sink.pAllocator, &props);
+ ok(hr == S_OK, "Got hr %#lx.\n", hr);
+ ok(props.cBuffers == 8, "Got %ld buffers.\n", props.cBuffers);
+ ok(props.cbBuffer == 9216, "Got size %ld.\n", props.cbBuffer);
+ ok(props.cbAlign == 1, "Got alignment %ld.\n", props.cbAlign);
+ ok(!props.cbPrefix, "Got prefix %ld.\n", props.cbPrefix);
+
+ hr = IMemAllocator_GetBuffer(testsink->sink.pAllocator, &sample, NULL, NULL, 0);
+ ok(hr == VFW_E_NOT_COMMITTED, "Got hr %#lx.\n", hr);
+
+ hr = IMediaControl_Pause(control);
+ ok(hr == S_OK, "Got hr %#lx.\n", hr);
+
+ hr = IMemAllocator_GetBuffer(testsink->sink.pAllocator, &sample, NULL, NULL, 0);
+ todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr);
+ if (hr == S_OK)
+ IMediaSample_Release(sample);
+
+ hr = IMediaControl_Stop(control);
+ ok(hr == S_OK, "Got hr %#lx.\n", hr);
+
+ hr = IMemAllocator_GetBuffer(testsink->sink.pAllocator, &sample, NULL, NULL, 0);
+ ok(hr == VFW_E_NOT_COMMITTED, "Got hr %#lx.\n", hr);
+
+ IFilterGraph2_Disconnect(graph, source);
+ IFilterGraph2_Disconnect(graph, &testsink->sink.pin.IPin_iface);
+
+ init_pcm_mt(&mt, &format, 1, 32000, 8);
+ hr = IFilterGraph2_ConnectDirect(graph, source, &testsink->sink.pin.IPin_iface, &mt);
+ ok(hr == S_OK, "Got hr %#lx.\n", hr);
+
+ ok(!!testsink->sink.pAllocator, "Expected an allocator.\n");
+ hr = IMemAllocator_GetProperties(testsink->sink.pAllocator, &props);
+ ok(hr == S_OK, "Got hr %#lx.\n", hr);
+ ok(props.cBuffers == 8, "Got %ld buffers.\n", props.cBuffers);
+ ok(props.cbBuffer == 4608, "Got size %ld.\n", props.cbBuffer);
+ ok(props.cbAlign == 1, "Got alignment %ld.\n", props.cbAlign);
+ ok(!props.cbPrefix, "Got prefix %ld.\n", props.cbPrefix);
+
+ IFilterGraph2_Disconnect(graph, source);
+ IFilterGraph2_Disconnect(graph, &testsink->sink.pin.IPin_iface);
+
+ CoCreateInstance(&CLSID_MemoryAllocator, NULL, CLSCTX_INPROC_SERVER,
+ &IID_IMemAllocator, (void **)&allocator);
+ testsink->sink.pAllocator = allocator;
+
+ hr = IMemAllocator_SetProperties(allocator, &req_props, &props);
+ ok(hr == S_OK, "Got hr %#lx.\n", hr);
+
+ init_pcm_mt(&mt, &format, 1, 32000, 16);
+ hr = IFilterGraph2_ConnectDirect(graph, source, &testsink->sink.pin.IPin_iface, &mt);
+ ok(hr == S_OK, "Got hr %#lx.\n", hr);
+
+ ok(testsink->sink.pAllocator == allocator, "Expected an allocator.\n");
+ hr = IMemAllocator_GetProperties(testsink->sink.pAllocator, &props);
+ ok(hr == S_OK, "Got hr %#lx.\n", hr);
+ ok(props.cBuffers == 8, "Got %ld buffers.\n", props.cBuffers);
+ ok(props.cbBuffer == 9216, "Got size %ld.\n", props.cbBuffer);
+ ok(props.cbAlign == 1, "Got alignment %ld.\n", props.cbAlign);
+ ok(!props.cbPrefix, "Got prefix %ld.\n", props.cbPrefix);
+
+ IFilterGraph2_Disconnect(graph, source);
+ IFilterGraph2_Disconnect(graph, &testsink->sink.pin.IPin_iface);
+
+ IFilterGraph2_Disconnect(graph, sink);
+ IFilterGraph2_Disconnect(graph, &testsource->source.pin.IPin_iface);
+
+ hr = IFilterGraph2_ConnectDirect(graph, &testsource->source.pin.IPin_iface, sink, &mp1_mt);
+ ok(hr == S_OK, "Got hr %#lx.\n", hr);
+
+ init_pcm_mt(&mt, &format, 1, 32000, 16);
+ hr = IFilterGraph2_ConnectDirect(graph, source, &testsink->sink.pin.IPin_iface, &mt);
+ ok(hr == S_OK, "Got hr %#lx.\n", hr);
+
+ ok(!!testsink->sink.pAllocator, "Expected an allocator.\n");
+ hr = IMemAllocator_GetProperties(testsink->sink.pAllocator, &props);
+ ok(hr == S_OK, "Got hr %#lx.\n", hr);
+ ok(props.cBuffers == 8, "Got %ld buffers.\n", props.cBuffers);
+ ok(props.cbBuffer == 3072, "Got size %ld.\n", props.cbBuffer);
+ ok(props.cbAlign == 1, "Got alignment %ld.\n", props.cbAlign);
+ ok(!props.cbPrefix, "Got prefix %ld.\n", props.cbPrefix);
+
+ IFilterGraph2_Disconnect(graph, source);
+ IFilterGraph2_Disconnect(graph, &testsink->sink.pin.IPin_iface);
+
+ IFilterGraph2_Disconnect(graph, sink);
+ IFilterGraph2_Disconnect(graph, &testsource->source.pin.IPin_iface);
+}
+
static void test_connect_pin(void)
{
IBaseFilter *filter = create_mpeg_audio_codec();
- struct testfilter testsource;
+ struct testfilter testsource, testsink;
IPin *sink, *source, *peer;
IEnumMediaTypes *enummt;
WAVEFORMATEX req_format;
@@ -950,6 +1078,8 @@ static void test_connect_pin(void)
CoCreateInstance(&CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
&IID_IFilterGraph2, (void **)&graph);
testfilter_init(&testsource);
+ testfilter_init(&testsink);
+ IFilterGraph2_AddFilter(graph, &testsink.filter.IBaseFilter_iface, L"sink");
IFilterGraph2_AddFilter(graph, &testsource.filter.IBaseFilter_iface, L"source");
IFilterGraph2_AddFilter(graph, filter, L"MPEG audio decoder");
IBaseFilter_FindPin(filter, L"In", &sink);
@@ -957,6 +1087,8 @@ static void test_connect_pin(void)
IPin_QueryInterface(sink, &IID_IMemInputPin, (void **)&meminput);
IFilterGraph2_QueryInterface(graph, &IID_IMediaControl, (void **)&control);
+ test_source_allocator(graph, control, sink, source, &testsource, &testsink);
+
/* Test sink connection. */
peer = (IPin *)0xdeadbeef;
@@ -1087,6 +1219,8 @@ static void test_connect_pin(void)
ok(!ref, "Got outstanding refcount %ld.\n", ref);
ref = IBaseFilter_Release(&testsource.filter.IBaseFilter_iface);
ok(!ref, "Got outstanding refcount %ld.\n", ref);
+ ref = IBaseFilter_Release(&testsink.filter.IBaseFilter_iface);
+ ok(!ref, "Got outstanding refcount %ld.\n", ref);
}
START_TEST(mpegaudio)
More information about the wine-cvs
mailing list