[gstreamer] Make sure gstreamer source element is thread-safe

https://bugs.webkit.org/show_bug.cgi?id=115352

Patch by Andre Moreira Magalhaes <andre.magalhaes@collabora.co.uk> on 2013-08-27
Reviewed by Philippe Normand.

Source/WebCore:

GStreamer source element may be created by any gstreamer element on any thread by calling
gst_element_make_from_uri with the URIs handled by the source element.
This patch makes sure the gstreamer source element is thread-safe to avoid issues with it
being created outside the main thread.

* platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
(webkit_web_src_init):
(webKitWebSrcDispose):
(webKitWebSrcFinalize):
(webKitWebSrcSetProperty):
(webKitWebSrcGetProperty):
(removeTimeoutSources):
(webKitWebSrcStop):
(webKitWebSrcStart):
(webKitWebSrcChangeState):
(webKitWebSrcQueryWithParent):
(webKitWebSrcGetUri):
(webKitWebSrcSetUri):
(webKitWebSrcNeedDataMainCb):
(webKitWebSrcNeedDataCb):
(webKitWebSrcEnoughDataMainCb):
(webKitWebSrcEnoughDataCb):
(webKitWebSrcSeekMainCb):
(webKitWebSrcSeekDataCb):
(webKitWebSrcSetMediaPlayer):
(StreamingClient::StreamingClient):
(StreamingClient::~StreamingClient):
(StreamingClient::createReadBuffer):
(StreamingClient::handleResponseReceived):
(StreamingClient::handleDataReceived):
(StreamingClient::handleNotifyFinished):
(CachedResourceStreamingClient::CachedResourceStreamingClient):
(CachedResourceStreamingClient::~CachedResourceStreamingClient):
(CachedResourceStreamingClient::loadFailed):
(CachedResourceStreamingClient::setDefersLoading):
(CachedResourceStreamingClient::getOrCreateReadBuffer):
(CachedResourceStreamingClient::responseReceived):
(CachedResourceStreamingClient::dataReceived):
(CachedResourceStreamingClient::notifyFinished):
(ResourceHandleStreamingClient::ResourceHandleStreamingClient):
(ResourceHandleStreamingClient::~ResourceHandleStreamingClient):
(ResourceHandleStreamingClient::loadFailed):
(ResourceHandleStreamingClient::setDefersLoading):
(ResourceHandleStreamingClient::getOrCreateReadBuffer):
(ResourceHandleStreamingClient::willSendRequest):
(ResourceHandleStreamingClient::didReceiveResponse):
(ResourceHandleStreamingClient::didReceiveData):
(ResourceHandleStreamingClient::didFinishLoading):
(ResourceHandleStreamingClient::didFail):
(ResourceHandleStreamingClient::wasBlocked):
(ResourceHandleStreamingClient::cannotShowURL):
Make element thread-safe, add support to use the element without a player associated (e.g.
the DASH plugin using the webkitsrc to download fragments), use GMutexLocker to simplify
locks and other general improvements.

Source/WTF:

Add convenience class that simplifies locking and unlocking a GMutex.

