[GStreamer] webaudio playback improvements
authorphiln@webkit.org <philn@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 May 2016 14:39:33 +0000 (14:39 +0000)
committerphiln@webkit.org <philn@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 May 2016 14:39:33 +0000 (14:39 +0000)
https://bugs.webkit.org/show_bug.cgi?id=155228

Reviewed by Michael Catanzaro.

* platform/audio/gstreamer/AudioDestinationGStreamer.cpp:
(WebCore::autoAudioSinkChildAddedCallback): Fix sink buffer-time
to 100ms to reduce playback latency.
(WebCore::AudioDestinationGStreamer::AudioDestinationGStreamer):
Connect to child-added signal of autoaudiosink to be notified when
a real sink is added into the bin.
* platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp:
(webKitWebAudioSrcConstructed): Fine-tune blocksize of appsrc
according to the buffer size already configured on the src element.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201077 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/audio/gstreamer/AudioDestinationGStreamer.cpp
Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp

index a162fd3..a66d444 100644 (file)
@@ -1,3 +1,20 @@
+2016-05-18  Philippe Normand  <pnormand@igalia.com>
+
+        [GStreamer] webaudio playback improvements
+        https://bugs.webkit.org/show_bug.cgi?id=155228
+
+        Reviewed by Michael Catanzaro.
+
+        * platform/audio/gstreamer/AudioDestinationGStreamer.cpp:
+        (WebCore::autoAudioSinkChildAddedCallback): Fix sink buffer-time
+        to 100ms to reduce playback latency.
+        (WebCore::AudioDestinationGStreamer::AudioDestinationGStreamer):
+        Connect to child-added signal of autoaudiosink to be notified when
+        a real sink is added into the bin.
+        * platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp:
+        (webKitWebAudioSrcConstructed): Fine-tune blocksize of appsrc
+        according to the buffer size already configured on the src element.
+
 2016-05-18  Gwang Yoon Hwang  <yoon@igalia.com>
 
         [GStreamer] Use FakeSink to get a decoded texture from a pipeline
index f359988..55f84d4 100644 (file)
@@ -28,6 +28,7 @@
 #include "GRefPtrGStreamer.h"
 #include "Logging.h"
 #include "WebKitWebAudioSourceGStreamer.h"
+#include <gst/audio/gstaudiobasesink.h>
 #include <gst/gst.h>
 #include <wtf/glib/GUniquePtr.h>
 
@@ -42,6 +43,12 @@ gboolean messageCallback(GstBus*, GstMessage* message, AudioDestinationGStreamer
     return destination->handleMessage(message);
 }
 
+static void autoAudioSinkChildAddedCallback(GstChildProxy*, GObject* object, gchar*, gpointer)
+{
+    if (GST_IS_AUDIO_BASE_SINK(object))
+        g_object_set(GST_AUDIO_BASE_SINK(object), "buffer-time", static_cast<gint64>(100000), nullptr);
+}
+
 std::unique_ptr<AudioDestination> AudioDestination::create(AudioIOCallback& callback, const String&, unsigned numberOfInputChannels, unsigned numberOfOutputChannels, float sampleRate)
 {
     // FIXME: make use of inputDeviceId as appropriate.
@@ -94,6 +101,8 @@ AudioDestinationGStreamer::AudioDestinationGStreamer(AudioIOCallback& callback,
         return;
     }
 
+    g_signal_connect(audioSink.get(), "child-added", G_CALLBACK(autoAudioSinkChildAddedCallback), nullptr);
+
     // Autoaudiosink does the real sink detection in the GST_STATE_NULL->READY transition
     // so it's best to roll it to READY as soon as possible to ensure the underlying platform
     // audiosink was loaded correctly.
index 13f6e8d..be78a86 100644 (file)
@@ -230,6 +230,7 @@ static void webKitWebAudioSrcConstructed(GObject* object)
 
         // Configure the appsrc for minimal latency.
         g_object_set(appsrc, "max-bytes", 2 * priv->bufferSize, "block", TRUE,
+            "blocksize", priv->bufferSize,
             "format", GST_FORMAT_TIME, "caps", caps.get(), nullptr);
 
         priv->sources = g_slist_prepend(priv->sources, gst_object_ref(appsrc));