From 23cbd7f591caef0dd74919bac4bc58dc82011363 Mon Sep 17 00:00:00 2001 From: Anton Baskanov Date: Wed, 18 Nov 2020 00:48:23 +0700 Subject: [PATCH] amstream: Implement AMMultiMediaStream::GetState. Signed-off-by: Anton Baskanov Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- dlls/amstream/multimedia.c | 14 ++++++--- dlls/amstream/tests/amstream.c | 53 ++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 4 deletions(-) diff --git a/dlls/amstream/multimedia.c b/dlls/amstream/multimedia.c index f927cd106a0..5c04c771535 100644 --- a/dlls/amstream/multimedia.c +++ b/dlls/amstream/multimedia.c @@ -42,6 +42,7 @@ struct multimedia_stream BOOL initialized; STREAM_TYPE type; OAEVENT event; + STREAM_STATE state; }; static inline struct multimedia_stream *impl_from_IAMMultiMediaStream(IAMMultiMediaStream *iface) @@ -136,13 +137,15 @@ static HRESULT WINAPI multimedia_stream_EnumMediaStreams(IAMMultiMediaStream *if return IMediaStreamFilter_EnumMediaStreams(mmstream->filter, index, stream); } -static HRESULT WINAPI multimedia_stream_GetState(IAMMultiMediaStream *iface, STREAM_STATE *pCurrentState) +static HRESULT WINAPI multimedia_stream_GetState(IAMMultiMediaStream *iface, STREAM_STATE *state) { - struct multimedia_stream *This = impl_from_IAMMultiMediaStream(iface); + struct multimedia_stream *mmstream = impl_from_IAMMultiMediaStream(iface); - FIXME("(%p/%p)->(%p) stub!\n", This, iface, pCurrentState); + TRACE("mmstream %p, state %p.\n", mmstream, state); - return E_NOTIMPL; + *state = mmstream->state; + + return S_OK; } static HRESULT WINAPI multimedia_stream_SetState(IAMMultiMediaStream *iface, STREAM_STATE new_state) @@ -165,6 +168,9 @@ static HRESULT WINAPI multimedia_stream_SetState(IAMMultiMediaStream *iface, STR else if (new_state == STREAMSTATE_STOP) hr = IMediaControl_Stop(This->media_control); + if (SUCCEEDED(hr)) + This->state = new_state; + return hr; } diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 47b92cc8a1a..b69e6070a35 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -2409,8 +2409,10 @@ static DWORD CALLBACK mmstream_set_state(void *param) static void test_set_state(void) { IAMMultiMediaStream *mmstream = create_ammultimediastream(); + IMediaControl *media_control; struct testfilter source; IGraphBuilder *graph; + STREAM_STATE state; HANDLE thread; HRESULT hr; ULONG ref; @@ -2422,6 +2424,8 @@ static void test_set_state(void) hr = IAMMultiMediaStream_GetFilterGraph(mmstream, &graph); ok(hr == S_OK, "Got hr %#x.\n", hr); ok(graph != NULL, "Expected non-NULL graph.\n"); + hr = IGraphBuilder_QueryInterface(graph, &IID_IMediaControl, (void **)&media_control); + ok(hr == S_OK, "Got hr %#x.\n", hr); testfilter_init(&source); hr = IGraphBuilder_AddFilter(graph, &source.filter.IBaseFilter_iface, NULL); @@ -2500,8 +2504,57 @@ static void test_set_state(void) ok(hr == S_OK, "Got hr %#x.\n", hr); source.wait_state_hr = S_OK; + /* Crashes on native. */ + if (0) + { + hr = IAMMultiMediaStream_GetState(mmstream, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + } + + state = 0xdeadbeef; + hr = IAMMultiMediaStream_GetState(mmstream, &state); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(state == STREAMSTATE_STOP, "Got state %#x.\n", state); + + hr = IMediaControl_Run(media_control); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + state = 0xdeadbeef; + hr = IAMMultiMediaStream_GetState(mmstream, &state); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(state == STREAMSTATE_STOP, "Got state %#x.\n", state); + + hr = IMediaControl_Stop(media_control); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_RUN); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + state = 0xdeadbeef; + hr = IAMMultiMediaStream_GetState(mmstream, &state); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(state == STREAMSTATE_RUN, "Got state %#x.\n", state); + + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_STOP); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + state = 0xdeadbeef; + hr = IAMMultiMediaStream_GetState(mmstream, &state); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(state == STREAMSTATE_STOP, "Got state %#x.\n", state); + + source.init_stream_hr = E_FAIL; + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_RUN); + ok(hr == E_FAIL, "Got hr %#x.\n", hr); + + state = 0xdeadbeef; + hr = IAMMultiMediaStream_GetState(mmstream, &state); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(state == STREAMSTATE_STOP, "Got state %#x.\n", state); + ref = IAMMultiMediaStream_Release(mmstream); ok(!ref, "Got outstanding refcount %d.\n", ref); + IMediaControl_Release(media_control); ref = IGraphBuilder_Release(graph); ok(!ref, "Got outstanding refcount %d.\n", ref); }