Title: [114269] trunk/Source/WebCore
Revision
114269
Author
[email protected]
Date
2012-04-16 10:14:12 -0700 (Mon, 16 Apr 2012)

Log Message

[GStreamer] HRTFDatabaseLoader conflicts with AudioFileReader
https://bugs.webkit.org/show_bug.cgi?id=78095

Reviewed by Martin Robinson.

Moved the GStreamer initialization logic to a new
GStreamerUtilities module, used by the MediaPlayer and the
AudioContext. I also removed the static variables as
gst_init_check already handles cases where it's called multiple
times.

* GNUmakefile.list.am:
* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::constructCommon):
* platform/audio/gstreamer/AudioDestinationGStreamer.cpp:
(WebCore::AudioDestinationGStreamer::AudioDestinationGStreamer):
* platform/audio/gstreamer/AudioFileReaderGStreamer.cpp:
(WebCore::AudioFileReader::createBus):
* platform/graphics/gstreamer/GRefPtrGStreamer.cpp:
(WTF::adoptGRef):
(WTF):
(WTF::GstElementFactory):
* platform/graphics/gstreamer/GRefPtrGStreamer.h:
(WTF):
* platform/graphics/gstreamer/GStreamerUtilities.cpp: Added.
(WebCore):
(WebCore::initializeGStreamer):
* platform/graphics/gstreamer/GStreamerUtilities.h: Added.
(WebCore):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::doGstInit):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (114268 => 114269)


--- trunk/Source/WebCore/ChangeLog	2012-04-16 17:06:14 UTC (rev 114268)
+++ trunk/Source/WebCore/ChangeLog	2012-04-16 17:14:12 UTC (rev 114269)
@@ -1,3 +1,37 @@
+2012-04-11  Philippe Normand  <[email protected]>
+
+        [GStreamer] HRTFDatabaseLoader conflicts with AudioFileReader
+        https://bugs.webkit.org/show_bug.cgi?id=78095
+
+        Reviewed by Martin Robinson.
+
+        Moved the GStreamer initialization logic to a new
+        GStreamerUtilities module, used by the MediaPlayer and the
+        AudioContext. I also removed the static variables as
+        gst_init_check already handles cases where it's called multiple
+        times.
+
+        * GNUmakefile.list.am:
+        * Modules/webaudio/AudioContext.cpp:
+        (WebCore::AudioContext::constructCommon):
+        * platform/audio/gstreamer/AudioDestinationGStreamer.cpp:
+        (WebCore::AudioDestinationGStreamer::AudioDestinationGStreamer):
+        * platform/audio/gstreamer/AudioFileReaderGStreamer.cpp:
+        (WebCore::AudioFileReader::createBus):
+        * platform/graphics/gstreamer/GRefPtrGStreamer.cpp:
+        (WTF::adoptGRef):
+        (WTF):
+        (WTF::GstElementFactory):
+        * platform/graphics/gstreamer/GRefPtrGStreamer.h:
+        (WTF):
+        * platform/graphics/gstreamer/GStreamerUtilities.cpp: Added.
+        (WebCore):
+        (WebCore::initializeGStreamer):
+        * platform/graphics/gstreamer/GStreamerUtilities.h: Added.
+        (WebCore):
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+        (WebCore::doGstInit):
+
 2012-04-16  ChangSeok Oh  <[email protected]>
 
         Update GraphicsContext3DOpenGLES.cpp and fix some issues to build with GLES.

Modified: trunk/Source/WebCore/GNUmakefile.list.am (114268 => 114269)


--- trunk/Source/WebCore/GNUmakefile.list.am	2012-04-16 17:06:14 UTC (rev 114268)
+++ trunk/Source/WebCore/GNUmakefile.list.am	2012-04-16 17:14:12 UTC (rev 114269)
@@ -4637,12 +4637,8 @@
 	Source/WebCore/platform/cairo/WidgetBackingStore.h \
 	Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp \
 	Source/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h \
