Changeset 139896 in webkit


Ignore:
Timestamp:
Jan 16, 2013, 10:44:18 AM (13 years ago)
Author:
Christophe Dumez
Message:

[gstreamer] Some media tests occasionally crash with gstreamer 1.0 backend
https://bugs.webkit.org/show_bug.cgi?id=106551

Reviewed by Philippe Normand.

ImageGStreamerCairo was passing mapped memory to
cairo_image_surface_create_for_data() and then unmapping it straight
away even though the cairo_surface_t is still used. The cairo
documentation states:
"The output buffer must be kept around until the cairo_surface_t is
destroyed or cairo_surface_finish() is called on the surface."

This patch keeps the GstBuffer memory mapped until the ImageGStreamer
is destroyed so that the internal cairo_surface_t stays valid while
avoiding copying the image data.

No new tests, already covered by existing tests.

  • platform/graphics/gstreamer/GRefPtrGStreamer.cpp:

(WTF::adoptGRef):
(WTF):
(WTF::GstBuffer):

  • platform/graphics/gstreamer/GRefPtrGStreamer.h:

(WTF): Add support for using GRefPtr with GstBuffer.

  • platform/graphics/gstreamer/ImageGStreamer.h:

(ImageGStreamer):

  • platform/graphics/gstreamer/ImageGStreamerCairo.cpp:

(ImageGStreamer::ImageGStreamer):
(ImageGStreamer::~ImageGStreamer):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r139894 r139896  
     12013-01-16  Christophe Dumez  <christophe.dumez@intel.com>
     2
     3        [gstreamer] Some media tests occasionally crash with gstreamer 1.0 backend
     4        https://bugs.webkit.org/show_bug.cgi?id=106551
     5
     6        Reviewed by Philippe Normand.
     7
     8        ImageGStreamerCairo was passing mapped memory to
     9        cairo_image_surface_create_for_data() and then unmapping it straight
     10        away even though the cairo_surface_t is still used. The cairo
     11        documentation states:
     12        "The output buffer must be kept around until the cairo_surface_t is
     13        destroyed or cairo_surface_finish() is called on the surface."
     14
     15        This patch keeps the GstBuffer memory mapped until the ImageGStreamer
     16        is destroyed so that the internal cairo_surface_t stays valid while
     17        avoiding copying the image data.
     18
     19        No new tests, already covered by existing tests.
     20
     21        * platform/graphics/gstreamer/GRefPtrGStreamer.cpp:
     22        (WTF::adoptGRef):
     23        (WTF):
     24        (WTF::GstBuffer):
     25        * platform/graphics/gstreamer/GRefPtrGStreamer.h:
     26        (WTF): Add support for using GRefPtr with GstBuffer.
     27        * platform/graphics/gstreamer/ImageGStreamer.h:
     28        (ImageGStreamer):
     29        * platform/graphics/gstreamer/ImageGStreamerCairo.cpp:
     30        (ImageGStreamer::ImageGStreamer):
     31        (ImageGStreamer::~ImageGStreamer):
     32
    1332013-01-16  Mike Reed  <reed@google.com>
    234
  • trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp

    r132081 r139896  
    166166}
    167167
     168template<> GRefPtr<GstBuffer> adoptGRef(GstBuffer* ptr)
     169{
     170    return GRefPtr<GstBuffer>(ptr, GRefPtrAdopt);
     171}
     172
     173template<> GstBuffer* refGPtr<GstBuffer>(GstBuffer* ptr)
     174{
     175    if (ptr)
     176        gst_buffer_ref(ptr);
     177
     178    return ptr;
     179}
     180
     181template<> void derefGPtr<GstBuffer>(GstBuffer* ptr)
     182{
     183    if (ptr)
     184        gst_buffer_unref(ptr);
     185}
    168186}
    169187#endif // USE(GSTREAMER)
  • trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h

    r131387 r139896  
    3131typedef struct _GstBus GstBus;
    3232typedef struct _GstElementFactory GstElementFactory;
     33typedef struct _GstBuffer GstBuffer;
    3334
    3435namespace WTF {
     
    6263template<> void derefGPtr<GstElementFactory>(GstElementFactory* ptr);
    6364
     65template<> GRefPtr<GstBuffer> adoptGRef(GstBuffer* ptr);
     66template<> GstBuffer* refGPtr<GstBuffer>(GstBuffer* ptr);
     67template<> void derefGPtr<GstBuffer>(GstBuffer* ptr);
    6468}
    6569
  • trunk/Source/WebCore/platform/graphics/gstreamer/ImageGStreamer.h

    r130636 r139896  
    6161        RefPtr<BitmapImage> m_image;
    6262        FloatRect m_cropRect;
     63
     64#if USE(CAIRO) && defined(GST_API_VERSION_1)
     65        GRefPtr<GstBuffer> m_buffer;
     66        GstMapInfo m_mapInfo;
     67#endif
    6368    };
    6469}
  • trunk/Source/WebCore/platform/graphics/gstreamer/ImageGStreamerCairo.cpp

    r120790 r139896  
    3737
    3838ImageGStreamer::ImageGStreamer(GstBuffer* buffer, GstCaps* caps)
     39#ifdef GST_API_VERSION_1
     40    : m_buffer(buffer)
     41#endif
    3942{
    4043    GstVideoFormat format;
     
    4447
    4548#ifdef GST_API_VERSION_1
    46     GstMapInfo mapInfo;
    47     gst_buffer_map(buffer, &mapInfo, GST_MAP_READ);
    48     unsigned char* bufferData = reinterpret_cast<unsigned char*>(mapInfo.data);
     49    gst_buffer_map(buffer, &m_mapInfo, GST_MAP_READ);
     50    unsigned char* bufferData = reinterpret_cast<unsigned char*>(m_mapInfo.data);
    4951#else
    5052    unsigned char* bufferData = reinterpret_cast<unsigned char*>(GST_BUFFER_DATA(buffer));
     
    6567    if (GstVideoCropMeta* cropMeta = gst_buffer_get_video_crop_meta(buffer))
    6668        setCropRect(FloatRect(cropMeta->x, cropMeta->y, cropMeta->width, cropMeta->height));
    67 
    68     gst_buffer_unmap(buffer, &mapInfo);
    6969#endif
    7070}
     
    7676
    7777    m_image = 0;
     78
     79#ifdef GST_API_VERSION_1
     80    // We keep the buffer memory mapped until the image is destroyed because the internal
     81    // cairo_surface_t was created using cairo_image_surface_create_for_data().
     82    gst_buffer_unmap(m_buffer.get(), &m_mapInfo);
     83#endif
    7884}
    7985#endif // USE(GSTREAMER)
Note: See TracChangeset for help on using the changeset viewer.