Signed-off-by: Anton Baskanov baskanov@gmail.com --- dlls/amstream/ddrawstream.c | 13 ++++-- dlls/amstream/tests/amstream.c | 76 ++++++++++++++++++---------------- 2 files changed, 51 insertions(+), 38 deletions(-)
diff --git a/dlls/amstream/ddrawstream.c b/dlls/amstream/ddrawstream.c index 7817df494d5..21cb4437e3d 100644 --- a/dlls/amstream/ddrawstream.c +++ b/dlls/amstream/ddrawstream.c @@ -57,6 +57,7 @@ struct ddraw_stream IMemAllocator *allocator; AM_MEDIA_TYPE mt; struct format format; + FILTER_STATE state; };
static HRESULT ddrawstreamsample_create(struct ddraw_stream *parent, IDirectDrawSurface *surface, @@ -260,11 +261,17 @@ static HRESULT WINAPI ddraw_IAMMediaStream_Initialize(IAMMediaStream *iface, IUn
static HRESULT WINAPI ddraw_IAMMediaStream_SetState(IAMMediaStream *iface, FILTER_STATE state) { - struct ddraw_stream *This = impl_from_IAMMediaStream(iface); + struct ddraw_stream *stream = impl_from_IAMMediaStream(iface);
- FIXME("(%p/%p)->(%u) stub!\n", This, iface, state); + TRACE("stream %p, state %u.\n", stream, state);
- return S_FALSE; + EnterCriticalSection(&stream->cs); + + stream->state = state; + + LeaveCriticalSection(&stream->cs); + + return S_OK; }
static HRESULT WINAPI ddraw_IAMMediaStream_JoinAMMultiMediaStream(IAMMediaStream *iface, IAMMultiMediaStream *mmstream) diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index d2126a15db3..af2d77d813e 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -3613,40 +3613,6 @@ static void test_ddrawstream_receive_connection(void) ok(!ref, "Got outstanding refcount %d.\n", ref); }
-static void test_audiostream_set_state(void) -{ - IAMMultiMediaStream *mmstream = create_ammultimediastream(); - IAMMediaStream *am_stream; - IMediaStream *stream; - 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, &stream); - ok(hr == S_OK, "Got hr %#x.\n", hr); - hr = IMediaStream_QueryInterface(stream, &IID_IAMMediaStream, (void **)&am_stream); - ok(hr == S_OK, "Got hr %#x.\n", hr); - - hr = IAMMediaStream_SetState(am_stream, 4); - ok(hr == S_OK, "Got hr %#x.\n", hr); - - hr = IAMMediaStream_SetState(am_stream, State_Running); - ok(hr == S_OK, "Got hr %#x.\n", hr); - - hr = IAMMediaStream_SetState(am_stream, State_Paused); - ok(hr == S_OK, "Got hr %#x.\n", hr); - - hr = IAMMediaStream_SetState(am_stream, State_Stopped); - ok(hr == S_OK, "Got hr %#x.\n", hr); - - ref = IAMMultiMediaStream_Release(mmstream); - ok(!ref, "Got outstanding refcount %d.\n", ref); - IAMMediaStream_Release(am_stream); - ref = IMediaStream_Release(stream); - ok(!ref, "Got outstanding refcount %d.\n", ref); -} - void test_audiostream_end_of_stream(void) { IAMMultiMediaStream *mmstream = create_ammultimediastream(); @@ -5358,6 +5324,46 @@ static void test_ammediastream_join_filter_graph(void) check_ammediastream_join_filter_graph(&MSPID_PrimaryVideo); }
+static void check_ammediastream_set_state(const MSPID *id) +{ + IAMMultiMediaStream *mmstream = create_ammultimediastream(); + IAMMediaStream *am_stream; + IMediaStream *stream; + 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, id, 0, &stream); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IMediaStream_QueryInterface(stream, &IID_IAMMediaStream, (void **)&am_stream); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAMMediaStream_SetState(am_stream, 4); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAMMediaStream_SetState(am_stream, State_Running); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAMMediaStream_SetState(am_stream, State_Paused); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAMMediaStream_SetState(am_stream, State_Stopped); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + ref = IAMMultiMediaStream_Release(mmstream); + ok(!ref, "Got outstanding refcount %d.\n", ref); + IAMMediaStream_Release(am_stream); + ref = IMediaStream_Release(stream); + ok(!ref, "Got outstanding refcount %d.\n", ref); +} + +static void test_ammediastream_set_state(void) +{ + check_ammediastream_set_state(&MSPID_PrimaryAudio); + check_ammediastream_set_state(&MSPID_PrimaryVideo); +} + void test_mediastreamfilter_get_state(void) { IAMMultiMediaStream *mmstream = create_ammultimediastream(); @@ -6851,7 +6857,6 @@ START_TEST(amstream) test_audiostream_get_format(); test_audiostream_set_format(); test_audiostream_receive_connection(); - test_audiostream_set_state(); test_audiostream_end_of_stream(); test_audiostream_receive(); test_audiostream_initialize(); @@ -6876,6 +6881,7 @@ START_TEST(amstream) test_ammediastream_join_am_multi_media_stream(); test_ammediastream_join_filter(); test_ammediastream_join_filter_graph(); + test_ammediastream_set_state();
test_mediastreamfilter_get_state(); test_mediastreamfilter_stop_pause_run();