diff --git a/dlls/amstream/audiostream.c b/dlls/amstream/audiostream.c index 1f9aed7338c..4e34b2549eb 100644 --- a/dlls/amstream/audiostream.c +++ b/dlls/amstream/audiostream.c @@ -184,6 +184,7 @@ struct audio_stream IMemAllocator *allocator; AM_MEDIA_TYPE mt; WAVEFORMATEX format; + FILTER_STATE state; }; static inline struct audio_stream *impl_from_IAMMediaStream(IAMMediaStream *iface) @@ -340,11 +341,17 @@ static HRESULT WINAPI audio_IAMMediaStream_Initialize(IAMMediaStream *iface, IUn static HRESULT WINAPI audio_IAMMediaStream_SetState(IAMMediaStream *iface, FILTER_STATE state) { - struct audio_stream *This = impl_from_IAMMediaStream(iface); + struct audio_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 audio_IAMMediaStream_JoinAMMultiMediaStream(IAMMediaStream *iface, diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 82a833ad6f9..472c6558fc4 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -2780,6 +2780,40 @@ static void test_audiostream_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_mediastreamfilter_get_state(void) { IAMMultiMediaStream *mmstream = create_ammultimediastream(); @@ -2951,6 +2985,7 @@ START_TEST(amstream) test_audiostream_get_format(); test_audiostream_set_format(); test_audiostream_receive_connection(); + test_audiostream_set_state(); test_mediastreamfilter_get_state(); test_mediastreamfilter_stop_pause_run();