Derek Lesho : winegstreamer: Implement IMFMediaSource::Stop.

Alexandre Julliard julliard at winehq.org
Fri Feb 19 17:20:07 CST 2021


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

Author: Derek Lesho <dlesho at codeweavers.com>
Date:   Thu Feb 18 17:01:26 2021 -0600

winegstreamer: Implement IMFMediaSource::Stop.

Signed-off-by: Derek Lesho <dlesho at codeweavers.com>
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/winegstreamer/media_source.c | 31 +++++++++++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/dlls/winegstreamer/media_source.c b/dlls/winegstreamer/media_source.c
index 6fb2c7f6f48..604e0ef056c 100644
--- a/dlls/winegstreamer/media_source.c
+++ b/dlls/winegstreamer/media_source.c
@@ -64,6 +64,7 @@ struct media_stream
 enum source_async_op
 {
     SOURCE_ASYNC_START,
+    SOURCE_ASYNC_STOP,
     SOURCE_ASYNC_REQUEST_SAMPLE,
 };
 
@@ -360,6 +361,24 @@ static void start_pipeline(struct media_source *source, struct source_async_comm
     gst_element_set_state(source->container, GST_STATE_PLAYING);
 }
 
+static void stop_pipeline(struct media_source *source)
+{
+    unsigned int i;
+
+    gst_element_set_state(source->container, GST_STATE_PAUSED);
+
+    for (i = 0; i < source->stream_count; i++)
+    {
+        struct media_stream *stream = source->streams[i];
+        if (stream->state != STREAM_INACTIVE)
+            IMFMediaEventQueue_QueueEventParamVar(stream->event_queue, MEStreamStopped, &GUID_NULL, S_OK, NULL);
+    }
+
+    IMFMediaEventQueue_QueueEventParamVar(source->event_queue, MESourceStopped, &GUID_NULL, S_OK, NULL);
+
+    source->state = SOURCE_STOPPED;
+}
+
 static void dispatch_end_of_presentation(struct media_source *source)
 {
     PROPVARIANT empty = {.vt = VT_EMPTY};
@@ -434,6 +453,9 @@ static HRESULT WINAPI source_async_commands_Invoke(IMFAsyncCallback *iface, IMFA
         case SOURCE_ASYNC_START:
             start_pipeline(source, command);
             break;
+        case SOURCE_ASYNC_STOP:
+            stop_pipeline(source);
+            break;
         case SOURCE_ASYNC_REQUEST_SAMPLE:
             wait_on_sample(command->u.request_sample.stream, command->u.request_sample.token);
             break;
@@ -1177,13 +1199,18 @@ static HRESULT WINAPI media_source_Start(IMFMediaSource *iface, IMFPresentationD
 static HRESULT WINAPI media_source_Stop(IMFMediaSource *iface)
 {
     struct media_source *source = impl_from_IMFMediaSource(iface);
+    struct source_async_command *command;
+    HRESULT hr;
 
-    FIXME("(%p): stub\n", source);
+    TRACE("(%p)\n", source);
 
     if (source->state == SOURCE_SHUTDOWN)
         return MF_E_SHUTDOWN;
 
-    return E_NOTIMPL;
+    if (SUCCEEDED(hr = source_create_async_op(SOURCE_ASYNC_STOP, &command)))
+        hr = MFPutWorkItem(source->async_commands_queue, &source->async_commands_callback, &command->IUnknown_iface);
+
+    return hr;
 }
 
 static HRESULT WINAPI media_source_Pause(IMFMediaSource *iface)




More information about the wine-cvs mailing list