[PATCH 3/4] winegstreamer: Defer a seek to pause time if necessary.

Zebediah Figura z.figura12 at gmail.com
Wed Feb 26 16:31:37 CST 2020


This fixes background music in Tomb Raider II.

Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
 dlls/winegstreamer/gstdemux.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c
index 2fb158d5628..02bf69cacd9 100644
--- a/dlls/winegstreamer/gstdemux.c
+++ b/dlls/winegstreamer/gstdemux.c
@@ -1386,6 +1386,7 @@ static void gstdemux_destroy(struct strmbase_filter *iface)
 static HRESULT gstdemux_init_stream(struct strmbase_filter *iface)
 {
     struct gstdemux *filter = impl_from_strmbase_filter(iface);
+    const SourceSeeking *seeking = &filter->sources[0]->seek;
     HRESULT hr = VFW_E_NOT_CONNECTED, pin_hr;
     GstStateChangeReturn ret;
     unsigned int i;
@@ -1407,6 +1408,21 @@ static HRESULT gstdemux_init_stream(struct strmbase_filter *iface)
     if (filter->no_more_pads_event)
         WaitForSingleObject(filter->no_more_pads_event, INFINITE);
 
+    /* GStreamer can't seek while stopped, and it resets position to the
+     * beginning of the stream every time it is stopped. */
+    if (seeking->llCurrent)
+    {
+        GstSeekType stop_type = GST_SEEK_TYPE_NONE;
+
+        if (seeking->llStop && seeking->llStop != seeking->llDuration)
+            stop_type = GST_SEEK_TYPE_SET;
+
+        gst_pad_push_event(filter->sources[0]->my_sink, gst_event_new_seek(
+                seeking->dRate, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH,
+                GST_SEEK_TYPE_SET, seeking->llCurrent * 100,
+                stop_type, seeking->llStop * 100));
+    }
+
     for (i = 0; i < filter->source_count; ++i)
     {
         if (SUCCEEDED(pin_hr = BaseOutputPinImpl_Active(&filter->sources[i]->pin)))
-- 
2.25.0




More information about the wine-devel mailing list