-	Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp \
-	Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h \
 	Source/WebCore/platform/graphics/gstreamer/GStreamerGWorld.cpp \
 	Source/WebCore/platform/graphics/gstreamer/GStreamerGWorld.h \
-	Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.cpp \
-	Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.h \
 	Source/WebCore/platform/graphics/gstreamer/ImageGStreamerCairo.cpp \
 	Source/WebCore/platform/graphics/gstreamer/ImageGStreamer.h \
 	Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp \
@@ -5673,6 +5669,15 @@
     $(WebCore)/Modules/webaudio/WaveTable.idl
 endif
 
+if USE_GSTREAMER
+webcore_sources += \
+	Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp \
+	Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h \
+	Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.cpp \
+	Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.h \
+	Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.cpp \
+	Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.h
+endif
 
 # ----
 # Web Sockets Support

Modified: trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp (114268 => 114269)


--- trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp	2012-04-16 17:06:14 UTC (rev 114268)
+++ trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp	2012-04-16 17:14:12 UTC (rev 114269)
@@ -68,6 +68,10 @@
 #include <stdio.h>
 #endif
 
+#if USE(GSTREAMER)
+#include "GStreamerUtilities.h"
+#endif
+
 #include <wtf/ArrayBuffer.h>
 #include <wtf/Atomics.h>
 #include <wtf/MainThread.h>
