Commit f5929538 authored by Brateau Etienne's avatar Brateau Etienne Committed by Jean-Baptiste Kempf
Browse files

(patch) Pass the canvas to the video output thread for the display video module

parent c70bc2ea
From 72e841d49d260825e94c98f3f69d98933abd38bc Mon Sep 17 00:00:00 2001
From: Etienne Brateau <etienne.brateau@gmail.com>
Date: Thu, 24 Aug 2017 17:26:13 +0200
Subject: [PATCH 07/10] Passing canvas to the the video display's thread, to
allow it to rendrer in the canvas.
---
src/posix/thread.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/src/posix/thread.c b/src/posix/thread.c
index 9490683991..b66f9490ae 100644
--- a/src/posix/thread.c
+++ b/src/posix/thread.c
@@ -51,6 +51,13 @@
# include <sys/pset.h>
#endif
+#ifdef __EMSCRIPTEN__
+#include <emscripten.h>
+#include <emscripten/threading.h>
+/* XXX This is an horrible hack to can get a vlc value during thread creation. */
+static libvlc_int_t* libvlc;
+#endif
+
#if !defined (_POSIX_TIMERS)
# define _POSIX_TIMERS (-1)
#endif
@@ -395,6 +402,13 @@ void vlc_threads_setup (libvlc_int_t *p_libvlc)
static vlc_mutex_t lock = VLC_STATIC_MUTEX;
static bool initialized = false;
+#if defined __EMSCRIPTEN__
+ /* We keep the libvlc instance to can get the "emscripten-display-creating" variable
+ * during the thread creation to know if we pass the canvas or not.
+ */
+ libvlc = p_libvlc;
+#endif
+
vlc_mutex_lock (&lock);
/* Initializes real-time priorities before any thread is created,
* just once per process. */
@@ -460,6 +474,17 @@ static int vlc_clone_attr (vlc_thread_t *th, pthread_attr_t *attr,
(void) priority;
#endif
+#if defined __EMSCRIPTEN__
+ /* We transfer the context webgl to can access to it from a thread.
+ * The context is existing only in one thread, so we have to pass it
+ * thread by thread until the display thread that need the context get it.
+ * The context is automaticatly release to the "parent"'s thread when it "die".
+ */
+ if (var_GetBool(libvlc, "emscripten-vout-proxy-create")){
+ emscripten_pthread_attr_settransferredcanvases(attr, "#canvas");
+ }
+#endif
+
/* The thread stack size.
* The lower the value, the less address space per thread, the highest
* maximum simultaneous threads per process. Too low values will cause
--
2.14.1
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