quartz/tests: Pass an IMediaControl to some functions.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2020-11-17 11:37:50 -06:00 committed by Alexandre Julliard
parent 6a1a8bdf35
commit f35e5c4de2
3 changed files with 28 additions and 54 deletions

View File

@ -746,14 +746,11 @@ static HRESULT send_frame(IMemInputPin *sink)
return ret; return ret;
} }
static void test_filter_state(IMemInputPin *input, IFilterGraph2 *graph) static void test_filter_state(IMemInputPin *input, IMediaControl *control)
{ {
IMediaControl *control;
OAFilterState state; OAFilterState state;
HRESULT hr; HRESULT hr;
IFilterGraph2_QueryInterface(graph, &IID_IMediaControl, (void **)&control);
hr = send_frame(input); hr = send_frame(input);
ok(hr == VFW_E_WRONG_STATE, "Got hr %#x.\n", hr); ok(hr == VFW_E_WRONG_STATE, "Got hr %#x.\n", hr);
@ -833,8 +830,6 @@ static void test_filter_state(IMemInputPin *input, IFilterGraph2 *graph)
/* The DirectSound renderer will silently refuse to transition to running /* The DirectSound renderer will silently refuse to transition to running
* if it hasn't finished pausing yet. Once it does it reports itself as * if it hasn't finished pausing yet. Once it does it reports itself as
* completely paused. */ * completely paused. */
IMediaControl_Release(control);
} }
static void test_connect_pin(void) static void test_connect_pin(void)
@ -860,6 +855,7 @@ static void test_connect_pin(void)
IBaseFilter *filter = create_dsound_render(); IBaseFilter *filter = create_dsound_render();
struct testfilter source; struct testfilter source;
IMemAllocator *allocator; IMemAllocator *allocator;
IMediaControl *control;
IFilterGraph2 *graph; IFilterGraph2 *graph;
IMemInputPin *input; IMemInputPin *input;
AM_MEDIA_TYPE mt; AM_MEDIA_TYPE mt;
@ -872,6 +868,7 @@ static void test_connect_pin(void)
CoCreateInstance(&CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, &IID_IFilterGraph2, (void **)&graph); CoCreateInstance(&CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, &IID_IFilterGraph2, (void **)&graph);
IFilterGraph2_AddFilter(graph, &source.filter.IBaseFilter_iface, L"source"); IFilterGraph2_AddFilter(graph, &source.filter.IBaseFilter_iface, L"source");
IFilterGraph2_AddFilter(graph, filter, L"sink"); IFilterGraph2_AddFilter(graph, filter, L"sink");
IFilterGraph2_QueryInterface(graph, &IID_IMediaControl, (void **)&control);
IBaseFilter_FindPin(filter, sink_id, &pin); IBaseFilter_FindPin(filter, sink_id, &pin);
@ -913,7 +910,7 @@ static void test_connect_pin(void)
hr = IMemInputPin_ReceiveCanBlock(input); hr = IMemInputPin_ReceiveCanBlock(input);
ok(hr == S_OK, "Got hr %#x.\n", hr); ok(hr == S_OK, "Got hr %#x.\n", hr);
test_filter_state(input, graph); test_filter_state(input, control);
hr = IFilterGraph2_Disconnect(graph, pin); hr = IFilterGraph2_Disconnect(graph, pin);
ok(hr == S_OK, "Got hr %#x.\n", hr); ok(hr == S_OK, "Got hr %#x.\n", hr);
@ -934,6 +931,7 @@ static void test_connect_pin(void)
ok(!ref, "Got outstanding refcount %d.\n", ref); ok(!ref, "Got outstanding refcount %d.\n", ref);
IMemInputPin_Release(input); IMemInputPin_Release(input);
IPin_Release(pin); IPin_Release(pin);
IMediaControl_Release(control);
ref = IFilterGraph2_Release(graph); ref = IFilterGraph2_Release(graph);
ok(!ref, "Got outstanding refcount %d.\n", ref); ok(!ref, "Got outstanding refcount %d.\n", ref);
ref = IBaseFilter_Release(filter); ref = IBaseFilter_Release(filter);

View File