* GNUmakefile.list.am:
* wtf/gobject/GMutexLocker.h: Added.
(WebCore::GMutexLocker::GMutexLocker):
(WebCore::GMutexLocker::~GMutexLocker):
(WebCore::GMutexLocker::lock):
(WebCore::GMutexLocker::unlock):
(WebCore::GMutexLocker::mutex):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154683 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 4e851ef4
2013-08-27 Andre Moreira Magalhaes <andre.magalhaes@collabora.co.uk>
[gstreamer] Make sure gstreamer source element is thread-safe
https://bugs.webkit.org/show_bug.cgi?id=115352
Reviewed by Philippe Normand.
Add convenience class that simplifies locking and unlocking a GMutex.
* GNUmakefile.list.am:
* wtf/gobject/GMutexLocker.h: Added.
(WebCore::GMutexLocker::GMutexLocker):
(WebCore::GMutexLocker::~GMutexLocker):
(WebCore::GMutexLocker::lock):
(WebCore::GMutexLocker::unlock):
(WebCore::GMutexLocker::mutex):
2013-08-26 Andy Estes <aestes@apple.com>
Don't leak objects in HardAutorelease when OBJC_NO_GC is undefined but
......
......@@ -213,6 +213,7 @@ wtf_sources += \
Source/WTF/wtf/dtoa/strtod.cc \
Source/WTF/wtf/dtoa/strtod.h \
Source/WTF/wtf/dtoa/utils.h \
Source/WTF/wtf/gobject/GMutexLocker.h \
Source/WTF/wtf/gobject/GOwnPtr.cpp \
Source/WTF/wtf/gobject/GOwnPtr.h \
Source/WTF/wtf/gobject/GRefPtr.cpp \
......
/*
* Copyright (C) 2013 Collabora Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef GMutexLocker_h
#define GMutexLocker_h
#if USE(GLIB)
#include <glib.h>
#include <wtf/FastAllocBase.h>
#include <wtf/Noncopyable.h>
namespace WebCore {
class GMutexLocker {
WTF_MAKE_NONCOPYABLE(GMutexLocker); WTF_MAKE_FAST_ALLOCATED;
public:
inline explicit GMutexLocker(GMutex* mutex)
: m_mutex(mutex)
, m_val(0)
{
lock();
}
inline ~GMutexLocker() { unlock(); }
inline void lock()
{
if (m_mutex && !m_val) {
g_mutex_lock(m_mutex);
m_val = 1;
}
}
inline void unlock()
{
if (m_mutex && m_val) {
m_val = 0;
g_mutex_unlock(m_mutex);
}
}
inline GMutex* mutex() const { return m_mutex; }
private:
GMutex* m_mutex;
uint8_t m_val;
};
}
#endif // USE(GLIB)
#endif // GMutexLocker_h
2013-08-27 Andre Moreira Magalhaes <andre.magalhaes@collabora.co.uk>
[gstreamer] Make sure gstreamer source element is thread-safe
https://bugs.webkit.org/show_bug.cgi?id=115352
Reviewed by Philippe Normand.
GStreamer source element may be created by any gstreamer element on any thread by calling
gst_element_make_from_uri with the URIs handled by the source element.
This patch makes sure the gstreamer source element is thread-safe to avoid issues with it
being created outside the main thread.
* platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
(webkit_web_src_init):
(webKitWebSrcDispose):
(webKitWebSrcFinalize):
(webKitWebSrcSetProperty):
(webKitWebSrcGetProperty):
(removeTimeoutSources):
(webKitWebSrcStop):
(webKitWebSrcStart):
(webKitWebSrcChangeState):
(webKitWebSrcQueryWithParent):
(webKitWebSrcGetUri):
(webKitWebSrcSetUri):
(webKitWebSrcNeedDataMainCb):
(webKitWebSrcNeedDataCb):
(webKitWebSrcEnoughDataMainCb):
(webKitWebSrcEnoughDataCb):
(webKitWebSrcSeekMainCb):
(webKitWebSrcSeekDataCb):
(webKitWebSrcSetMediaPlayer):
(StreamingClient::StreamingClient):
(StreamingClient::~StreamingClient):
(StreamingClient::createReadBuffer):
(StreamingClient::handleResponseReceived):
(StreamingClient::handleDataReceived):
(StreamingClient::handleNotifyFinished):
(CachedResourceStreamingClient::CachedResourceStreamingClient):
(CachedResourceStreamingClient::~CachedResourceStreamingClient):
(CachedResourceStreamingClient::loadFailed):
(CachedResourceStreamingClient::setDefersLoading):
(CachedResourceStreamingClient::getOrCreateReadBuffer):
(CachedResourceStreamingClient::responseReceived):
(CachedResourceStreamingClient::dataReceived):
(CachedResourceStreamingClient::notifyFinished):
(ResourceHandleStreamingClient::ResourceHandleStreamingClient):
(ResourceHandleStreamingClient::~ResourceHandleStreamingClient):
(ResourceHandleStreamingClient::loadFailed):
(ResourceHandleStreamingClient::setDefersLoading):
(ResourceHandleStreamingClient::getOrCreateReadBuffer):
(ResourceHandleStreamingClient::willSendRequest):
(ResourceHandleStreamingClient::didReceiveResponse):
(ResourceHandleStreamingClient::didReceiveData):
(ResourceHandleStreamingClient::didFinishLoading):
(ResourceHandleStreamingClient::didFail):
(ResourceHandleStreamingClient::wasBlocked):
(ResourceHandleStreamingClient::cannotShowURL):
Make element thread-safe, add support to use the element without a player associated (e.g.
the DASH plugin using the webkitsrc to download fragments), use GMutexLocker to simplify
locks and other general improvements.
2013-08-27 Antti Koivisto <antti@apple.com>
Remove branch from DescendantIteratorAdapter::begin() when invoking for ContainerNode
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment