Zebediah Figura : winegstreamer: Move QoS notification to the Unix library.

Alexandre Julliard julliard at winehq.org
Tue Feb 16 16:03:18 CST 2021


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

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Mon Feb 15 17:01:54 2021 -0600

winegstreamer: Move QoS notification to the Unix library.

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

---

 dlls/winegstreamer/gst_private.h |  2 ++
 dlls/winegstreamer/gstdemux.c    | 28 ++++++++++------------------
 dlls/winegstreamer/wg_parser.c   | 12 ++++++++++++
 3 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h
index ee698bdf32f..3c6d1147477 100644
--- a/dlls/winegstreamer/gst_private.h
+++ b/dlls/winegstreamer/gst_private.h
@@ -226,6 +226,8 @@ struct unix_funcs
     void (CDECL *wg_parser_stream_disable)(struct wg_parser_stream *stream);
 
     bool (CDECL *wg_parser_stream_get_event)(struct wg_parser_stream *stream, struct wg_parser_event *event);
+    void (CDECL *wg_parser_stream_notify_qos)(struct wg_parser_stream *stream,
+            bool underflow, double proportion, int64_t diff, uint64_t timestamp);
 };
 
 extern const struct unix_funcs *unix_funcs;
diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c
index 63368febc5c..da294c31e01 100644
--- a/dlls/winegstreamer/gstdemux.c
+++ b/dlls/winegstreamer/gstdemux.c
@@ -1350,11 +1350,8 @@ static ULONG WINAPI GST_QualityControl_Release(IQualityControl *iface)
 static HRESULT WINAPI GST_QualityControl_Notify(IQualityControl *iface, IBaseFilter *sender, Quality q)
 {
     struct parser_source *pin = impl_from_IQualityControl(iface);
-    struct wg_parser_stream *stream = pin->wg_stream;
-    GstQOSType type = GST_QOS_TYPE_OVERFLOW;
-    GstClockTime timestamp;
-    GstClockTimeDiff diff;
-    GstEvent *event;
+    uint64_t timestamp;
+    int64_t diff;
 
     TRACE("pin %p, sender %p, type %s, proportion %u, late %s, timestamp %s.\n",
             pin, sender, q.Type == Famine ? "Famine" : "Flood", q.Proportion,
@@ -1362,20 +1359,14 @@ static HRESULT WINAPI GST_QualityControl_Notify(IQualityControl *iface, IBaseFil
 
     mark_wine_thread();
 
-    /* GST_QOS_TYPE_OVERFLOW is also used for buffers that arrive on time, but
-     * DirectShow filters might use Famine, so check that there actually is an
-     * underrun. */
-    if (q.Type == Famine && q.Proportion < 1000)
-        type = GST_QOS_TYPE_UNDERFLOW;
-
     /* DirectShow filters sometimes pass negative timestamps (Audiosurf uses the
      * current time instead of the time of the last buffer). GstClockTime is
      * unsigned, so clamp it to 0. */
-    timestamp = max(q.TimeStamp * 100, 0);
+    timestamp = max(q.TimeStamp, 0);
 
     /* The documentation specifies that timestamp + diff must be nonnegative. */
-    diff = q.Late * 100;
-    if (diff < 0 && timestamp < (GstClockTime)-diff)
+    diff = q.Late;
+    if (diff < 0 && timestamp < (uint64_t)-diff)
         diff = -timestamp;
 
     /* DirectShow "Proportion" describes what percentage of buffers the upstream
@@ -1395,10 +1386,11 @@ static HRESULT WINAPI GST_QualityControl_Notify(IQualityControl *iface, IBaseFil
         return S_OK;
     }
 
-    if (!(event = gst_event_new_qos(type, 1000.0 / q.Proportion, diff, timestamp)))
-        ERR("Failed to create QOS event.\n");
-
-    gst_pad_push_event(stream->my_sink, event);
+    /* GST_QOS_TYPE_OVERFLOW is also used for buffers that arrive on time, but
+     * DirectShow filters might use Famine, so check that there actually is an
+     * underrun. */
+    unix_funcs->wg_parser_stream_notify_qos(pin->wg_stream, q.Type == Famine && q.Proportion < 1000,
+            1000.0 / q.Proportion, diff, timestamp);
 
     return S_OK;
 }
diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c
index bb1d6188a8b..79fa45eadca 100644
--- a/dlls/winegstreamer/wg_parser.c
+++ b/dlls/winegstreamer/wg_parser.c
@@ -391,6 +391,17 @@ static bool CDECL wg_parser_stream_get_event(struct wg_parser_stream *stream, st
     return true;
 }
 
+static void CDECL wg_parser_stream_notify_qos(struct wg_parser_stream *stream,
+        bool underflow, double proportion, int64_t diff, uint64_t timestamp)
+{
+    GstEvent *event;
+
+    if (!(event = gst_event_new_qos(underflow ? GST_QOS_TYPE_UNDERFLOW : GST_QOS_TYPE_OVERFLOW,
+            1000.0 / proportion, diff * 100, timestamp * 100)))
+        ERR("Failed to create QOS event.\n");
+    gst_pad_push_event(stream->my_sink, event);
+}
+
 static GstAutoplugSelectResult autoplug_blacklist(GstElement *bin, GstPad *pad, GstCaps *caps, GstElementFactory *fact, gpointer user)
 {
     const char *name = gst_element_factory_get_longname(fact);
@@ -1553,6 +1564,7 @@ static const struct unix_funcs funcs =
     wg_parser_stream_disable,
 
     wg_parser_stream_get_event,
+    wg_parser_stream_notify_qos,
 };
 
 NTSTATUS CDECL __wine_init_unix_lib(HMODULE module, DWORD reason, const void *ptr_in, void *ptr_out)




More information about the wine-cvs mailing list