⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 140443 in webkit


Ignore:
Timestamp:
Jan 22, 2013, 11:15:38 AM (14 years ago)
Author:
Christophe Dumez
Message:

[gstreamer] GstBus signal watch should be removed on clean up
https://bugs.webkit.org/show_bug.cgi?id=107544

Reviewed by Philippe Normand.

Our gstreamer backend code currently calls gst_bus_add_signal_watch()
on GstBus to add a signal watch. As per the gstreamer documentation,
"To clean up, the caller is responsible for calling
gst_bus_remove_signal_watch() as many times as this function is
called". This is because gst_bus_add_signal_watch() causes the GstBus
object to be ref'd and gst_bus_remove_signal_watch() needs to be
called to properly unref it.

This patch makes sure that gst_bus_remove_signal_watch() is called
on the GstBus object when cleaning up. This patch also uses smart
pointers for GstBus objects for consistency.

No new tests, no behavior change for layout tests.

  • platform/audio/gstreamer/AudioDestinationGStreamer.cpp:

(WebCore::AudioDestinationGStreamer::AudioDestinationGStreamer):
(WebCore::AudioDestinationGStreamer::~AudioDestinationGStreamer):

  • platform/audio/gstreamer/AudioFileReaderGStreamer.cpp:

(WebCore::AudioFileReader::~AudioFileReader):
(WebCore::AudioFileReader::decodeAudioForBusCreation):

  • platform/graphics/gstreamer/GStreamerGWorld.cpp:

(WebCore::GStreamerGWorld::GStreamerGWorld):

  • platform/graphics/gstreamer/GStreamerVersioning.cpp:

(webkitGstPipelineGetBus):

  • platform/graphics/gstreamer/GStreamerVersioning.h:
  • platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:

