Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/qcap/tests/videocapture.c | 57 ++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+)
diff --git a/dlls/qcap/tests/videocapture.c b/dlls/qcap/tests/videocapture.c index fafd18009f4..7733dfdc8ed 100644 --- a/dlls/qcap/tests/videocapture.c +++ b/dlls/qcap/tests/videocapture.c @@ -360,12 +360,65 @@ static void testfilter_init(struct testfilter *filter) strmbase_sink_init(&filter->sink, &filter->filter, L"sink", &testsink_ops, NULL); }
+static void test_filter_state(IMediaControl *control) +{ + OAFilterState state; + HRESULT hr; + + hr = IMediaControl_GetState(control, 0, &state); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(state == State_Stopped, "Got state %u.\n", state); + + hr = IMediaControl_Pause(control); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaControl_GetState(control, 0, &state); + ok(hr == VFW_S_CANT_CUE, "Got hr %#x.\n", hr); + ok(state == State_Paused, "Got state %u.\n", state); + + hr = IMediaControl_Run(control); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaControl_GetState(control, 0, &state); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(state == State_Running, "Got state %u.\n", state); + + hr = IMediaControl_Pause(control); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaControl_GetState(control, 0, &state); + ok(hr == VFW_S_CANT_CUE, "Got hr %#x.\n", hr); + ok(state == State_Paused, "Got state %u.\n", state); + + hr = IMediaControl_Stop(control); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaControl_GetState(control, 0, &state); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(state == State_Stopped, "Got state %u.\n", state); + + hr = IMediaControl_Run(control); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaControl_GetState(control, 0, &state); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(state == State_Running, "Got state %u.\n", state); + + hr = IMediaControl_Stop(control); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaControl_GetState(control, 0, &state); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(state == State_Stopped, "Got state %u.\n", state); +} + static void test_connect_pin(IBaseFilter *filter, IPin *source) { AM_MEDIA_TYPE req_mt, default_mt, mt, *mts[2]; IAMStreamConfig *stream_config; struct testfilter testsink; IEnumMediaTypes *enummt; + IMediaControl *control; IFilterGraph2 *graph; ULONG count, ref; HRESULT hr; @@ -373,6 +426,7 @@ static void test_connect_pin(IBaseFilter *filter, IPin *source)
CoCreateInstance(&CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, &IID_IFilterGraph2, (void **)&graph); + IFilterGraph2_QueryInterface(graph, &IID_IMediaControl, (void **)&control); testfilter_init(&testsink); IFilterGraph2_AddFilter(graph, &testsink.filter.IBaseFilter_iface, L"sink"); IFilterGraph2_AddFilter(graph, filter, L"source"); @@ -406,6 +460,8 @@ static void test_connect_pin(IBaseFilter *filter, IPin *source) hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); ok(hr == S_OK, "Got hr %#x.\n", hr);
+ test_filter_state(control); + hr = IPin_ConnectedTo(source, &peer); ok(hr == S_OK, "Got hr %#x.\n", hr); ok(peer == &testsink.sink.pin.IPin_iface, "Got peer %p.\n", peer); @@ -445,6 +501,7 @@ static void test_connect_pin(IBaseFilter *filter, IPin *source) FreeMediaType(&req_mt); FreeMediaType(&default_mt); IAMStreamConfig_Release(stream_config); + IMediaControl_Release(control); ref = IFilterGraph2_Release(graph); ok(!ref, "Got outstanding refcount %d.\n", ref); ref = IBaseFilter_Release(&testsink.filter.IBaseFilter_iface);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/qcap/tests/videocapture.c | 38 ++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-)
diff --git a/dlls/qcap/tests/videocapture.c b/dlls/qcap/tests/videocapture.c index 7733dfdc8ed..530b33a1e32 100644 --- a/dlls/qcap/tests/videocapture.c +++ b/dlls/qcap/tests/videocapture.c @@ -360,8 +360,9 @@ static void testfilter_init(struct testfilter *filter) strmbase_sink_init(&filter->sink, &filter->filter, L"sink", &testsink_ops, NULL); }
-static void test_filter_state(IMediaControl *control) +static void test_filter_state(IMediaControl *control, IMemAllocator *allocator) { + IMediaSample *sample; OAFilterState state; HRESULT hr;
@@ -369,6 +370,9 @@ static void test_filter_state(IMediaControl *control) ok(hr == S_OK, "Got hr %#x.\n", hr); ok(state == State_Stopped, "Got state %u.\n", state);
+ hr = IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, 0); + ok(hr == VFW_E_NOT_COMMITTED, "Got hr %#x.\n", hr); + hr = IMediaControl_Pause(control); ok(hr == S_OK, "Got hr %#x.\n", hr);
@@ -376,6 +380,10 @@ static void test_filter_state(IMediaControl *control) ok(hr == VFW_S_CANT_CUE, "Got hr %#x.\n", hr); ok(state == State_Paused, "Got state %u.\n", state);
+ hr = IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, AM_GBF_NOWAIT); + ok(hr == S_OK, "Got hr %#x.\n", hr); + IMediaSample_Release(sample); + hr = IMediaControl_Run(control); ok(hr == S_OK, "Got hr %#x.\n", hr);
@@ -397,6 +405,9 @@ static void test_filter_state(IMediaControl *control) ok(hr == S_OK, "Got hr %#x.\n", hr); ok(state == State_Stopped, "Got state %u.\n", state);
+ hr = IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, 0); + ok(hr == VFW_E_NOT_COMMITTED, "Got hr %#x.\n", hr); + hr = IMediaControl_Run(control); ok(hr == S_OK, "Got hr %#x.\n", hr);
@@ -404,12 +415,33 @@ static void test_filter_state(IMediaControl *control) ok(hr == S_OK, "Got hr %#x.\n", hr); ok(state == State_Running, "Got state %u.\n", state);
+ hr = IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, AM_GBF_NOWAIT); + todo_wine ok(hr == VFW_E_TIMEOUT, "Got hr %#x.\n", hr); + if (hr == S_OK) IMediaSample_Release(sample); + hr = IMediaControl_Stop(control); ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IMediaControl_GetState(control, 0, &state); ok(hr == S_OK, "Got hr %#x.\n", hr); ok(state == State_Stopped, "Got state %u.\n", state); + + hr = IMemAllocator_GetBuffer(allocator, &sample, NULL, NULL, 0); + ok(hr == VFW_E_NOT_COMMITTED, "Got hr %#x.\n", hr); + + /* Test committing the allocator before the capture filter does. */ + + hr = IMemAllocator_Commit(allocator); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaControl_Pause(control); + todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMemAllocator_Decommit(allocator); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaControl_Stop(control); + ok(hr == S_OK, "Got hr %#x.\n", hr); }
static void test_connect_pin(IBaseFilter *filter, IPin *source) @@ -460,7 +492,9 @@ static void test_connect_pin(IBaseFilter *filter, IPin *source) hr = IFilterGraph2_ConnectDirect(graph, source, &testsink.sink.pin.IPin_iface, &req_mt); ok(hr == S_OK, "Got hr %#x.\n", hr);
- test_filter_state(control); + ok(!!testsink.sink.pAllocator, "Expected to be assigned an allocator.\n"); + + test_filter_state(control, testsink.sink.pAllocator);
hr = IPin_ConnectedTo(source, &peer); ok(hr == S_OK, "Got hr %#x.\n", hr);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- Reported by a user in #winehq.
dlls/qcap/tests/videocapture.c | 2 +- dlls/qcap/vfwcapture.c | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/dlls/qcap/tests/videocapture.c b/dlls/qcap/tests/videocapture.c index 530b33a1e32..c44070b0bd5 100644 --- a/dlls/qcap/tests/videocapture.c +++ b/dlls/qcap/tests/videocapture.c @@ -435,7 +435,7 @@ static void test_filter_state(IMediaControl *control, IMemAllocator *allocator) ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IMediaControl_Pause(control); - todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IMemAllocator_Decommit(allocator); ok(hr == S_OK, "Got hr %#x.\n", hr); diff --git a/dlls/qcap/vfwcapture.c b/dlls/qcap/vfwcapture.c index 48401344ac4..ae073b845e0 100644 --- a/dlls/qcap/vfwcapture.c +++ b/dlls/qcap/vfwcapture.c @@ -197,11 +197,9 @@ static HRESULT vfw_capture_init_stream(struct strmbase_filter *iface) req_props.cbBuffer = get_image_size(filter); req_props.cbAlign = 1; req_props.cbPrefix = 0; - if (FAILED(hr = IMemAllocator_SetProperties(filter->source.pAllocator, &req_props, &ret_props))) - { + if (FAILED(hr = IMemAllocator_SetProperties(filter->source.pAllocator, &req_props, &ret_props)) + && hr != VFW_E_ALREADY_COMMITTED) ERR("Failed to set allocator properties (buffer size %u), hr %#x.\n", req_props.cbBuffer, hr); - return hr; - }
if (FAILED(hr = IMemAllocator_Commit(filter->source.pAllocator))) ERR("Failed to commit allocator, hr %#x.\n", hr);