aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--layer_video.cpp16
-rw-r--r--layer_video.h2
2 files changed, 12 insertions, 6 deletions
diff --git a/layer_video.cpp b/layer_video.cpp
index 57ab4b9..bf6aa01 100644
--- a/layer_video.cpp
+++ b/layer_video.cpp
@@ -13,6 +13,8 @@
Layer::CtorInfo LayerVideo::ctor_info = {"video", "s" /* url */};
+libvlc_instance_t *LayerVideo::vlcinst = NULL;
+
static void *
lock_cb(void *data, void **p_pixels)
{
@@ -40,10 +42,15 @@ display_cb(void *data __attribute__((unused)), void *id __attribute__((unused)))
LayerVideo::LayerVideo(const char *name, SDL_Rect geo, float opacity,
const char *url) : Layer(name), mp(NULL), surf(NULL)
{
- char const *vlc_argv[] = {
- "--no-audio", /* skip any audio track */
- "--no-xlib" /* tell VLC to not use Xlib */
- };
+ /* static initialization */
+ if (!vlcinst) {
+ static char const *vlc_argv[] = {
+ "--no-audio", /* skip any audio track */
+ "--no-xlib" /* tell VLC to not use Xlib */
+ };
+
+ vlcinst = libvlc_new(NARRAY(vlc_argv), vlc_argv);
+ }
url_osc_id = register_method("url", "s", (OSCServer::MethodHandlerCb)url_osc);
rate_osc_id = register_method("rate", "f", (OSCServer::MethodHandlerCb)rate_osc);
@@ -58,7 +65,6 @@ LayerVideo::LayerVideo(const char *name, SDL_Rect geo, float opacity,
LayerVideo::paused(true);
mutex = SDL_CreateMutex();
- vlcinst = libvlc_new(NARRAY(vlc_argv), vlc_argv);
LayerVideo::url(url);
}
diff --git a/layer_video.h b/layer_video.h
index 9b864d2..c3a4806 100644
--- a/layer_video.h
+++ b/layer_video.h
@@ -12,7 +12,7 @@
#include "layer.h"
class LayerVideo : public Layer {
- libvlc_instance_t *vlcinst;
+ static libvlc_instance_t *vlcinst;
libvlc_media_player_t *mp;
SDL_Surface *surf;