(WebCore::MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer):

Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r140441 r140443  
     12013-01-22  Christophe Dumez  <christophe.dumez@intel.com>
     2
     3        [gstreamer] GstBus signal watch should be removed on clean up
     4        https://bugs.webkit.org/show_bug.cgi?id=107544
     5
     6        Reviewed by Philippe Normand.
     7
     8        Our gstreamer backend code currently calls gst_bus_add_signal_watch()
     9        on GstBus to add a signal watch. As per the gstreamer  documentation,
     10        "To clean up, the caller is responsible for calling
     11        gst_bus_remove_signal_watch() as many times as this function is
     12        called". This is because gst_bus_add_signal_watch() causes the GstBus
     13        object to be ref'd and gst_bus_remove_signal_watch() needs to be
     14        called to properly unref it.
     15
     16        This patch makes sure that gst_bus_remove_signal_watch() is called
     17        on the GstBus object when cleaning up. This patch also uses smart
     18        pointers for GstBus objects for consistency.
     19
     20        No new tests, no behavior change for layout tests.
     21
     22        * platform/audio/gstreamer/AudioDestinationGStreamer.cpp:
     23        (WebCore::AudioDestinationGStreamer::AudioDestinationGStreamer):
     24        (WebCore::AudioDestinationGStreamer::~AudioDestinationGStreamer):
     25        * platform/audio/gstreamer/AudioFileReaderGStreamer.cpp:
     26        (WebCore::AudioFileReader::~AudioFileReader):
     27        (WebCore::AudioFileReader::decodeAudioForBusCreation):
     28        * platform/graphics/gstreamer/GStreamerGWorld.cpp:
     29        (WebCore::GStreamerGWorld::GStreamerGWorld):
     30        * platform/graphics/gstreamer/GStreamerVersioning.cpp:
     31        (webkitGstPipelineGetBus):
     32        * platform/graphics/gstreamer/GStreamerVersioning.h:
     33        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
     34        (WebCore::MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer):
     35
    1362013-01-22  Adam Barth  <abarth@webkit.org>
    237
  • trunk/Source/WebCore/platform/audio/gstreamer/AudioDestinationGStreamer.cpp

    r139290 r140443  
    2727#include <wtf/gobject/GOwnPtr.h>
    2828#include "GRefPtrGStreamer.h"
     29#include "GStreamerVersioning.h"
    2930#include "Logging.h"
    3031#include "WebKitWebAudioSourceGStreamer.h"
     
    7576{
    7677    m_pipeline = gst_pipeline_new("play");
    77     GstBus* bus = gst_pipeline_get_bus(GST_PIPELINE(m_pipeline));
     78    GRefPtr<GstBus> bus = webkitGstPipelineGetBus(GST_PIPELINE(m_pipeline));
    7879    ASSERT(bus);
    79     gst_bus_add_signal_watch(bus);
    80     g_signal_connect(bus, "message", G_CALLBACK(messageCallback), this);
    81     gst_object_unref(bus);
     80    gst_bus_add_signal_watch(bus.get());
     81    g_signal_connect(bus.get(), "message", G_CALLBACK(messageCallback), this);
    8282
    8383    GstElement* webkitAudioSrc = reinterpret_cast<GstElement*>(g_object_new(WEBKIT_TYPE_WEB_AUDIO_SRC,
     
    108108AudioDestinationGStreamer::~AudioDestinationGStreamer()
    109109{
    110     GstBus* bus = gst_pipeline_get_bus(GST_PIPELINE(m_pipeline));
     110    GRefPtr<GstBus> bus = webkitGstPipelineGetBus(GST_PIPELINE(m_pipeline));
    111111    ASSERT(bus);
    112     g_signal_handlers_disconnect_by_func(bus, reinterpret_cast<gpointer>(messageCallback), this);
    113     gst_object_unref(bus);
     112    g_signal_handlers_disconnect_by_func(bus.get(), reinterpret_cast<gpointer>(messageCallback), this);
     113    gst_bus_remove_signal_watch(bus.get());
     114
    114115    gst_element_set_state(m_pipeline, GST_STATE_NULL);
    115116    gst_object_unref(m_pipeline);
  • trunk/Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp

    r138786 r140443  
    182182{
    183183    if (m_pipeline) {
    184         GstBus* bus = gst_pipeline_get_bus(GST_PIPELINE(m_pipeline));
     184        GRefPtr<GstBus> bus = webkitGstPipelineGetBus(GST_PIPELINE(m_pipeline));
    185185        ASSERT(bus);
    186         g_signal_handlers_disconnect_by_func(bus, reinterpret_cast<gpointer>(messageCallback), this);
    187         gst_object_unref(bus);
     186        g_signal_handlers_disconnect_by_func(bus.get(), reinterpret_cast<gpointer>(messageCallback), this);
     187        gst_bus_remove_signal_watch(bus.get());
     188
    188189        gst_element_set_state(m_pipeline, GST_STATE_NULL);
    189190        gst_object_unref(GST_OBJECT(m_pipeline));
     
    414415    m_pipeline = gst_pipeline_new(0);
    415416
    416     GstBus* bus = gst_pipeline_get_bus(GST_PIPELINE(m_pipeline));
     417    GRefPtr<GstBus> bus = webkitGstPipelineGetBus(GST_PIPELINE(m_pipeline));
    417418    ASSERT(bus);
    418     gst_bus_add_signal_watch(bus);
    419     g_signal_connect(bus, "message", G_CALLBACK(messageCallback), this);
    420     gst_object_unref(bus);
     419    gst_bus_add_signal_watch(bus.get());
     420    g_signal_connect(bus.get(), "message", G_CALLBACK(messageCallback), this);
    421421
    422422    GstElement* source;
  • trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerGWorld.cpp

    r128570 r140443  
    2323
    2424#include "GRefPtrGStreamer.h"
     25#include "GStreamerVersioning.h"
    2526#include <gst/gst.h>
    2627#include <gst/interfaces/xoverlay.h>
     
    6061{
    6162    // XOverlay messages need to be handled synchronously.
    62     GstBus* bus = gst_pipeline_get_bus(GST_PIPELINE(m_pipeline));
    63     gst_bus_set_sync_handler(bus, gst_bus_sync_signal_handler, this);
    64     g_signal_connect(bus, "sync-message::element", G_CALLBACK(gstGWorldSyncMessageCallback), this);
    65     gst_object_unref(bus);
     63    GRefPtr<GstBus> bus = webkitGstPipelineGetBus(GST_PIPELINE(m_pipeline));
     64    gst_bus_set_sync_handler(bus.get(), gst_bus_sync_signal_handler, this);
     65    g_signal_connect(bus.get(), "sync-message::element", G_CALLBACK(gstGWorldSyncMessageCallback), this);
    6666}
    6767
  • trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.cpp

    r140425 r140443  
    6868#else
    6969    return GST_PAD_CAPS(pad);
     70#endif
     71}
     72
     73GRefPtr<GstBus> webkitGstPipelineGetBus(GstPipeline* pipeline)
     74{
     75#ifdef GST_API_VERSION_1
     76    return adoptGRef(gst_pipeline_get_bus(pipeline));
     77#else
     78    // gst_pipeline_get_bus returns a floating reference in
     79    // gstreamer 0.10 so we should not adopt.
     80    return gst_pipeline_get_bus(pipeline);
    7081#endif
    7182}
  • trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.h

    r140425 r140443  
    3333GstPad* webkitGstGhostPadFromStaticTemplate(GstStaticPadTemplate*, const gchar* name, GstPad* target);
    3434GRefPtr<GstCaps> webkitGstGetPadCaps(GstPad*);
     35GRefPtr<GstBus> webkitGstPipelineGetBus(GstPipeline*);
    3536#if ENABLE(VIDEO)
    3637bool getVideoSizeAndFormatFromCaps(GstCaps*, WebCore::IntSize&, GstVideoFormat&, int& pixelAspectRatioNumerator, int& pixelAspectRatioDenominator, int& stride);
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp

    r140422 r140443  
    276276
    277277    if (m_playBin) {
     278        GRefPtr<GstBus> bus = webkitGstPipelineGetBus(GST_PIPELINE(m_playBin.get()));
     279        ASSERT(bus);
     280        g_signal_handlers_disconnect_by_func(bus.get(), reinterpret_cast<gpointer>(mediaPlayerPrivateMessageCallback), this);
     281        gst_bus_remove_signal_watch(bus.get());
     282
    278283        gst_element_set_state(m_playBin.get(), GST_STATE_NULL);
    279284        m_playBin = 0;
     
    18021807#endif
    18031808
    1804     GstBus* bus = gst_pipeline_get_bus(GST_PIPELINE(m_playBin.get()));
    1805     gst_bus_add_signal_watch(bus);
    1806     g_signal_connect(bus, "message", G_CALLBACK(mediaPlayerPrivateMessageCallback), this);
    1807     gst_object_unref(bus);
     1809    GRefPtr<GstBus> bus = webkitGstPipelineGetBus(GST_PIPELINE(m_playBin.get()));
     1810    gst_bus_add_signal_watch(bus.get());
     1811    g_signal_connect(bus.get(), "message", G_CALLBACK(mediaPlayerPrivateMessageCallback), this);
    18081812
    18091813    g_object_set(m_playBin.get(), "mute", m_player->muted(), NULL);
Note: See TracChangeset for help on using the changeset viewer.