Derek Lesho : winegstreamer: Implement IMFMediaSource::Shutdown.

Alexandre Julliard julliard at winehq.org
Mon Sep 7 16:12:54 CDT 2020


Module: wine
Branch: master
Commit: e7b8911695d42ddb826c941dcd9c26da5c3312b9
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=e7b8911695d42ddb826c941dcd9c26da5c3312b9

Author: Derek Lesho <dlesho at codeweavers.com>
Date:   Wed Sep  2 14:26:02 2020 -0500

winegstreamer: Implement IMFMediaSource::Shutdown.

Signed-off-by: Derek Lesho <dlesho at codeweavers.com>
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/mfplat/tests/mfplat.c        |  4 ++--
 dlls/winegstreamer/media_source.c | 36 ++++++++++++++++++++++++++++++++++--
 2 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c
index 94fdf9e6f3..309f7b669a 100644
--- a/dlls/mfplat/tests/mfplat.c
+++ b/dlls/mfplat/tests/mfplat.c
@@ -673,14 +673,14 @@ todo_wine
     IMFMediaTypeHandler_Release(handler);
     IMFPresentationDescriptor_Release(descriptor);
 
+skip_source_tests:
+
     hr = IMFMediaSource_Shutdown(mediasource);
     ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
 
     hr = IMFMediaSource_CreatePresentationDescriptor(mediasource, NULL);
     ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
 
-skip_source_tests:
-
     IMFMediaSource_Release(mediasource);
     IMFByteStream_Release(stream);
 
diff --git a/dlls/winegstreamer/media_source.c b/dlls/winegstreamer/media_source.c
index cbe51fa957..84ecf305d4 100644
--- a/dlls/winegstreamer/media_source.c
+++ b/dlls/winegstreamer/media_source.c
@@ -39,6 +39,12 @@ struct media_source
     IMFMediaSource IMFMediaSource_iface;
     LONG ref;
     IMFMediaEventQueue *event_queue;
+    enum
+    {
+        SOURCE_OPENING,
+        SOURCE_STOPPED,
+        SOURCE_SHUTDOWN,
+    } state;
 };
 
 static inline struct media_source *impl_from_IMFMediaSource(IMFMediaSource *iface)
@@ -88,6 +94,7 @@ static ULONG WINAPI media_source_Release(IMFMediaSource *iface)
 
     if (!ref)
     {
+        IMFMediaSource_Shutdown(&source->IMFMediaSource_iface);
         IMFMediaEventQueue_Release(source->event_queue);
         heap_free(source);
     }
@@ -138,6 +145,9 @@ static HRESULT WINAPI media_source_GetCharacteristics(IMFMediaSource *iface, DWO
 
     FIXME("(%p)->(%p): stub\n", source, characteristics);
 
+    if (source->state == SOURCE_SHUTDOWN)
+        return MF_E_SHUTDOWN;
+
     return E_NOTIMPL;
 }
 
@@ -147,6 +157,9 @@ static HRESULT WINAPI media_source_CreatePresentationDescriptor(IMFMediaSource *
 
     FIXME("(%p)->(%p): stub\n", source, descriptor);
 
+    if (source->state == SOURCE_SHUTDOWN)
+        return MF_E_SHUTDOWN;
+
     return E_NOTIMPL;
 }
 
@@ -157,6 +170,9 @@ static HRESULT WINAPI media_source_Start(IMFMediaSource *iface, IMFPresentationD
 
     FIXME("(%p)->(%p, %p, %p): stub\n", source, descriptor, time_format, start_position);
 
+    if (source->state == SOURCE_SHUTDOWN)
+        return MF_E_SHUTDOWN;
+
     return E_NOTIMPL;
 }
 
@@ -166,6 +182,9 @@ static HRESULT WINAPI media_source_Stop(IMFMediaSource *iface)
 
     FIXME("(%p): stub\n", source);
 
+    if (source->state == SOURCE_SHUTDOWN)
+        return MF_E_SHUTDOWN;
+
     return E_NOTIMPL;
 }
 
@@ -175,6 +194,9 @@ static HRESULT WINAPI media_source_Pause(IMFMediaSource *iface)
 
     FIXME("(%p): stub\n", source);
 
+    if (source->state == SOURCE_SHUTDOWN)
+        return MF_E_SHUTDOWN;
+
     return E_NOTIMPL;
 }
 
@@ -182,9 +204,17 @@ static HRESULT WINAPI media_source_Shutdown(IMFMediaSource *iface)
 {
     struct media_source *source = impl_from_IMFMediaSource(iface);
 
-    FIXME("(%p): stub\n", source);
+    TRACE("(%p)\n", source);
 
-    return E_NOTIMPL;
+    if (source->state == SOURCE_SHUTDOWN)
+        return MF_E_SHUTDOWN;
+
+    source->state = SOURCE_SHUTDOWN;
+
+    if (source->event_queue)
+        IMFMediaEventQueue_Shutdown(source->event_queue);
+
+    return S_OK;
 }
 
 static const IMFMediaSourceVtbl IMFMediaSource_vtbl =
@@ -215,6 +245,8 @@ static HRESULT media_source_constructor(IMFByteStream *bytestream, struct media_
     if (FAILED(hr = MFCreateEventQueue(&object->event_queue)))
         goto fail;
 
+    object->state = SOURCE_STOPPED;
+
     object->IMFMediaSource_iface.lpVtbl = &IMFMediaSource_vtbl;
     object->ref = 1;
 




More information about the wine-cvs mailing list