Signed-off-by: Anton Baskanov baskanov@gmail.com --- dlls/amstream/multimedia.c | 4 ++ dlls/amstream/tests/amstream.c | 71 ++++++++++++++++++++++++++++++++-- 2 files changed, 71 insertions(+), 4 deletions(-)
diff --git a/dlls/amstream/multimedia.c b/dlls/amstream/multimedia.c index f615e436b1..b2c9082cae 100644 --- a/dlls/amstream/multimedia.c +++ b/dlls/amstream/multimedia.c @@ -153,7 +153,11 @@ static HRESULT WINAPI multimedia_stream_SetState(IAMMultiMediaStream *iface, STR TRACE("(%p/%p)->(%u)\n", This, iface, new_state);
if (new_state == STREAMSTATE_RUN) + { hr = IMediaControl_Run(This->media_control); + if (SUCCEEDED(hr)) + hr = S_OK; + } else if (new_state == STREAMSTATE_STOP) hr = IMediaControl_Stop(This->media_control);
diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index e79fcdd87f..55d75fbc3a 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -720,6 +720,8 @@ struct testfilter LONGLONG stop_position; HRESULT get_duration_hr; HRESULT set_positions_hr; + HRESULT init_stream_hr; + HRESULT cleanup_stream_hr; };
static inline struct testfilter *impl_from_BaseFilter(struct strmbase_filter *iface) @@ -746,16 +748,20 @@ static HRESULT testfilter_init_stream(struct strmbase_filter *iface) { struct testfilter *filter = impl_from_BaseFilter(iface);
- BaseOutputPinImpl_Active(&filter->source); - return S_OK; + if (SUCCEEDED(filter->init_stream_hr)) + BaseOutputPinImpl_Active(&filter->source); + + return filter->init_stream_hr; }
static HRESULT testfilter_cleanup_stream(struct strmbase_filter *iface) { struct testfilter *filter = impl_from_BaseFilter(iface);
- BaseOutputPinImpl_Inactive(&filter->source); - return S_OK; + if (SUCCEEDED(filter->cleanup_stream_hr)) + BaseOutputPinImpl_Inactive(&filter->source); + + return filter->cleanup_stream_hr; }
static const struct strmbase_filter_ops testfilter_ops = @@ -2072,6 +2078,62 @@ static void test_initialize(void) IUnknown_Release(graph_inner_unk); }
+static void test_set_state(void) +{ + IAMMultiMediaStream *mmstream = create_ammultimediastream(); + struct testfilter source; + IGraphBuilder *graph; + HRESULT hr; + ULONG ref; + + hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryAudio, 0, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_GetFilterGraph(mmstream, &graph); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(graph != NULL, "Expected non-NULL graph.\n"); + testfilter_init(&source); + + hr = IGraphBuilder_AddFilter(graph, &source.filter.IBaseFilter_iface, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + source.init_stream_hr = E_FAIL; + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_RUN); + ok(hr == E_FAIL, "Got hr %#x.\n", hr); + source.init_stream_hr = S_OK; + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_STOP); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + source.init_stream_hr = S_FALSE; + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_RUN); + ok(hr == S_OK, "Got hr %#x.\n", hr); + source.init_stream_hr = S_OK; + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_STOP); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_RUN); + ok(hr == S_OK, "Got hr %#x.\n", hr); + source.cleanup_stream_hr = E_FAIL; + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_STOP); + ok(hr == E_FAIL, "Got hr %#x.\n", hr); + source.cleanup_stream_hr = S_OK; + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_STOP); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_RUN); + ok(hr == S_OK, "Got hr %#x.\n", hr); + source.cleanup_stream_hr = S_FALSE; + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_STOP); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + source.cleanup_stream_hr = S_OK; + + ref = IAMMultiMediaStream_Release(mmstream); + ok(!ref, "Got outstanding refcount %d.\n", ref); + ref = IGraphBuilder_Release(graph); + ok(!ref, "Got outstanding refcount %d.\n", ref); +} + static void test_enum_media_types(void) { IAMMultiMediaStream *mmstream = create_ammultimediastream(); @@ -5126,6 +5188,7 @@ START_TEST(amstream) test_find_pin(); test_pin_info(); test_initialize(); + test_set_state(); test_enum_media_types(); test_media_types(); test_IDirectDrawStreamSample();