Use WTF::Lock instead of GMutex
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Apr 2018 03:18:50 +0000 (03:18 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Apr 2018 03:18:50 +0000 (03:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=184227

Reviewed by Saam Barati.

Prefer WTF::Lock over GMutex since these locks are just protecting WebKit C++ fields.

No behavior change.

* platform/audio/gstreamer/AudioSourceProviderGStreamer.cpp:
(WebCore::AudioSourceProviderGStreamer::AudioSourceProviderGStreamer):
(WebCore::AudioSourceProviderGStreamer::~AudioSourceProviderGStreamer):
(WebCore::AudioSourceProviderGStreamer::provideInput):
(WebCore::AudioSourceProviderGStreamer::handleAudioBuffer):
(WebCore::AudioSourceProviderGStreamer::clearAdapters):
* platform/audio/gstreamer/AudioSourceProviderGStreamer.h:
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
(WebCore::MediaPlayerPrivateGStreamerBase::MediaPlayerPrivateGStreamerBase):
(WebCore::MediaPlayerPrivateGStreamerBase::~MediaPlayerPrivateGStreamerBase):
(WebCore::MediaPlayerPrivateGStreamerBase::naturalSize const):
(WebCore::MediaPlayerPrivateGStreamerBase::pushTextureToCompositor):
(WebCore::MediaPlayerPrivateGStreamerBase::triggerRepaint):
(WebCore::MediaPlayerPrivateGStreamerBase::flushCurrentBuffer):
(WebCore::MediaPlayerPrivateGStreamerBase::paint):
(WebCore::MediaPlayerPrivateGStreamerBase::copyVideoTextureToPlatformTexture):
(WebCore::MediaPlayerPrivateGStreamerBase::nativeImageForCurrentTime):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
* platform/graphics/gstreamer/mse/PlaybackPipeline.cpp:
* platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamer.cpp:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230147 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/audio/gstreamer/AudioSourceProviderGStreamer.cpp
Source/WebCore/platform/audio/gstreamer/AudioSourceProviderGStreamer.h
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h
Source/WebCore/platform/graphics/gstreamer/mse/PlaybackPipeline.cpp
Source/WebCore/platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamer.cpp

index 38bd54a..0bde292 100644 (file)
@@ -1,3 +1,35 @@
+2018-04-01  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        Use WTF::Lock instead of GMutex
+        https://bugs.webkit.org/show_bug.cgi?id=184227
+
+        Reviewed by Saam Barati.
+
+        Prefer WTF::Lock over GMutex since these locks are just protecting WebKit C++ fields.
+
+        No behavior change.
+
+        * platform/audio/gstreamer/AudioSourceProviderGStreamer.cpp:
+        (WebCore::AudioSourceProviderGStreamer::AudioSourceProviderGStreamer):
+        (WebCore::AudioSourceProviderGStreamer::~AudioSourceProviderGStreamer):
+        (WebCore::AudioSourceProviderGStreamer::provideInput):
+        (WebCore::AudioSourceProviderGStreamer::handleAudioBuffer):
+        (WebCore::AudioSourceProviderGStreamer::clearAdapters):
+        * platform/audio/gstreamer/AudioSourceProviderGStreamer.h:
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
+        (WebCore::MediaPlayerPrivateGStreamerBase::MediaPlayerPrivateGStreamerBase):
+        (WebCore::MediaPlayerPrivateGStreamerBase::~MediaPlayerPrivateGStreamerBase):
+        (WebCore::MediaPlayerPrivateGStreamerBase::naturalSize const):
+        (WebCore::MediaPlayerPrivateGStreamerBase::pushTextureToCompositor):
+        (WebCore::MediaPlayerPrivateGStreamerBase::triggerRepaint):
+        (WebCore::MediaPlayerPrivateGStreamerBase::flushCurrentBuffer):
+        (WebCore::MediaPlayerPrivateGStreamerBase::paint):
+        (WebCore::MediaPlayerPrivateGStreamerBase::copyVideoTextureToPlatformTexture):
+        (WebCore::MediaPlayerPrivateGStreamerBase::nativeImageForCurrentTime):
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
+        * platform/graphics/gstreamer/mse/PlaybackPipeline.cpp:
+        * platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamer.cpp:
+
 2018-03-31  Brent Fulgham  <bfulgham@apple.com>
 
         Show punycode if URL contains hyphen character
index 4d7e3e4..d4a0ca2 100644 (file)
@@ -26,7 +26,6 @@
 #include <gst/app/gstappsink.h>
 #include <gst/audio/audio-info.h>
 #include <gst/base/gstadapter.h>
-#include <wtf/glib/GMutexLocker.h>
 
 
 namespace WebCore {
@@ -91,7 +90,6 @@ AudioSourceProviderGStreamer::AudioSourceProviderGStreamer()
     , m_deinterleaveNoMorePadsHandlerId(0)
     , m_deinterleavePadRemovedHandlerId(0)
 {
-    g_mutex_init(&m_adapterMutex);
     m_frontLeftAdapter = gst_adapter_new();
     m_frontRightAdapter = gst_adapter_new();
 }
@@ -109,7 +107,6 @@ AudioSourceProviderGStreamer::~AudioSourceProviderGStreamer()
 
     g_object_unref(m_frontLeftAdapter);
     g_object_unref(m_frontRightAdapter);
-    g_mutex_clear(&m_adapterMutex);
 }
 
 void AudioSourceProviderGStreamer::configureAudioBin(GstElement* audioBin, GstElement* teePredecessor)
@@ -154,7 +151,7 @@ void AudioSourceProviderGStreamer::configureAudioBin(GstElement* audioBin, GstEl
 
 void AudioSourceProviderGStreamer::provideInput(AudioBus* bus, size_t framesToProcess)
 {
-    WTF::GMutexLocker<GMutex> lock(m_adapterMutex);
+    auto locker = holdLock(m_adapterMutex);
     copyGStreamerBuffersToAudioChannel(m_frontLeftAdapter, bus, 0, framesToProcess);
     copyGStreamerBuffersToAudioChannel(m_frontRightAdapter, bus, 1, framesToProcess);
 }
@@ -181,7 +178,7 @@ GstFlowReturn AudioSourceProviderGStreamer::handleAudioBuffer(GstAppSink* sink)
     GstAudioInfo info;
     gst_audio_info_from_caps(&info, caps);
 
-    WTF::GMutexLocker<GMutex> lock(m_adapterMutex);
+    auto locker = holdLock(m_adapterMutex);
 
     // Check the first audio channel. The buffer is supposed to store
     // data of a single channel anyway.
@@ -351,7 +348,7 @@ void AudioSourceProviderGStreamer::deinterleavePadsConfigured()
 
 void AudioSourceProviderGStreamer::clearAdapters()
 {
-    WTF::GMutexLocker<GMutex> lock(m_adapterMutex);
+    auto locker = holdLock(m_adapterMutex);
     gst_adapter_clear(m_frontLeftAdapter);
     gst_adapter_clear(m_frontRightAdapter);
 }
index 3d5d65b..ab60198 100644 (file)
@@ -66,7 +66,7 @@ private:
     unsigned long m_deinterleavePadAddedHandlerId;
     unsigned long m_deinterleaveNoMorePadsHandlerId;
     unsigned long m_deinterleavePadRemovedHandlerId;
-    GMutex m_adapterMutex;
+    Lock m_adapterMutex;
 };
 
 }
index e649e12..a48acaa 100644 (file)
@@ -37,7 +37,6 @@
 #include "NotImplemented.h"
 #include "VideoSinkGStreamer.h"
 #include "WebKitWebSourceGStreamer.h"
-#include <wtf/glib/GMutexLocker.h>
 #include <wtf/glib/GUniquePtr.h>
 #include <wtf/text/AtomicString.h>
 #include <wtf/text/CString.h>
@@ -237,7 +236,6 @@ MediaPlayerPrivateGStreamerBase::MediaPlayerPrivateGStreamerBase(MediaPlayer* pl
     , m_platformLayerProxy(adoptRef(new TextureMapperPlatformLayerProxy()))
 #endif
 {
-    g_mutex_init(&m_sampleMutex);
 }
 
 MediaPlayerPrivateGStreamerBase::~MediaPlayerPrivateGStreamerBase()
@@ -268,8 +266,6 @@ MediaPlayerPrivateGStreamerBase::~MediaPlayerPrivateGStreamerBase()
     if (m_pipeline)
         gst_element_set_state(m_pipeline.get(), GST_STATE_NULL);
 
-    g_mutex_clear(&m_sampleMutex);
-
     m_player = nullptr;
 }
 
@@ -520,7 +516,7 @@ FloatSize MediaPlayerPrivateGStreamerBase::naturalSize() const
     if (!m_videoSize.isEmpty())
         return m_videoSize;
 
-    WTF::GMutexLocker<GMutex> lock(m_sampleMutex);
+    auto sampleLocker = holdLock(m_sampleMutex);
     if (!GST_IS_SAMPLE(m_sample.get()))
         return FloatSize();
 
@@ -739,7 +735,7 @@ void MediaPlayerPrivateGStreamerBase::pushTextureToCompositor()
     ConditionNotifier notifier(m_drawMutex, m_drawCondition);
 #endif
 
-    WTF::GMutexLocker<GMutex> lock(m_sampleMutex);
+    auto sampleLocker = holdLock(m_sampleMutex);
     if (!GST_IS_SAMPLE(m_sample.get()))
         return;
 
@@ -790,7 +786,7 @@ void MediaPlayerPrivateGStreamerBase::triggerRepaint(GstSample* sample)
 {
     bool triggerResize;
     {
-        WTF::GMutexLocker<GMutex> lock(m_sampleMutex);
+        auto sampleLocker = holdLock(m_sampleMutex);
         triggerResize = !m_sample;
         m_sample = sample;
     }
@@ -865,7 +861,7 @@ GstFlowReturn MediaPlayerPrivateGStreamerBase::newPrerollCallback(GstElement* si
 void MediaPlayerPrivateGStreamerBase::flushCurrentBuffer()
 {
     GST_DEBUG_OBJECT(pipeline(), "Flushing video sample");
-    WTF::GMutexLocker<GMutex> lock(m_sampleMutex);
+    auto sampleLocker = holdLock(m_sampleMutex);
     m_sample.clear();
 
     {
@@ -890,7 +886,7 @@ void MediaPlayerPrivateGStreamerBase::paint(GraphicsContext& context, const Floa
     if (!m_player->visible())
         return;
 
-    WTF::GMutexLocker<GMutex> lock(m_sampleMutex);
+    auto sampleLocker = holdLock(m_sampleMutex);
     if (!GST_IS_SAMPLE(m_sample.get()))
         return;
 
@@ -917,7 +913,7 @@ bool MediaPlayerPrivateGStreamerBase::copyVideoTextureToPlatformTexture(Graphics
     if (premultiplyAlpha)
         return false;
 
-    WTF::GMutexLocker<GMutex> lock(m_sampleMutex);
+    auto sampleLocker = holdLock(m_sampleMutex);
 
     GstVideoInfo videoInfo;
     if (!getSampleVideoInfo(m_sample.get(), videoInfo))
@@ -949,7 +945,7 @@ NativeImagePtr MediaPlayerPrivateGStreamerBase::nativeImageForCurrentTime()
     if (m_usingFallbackVideoSink)
         return nullptr;
 
-    WTF::GMutexLocker<GMutex> lock(m_sampleMutex);
+    auto sampleLocker = holdLock(m_sampleMutex);
 
     GstVideoInfo videoInfo;
     if (!getSampleVideoInfo(m_sample.get(), videoInfo))
index b4cc65d..fe65e93 100644 (file)
@@ -226,7 +226,7 @@ protected:
     MediaPlayer::ReadyState m_readyState;
     mutable MediaPlayer::NetworkState m_networkState;
     IntSize m_size;
-    mutable GMutex m_sampleMutex;
+    mutable Lock m_sampleMutex;
     GRefPtr<GstSample> m_sample;
 
     mutable FloatSize m_videoSize;
index 73d3261..5b1e398 100644 (file)
@@ -36,7 +36,6 @@
 #include <gst/gst.h>
 #include <wtf/MainThread.h>
 #include <wtf/RefCounted.h>
-#include <wtf/glib/GMutexLocker.h>
 #include <wtf/glib/GRefPtr.h>
 #include <wtf/glib/GUniquePtr.h>
 #include <wtf/text/AtomicString.h>
index 042e03a..2a6fd9a 100644 (file)
@@ -48,7 +48,6 @@
 #include <gst/video/video.h>
 #include <wtf/Condition.h>
 #include <wtf/MainThread.h>
-#include <wtf/glib/GMutexLocker.h>
 #include <wtf/glib/GUniquePtr.h>
 #include <wtf/text/CString.h>