Title: [276754] releases/WebKitGTK/webkit-2.32/Source/WebCore
Revision
276754
Author
[email protected]
Date
2021-04-29 01:09:04 -0700 (Thu, 29 Apr 2021)

Log Message

Merge r275512 - [GTK][GStreamer] Web Audio - Media element source - Audio is cracking.
https://bugs.webkit.org/show_bug.cgi?id=196293

Patch by Philippe Normand <[email protected]> on 2021-04-06
Reviewed by Xabier Rodriguez-Calvar.

The provider client might request samples faster than the current clock speed, so this sink
should process buffers as fast as possible. The cracks were consequence of the audio sink of
the AudioDestination starving off.

* platform/audio/gstreamer/AudioSourceProviderGStreamer.cpp:
(WebCore::AudioSourceProviderGStreamer::handleNewDeinterleavePad):

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.32/Source/WebCore/ChangeLog (276753 => 276754)


--- releases/WebKitGTK/webkit-2.32/Source/WebCore/ChangeLog	2021-04-29 07:45:45 UTC (rev 276753)
+++ releases/WebKitGTK/webkit-2.32/Source/WebCore/ChangeLog	2021-04-29 08:09:04 UTC (rev 276754)
@@ -1,3 +1,17 @@
+2021-04-06  Philippe Normand  <[email protected]>
+
+        [GTK][GStreamer] Web Audio - Media element source - Audio is cracking.
+        https://bugs.webkit.org/show_bug.cgi?id=196293
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        The provider client might request samples faster than the current clock speed, so this sink
+        should process buffers as fast as possible. The cracks were consequence of the audio sink of
+        the AudioDestination starving off.
+
+        * platform/audio/gstreamer/AudioSourceProviderGStreamer.cpp:
+        (WebCore::AudioSourceProviderGStreamer::handleNewDeinterleavePad):
+
 2021-04-09  Philippe Normand  <[email protected]>
 
         [GStreamer] fast/canvas/canvas-createPattern-video-loading.html is failing since r218170

Modified: releases/WebKitGTK/webkit-2.32/Source/WebCore/platform/audio/gstreamer/AudioSourceProviderGStreamer.cpp (276753 => 276754)


--- releases/WebKitGTK/webkit-2.32/Source/WebCore/platform/audio/gstreamer/AudioSourceProviderGStreamer.cpp	2021-04-29 07:45:45 UTC (rev 276753)
+++ releases/WebKitGTK/webkit-2.32/Source/WebCore/platform/audio/gstreamer/AudioSourceProviderGStreamer.cpp	2021-04-29 08:09:04 UTC (rev 276754)
@@ -289,8 +289,9 @@
     // A new pad for a planar channel was added in deinterleave. Plug
     // in an appsink so we can pull the data from each
     // channel. Pipeline looks like:
-    // ... deinterleave ! appsink.
-    GstElement* sink = gst_element_factory_make("appsink", nullptr);
+    // ... deinterleave ! queue ! appsink.
+    auto* queue = gst_element_factory_make("queue", nullptr);
+    auto* sink = gst_element_factory_make("appsink", nullptr);
 
     static GstAppSinkCallbacks callbacks = {
         nullptr,
@@ -303,15 +304,19 @@
         { nullptr }
     };
     gst_app_sink_set_callbacks(GST_APP_SINK(sink), &callbacks, this, nullptr);
-    g_object_set(sink, "async", FALSE, nullptr);
+    // The provider client might request samples faster than the current clock speed, so this sink
+    // should process buffers as fast as possible.
+    g_object_set(sink, "async", FALSE, "sync", FALSE, nullptr);
 
     auto caps = adoptGRef(gst_caps_new_simple("audio/x-raw", "rate", G_TYPE_INT, static_cast<int>(gSampleBitRate),
         "channels", G_TYPE_INT, 1, "format", G_TYPE_STRING, GST_AUDIO_NE(F32), "layout", G_TYPE_STRING, "interleaved", nullptr));
     gst_app_sink_set_caps(GST_APP_SINK(sink), caps.get());
 
-    gst_bin_add(GST_BIN_CAST(m_audioSinkBin.get()), sink);
+    gst_bin_add_many(GST_BIN_CAST(m_audioSinkBin.get()), queue, sink, nullptr);
 
-    auto sinkPad = adoptGRef(gst_element_get_static_pad(sink, "sink"));
+    gst_element_link(queue, sink);
+
+    auto sinkPad = adoptGRef(gst_element_get_static_pad(queue, "sink"));
     gst_pad_link_full(pad, sinkPad.get(), GST_PAD_LINK_CHECK_NOTHING);
 
     GQuark quark = g_quark_from_static_string("peer");
@@ -333,6 +338,7 @@
         return GST_PAD_PROBE_OK;
     }, this, nullptr);
 
+    gst_element_sync_state_with_parent(queue);
     gst_element_sync_state_with_parent(sink);
 }
 
@@ -349,9 +355,14 @@
     if (!sinkPad)
         return;
 
-    auto sink = adoptGRef(gst_pad_get_parent_element(sinkPad));
+    auto queue = adoptGRef(gst_pad_get_parent_element(sinkPad));
+    auto srcPad = adoptGRef(gst_element_get_static_pad(queue.get(), "src"));
+    auto sinkSinkPad = adoptGRef(gst_pad_get_peer(srcPad.get()));
+    auto sink = adoptGRef(gst_pad_get_parent_element(sinkSinkPad.get()));
+    gst_pad_unlink(srcPad.get(), sinkSinkPad.get());
+    gst_element_set_state(queue.get(), GST_STATE_NULL);
     gst_element_set_state(sink.get(), GST_STATE_NULL);
-    gst_bin_remove(GST_BIN_CAST(m_audioSinkBin.get()), sink.get());
+    gst_bin_remove_many(GST_BIN_CAST(m_audioSinkBin.get()), queue.get(), sink.get(), nullptr);
 }
 
 void AudioSourceProviderGStreamer::deinterleavePadsConfigured()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to