aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2012-09-26 21:18:28 +0200
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2012-09-26 21:18:28 +0200
commitae1e2d5bf8a59095d1a978be51b7eec793d19da2 (patch)
tree4ffc69b63065c851af000ac77a469a23d9f46b64
parent7110cea433b6aa4ce973b5c89c9ff9721e64ef55 (diff)
downloadosc-graphics-ae1e2d5bf8a59095d1a978be51b7eec793d19da2.tar.gz
make vlcinst a static class member since it's required only once for all LayerVideo instances
-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;