@ -823,17 +823,14 @@ static HRESULT join_thread_(int line, HANDLE thread)
} }
#define join_thread(a) join_thread_(__LINE__, a) #define join_thread(a) join_thread_(__LINE__, a)
static void test_filter_state(IMemInputPin *input, IFilterGraph2 *graph) static void test_filter_state(IMemInputPin *input, IMediaControl *control)
{ {
IMemAllocator *allocator; IMemAllocator *allocator;
IMediaControl *control;
IMediaSample *sample; IMediaSample *sample;
OAFilterState state; OAFilterState state;
HANDLE thread; HANDLE thread;
HRESULT hr; HRESULT hr;
IFilterGraph2_QueryInterface(graph, &IID_IMediaControl, (void **)&control);
thread = send_frame(input); thread = send_frame(input);
hr = join_thread(thread); hr = join_thread(thread);
todo_wine ok(hr == E_FAIL, "Got hr %#x.\n", hr); todo_wine ok(hr == E_FAIL, "Got hr %#x.\n", hr);
@ -961,18 +958,14 @@ static void test_filter_state(IMemInputPin *input, IFilterGraph2 *graph)
ok(hr == S_OK, "Got hr %#x.\n", hr); ok(hr == S_OK, "Got hr %#x.\n", hr);
IMemAllocator_Release(allocator); IMemAllocator_Release(allocator);
IMediaControl_Release(control);
} }
static void test_flushing(IPin *pin, IMemInputPin *input, IFilterGraph2 *graph) static void test_flushing(IPin *pin, IMemInputPin *input, IMediaControl *control)
{ {
IMediaControl *control;
OAFilterState state; OAFilterState state;
HANDLE thread; HANDLE thread;
HRESULT hr; HRESULT hr;
IFilterGraph2_QueryInterface(graph, &IID_IMediaControl, (void **)&control);
hr = IMediaControl_Pause(control); hr = IMediaControl_Pause(control);
ok(hr == S_FALSE, "Got hr %#x.\n", hr); ok(hr == S_FALSE, "Got hr %#x.\n", hr);
@ -1022,20 +1015,16 @@ static void test_flushing(IPin *pin, IMemInputPin *input, IFilterGraph2 *graph)
hr = IMediaControl_Stop(control); hr = IMediaControl_Stop(control);
ok(hr == S_OK, "Got hr %#x.\n", hr); ok(hr == S_OK, "Got hr %#x.\n", hr);
IMediaControl_Release(control);
} }
static void test_sample_time(IBaseFilter *filter, IPin *pin, IMemInputPin *input, IFilterGraph2 *graph) static void test_sample_time(IBaseFilter *filter, IPin *pin, IMemInputPin *input, IMediaControl *control)
{ {
IMediaControl *control;
IMediaSeeking *seeking; IMediaSeeking *seeking;
REFERENCE_TIME time; REFERENCE_TIME time;
OAFilterState state; OAFilterState state;
HANDLE thread; HANDLE thread;
HRESULT hr; HRESULT hr;
IFilterGraph2_QueryInterface(graph, &IID_IMediaControl, (void **)&control);
IBaseFilter_QueryInterface(filter, &IID_IMediaSeeking, (void **)&seeking); IBaseFilter_QueryInterface(filter, &IID_IMediaSeeking, (void **)&seeking);
hr = IMediaControl_Pause(control); hr = IMediaControl_Pause(control);
@ -1108,7 +1097,6 @@ static void test_sample_time(IBaseFilter *filter, IPin *pin, IMemInputPin *input
ok(hr == S_OK, "Got hr %#x.\n", hr); ok(hr == S_OK, "Got hr %#x.\n", hr);
IMediaSeeking_Release(seeking); IMediaSeeking_Release(seeking);
IMediaControl_Release(control);
} }
static unsigned int check_ec_complete(IMediaEvent *eventsrc, DWORD timeout) static unsigned int check_ec_complete(IMediaEvent *eventsrc, DWORD timeout)
@ -1134,16 +1122,14 @@ static unsigned int check_ec_complete(IMediaEvent *eventsrc, DWORD timeout)
return ret; return ret;
} }
static void test_eos(IPin *pin, IMemInputPin *input, IFilterGraph2 *graph) static void test_eos(IPin *pin, IMemInputPin *input, IMediaControl *control)
{ {
IMediaControl *control;
IMediaEvent *eventsrc; IMediaEvent *eventsrc;
OAFilterState state; OAFilterState state;
HRESULT hr; HRESULT hr;
BOOL ret; BOOL ret;
IFilterGraph2_QueryInterface(graph, &IID_IMediaControl, (void **)&control); IMediaControl_QueryInterface(control, &IID_IMediaEvent, (void **)&eventsrc);
IFilterGraph2_QueryInterface(graph, &IID_IMediaEvent, (void **)&eventsrc);
hr = IMediaControl_Pause(control); hr = IMediaControl_Pause(control);
ok(hr == S_FALSE, "Got hr %#x.\n", hr); ok(hr == S_FALSE, "Got hr %#x.\n", hr);
@ -1246,15 +1232,13 @@ static void test_eos(IPin *pin, IMemInputPin *input, IFilterGraph2 *graph)
ok(!ret, "Got unexpected EC_COMPLETE.\n"); ok(!ret, "Got unexpected EC_COMPLETE.\n");
IMediaEvent_Release(eventsrc); IMediaEvent_Release(eventsrc);
IMediaControl_Release(control);
} }
static void test_current_image(IBaseFilter *filter, IMemInputPin *input, static void test_current_image(IBaseFilter *filter, IMemInputPin *input,
IFilterGraph2 *graph, const BITMAPINFOHEADER *expect_bih) IMediaControl *control, const BITMAPINFOHEADER *expect_bih)
{ {
LONG buffer[(sizeof(BITMAPINFOHEADER) + 32 * 16 * 2) / 4]; LONG buffer[(sizeof(BITMAPINFOHEADER) + 32 * 16 * 2) / 4];
const BITMAPINFOHEADER *bih = (BITMAPINFOHEADER *)buffer; const BITMAPINFOHEADER *bih = (BITMAPINFOHEADER *)buffer;
IMediaControl *control;
OAFilterState state; OAFilterState state;
IBasicVideo *video; IBasicVideo *video;
unsigned int i; unsigned int i;
@ -1262,7 +1246,6 @@ static void test_current_image(IBaseFilter *filter, IMemInputPin *input,
HRESULT hr; HRESULT hr;
LONG size; LONG size;
IFilterGraph2_QueryInterface(graph, &IID_IMediaControl, (void **)&control);
IBaseFilter_QueryInterface(filter, &IID_IBasicVideo, (void **)&video); IBaseFilter_QueryInterface(filter, &IID_IBasicVideo, (void **)&video);
hr = IBasicVideo_GetCurrentImage(video, NULL, NULL); hr = IBasicVideo_GetCurrentImage(video, NULL, NULL);
@ -1321,7 +1304,6 @@ static void test_current_image(IBaseFilter *filter, IMemInputPin *input,
ok(hr == S_OK, "Got hr %#x.\n", hr); ok(hr == S_OK, "Got hr %#x.\n", hr);
IBasicVideo_Release(video); IBasicVideo_Release(video);
IMediaControl_Release(control);
} }
static void test_connect_pin(void) static void test_connect_pin(void)
@ -1347,6 +1329,7 @@ static void test_connect_pin(void)
IFilterGraph2 *graph = create_graph(); IFilterGraph2 *graph = create_graph();
struct testfilter source; struct testfilter source;
IMemAllocator *allocator; IMemAllocator *allocator;
IMediaControl *control;
IMemInputPin *input; IMemInputPin *input;
AM_MEDIA_TYPE mt; AM_MEDIA_TYPE mt;
IPin *pin, *peer; IPin *pin, *peer;
@ -1366,6 +1349,7 @@ static void test_connect_pin(void)
IFilterGraph2_AddFilter(graph, &source.filter.IBaseFilter_iface, NULL); IFilterGraph2_AddFilter(graph, &source.filter.IBaseFilter_iface, NULL);
IFilterGraph2_AddFilter(graph, filter, NULL); IFilterGraph2_AddFilter(graph, filter, NULL);
IFilterGraph2_QueryInterface(graph, &IID_IMediaControl, (void **)&control);
IBaseFilter_FindPin(filter, L"In", &pin); IBaseFilter_FindPin(filter, L"In", &pin);
@ -1424,11 +1408,11 @@ static void test_connect_pin(void)
hr = IMemInputPin_ReceiveCanBlock(input); hr = IMemInputPin_ReceiveCanBlock(input);
ok(hr == S_OK, "Got hr %#x.\n", hr); ok(hr == S_OK, "Got hr %#x.\n", hr);
test_filter_state(input, graph); test_filter_state(input, control);
test_flushing(pin, input, graph); test_flushing(pin, input, control);
test_sample_time(filter, pin, input, graph); test_sample_time(filter, pin, input, control);
test_eos(pin, input, graph); test_eos(pin, input, control);
test_current_image(filter, input, graph, &vih.bmiHeader); test_current_image(filter, input, control, &vih.bmiHeader);
hr = IFilterGraph2_Disconnect(graph, pin); hr = IFilterGraph2_Disconnect(graph, pin);
ok(hr == S_OK, "Got hr %#x.\n", hr); ok(hr == S_OK, "Got hr %#x.\n", hr);
@ -1449,6 +1433,7 @@ static void test_connect_pin(void)
ok(!ref, "Got outstanding refcount %d.\n", ref); ok(!ref, "Got outstanding refcount %d.\n", ref);
IMemInputPin_Release(input); IMemInputPin_Release(input);
IPin_Release(pin); IPin_Release(pin);
IMediaControl_Release(control);
ref = IFilterGraph2_Release(graph); ref = IFilterGraph2_Release(graph);
ok(!ref, "Got outstanding refcount %d.\n", ref); ok(!ref, "Got outstanding refcount %d.\n", ref);
ref = IBaseFilter_Release(filter); ref = IBaseFilter_Release(filter);

View File

@ -1022,17 +1022,14 @@ static HRESULT join_thread_(int line, HANDLE thread)
} }
#define join_thread(a) join_thread_(__LINE__, a) #define join_thread(a) join_thread_(__LINE__, a)
static void test_filter_state(IMemInputPin *input, IFilterGraph2 *graph) static void test_filter_state(IMemInputPin *input, IMediaControl *control)
{ {
IMemAllocator *allocator; IMemAllocator *allocator;
IMediaControl *control;
IMediaSample *sample; IMediaSample *sample;
OAFilterState state; OAFilterState state;
HANDLE thread; HANDLE thread;
HRESULT hr; HRESULT hr;
IFilterGraph2_QueryInterface(graph, &IID_IMediaControl, (void **)&control);
thread = send_frame(input); thread = send_frame(input);
hr = join_thread(thread); hr = join_thread(thread);
ok(hr == VFW_E_WRONG_STATE, "Got hr %#x.\n", hr); ok(hr == VFW_E_WRONG_STATE, "Got hr %#x.\n", hr);
@ -1163,19 +1160,15 @@ static void test_filter_state(IMemInputPin *input, IFilterGraph2 *graph)
ok(hr == S_OK, "Got hr %#x.\n", hr); ok(hr == S_OK, "Got hr %#x.\n", hr);
IMemAllocator_Release(allocator); IMemAllocator_Release(allocator);
IMediaControl_Release(control);
} }
static void test_flushing(IPin *pin, IMemInputPin *input, IFilterGraph2 *graph) static void test_flushing(IPin *pin, IMemInputPin *input, IMediaControl *control)
{ {
IMemAllocator *allocator; IMemAllocator *allocator;
IMediaControl *control;
OAFilterState state; OAFilterState state;
HANDLE thread; HANDLE thread;
HRESULT hr; HRESULT hr;
IFilterGraph2_QueryInterface(graph, &IID_IMediaControl, (void **)&control);
hr = IMemInputPin_GetAllocator(input, &allocator); hr = IMemInputPin_GetAllocator(input, &allocator);
ok(hr == S_OK, "Got hr %#x.\n", hr); ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IMemAllocator_Commit(allocator); hr = IMemAllocator_Commit(allocator);
@ -1233,19 +1226,16 @@ static void test_flushing(IPin *pin, IMemInputPin *input, IFilterGraph2 *graph)
hr = IMediaControl_Stop(control); hr = IMediaControl_Stop(control);
ok(hr == S_OK, "Got hr %#x.\n", hr); ok(hr == S_OK, "Got hr %#x.\n", hr);
IMediaControl_Release(control);
} }
static void test_current_image(IBaseFilter *filter, IMemInputPin *input, static void test_current_image(IBaseFilter *filter, IMemInputPin *input,
IFilterGraph2 *graph, const BITMAPINFOHEADER *req_bih) IMediaControl *control, const BITMAPINFOHEADER *req_bih)
{ {
LONG buffer[(sizeof(BITMAPINFOHEADER) + 32 * 16 * 4) / 4]; LONG buffer[(sizeof(BITMAPINFOHEADER) + 32 * 16 * 4) / 4];
const BITMAPINFOHEADER *bih = (BITMAPINFOHEADER *)buffer; const BITMAPINFOHEADER *bih = (BITMAPINFOHEADER *)buffer;
const DWORD *data = (DWORD *)((char *)buffer + sizeof(BITMAPINFOHEADER)); const DWORD *data = (DWORD *)((char *)buffer + sizeof(BITMAPINFOHEADER));
BITMAPINFOHEADER expect_bih = *req_bih; BITMAPINFOHEADER expect_bih = *req_bih;
IMemAllocator *allocator; IMemAllocator *allocator;
IMediaControl *control;
OAFilterState state; OAFilterState state;
IBasicVideo *video; IBasicVideo *video;
unsigned int i; unsigned int i;
@ -1258,7 +1248,6 @@ static void test_current_image(IBaseFilter *filter, IMemInputPin *input,
expect_bih.biBitCount = 32; expect_bih.biBitCount = 32;
expect_bih.biSizeImage = 32 * 16 * 4; expect_bih.biSizeImage = 32 * 16 * 4;
IFilterGraph2_QueryInterface(graph, &IID_IMediaControl, (void **)&control);
IBaseFilter_QueryInterface(filter, &IID_IBasicVideo, (void **)&video); IBaseFilter_QueryInterface(filter, &IID_IBasicVideo, (void **)&video);
hr = IBasicVideo_GetCurrentImage(video, NULL, NULL); hr = IBasicVideo_GetCurrentImage(video, NULL, NULL);
@ -1337,7 +1326,6 @@ static void test_current_image(IBaseFilter *filter, IMemInputPin *input,
ok(hr == S_OK, "Got hr %#x.\n", hr); ok(hr == S_OK, "Got hr %#x.\n", hr);
IBasicVideo_Release(video); IBasicVideo_Release(video);
IMediaControl_Release(control);
} }
static void test_connect_pin(void) static void test_connect_pin(void)
@ -1363,6 +1351,7 @@ static void test_connect_pin(void)
IFilterGraph2 *graph = create_graph(); IFilterGraph2 *graph = create_graph();
struct testfilter source; struct testfilter source;
IMemAllocator *allocator; IMemAllocator *allocator;
IMediaControl *control;
IMemInputPin *input; IMemInputPin *input;
AM_MEDIA_TYPE mt; AM_MEDIA_TYPE mt;
IPin *pin, *peer; IPin *pin, *peer;
@ -1382,6 +1371,7 @@ static void test_connect_pin(void)
IFilterGraph2_AddFilter(graph, &source.filter.IBaseFilter_iface, NULL); IFilterGraph2_AddFilter(graph, &source.filter.IBaseFilter_iface, NULL);
IFilterGraph2_AddFilter(graph, filter, NULL); IFilterGraph2_AddFilter(graph, filter, NULL);
IFilterGraph2_QueryInterface(graph, &IID_IMediaControl, (void **)&control);
IBaseFilter_FindPin(filter, L"VMR Input0", &pin); IBaseFilter_FindPin(filter, L"VMR Input0", &pin);
@ -1469,9 +1459,9 @@ static void test_connect_pin(void)
hr = IMemInputPin_ReceiveCanBlock(input); hr = IMemInputPin_ReceiveCanBlock(input);
ok(hr == S_OK, "Got hr %#x.\n", hr); ok(hr == S_OK, "Got hr %#x.\n", hr);
test_filter_state(input, graph); test_filter_state(input, control);
test_flushing(pin, input, graph); test_flushing(pin, input, control);
test_current_image(filter, input, graph, &vih.bmiHeader); test_current_image(filter, input, control, &vih.bmiHeader);
hr = IFilterGraph2_Disconnect(graph, pin); hr = IFilterGraph2_Disconnect(graph, pin);
ok(hr == S_OK, "Got hr %#x.\n", hr); ok(hr == S_OK, "Got hr %#x.\n", hr);
@ -1490,6 +1480,7 @@ static void test_connect_pin(void)
IMemInputPin_Release(input); IMemInputPin_Release(input);
IPin_Release(pin); IPin_Release(pin);
IMediaControl_Release(control);
ref = IFilterGraph2_Release(graph); ref = IFilterGraph2_Release(graph);
ok(!ref, "Got outstanding refcount %d.\n", ref); ok(!ref, "Got outstanding refcount %d.\n", ref);
ref = IBaseFilter_Release(filter); ref = IBaseFilter_Release(filter);