Changeset 131478 in webkit


Ignore:
Timestamp:
Oct 16, 2012 11:20:12 AM (12 years ago)
Author:
zandobersek@gmail.com
Message:

[GStreamer] GstBuffer ref race in WebKitWebAudioSrcLoop
https://bugs.webkit.org/show_bug.cgi?id=95833

Reviewed by Philippe Normand.

The render bus used in GStreamer's implementation of AudioDestination no longer
allocates memory for each of its channels. Rather than that, when looping, the
data is rendered into a channel-specific GstBuffer. Each buffer is then chained
to the appropriate GstPad, as has been the case before.

No new tests - there are tests covering this change but they are not yet working
on the GTK port or any other GStreamer implementation of Web Audio.

  • platform/audio/gstreamer/AudioDestinationGStreamer.cpp:

(WebCore::AudioDestinationGStreamer::AudioDestinationGStreamer):

  • platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp:

(_WebKitWebAudioSourcePrivate): Remove an unused member variable.
(webkit_web_audio_src_init): Remove an unnecessary line.
(webKitWebAudioSrcConstructed): Ditto.
(webKitWebAudioSrcLoop):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r131477 r131478  
     12012-10-16  Zan Dobersek  <zandobersek@gmail.com>
     2
     3        [GStreamer] GstBuffer ref race in WebKitWebAudioSrcLoop
     4        https://bugs.webkit.org/show_bug.cgi?id=95833
     5
     6        Reviewed by Philippe Normand.
     7
     8        The render bus used in GStreamer's implementation of AudioDestination no longer
     9        allocates memory for each of its channels. Rather than that, when looping, the
     10        data is rendered into a channel-specific GstBuffer. Each buffer is then chained
     11        to the appropriate GstPad, as has been the case before.
     12
     13        No new tests - there are tests covering this change but they are not yet working
     14        on the GTK port or any other GStreamer implementation of Web Audio.
     15
     16        * platform/audio/gstreamer/AudioDestinationGStreamer.cpp:
     17        (WebCore::AudioDestinationGStreamer::AudioDestinationGStreamer):
     18        * platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp:
     19        (_WebKitWebAudioSourcePrivate): Remove an unused member variable.
     20        (webkit_web_audio_src_init): Remove an unnecessary line.
     21        (webKitWebAudioSrcConstructed): Ditto.
     22        (webKitWebAudioSrcLoop):
     23
    1242012-10-16  Pablo Flouret  <pablof@motorola.com>
    225
  • trunk/Source/WebCore/platform/audio/gstreamer/AudioDestinationGStreamer.cpp

    r124264 r131478  
    5454AudioDestinationGStreamer::AudioDestinationGStreamer(AudioIOCallback& callback, float sampleRate)
    5555    : m_callback(callback)
    56     , m_renderBus(2, framesToPull, true)
     56    , m_renderBus(2, framesToPull, false)
    5757    , m_sampleRate(sampleRate)
    5858    , m_isPlaying(false)
  • trunk/Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp

    r124264 r131478  
    5050    AudioIOCallback* provider;
    5151    guint framesToPull;
    52     guint64 currentBufferOffset;
    5352
    5453    GRefPtr<GstElement> interleave;
     
    186185    priv->provider = 0;
    187186    priv->bus = 0;
    188     priv->currentBufferOffset = 0;
    189187
    190188    priv->mutex = g_new(GStaticRecMutex, 1);
     
    219217    gst_bin_add_many(GST_BIN(src), priv->interleave.get(), priv->wavEncoder.get(), NULL);
    220218    gst_element_link_pads_full(priv->interleave.get(), "src", priv->wavEncoder.get(), "sink", GST_PAD_LINK_CHECK_NOTHING);
    221 
    222219
    223220    // For each channel of the bus create a new upstream branch for interleave, like:
     
    248245    priv->pads = g_slist_reverse(priv->pads);
    249246
    250 
    251247    // wavenc's src pad is the only visible pad of our element.
    252248    GRefPtr<GstPad> targetPad = adoptGRef(gst_element_get_static_pad(priv->wavEncoder.get(), "src"));
     
    324320        return;
    325321
     322    GSList* channelBufferList = 0;
     323    unsigned bufferSize = priv->framesToPull * sizeof(float);
     324    for (unsigned i = 0; i < g_slist_length(priv->pads); i++) {
     325        GstBuffer* channelBuffer = gst_buffer_new_and_alloc(bufferSize);
     326        ASSERT(channelBuffer);
     327        channelBufferList = g_slist_prepend(channelBufferList, channelBuffer);
     328        priv->bus->setChannelMemory(i, reinterpret_cast<float*>(GST_BUFFER_DATA(channelBuffer)), priv->framesToPull);
     329    }
     330    channelBufferList = g_slist_reverse(channelBufferList);
     331
    326332    // FIXME: Add support for local/live audio input.
    327333    priv->provider->render(0, priv->bus, priv->framesToPull);
    328334
    329     unsigned bufferSize = priv->framesToPull * sizeof(float);
    330     for (unsigned index = 0; index < g_slist_length(priv->pads); index++) {
    331         GstPad* pad = static_cast<GstPad*>(g_slist_nth_data(priv->pads, index));
    332 
    333         GstBuffer* buffer = gst_buffer_new();
    334         ASSERT(buffer);
    335         ASSERT(!GST_BUFFER_MALLOCDATA(buffer));
    336 
    337         GST_BUFFER_DATA(buffer) = reinterpret_cast<guint8*>(const_cast<float*>(priv->bus->channel(index)->data()));
    338         GST_BUFFER_SIZE(buffer) = bufferSize;
    339         GST_BUFFER_OFFSET(buffer) = priv->currentBufferOffset;
    340         GST_BUFFER_OFFSET_END(buffer) = priv->currentBufferOffset + priv->framesToPull;
     335    for (unsigned i = 0; i < g_slist_length(priv->pads); i++) {
     336        GstPad* pad = static_cast<GstPad*>(g_slist_nth_data(priv->pads, i));
     337        GstBuffer* channelBuffer = static_cast<GstBuffer*>(g_slist_nth_data(channelBufferList, i));
    341338
    342339        GRefPtr<GstCaps> monoCaps = adoptGRef(getGStreamerMonoAudioCaps(priv->sampleRate));
    343340        GstStructure* structure = gst_caps_get_structure(monoCaps.get(), 0);
    344         GstAudioChannelPosition channelPosition = webKitWebAudioGStreamerChannelPosition(index);
     341        GstAudioChannelPosition channelPosition = webKitWebAudioGStreamerChannelPosition(i);
    345342        gst_audio_set_channel_positions(structure, &channelPosition);
    346         gst_buffer_set_caps(buffer, monoCaps.get());
    347 
    348         gst_pad_chain(pad, buffer);
    349     }
    350 
    351     priv->currentBufferOffset += priv->framesToPull;
     343        gst_buffer_set_caps(channelBuffer, monoCaps.get());
     344
     345        gst_pad_chain(pad, channelBuffer);
     346    }
     347
     348    g_slist_free(channelBufferList);
    352349}
    353350
Note: See TracChangeset for help on using the changeset viewer.