{
g_mutex_init(&threading.mutex);
g_cond_init(&threading.cond);
- g_mutex_init(&threading.ready_mutex);
- g_cond_init(&threading.ready_cond);
{
GMutexHolder lock(threading.mutex);
g_mutex_clear(&threading.mutex);
g_cond_clear(&threading.cond);
- g_mutex_clear(&threading.ready_mutex);
- g_cond_clear(&threading.ready_cond);
}
template<typename Function>
WPEView* WPEContextThread::createWPEView(GstWpeSrc* src, GstGLContext* context, GstGLDisplay* display, int width, int height)
{
GST_DEBUG("context %p display %p, size (%d,%d)", context, display, width, height);
- threading.ready = FALSE;
static std::once_flag s_loaderFlag;
std::call_once(s_loaderFlag,
if (view && view->hasUri()) {
GST_DEBUG("waiting load to finish");
- GMutexHolder lock(threading.ready_mutex);
- while (!threading.ready)
- g_cond_wait(&threading.ready_cond, &threading.ready_mutex);
+ view->waitLoadCompletion();
GST_DEBUG("done");
}
return view;
}
-void WPEContextThread::notifyLoadFinished()
-{
- GMutexHolder lock(threading.ready_mutex);
- if (!threading.ready) {
- threading.ready = TRUE;
- g_cond_signal(&threading.ready_cond);
- }
-}
-
static gboolean s_loadFailed(WebKitWebView*, WebKitLoadEvent, gchar* failing_uri, GError* error, gpointer data)
{
GstWpeSrc* src = GST_WPE_SRC(data);
WPEView::WPEView(WebKitWebContext* web_context, GstWpeSrc* src, GstGLContext* context, GstGLDisplay* display, int width, int height)
{
+ g_mutex_init(&threading.ready_mutex);
+ g_cond_init(&threading.ready_cond);
+ threading.ready = FALSE;
+
g_mutex_init(&images_mutex);
if (context)
gst.context = GST_GL_CONTEXT(gst_object_ref(context));
WPEView::~WPEView()
{
+ g_mutex_clear(&threading.ready_mutex);
+ g_cond_clear(&threading.ready_cond);
+
{
GMutexHolder lock(images_mutex);
g_mutex_clear(&images_mutex);
}
+void WPEView::notifyLoadFinished()
+{
+ GMutexHolder lock(threading.ready_mutex);
+ if (!threading.ready) {
+ threading.ready = TRUE;
+ g_cond_signal(&threading.ready_cond);
+ }
+}
+
+void WPEView::waitLoadCompletion()
+{
+ GMutexHolder lock(threading.ready_mutex);
+ while (!threading.ready)
+ g_cond_wait(&threading.ready_cond, &threading.ready_mutex);
+}
+
GstEGLImage* WPEView::image()
{
GstEGLImage* ret = nullptr;
GST_TRACE("EGLImage %p wrapped in GstEGLImage %" GST_PTR_FORMAT, eglImage, gstImage);
egl.pending = gstImage;
- s_view->notifyLoadFinished();
+ notifyLoadFinished();
}
}
GMutexHolder lock(images_mutex);
GST_TRACE("SHM buffer %p wrapped in buffer %" GST_PTR_FORMAT, buffer, gstBuffer);
shm.pending = gstBuffer;
- s_view->notifyLoadFinished();
+ notifyLoadFinished();
}
}
#endif
/* Used by WPEContextThread */
bool hasUri() const { return webkit.uri; }
void disconnectLoadFailedSignal();
+ void waitLoadCompletion();
protected:
void handleExportedImage(gpointer);
struct wpe_view_backend* backend() const;
void frameComplete();
void loadUriUnlocked(const gchar*);
+ void notifyLoadFinished();
void releaseImage(gpointer);
#if ENABLE_SHM_BUFFER_SUPPORT
bool m_isValid { false };
+ struct {
+ GMutex ready_mutex;
+ GCond ready_cond;
+ gboolean ready;
+ } threading;
+
// This mutex guards access to either egl or shm resources declared below,
// depending on the runtime behavior.
GMutex images_mutex;
template<typename Function>
void dispatch(Function);
- void notifyLoadFinished();
-
private:
static gpointer s_viewThread(gpointer);
struct {
GMutex mutex;
GCond cond;
- GMutex ready_mutex;
- GCond ready_cond;
- gboolean ready;
GThread* thread { nullptr };
} threading;