Title: [139896] trunk/Source/WebCore
- Revision
- 139896
- Author
- christophe.du...@intel.com
- Date
- 2013-01-16 10:44:18 -0800 (Wed, 16 Jan 2013)
Log 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):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (139895 => 139896)
--- trunk/Source/WebCore/ChangeLog 2013-01-16 18:37:48 UTC (rev 139895)
+++ trunk/Source/WebCore/ChangeLog 2013-01-16 18:44:18 UTC (rev 139896)
@@ -1,3 +1,35 @@
+2013-01-16 Christophe Dumez <christophe.du...@intel.com>
+
+ [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):
+
2013-01-16 Mike Reed <r...@google.com>
Use SkMatrix::I() when we need to pass identity, rather than constructing a new matrix.
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp (139895 => 139896)
--- trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp 2013-01-16 18:37:48 UTC (rev 139895)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp 2013-01-16 18:44:18 UTC (rev 139896)
@@ -165,5 +165,23 @@
gst_object_unref(ptr);
}
+template<> GRefPtr<GstBuffer> adoptGRef(GstBuffer* ptr)
+{
+ return GRefPtr<GstBuffer>(ptr, GRefPtrAdopt);
}
+
+template<> GstBuffer* refGPtr<GstBuffer>(GstBuffer* ptr)
+{
+ if (ptr)
+ gst_buffer_ref(ptr);
+
+ return ptr;
+}
+
+template<> void derefGPtr<GstBuffer>(GstBuffer* ptr)
+{
+ if (ptr)
+ gst_buffer_unref(ptr);
+}
+}
#endif // USE(GSTREAMER)
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h (139895 => 139896)
--- trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h 2013-01-16 18:37:48 UTC (rev 139895)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h 2013-01-16 18:44:18 UTC (rev 139896)
@@ -30,6 +30,7 @@
typedef struct _GstTask GstTask;
typedef struct _GstBus GstBus;
typedef struct _GstElementFactory GstElementFactory;
+typedef struct _GstBuffer GstBuffer;
namespace WTF {
@@ -61,6 +62,9 @@
template<> GstElementFactory* refGPtr<GstElementFactory>(GstElementFactory* ptr);
template<> void derefGPtr<GstElementFactory>(GstElementFactory* ptr);
+template<> GRefPtr<GstBuffer> adoptGRef(GstBuffer* ptr);
+template<> GstBuffer* refGPtr<GstBuffer>(GstBuffer* ptr);
+template<> void derefGPtr<GstBuffer>(GstBuffer* ptr);
}
#endif // USE(GSTREAMER)
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/ImageGStreamer.h (139895 => 139896)
--- trunk/Source/WebCore/platform/graphics/gstreamer/ImageGStreamer.h 2013-01-16 18:37:48 UTC (rev 139895)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/ImageGStreamer.h 2013-01-16 18:44:18 UTC (rev 139896)
@@ -60,6 +60,11 @@
ImageGStreamer(GstBuffer*, GstCaps*);
RefPtr<BitmapImage> m_image;
FloatRect m_cropRect;
+
+#if USE(CAIRO) && defined(GST_API_VERSION_1)
+ GRefPtr<GstBuffer> m_buffer;
+ GstMapInfo m_mapInfo;
+#endif
};
}
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/ImageGStreamerCairo.cpp (139895 => 139896)
--- trunk/Source/WebCore/platform/graphics/gstreamer/ImageGStreamerCairo.cpp 2013-01-16 18:37:48 UTC (rev 139895)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/ImageGStreamerCairo.cpp 2013-01-16 18:44:18 UTC (rev 139896)
@@ -36,6 +36,9 @@
using namespace WebCore;
ImageGStreamer::ImageGStreamer(GstBuffer* buffer, GstCaps* caps)
+#ifdef GST_API_VERSION_1
+ : m_buffer(buffer)
+#endif
{
GstVideoFormat format;
IntSize size;
@@ -43,9 +46,8 @@
getVideoSizeAndFormatFromCaps(caps, size, format, pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride);
#ifdef GST_API_VERSION_1
- GstMapInfo mapInfo;
- gst_buffer_map(buffer, &mapInfo, GST_MAP_READ);
- unsigned char* bufferData = reinterpret_cast<unsigned char*>(mapInfo.data);
+ gst_buffer_map(buffer, &m_mapInfo, GST_MAP_READ);
+ unsigned char* bufferData = reinterpret_cast<unsigned char*>(m_mapInfo.data);
#else
unsigned char* bufferData = reinterpret_cast<unsigned char*>(GST_BUFFER_DATA(buffer));
#endif
@@ -64,8 +66,6 @@
#ifdef GST_API_VERSION_1
if (GstVideoCropMeta* cropMeta = gst_buffer_get_video_crop_meta(buffer))
setCropRect(FloatRect(cropMeta->x, cropMeta->y, cropMeta->width, cropMeta->height));
-
- gst_buffer_unmap(buffer, &mapInfo);
#endif
}
@@ -75,5 +75,11 @@
m_image.clear();
m_image = 0;
+
+#ifdef GST_API_VERSION_1
+ // We keep the buffer memory mapped until the image is destroyed because the internal
+ // cairo_surface_t was created using cairo_image_surface_create_for_data().
+ gst_buffer_unmap(m_buffer.get(), &m_mapInfo);
+#endif
}
#endif // USE(GSTREAMER)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes