From: Anton Baskanov baskanov@gmail.com
Signed-off-by: Anton Baskanov baskanov@gmail.com Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- v2: punctuate a couple of messages.
dlls/amstream/filter.c | 15 +++++++++++++-- dlls/amstream/tests/amstream.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-)
diff --git a/dlls/amstream/filter.c b/dlls/amstream/filter.c index 80a885de244..1cb2ca71bac 100644 --- a/dlls/amstream/filter.c +++ b/dlls/amstream/filter.c @@ -171,6 +171,7 @@ struct filter IFilterGraph *graph; ULONG nb_streams; IAMMediaStream **streams; + FILTER_STATE state; };
static inline struct filter *impl_from_IMediaStreamFilter(IMediaStreamFilter *iface) @@ -264,9 +265,19 @@ static HRESULT WINAPI filter_Run(IMediaStreamFilter *iface, REFERENCE_TIME start
static HRESULT WINAPI filter_GetState(IMediaStreamFilter *iface, DWORD timeout, FILTER_STATE *state) { - FIXME("iface %p, timeout %u, state %p, stub!\n", iface, timeout, state); + struct filter *filter = impl_from_IMediaStreamFilter(iface); + + TRACE("iface %p, timeout %u, state %p.\n", iface, timeout, state); + + if (!state) + return E_POINTER; + + EnterCriticalSection(&filter->cs); + + *state = filter->state; + + LeaveCriticalSection(&filter->cs);
- *state = State_Stopped; return S_OK; }
diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 09686cfcf4d..cfdd8b6c8d4 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -2737,6 +2737,37 @@ static void test_audiostream_receive_connection(void) ok(!ref, "Got outstanding refcount %d.\n", ref); }
+void test_mediastreamfilter_get_state(void) +{ + IAMMultiMediaStream *mmstream = create_ammultimediastream(); + IMediaStreamFilter *filter; + FILTER_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_GetFilter(mmstream, &filter); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(!!filter, "Expected non-null filter.\n"); + + /* Crashes on native. */ + if (0) + { + hr = IMediaStreamFilter_GetState(filter, 0, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + } + + state = 0xcc; + hr = IMediaStreamFilter_GetState(filter, 0, &state); + ok(state == State_Stopped, "Got state %#x.\n", state); + + ref = IAMMultiMediaStream_Release(mmstream); + ok(!ref, "Got outstanding refcount %d.\n", ref); + ref = IMediaStreamFilter_Release(filter); + ok(!ref, "Got outstanding refcount %d.\n", ref); +} + START_TEST(amstream) { HANDLE file; @@ -2774,5 +2805,7 @@ START_TEST(amstream) test_audiostream_set_format(); test_audiostream_receive_connection();
+ test_mediastreamfilter_get_state(); + CoUninitialize(); }