Signed-off-by: Anton Baskanov baskanov@gmail.com --- dlls/amstream/tests/amstream.c | 54 ++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 16 deletions(-)
diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 9cefec12442..e7fd731dd72 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -2128,8 +2128,8 @@ static HRESULT WINAPI graph_FindFilterByName(IFilterGraph2 *iface, const WCHAR *
static HRESULT WINAPI graph_ConnectDirect(IFilterGraph2 *iface, IPin *source, IPin *sink, const AM_MEDIA_TYPE *mt) { - ok(0, "Unexpected call.\n"); - return E_NOTIMPL; + struct graph *graph = impl_from_IFilterGraph2(iface); + return IFilterGraph2_ConnectDirect(graph->inner, source, sink, mt); }
static HRESULT WINAPI graph_Reconnect(IFilterGraph2 *iface, IPin *pin) @@ -2140,8 +2140,8 @@ static HRESULT WINAPI graph_Reconnect(IFilterGraph2 *iface, IPin *pin)
static HRESULT WINAPI graph_Disconnect(IFilterGraph2 *iface, IPin *pin) { - ok(0, "Unexpected call.\n"); - return E_NOTIMPL; + struct graph *graph = impl_from_IFilterGraph2(iface); + return IFilterGraph2_Disconnect(graph->inner, pin); }
static HRESULT WINAPI graph_SetDefaultSyncSource(IFilterGraph2 *iface) @@ -6065,30 +6065,36 @@ static void test_ammediastream_set_state(void) check_ammediastream_set_state(&MSPID_PrimaryVideo); }
-static void check_ammediastream_end_of_stream(const MSPID *id, const AM_MEDIA_TYPE *mt) +static void check_ammediastream_end_of_stream(const CLSID *clsid, const MSPID *id, const AM_MEDIA_TYPE *mt) { IAMMultiMediaStream *mmstream = create_ammultimediastream(); + IMediaStreamFilter *filter; struct testfilter source; - IGraphBuilder *graph; IMediaStream *stream; + struct graph graph; HRESULT hr; ULONG ref; IPin *pin;
- hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL); + graph_init(&graph); + + hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, (IGraphBuilder *)&graph.IFilterGraph2_iface); 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_IPin, (void **)&pin); ok(hr == S_OK, "Got hr %#x.\n", hr); - hr = IAMMultiMediaStream_GetFilterGraph(mmstream, &graph); + hr = IAMMultiMediaStream_GetFilter(mmstream, &filter); ok(hr == S_OK, "Got hr %#x.\n", hr); - ok(!!graph, "Expected non-NULL graph.\n"); testfilter_init(&source); - hr = IGraphBuilder_AddFilter(graph, &source.filter.IBaseFilter_iface, NULL); + source.IMediaSeeking_iface.lpVtbl = &testsource_seeking_vtbl; + hr = IFilterGraph2_AddFilter(&graph.IFilterGraph2_iface, &source.filter.IBaseFilter_iface, NULL); ok(hr == S_OK, "Got hr %#x.\n", hr);
- hr = IGraphBuilder_ConnectDirect(graph, &source.source.pin.IPin_iface, pin, mt); + hr = IFilterGraph2_ConnectDirect(&graph.IFilterGraph2_iface, &source.source.pin.IPin_iface, pin, mt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaStreamFilter_SupportSeeking(filter, TRUE); ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IPin_EndOfStream(pin); @@ -6112,12 +6118,28 @@ static void check_ammediastream_end_of_stream(const MSPID *id, const AM_MEDIA_TY hr = IPin_EndOfStream(pin); ok(hr == E_FAIL, "Got hr %#x.\n", hr);
- IGraphBuilder_Disconnect(graph, pin); - IGraphBuilder_Disconnect(graph, &source.source.pin.IPin_iface); + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_RUN); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + graph.got_notify = 0; + graph.event_code = 0xcc; + + hr = IPin_EndOfStream(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + todo_wine ok(graph.got_notify == 1, "Got %d calls to IMediaEventSink::Notify().\n", graph.got_notify); + todo_wine ok(graph.event_code == EC_COMPLETE, "Got event code %d.\n", graph.event_code); + + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_STOP); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + IFilterGraph2_Disconnect(&graph.IFilterGraph2_iface, pin); + IFilterGraph2_Disconnect(&graph.IFilterGraph2_iface, &source.source.pin.IPin_iface);
ref = IAMMultiMediaStream_Release(mmstream); ok(!ref, "Got outstanding refcount %d.\n", ref); - ref = IGraphBuilder_Release(graph); + graph_destroy(&graph); + ref = IMediaStreamFilter_Release(filter); ok(!ref, "Got outstanding refcount %d.\n", ref); IPin_Release(pin); ref = IMediaStream_Release(stream); @@ -6126,8 +6148,8 @@ static void check_ammediastream_end_of_stream(const MSPID *id, const AM_MEDIA_TY
static void test_ammediastream_end_of_stream(void) { - check_ammediastream_end_of_stream(&MSPID_PrimaryAudio, &audio_mt); - check_ammediastream_end_of_stream(&MSPID_PrimaryVideo, &rgb32_mt); + check_ammediastream_end_of_stream(&CLSID_AMAudioStream, &MSPID_PrimaryAudio, &audio_mt); + check_ammediastream_end_of_stream(&CLSID_AMDirectDrawStream, &MSPID_PrimaryVideo, &rgb32_mt); }
void test_mediastreamfilter_get_state(void)
Signed-off-by: Anton Baskanov baskanov@gmail.com --- dlls/amstream/audiostream.c | 5 +++++ dlls/amstream/ddrawstream.c | 5 +++++ dlls/amstream/tests/amstream.c | 4 ++-- 3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/dlls/amstream/audiostream.c b/dlls/amstream/audiostream.c index dc6c810d19a..a07e62a4672 100644 --- a/dlls/amstream/audiostream.c +++ b/dlls/amstream/audiostream.c @@ -1157,6 +1157,11 @@ static HRESULT WINAPI audio_sink_EndOfStream(IPin *iface)
LeaveCriticalSection(&stream->cs);
+ /* Calling IMediaStreamFilter::EndOfStream() inside the critical section + * would invert the locking order, so we must leave it first to avoid + * the streaming thread deadlocking on the filter's critical section. */ + IMediaStreamFilter_EndOfStream(stream->filter); + return S_OK; }
diff --git a/dlls/amstream/ddrawstream.c b/dlls/amstream/ddrawstream.c index d6f07e1b10a..e04e3a1c56f 100644 --- a/dlls/amstream/ddrawstream.c +++ b/dlls/amstream/ddrawstream.c @@ -1177,6 +1177,11 @@ static HRESULT WINAPI ddraw_sink_EndOfStream(IPin *iface)
LeaveCriticalSection(&stream->cs);
+ /* Calling IMediaStreamFilter::EndOfStream() inside the critical section + * would invert the locking order, so we must leave it first to avoid + * the streaming thread deadlocking on the filter's critical section. */ + IMediaStreamFilter_EndOfStream(stream->filter); + return S_OK; }
diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index e7fd731dd72..a6ec84fbdea 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -6127,8 +6127,8 @@ static void check_ammediastream_end_of_stream(const CLSID *clsid, const MSPID *i hr = IPin_EndOfStream(pin); ok(hr == S_OK, "Got hr %#x.\n", hr);
- todo_wine ok(graph.got_notify == 1, "Got %d calls to IMediaEventSink::Notify().\n", graph.got_notify); - todo_wine ok(graph.event_code == EC_COMPLETE, "Got event code %d.\n", graph.event_code); + ok(graph.got_notify == 1, "Got %d calls to IMediaEventSink::Notify().\n", graph.got_notify); + ok(graph.event_code == EC_COMPLETE, "Got event code %d.\n", graph.event_code);
hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_STOP); ok(hr == S_OK, "Got hr %#x.\n", hr);
Signed-off-by: Zebediah Figura z.figura12@gmail.com
Signed-off-by: Anton Baskanov baskanov@gmail.com --- dlls/amstream/tests/amstream.c | 249 ++++++++++++++++++++++++++++++--- 1 file changed, 228 insertions(+), 21 deletions(-)
diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index a6ec84fbdea..eaa1073532d 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -1231,8 +1231,8 @@ static HRESULT WINAPI testsource_seeking_GetStopPosition(IMediaSeeking *iface, L
static HRESULT WINAPI testsource_seeking_GetCurrentPosition(IMediaSeeking *iface, LONGLONG *current) { - ok(0, "Unexpected call.\n"); - return E_NOTIMPL; + *current = 0; + return S_OK; }
static HRESULT WINAPI testsource_seeking_ConvertTimeFormat(IMediaSeeking *iface, LONGLONG *target, @@ -4071,30 +4071,47 @@ static void test_audiostream_initialize(void) static void test_audiostream_begin_flush_end_flush(void) { IAMMultiMediaStream *mmstream = create_ammultimediastream(); + static const MSPID mspid = {0x88888888, 1}; IAudioStreamSample *stream_sample; IAudioMediaStream *audio_stream; + IMediaStreamFilter *filter; IMediaSample *media_sample; + struct testfilter source2; struct testfilter source; + IAMMediaStream *stream2; IAudioData *audio_data; - IGraphBuilder *graph; IMediaStream *stream; + struct graph graph; HRESULT hr; + IPin *pin2; ULONG ref; IPin *pin;
- hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL); + graph_init(&graph); + hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, (IGraphBuilder *)&graph.IFilterGraph2_iface); 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 = CoCreateInstance(&CLSID_AMAudioStream, NULL, CLSCTX_INPROC_SERVER, &IID_IAMMediaStream, (void **)&stream2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMediaStream_Initialize(stream2, NULL, 0, &mspid, STREAMTYPE_READ); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_AddMediaStream(mmstream, (IUnknown *)stream2, &mspid, 0, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); hr = IMediaStream_QueryInterface(stream, &IID_IAudioMediaStream, (void **)&audio_stream); ok(hr == S_OK, "Got hr %#x.\n", hr); hr = IMediaStream_QueryInterface(stream, &IID_IPin, (void **)&pin); ok(hr == S_OK, "Got hr %#x.\n", hr); - hr = IAMMultiMediaStream_GetFilterGraph(mmstream, &graph); + hr = IAMMediaStream_QueryInterface(stream2, &IID_IPin, (void **)&pin2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_GetFilter(mmstream, &filter); ok(hr == S_OK, "Got hr %#x.\n", hr); - ok(graph != NULL, "Expected non-NULL graph.\n"); testfilter_init(&source); - hr = IGraphBuilder_AddFilter(graph, &source.filter.IBaseFilter_iface, NULL); + testfilter_init(&source2); + source.IMediaSeeking_iface.lpVtbl = &testsource_seeking_vtbl; + hr = IFilterGraph2_AddFilter(&graph.IFilterGraph2_iface, &source.filter.IBaseFilter_iface, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IFilterGraph2_AddFilter(&graph.IFilterGraph2_iface, &source2.filter.IBaseFilter_iface, NULL); ok(hr == S_OK, "Got hr %#x.\n", hr); hr = CoCreateInstance(&CLSID_AMAudioData, NULL, CLSCTX_INPROC_SERVER, &IID_IAudioData, (void **)&audio_data); ok(hr == S_OK, "Got hr %#x.\n", hr); @@ -4103,7 +4120,12 @@ static void test_audiostream_begin_flush_end_flush(void) hr = IAudioMediaStream_CreateSample(audio_stream, audio_data, 0, &stream_sample); ok(hr == S_OK, "Got hr %#x.\n", hr);
- hr = IGraphBuilder_ConnectDirect(graph, &source.source.pin.IPin_iface, pin, &audio_mt); + hr = IFilterGraph2_ConnectDirect(&graph.IFilterGraph2_iface, &source.source.pin.IPin_iface, pin, &audio_mt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IFilterGraph2_ConnectDirect(&graph.IFilterGraph2_iface, &source2.source.pin.IPin_iface, pin2, &audio_mt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaStreamFilter_SupportSeeking(filter, TRUE); ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_RUN); @@ -4154,9 +4176,88 @@ static void test_audiostream_begin_flush_end_flush(void)
hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_STOP); ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_RUN); + ok(hr == S_OK, "Got hr %#x.\n", hr);
- IGraphBuilder_Disconnect(graph, pin); - IGraphBuilder_Disconnect(graph, &source.source.pin.IPin_iface); + hr = IPin_BeginFlush(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IPin_EndFlush(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_EndOfStream(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + graph.got_notify = 0; + + hr = IPin_EndOfStream(pin2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + ok(graph.got_notify == 1, "Got %d calls to IMediaEventSink::Notify().\n", graph.got_notify); + ok(graph.event_code == EC_COMPLETE, "Got event code %d.\n", graph.event_code); + + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_STOP); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_RUN); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_EndOfStream(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_BeginFlush(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IPin_EndFlush(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + graph.got_notify = 0; + graph.event_code = 0xcc; + + hr = IPin_EndOfStream(pin2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + todo_wine ok(graph.got_notify == 0, "Got %d calls to IMediaEventSink::Notify().\n", graph.got_notify); + + hr = IPin_EndOfStream(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + ok(graph.got_notify == 1, "Got %d calls to IMediaEventSink::Notify().\n", graph.got_notify); + ok(graph.event_code == EC_COMPLETE, "Got event code %d.\n", graph.event_code); + + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_STOP); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_RUN); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_EndOfStream(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_BeginFlush(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IPin_EndFlush(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IPin_BeginFlush(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IPin_EndFlush(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_EndOfStream(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + graph.got_notify = 0; + graph.event_code = 0xcc; + + hr = IPin_EndOfStream(pin2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + todo_wine ok(graph.got_notify == 1, "Got %d calls to IMediaEventSink::Notify().\n", graph.got_notify); + todo_wine ok(graph.event_code == EC_COMPLETE, "Got event code %d.\n", graph.event_code); + + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_STOP); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + IFilterGraph2_Disconnect(&graph.IFilterGraph2_iface, pin); + IFilterGraph2_Disconnect(&graph.IFilterGraph2_iface, &source.source.pin.IPin_iface); + IFilterGraph2_Disconnect(&graph.IFilterGraph2_iface, pin2); + IFilterGraph2_Disconnect(&graph.IFilterGraph2_iface, &source2.source.pin.IPin_iface);
ref = IAudioStreamSample_Release(stream_sample); ok(!ref, "Got outstanding refcount %d.\n", ref); @@ -4164,12 +4265,16 @@ static void test_audiostream_begin_flush_end_flush(void) ok(!ref, "Got outstanding refcount %d.\n", ref); ref = IAMMultiMediaStream_Release(mmstream); ok(!ref, "Got outstanding refcount %d.\n", ref); - ref = IGraphBuilder_Release(graph); + graph_destroy(&graph); + ref = IMediaStreamFilter_Release(filter); ok(!ref, "Got outstanding refcount %d.\n", ref); IPin_Release(pin); IAudioMediaStream_Release(audio_stream); ref = IMediaStream_Release(stream); ok(!ref, "Got outstanding refcount %d.\n", ref); + IPin_Release(pin2); + ref = IAMMediaStream_Release(stream2); + ok(!ref, "Got outstanding refcount %d.\n", ref); }
static IMediaSample *ammediastream_allocate_sample(struct testfilter *source, const BYTE *input_data, DWORD input_length) @@ -5548,35 +5653,52 @@ static void test_ddrawstream_receive(void) static void test_ddrawstream_begin_flush_end_flush(void) { IAMMultiMediaStream *mmstream = create_ammultimediastream(); + static const MSPID mspid = {0x88888888, 1}; IDirectDrawStreamSample *stream_sample; IDirectDrawMediaStream *ddraw_stream; + IMediaStreamFilter *filter; IMediaSample *media_sample; IMediaFilter *media_filter; + struct testfilter source2; struct testfilter source; - IGraphBuilder *graph; + IAMMediaStream *stream2; IMediaStream *stream; VIDEOINFO video_info; + struct graph graph; AM_MEDIA_TYPE mt; HANDLE thread; HRESULT hr; + IPin *pin2; ULONG ref; IPin *pin;
- hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL); + graph_init(&graph); + hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, (IGraphBuilder *)&graph.IFilterGraph2_iface); ok(hr == S_OK, "Got hr %#x.\n", hr); hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryVideo, 0, &stream); ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = CoCreateInstance(&CLSID_AMDirectDrawStream, NULL, CLSCTX_INPROC_SERVER, &IID_IAMMediaStream, (void **)&stream2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMediaStream_Initialize(stream2, NULL, 0, &mspid, STREAMTYPE_READ); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_AddMediaStream(mmstream, (IUnknown *)stream2, &mspid, 0, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); hr = IMediaStream_QueryInterface(stream, &IID_IDirectDrawMediaStream, (void **)&ddraw_stream); ok(hr == S_OK, "Got hr %#x.\n", hr); hr = IMediaStream_QueryInterface(stream, &IID_IPin, (void **)&pin); ok(hr == S_OK, "Got hr %#x.\n", hr); - hr = IAMMultiMediaStream_GetFilterGraph(mmstream, &graph); + hr = IAMMediaStream_QueryInterface(stream2, &IID_IPin, (void **)&pin2); ok(hr == S_OK, "Got hr %#x.\n", hr); - ok(graph != NULL, "Expected non-NULL graph.\n"); - hr = IGraphBuilder_QueryInterface(graph, &IID_IMediaFilter, (void **)&media_filter); + hr = IFilterGraph2_QueryInterface(&graph.IFilterGraph2_iface, &IID_IMediaFilter, (void **)&media_filter); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_GetFilter(mmstream, &filter); ok(hr == S_OK, "Got hr %#x.\n", hr); testfilter_init(&source); - hr = IGraphBuilder_AddFilter(graph, &source.filter.IBaseFilter_iface, NULL); + testfilter_init(&source2); + source.IMediaSeeking_iface.lpVtbl = &testsource_seeking_vtbl; + hr = IFilterGraph2_AddFilter(&graph.IFilterGraph2_iface, &source.filter.IBaseFilter_iface, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IFilterGraph2_AddFilter(&graph.IFilterGraph2_iface, &source2.filter.IBaseFilter_iface, NULL); ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IMediaFilter_SetSyncSource(media_filter, NULL); @@ -5587,7 +5709,12 @@ static void test_ddrawstream_begin_flush_end_flush(void) video_info.bmiHeader.biHeight = 1; mt = rgb32_mt; mt.pbFormat = (BYTE *)&video_info; - hr = IGraphBuilder_ConnectDirect(graph, &source.source.pin.IPin_iface, pin, &mt); + hr = IFilterGraph2_ConnectDirect(&graph.IFilterGraph2_iface, &source.source.pin.IPin_iface, pin, &mt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IFilterGraph2_ConnectDirect(&graph.IFilterGraph2_iface, &source2.source.pin.IPin_iface, pin2, &mt); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaStreamFilter_SupportSeeking(filter, TRUE); ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IDirectDrawMediaStream_CreateSample(ddraw_stream, NULL, NULL, 0, &stream_sample); @@ -5643,16 +5770,96 @@ static void test_ddrawstream_begin_flush_end_flush(void)
hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_STOP); ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_RUN); + ok(hr == S_OK, "Got hr %#x.\n", hr);
- IGraphBuilder_Disconnect(graph, pin); - IGraphBuilder_Disconnect(graph, &source.source.pin.IPin_iface); + hr = IPin_BeginFlush(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IPin_EndFlush(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_EndOfStream(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + graph.got_notify = 0; + + hr = IPin_EndOfStream(pin2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + ok(graph.got_notify == 1, "Got %d calls to IMediaEventSink::Notify().\n", graph.got_notify); + ok(graph.event_code == EC_COMPLETE, "Got event code %d.\n", graph.event_code); + + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_STOP); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_RUN); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_EndOfStream(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_BeginFlush(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IPin_EndFlush(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + graph.got_notify = 0; + graph.event_code = 0xcc; + + hr = IPin_EndOfStream(pin2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + todo_wine ok(graph.got_notify == 0, "Got %d calls to IMediaEventSink::Notify().\n", graph.got_notify); + + hr = IPin_EndOfStream(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + ok(graph.got_notify == 1, "Got %d calls to IMediaEventSink::Notify().\n", graph.got_notify); + ok(graph.event_code == EC_COMPLETE, "Got event code %d.\n", graph.event_code); + + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_STOP); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_RUN); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_EndOfStream(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_BeginFlush(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IPin_EndFlush(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IPin_BeginFlush(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IPin_EndFlush(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_EndOfStream(pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + graph.got_notify = 0; + graph.event_code = 0xcc; + + hr = IPin_EndOfStream(pin2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + todo_wine ok(graph.got_notify == 1, "Got %d calls to IMediaEventSink::Notify().\n", graph.got_notify); + todo_wine ok(graph.event_code == EC_COMPLETE, "Got event code %d.\n", graph.event_code); + + hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_STOP); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + IFilterGraph2_Disconnect(&graph.IFilterGraph2_iface, pin); + IFilterGraph2_Disconnect(&graph.IFilterGraph2_iface, &source.source.pin.IPin_iface); + IFilterGraph2_Disconnect(&graph.IFilterGraph2_iface, pin2); + IFilterGraph2_Disconnect(&graph.IFilterGraph2_iface, &source2.source.pin.IPin_iface);
ref = IDirectDrawStreamSample_Release(stream_sample); ok(!ref, "Got outstanding refcount %d.\n", ref); ref = IAMMultiMediaStream_Release(mmstream); ok(!ref, "Got outstanding refcount %d.\n", ref); IMediaFilter_Release(media_filter); - ref = IGraphBuilder_Release(graph); + graph_destroy(&graph); + ref = IMediaStreamFilter_Release(filter); ok(!ref, "Got outstanding refcount %d.\n", ref); IPin_Release(pin); IDirectDrawMediaStream_Release(ddraw_stream);
Signed-off-by: Zebediah Figura z.figura12@gmail.com
Signed-off-by: Anton Baskanov baskanov@gmail.com --- dlls/amstream/audiostream.c | 8 ++++++++ dlls/amstream/ddrawstream.c | 8 ++++++++ dlls/amstream/tests/amstream.c | 12 ++++++------ 3 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/dlls/amstream/audiostream.c b/dlls/amstream/audiostream.c index a07e62a4672..77ed4072ccf 100644 --- a/dlls/amstream/audiostream.c +++ b/dlls/amstream/audiostream.c @@ -1168,17 +1168,25 @@ static HRESULT WINAPI audio_sink_EndOfStream(IPin *iface) static HRESULT WINAPI audio_sink_BeginFlush(IPin *iface) { struct audio_stream *stream = impl_from_IPin(iface); + BOOL cancel_eos;
TRACE("stream %p.\n", stream);
EnterCriticalSection(&stream->cs);
+ cancel_eos = stream->eos; + stream->flushing = TRUE; stream->eos = FALSE; flush_receive_queue(stream);
LeaveCriticalSection(&stream->cs);
+ /* Calling IMediaStreamFilter::Flush() inside the critical section would + * invert the locking order, so we must leave it first to avoid the + * application thread deadlocking on the filter's critical section. */ + IMediaStreamFilter_Flush(stream->filter, cancel_eos); + return S_OK; }
diff --git a/dlls/amstream/ddrawstream.c b/dlls/amstream/ddrawstream.c index e04e3a1c56f..b1ef12cb524 100644 --- a/dlls/amstream/ddrawstream.c +++ b/dlls/amstream/ddrawstream.c @@ -1188,17 +1188,25 @@ static HRESULT WINAPI ddraw_sink_EndOfStream(IPin *iface) static HRESULT WINAPI ddraw_sink_BeginFlush(IPin *iface) { struct ddraw_stream *stream = impl_from_IPin(iface); + BOOL cancel_eos;
TRACE("stream %p.\n", stream);
EnterCriticalSection(&stream->cs);
+ cancel_eos = stream->eos; + stream->flushing = TRUE; stream->eos = FALSE; WakeConditionVariable(&stream->update_queued_cv);
LeaveCriticalSection(&stream->cs);
+ /* Calling IMediaStreamFilter::Flush() inside the critical section would + * invert the locking order, so we must leave it first to avoid the + * application thread deadlocking on the filter's critical section. */ + IMediaStreamFilter_Flush(stream->filter, cancel_eos); + return S_OK; }
diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index eaa1073532d..182fb06a082 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -4214,7 +4214,7 @@ static void test_audiostream_begin_flush_end_flush(void) hr = IPin_EndOfStream(pin2); ok(hr == S_OK, "Got hr %#x.\n", hr);
- todo_wine ok(graph.got_notify == 0, "Got %d calls to IMediaEventSink::Notify().\n", graph.got_notify); + ok(graph.got_notify == 0, "Got %d calls to IMediaEventSink::Notify().\n", graph.got_notify);
hr = IPin_EndOfStream(pin); ok(hr == S_OK, "Got hr %#x.\n", hr); @@ -4248,8 +4248,8 @@ static void test_audiostream_begin_flush_end_flush(void) hr = IPin_EndOfStream(pin2); ok(hr == S_OK, "Got hr %#x.\n", hr);
- todo_wine ok(graph.got_notify == 1, "Got %d calls to IMediaEventSink::Notify().\n", graph.got_notify); - todo_wine ok(graph.event_code == EC_COMPLETE, "Got event code %d.\n", graph.event_code); + ok(graph.got_notify == 1, "Got %d calls to IMediaEventSink::Notify().\n", graph.got_notify); + ok(graph.event_code == EC_COMPLETE, "Got event code %d.\n", graph.event_code);
hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_STOP); ok(hr == S_OK, "Got hr %#x.\n", hr); @@ -5808,7 +5808,7 @@ static void test_ddrawstream_begin_flush_end_flush(void) hr = IPin_EndOfStream(pin2); ok(hr == S_OK, "Got hr %#x.\n", hr);
- todo_wine ok(graph.got_notify == 0, "Got %d calls to IMediaEventSink::Notify().\n", graph.got_notify); + ok(graph.got_notify == 0, "Got %d calls to IMediaEventSink::Notify().\n", graph.got_notify);
hr = IPin_EndOfStream(pin); ok(hr == S_OK, "Got hr %#x.\n", hr); @@ -5842,8 +5842,8 @@ static void test_ddrawstream_begin_flush_end_flush(void) hr = IPin_EndOfStream(pin2); ok(hr == S_OK, "Got hr %#x.\n", hr);
- todo_wine ok(graph.got_notify == 1, "Got %d calls to IMediaEventSink::Notify().\n", graph.got_notify); - todo_wine ok(graph.event_code == EC_COMPLETE, "Got event code %d.\n", graph.event_code); + ok(graph.got_notify == 1, "Got %d calls to IMediaEventSink::Notify().\n", graph.got_notify); + ok(graph.event_code == EC_COMPLETE, "Got event code %d.\n", graph.event_code);
hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_STOP); ok(hr == S_OK, "Got hr %#x.\n", hr);
Signed-off-by: Zebediah Figura z.figura12@gmail.com