From: philn@webkit.org Date: Mon, 16 Apr 2012 17:14:12 +0000 (+0000) Subject: [GStreamer] HRTFDatabaseLoader conflicts with AudioFileReader X-Git-Tag: 070512121124~6912 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6e2e6cab2edc6b4a286927a5f5e288e53ad83c52;p=profile%2Fivi%2Fwebkit-efl.git [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): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@114269 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 0503aa8..be3c54b 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,37 @@ +2012-04-11 Philippe Normand + + [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 Update GraphicsContext3DOpenGLES.cpp and fix some issues to build with GLES. diff --git a/Source/WebCore/GNUmakefile.list.am b/Source/WebCore/GNUmakefile.list.am index 574bb04..7849e1f 100644 --- a/Source/WebCore/GNUmakefile.list.am +++ b/Source/WebCore/GNUmakefile.list.am @@ -4637,12 +4637,8 @@ webcoregtk_sources += \ 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 @@ dom_binding_idls += \ $(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 diff --git a/Source/WebCore/Modules/webaudio/AudioContext.cpp b/Source/WebCore/Modules/webaudio/AudioContext.cpp index a2b63bf..f78905b 100644 --- a/Source/WebCore/Modules/webaudio/AudioContext.cpp +++ b/Source/WebCore/Modules/webaudio/AudioContext.cpp @@ -68,6 +68,10 @@ #include #endif +#if USE(GSTREAMER) +#include "GStreamerUtilities.h" +#endif + #include #include #include @@ -178,6 +182,10 @@ AudioContext::AudioContext(Document* document, unsigned numberOfChannels, size_t void AudioContext::constructCommon() { +#if USE(GSTREAMER) + initializeGStreamer(); +#endif + FFTFrame::initialize(); m_listener = AudioListener::create(); diff --git a/Source/WebCore/PlatformEfl.cmake b/Source/WebCore/PlatformEfl.cmake index 79a5013..0f3ee3a 100644 --- a/Source/WebCore/PlatformEfl.cmake +++ b/Source/WebCore/PlatformEfl.cmake @@ -188,6 +188,7 @@ IF (ENABLE_VIDEO) 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 diff --git a/Source/WebCore/Target.pri b/Source/WebCore/Target.pri index a4172c6..e567a3d 100644 --- a/Source/WebCore/Target.pri +++ b/Source/WebCore/Target.pri @@ -3268,6 +3268,7 @@ contains(DEFINES, ENABLE_VIDEO=1) { 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 @@ contains(DEFINES, ENABLE_VIDEO=1) { 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 \ diff --git a/Source/WebCore/platform/audio/gstreamer/AudioDestinationGStreamer.cpp b/Source/WebCore/platform/audio/gstreamer/AudioDestinationGStreamer.cpp index b606a33..5611bdb 100644 --- a/Source/WebCore/platform/audio/gstreamer/AudioDestinationGStreamer.cpp +++ b/Source/WebCore/platform/audio/gstreamer/AudioDestinationGStreamer.cpp @@ -57,11 +57,6 @@ AudioDestinationGStreamer::AudioDestinationGStreamer(AudioSourceProvider& provid , 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(g_object_new(WEBKIT_TYPE_WEB_AUDIO_SRC, diff --git a/Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp b/Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp index a7a5c71..5b92eb7 100644 --- a/Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp +++ b/Source/WebCore/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp @@ -324,13 +324,6 @@ PassOwnPtr AudioFileReader::createBus(float sampleRate, bool mixToMono { 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); diff --git a/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp b/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp index 5306974..062e3fc 100644 --- a/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp +++ b/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp @@ -140,5 +140,25 @@ template <> void derefGPtr(GstBus* ptr) gst_object_unref(ptr); } +template <> GRefPtr adoptGRef(GstElementFactory* ptr) +{ + ASSERT(!GST_OBJECT_IS_FLOATING(GST_OBJECT(ptr))); + return GRefPtr(ptr, GRefPtrAdopt); +} + +template <> GstElementFactory* refGPtr(GstElementFactory* ptr) +{ + if (ptr) + webkitGstObjectRefSink(GST_OBJECT(ptr)); + + return ptr; +} + +template <> void derefGPtr(GstElementFactory* ptr) +{ + if (ptr) + gst_object_unref(ptr); +} + } #endif // USE(GSTREAMER) diff --git a/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h b/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h index 940470a..a3dcda8 100644 --- a/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h +++ b/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h @@ -29,6 +29,7 @@ typedef struct _GstPadTemplate GstPadTemplate; typedef struct _GstCaps GstCaps; typedef struct _GstTask GstTask; typedef struct _GstBus GstBus; +typedef struct _GstElementFactory GstElementFactory; namespace WTF { @@ -55,6 +56,10 @@ template<> GRefPtr adoptGRef(GstBus* ptr); template<> GstBus* refGPtr(GstBus* ptr); template<> void derefGPtr(GstBus* ptr); +template<> GRefPtr adoptGRef(GstElementFactory* ptr); +template<> GstElementFactory* refGPtr(GstElementFactory* ptr); +template<> void derefGPtr(GstElementFactory* ptr); + } #endif // USE(GSTREAMER) diff --git a/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.cpp b/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.cpp new file mode 100644 index 0000000..ac363a7 --- /dev/null +++ b/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.cpp @@ -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 +#include + +#if USE(GSTREAMER) + +namespace WebCore { + +bool initializeGStreamer() +{ + GOwnPtr 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) diff --git a/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.h b/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.h new file mode 100644 index 0000000..b9eb165 --- /dev/null +++ b/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.h @@ -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(); +} diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp index ea49d0e..d0993c2 100644 --- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp +++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp @@ -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 @@ void MediaPlayerPrivateGStreamer::registerMediaEngine(MediaEngineRegistrar regis 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 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 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 factory = gst_element_factory_find(gPlaybinName); + return factory; } MediaPlayerPrivateGStreamer::MediaPlayerPrivateGStreamer(MediaPlayer* player) @@ -244,7 +235,7 @@ MediaPlayerPrivateGStreamer::MediaPlayerPrivateGStreamer(MediaPlayer* player) , m_videoTimerHandler(0) , m_webkitAudioSink(0) { - if (doGstInit()) + if (initializeGStreamerAndRegisterWebKitElements()) createGSTPlayBin(); } @@ -1504,7 +1495,7 @@ void MediaPlayerPrivateGStreamer::paint(GraphicsContext* context, const IntRect& static HashSet mimeTypeCache() { - doGstInit(); + initializeGStreamerAndRegisterWebKitElements(); DEFINE_STATIC_LOCAL(HashSet, cache, ()); static bool typeListInitialized = false;