Changeset 275512 in webkit


Ignore:
Timestamp:
Apr 6, 2021 6:30:45 AM (3 years ago)
Author:
commit-queue@webkit.org
Message:

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

Patch by Philippe Normand <pnormand@igalia.com> 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):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r275511 r275512  
     12021-04-06  Philippe Normand  <pnormand@igalia.com>
     2
     3        [GTK][GStreamer] Web Audio - Media element source - Audio is cracking.
     4        https://bugs.webkit.org/show_bug.cgi?id=196293
     5
     6        Reviewed by Xabier Rodriguez-Calvar.
     7
     8        The provider client might request samples faster than the current clock speed, so this sink
     9        should process buffers as fast as possible. The cracks were consequence of the audio sink of
     10        the AudioDestination starving off.
     11
     12        * platform/audio/gstreamer/AudioSourceProviderGStreamer.cpp:
     13        (WebCore::AudioSourceProviderGStreamer::handleNewDeinterleavePad):
     14
    1152021-04-06  Philippe Normand  <pnormand@igalia.com>
    216
  • trunk/Source/WebCore/platform/audio/gstreamer/AudioSourceProviderGStreamer.cpp

    r275511 r275512  
    292292    // in an appsink so we can pull the data from each
    293293    // channel. Pipeline looks like:
    294     // ... deinterleave ! appsink.
    295     GstElement* sink = gst_element_factory_make("appsink", nullptr);
     294    // ... deinterleave ! queue ! appsink.
     295    auto* queue = gst_element_factory_make("queue", nullptr);
     296    auto* sink = gst_element_factory_make("appsink", nullptr);
    296297
    297298    static GstAppSinkCallbacks callbacks = {
     
    306307    };
    307308    gst_app_sink_set_callbacks(GST_APP_SINK(sink), &callbacks, this, nullptr);
    308     g_object_set(sink, "async", FALSE, nullptr);
     309    // The provider client might request samples faster than the current clock speed, so this sink
     310    // should process buffers as fast as possible.
     311    g_object_set(sink, "async", FALSE, "sync", FALSE, nullptr);
    309312
    310313    auto caps = adoptGRef(gst_caps_new_simple("audio/x-raw", "rate", G_TYPE_INT, static_cast<int>(gSampleBitRate),
     
    312315    gst_app_sink_set_caps(GST_APP_SINK(sink), caps.get());
    313316
    314     gst_bin_add(GST_BIN_CAST(m_audioSinkBin.get()), sink);
    315 
    316     auto sinkPad = adoptGRef(gst_element_get_static_pad(sink, "sink"));
     317    gst_bin_add_many(GST_BIN_CAST(m_audioSinkBin.get()), queue, sink, nullptr);
     318
     319    gst_element_link(queue, sink);
     320
     321    auto sinkPad = adoptGRef(gst_element_get_static_pad(queue, "sink"));
    317322    gst_pad_link_full(pad, sinkPad.get(), GST_PAD_LINK_CHECK_NOTHING);
    318323
     
    336341    }, this, nullptr);
    337342
     343    gst_element_sync_state_with_parent(queue);
    338344    gst_element_sync_state_with_parent(sink);
    339345}
     
    352358        return;
    353359
    354     auto sink = adoptGRef(gst_pad_get_parent_element(sinkPad));
     360    auto queue = adoptGRef(gst_pad_get_parent_element(sinkPad));
     361    auto srcPad = adoptGRef(gst_element_get_static_pad(queue.get(), "src"));
     362    auto sinkSinkPad = adoptGRef(gst_pad_get_peer(srcPad.get()));
     363    auto sink = adoptGRef(gst_pad_get_parent_element(sinkSinkPad.get()));
     364    gst_pad_unlink(srcPad.get(), sinkSinkPad.get());
     365    gst_element_set_state(queue.get(), GST_STATE_NULL);
    355366    gst_element_set_state(sink.get(), GST_STATE_NULL);
    356     gst_bin_remove(GST_BIN_CAST(m_audioSinkBin.get()), sink.get());
     367    gst_bin_remove_many(GST_BIN_CAST(m_audioSinkBin.get()), queue.get(), sink.get(), nullptr);
    357368}
    358369
Note: See TracChangeset for help on using the changeset viewer.