@@ -178,6 +182,10 @@
 
 void AudioContext::constructCommon()
 {
+#if USE(GSTREAMER)
+    initializeGStreamer();
+#endif
+
     FFTFrame::initialize();
     
     m_listener = AudioListener::create();

Modified: trunk/Source/WebCore/PlatformEfl.cmake (114268 => 114269)


--- trunk/Source/WebCore/PlatformEfl.cmake	2012-04-16 17:06:14 UTC (rev 114268)
+++ trunk/Source/WebCore/PlatformEfl.cmake	2012-04-16 17:14:12 UTC (rev 114269)
@@ -188,6 +188,7 @@
   LIST(APPEND WebCore_SOURCES
     platform/graphics/gstreamer/GRefPtrGStreamer.cpp
     platform/graphics/gstreamer/GStreamerGWorld.cpp
+    platform/graphics/gstreamer/GStreamerUtilities.cpp
     platform/graphics/gstreamer/GStreamerVersioning.cpp
     platform/graphics/gstreamer/ImageGStreamerCairo.cpp
     platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp

Modified: trunk/Source/WebCore/Target.pri (114268 => 114269)


--- trunk/Source/WebCore/Target.pri	2012-04-16 17:06:14 UTC (rev 114268)
+++ trunk/Source/WebCore/Target.pri	2012-04-16 17:14:12 UTC (rev 114269)
@@ -3268,6 +3268,7 @@
         HEADERS += \
             platform/graphics/gstreamer/GRefPtrGStreamer.h \
             platform/graphics/gstreamer/GStreamerGWorld.h \
+            platform/graphics/gstreamer/GStreamerUtilities.h \
             platform/graphics/gstreamer/GStreamerVersioning.h \
             platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h \
             platform/graphics/gstreamer/VideoSinkGStreamer.h \
@@ -3278,6 +3279,7 @@
         SOURCES += \
             platform/graphics/gstreamer/GRefPtrGStreamer.cpp \
             platform/graphics/gstreamer/GStreamerGWorld.cpp \
+            platform/graphics/gstreamer/GStreamerUtilities.cpp \
             platform/graphics/gstreamer/GStreamerVersioning.cpp \
             platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp \
             platform/graphics/gstreamer/VideoSinkGStreamer.cpp \

Modified: trunk/Source/WebCore/platform/audio/gstreamer/AudioDestinationGStreamer.cpp (114268 => 114269)


--- trunk/Source/WebCore/platform/audio/gstreamer/AudioDestinationGStreamer.cpp	2012-04-16 17:06:14 UTC (rev 114268)
+++ trunk/Source/WebCore/platform/audio/gstreamer/AudioDestinationGStreamer.cpp	2012-04-16 17:14:12 UTC (rev 114269)
@@ -57,11 +57,6 @@
     , m_sampleRate(sampleRate)
     , m_isPlaying(false)
 {
-    static bool gstInitialized = false;
-    if (!gstInitialized)
-        gstInitialized = gst_init_check(0, 0, 0);
-    ASSERT_WITH_MESSAGE(gstInitialized, "GStreamer initialization failed");
-
     m_pipeline = gst_pipeline_new("play");
 
     GstElement* webkitAudioSrc = reinterpret_cast<GstElement*>(g_object_new(WEBKIT_TYPE_WEB_AUDIO_SRC,

Modified: trunk/Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp (114268 => 114269)


--- trunk/Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp	2012-04-16 17:06:14 UTC (rev 114268)
+++ trunk/Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp	2012-04-16 17:14:12 UTC (rev 114269)
@@ -324,13 +324,6 @@
 {
     m_sampleRate = sampleRate;
 
-    static bool gstInitialized = false;
-    if (!gstInitialized)
-        gstInitialized = gst_init_check(0, 0, 0);
-
-    if (!gstInitialized)
-        return nullptr;
-
     m_frontLeftBuffers = gst_buffer_list_new();
     m_frontLeftBuffersIterator = gst_buffer_list_iterate(m_frontLeftBuffers);
     gst_buffer_list_iterator_add_group(m_frontLeftBuffersIterator);

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp (114268 => 114269)


--- trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp	2012-04-16 17:06:14 UTC (rev 114268)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp	2012-04-16 17:14:12 UTC (rev 114269)
@@ -140,5 +140,25 @@
         gst_object_unref(ptr);
 }
 
+template <> GRefPtr<GstElementFactory> adoptGRef(GstElementFactory* ptr)
+{
+    ASSERT(!GST_OBJECT_IS_FLOATING(GST_OBJECT(ptr)));
+    return GRefPtr<GstElementFactory>(ptr, GRefPtrAdopt);
 }
+
+template <> GstElementFactory* refGPtr<GstElementFactory>(GstElementFactory* ptr)
+{
+    if (ptr)
+        webkitGstObjectRefSink(GST_OBJECT(ptr));
+
+    return ptr;
+}
+
+template <> void derefGPtr<GstElementFactory>(GstElementFactory* ptr)
+{
+    if (ptr)
+        gst_object_unref(ptr);
+}
+
+}
 #endif // USE(GSTREAMER)

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h (114268 => 114269)


--- trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h	2012-04-16 17:06:14 UTC (rev 114268)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h	2012-04-16 17:14:12 UTC (rev 114269)
@@ -29,6 +29,7 @@
 typedef struct _GstCaps GstCaps;
 typedef struct _GstTask GstTask;
 typedef struct _GstBus GstBus;
+typedef struct _GstElementFactory GstElementFactory;
 
 namespace WTF {
 
@@ -55,6 +56,10 @@
 template<> GstBus* refGPtr<GstBus>(GstBus* ptr);
 template<> void derefGPtr<GstBus>(GstBus* ptr);
 
+template<> GRefPtr<GstElementFactory> adoptGRef(GstElementFactory* ptr);
+template<> GstElementFactory* refGPtr<GstElementFactory>(GstElementFactory* ptr);
+template<> void derefGPtr<GstElementFactory>(GstElementFactory* ptr);
+
 }
 
 #endif // USE(GSTREAMER)

Added: trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.cpp (0 => 114269)


--- trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.cpp	2012-04-16 17:14:12 UTC (rev 114269)
@@ -0,0 +1,41 @@
+/*
+ *  Copyright (C) 2012 Igalia S.L
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+
+#include "config.h"
+#include "GStreamerUtilities.h"
+
+#include <gst/gst.h>
+#include <wtf/gobject/GOwnPtr.h>
+
+#if USE(GSTREAMER)
+
+namespace WebCore {
+
+bool initializeGStreamer()
+{
+    GOwnPtr<GError> error;
+    // FIXME: We should probably pass the arguments from the command line.
+    bool gstInitialized = gst_init_check(0, 0, &error.outPtr());
+    ASSERT_WITH_MESSAGE(gstInitialized, "GStreamer initialization failed: %s", error ? error->message : "unknown error occurred");
+    return gstInitialized;
+}
+
+}
+
+#endif // ENABLE(WEB_AUDIO) && USE(GSTREAMER)

Added: trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.h (0 => 114269)


--- trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.h	2012-04-16 17:14:12 UTC (rev 114269)
@@ -0,0 +1,22 @@
+/*
+ *  Copyright (C) 2012 Igalia S.L
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+
+namespace WebCore {
+bool initializeGStreamer();
+}

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp (114268 => 114269)


--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2012-04-16 17:06:14 UTC (rev 114268)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2012-04-16 17:14:12 UTC (rev 114269)
@@ -31,6 +31,7 @@
 #include "Frame.h"
 #include "FrameView.h"
 #include "GStreamerGWorld.h"
+#include "GStreamerUtilities.h"
 #include "GStreamerVersioning.h"
 #include "GraphicsContext.h"
 #include "GraphicsTypes.h"
@@ -175,35 +176,25 @@
         registrar(create, getSupportedTypes, supportsType, 0, 0, 0);
 }
 
-static bool gstInitialized = false;
-
-static bool doGstInit()
+bool initializeGStreamerAndRegisterWebKitElements()
 {
-    // FIXME: We should pass the arguments from the command line
-    if (!gstInitialized) {
-        GOwnPtr<GError> error;
-        gstInitialized = gst_init_check(0, 0, &error.outPtr());
-        if (!gstInitialized)
-            LOG_VERBOSE(Media, "Could not initialize GStreamer: %s",
-                        error ? error->message : "unknown error occurred");
-        else
-            gst_element_register(0, "webkitwebsrc", GST_RANK_PRIMARY + 100,
-                                 WEBKIT_TYPE_WEB_SRC);
-    }
-    return gstInitialized;
+    if (!initializeGStreamer())
+        return false;
+
+    GRefPtr<GstElementFactory> srcFactory = gst_element_factory_find("webkitwebsrc");
+    if (!srcFactory)
+        return gst_element_register(0, "webkitwebsrc", GST_RANK_PRIMARY + 100, WEBKIT_TYPE_WEB_SRC);
+
+    return true;
 }
 
 bool MediaPlayerPrivateGStreamer::isAvailable()
 {
-    if (!doGstInit())
+    if (!initializeGStreamerAndRegisterWebKitElements())
         return false;
 
-    GstElementFactory* factory = gst_element_factory_find(gPlaybinName);
-    if (factory) {
-        gst_object_unref(GST_OBJECT(factory));
-        return true;
-    }
-    return false;
+    GRefPtr<GstElementFactory> factory = gst_element_factory_find(gPlaybinName);
+    return factory;
 }
 
 MediaPlayerPrivateGStreamer::MediaPlayerPrivateGStreamer(MediaPlayer* player)
@@ -244,7 +235,7 @@
     , m_videoTimerHandler(0)
     , m_webkitAudioSink(0)
 {
-    if (doGstInit())
+    if (initializeGStreamerAndRegisterWebKitElements())
         createGSTPlayBin();
 }
 
@@ -1504,7 +1495,7 @@
 static HashSet<String> mimeTypeCache()
 {
 
-    doGstInit();
+    initializeGStreamerAndRegisterWebKitElements();
 
     DEFINE_STATIC_LOCAL(HashSet<String>, cache, ());
     static bool typeListInitialized = false;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to