Signed-off-by: Anton Baskanov baskanov@gmail.com --- dlls/amstream/multimedia.c | 14 ++++-- dlls/amstream/tests/amstream.c | 80 ++++++++++++++++++++++++++++++++++ 2 files changed, 90 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 2e5d6bc92be..cd014ee7f91 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -2506,6 +2506,85 @@ static void test_set_state(void) ok(!ref, "Got outstanding refcount %d.\n", ref); }
+static void test_get_state(void) +{ + IAMMultiMediaStream *mmstream = create_ammultimediastream(); + IMediaControl *media_control; + struct testfilter source; + IGraphBuilder *graph; + STREAM_STATE state; + 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"); + 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); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + /* 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); +} + static void test_enum_media_types(void) { IAMMultiMediaStream *mmstream = create_ammultimediastream(); @@ -8904,6 +8983,7 @@ START_TEST(amstream) test_pin_info(); test_initialize(); test_set_state(); + test_get_state(); test_enum_media_types(); test_media_types();