[vlc-commits] commit: mozilla: fix building for win32 (events not implemented yet) ( Jean-Paul Saman )

git version control git at videolan.org
Thu Mar 4 13:15:37 CET 2010


vlc | branch: master | Jean-Paul Saman <jean-paul.saman at m2x.nl> | Thu Feb 25 16:05:39 2010 +0100| [37a18cbfcc90f731a4b6843c21c3dfab80d6fd1b] | committer: Jean-Paul Saman 

mozilla: fix building for win32 (events not implemented yet)

ifdef the dependency on pthread for windows. It restricts pthread usage to XP_UNIX only. The events object should be extended to support MacOS X and Win32 too, this will be done in coming commits.

Signed-off-by: Jean-Paul Saman <jean-paul.saman at m2x.nl>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=37a18cbfcc90f731a4b6843c21c3dfab80d6fd1b
---

 projects/mozilla/vlcplugin.cpp |   46 ++++++++++++++++++++++++++++++++++-----
 projects/mozilla/vlcplugin.h   |    6 +++-
 2 files changed, 44 insertions(+), 8 deletions(-)

diff --git a/projects/mozilla/vlcplugin.cpp b/projects/mozilla/vlcplugin.cpp
index 3356161..895d7a2 100644
--- a/projects/mozilla/vlcplugin.cpp
+++ b/projects/mozilla/vlcplugin.cpp
@@ -36,7 +36,12 @@
 #include "control/npolibvlc.h"
 
 #include <ctype.h>
-#include <pthread.h>
+#if defined(XP_UNIX)
+# include <pthread.h>
+#else
+#warning "locking not implemented for this platform"
+#endif
+
 #include <stdio.h>
 
 /*****************************************************************************
@@ -88,14 +93,34 @@ static bool boolValue(const char *value) {
              !strcasecmp(value, "yes") );
 }
 
+bool EventObj::init()
+{
+#if defined(XP_UNIX)
+    return pthread_mutex_init(&mutex, NULL) == 0;
+#else
+#warning "locking not implemented for this platform"
+#endif
+}
+
+EventObj::~EventObj()
+{
+#if defined(XP_UNIX)
+    pthread_mutex_destroy(&mutex);
+#else
+#warning "locking not implemented for this platform"
+#endif
+}
 
 void EventObj::deliver(NPP browser)
 {
     NPVariant result;
     NPVariant params[1];
 
+#if defined(XP_UNIX)
     pthread_mutex_lock(&mutex);
-
+#else
+#warning "locking not implemented for this platform"
+#endif
     for( ev_l::iterator i=_elist.begin();i!=_elist.end();++i )
     {
         libvlc_event_type_t event = *i;
@@ -114,8 +139,11 @@ void EventObj::deliver(NPP browser)
         }
     }
     _elist.clear();
-
+#if defined(XP_UNIX)
     pthread_mutex_unlock(&mutex);
+#else
+#warning "locking not implemented for this platform"
+#endif
 }
 
 void VlcPlugin::eventAsync(void *param)
@@ -126,18 +154,24 @@ void VlcPlugin::eventAsync(void *param)
 
 void EventObj::callback(const libvlc_event_t* event)
 {
+#if defined(XP_UNIX)
     pthread_mutex_lock(&mutex);
-
+#else
+#warning "locking not implemented for this platform"
+#endif
     if( have_event(event->type) )
         _elist.push_back(event->type);
-
+#if defined(XP_UNIX)
     pthread_mutex_unlock(&mutex);
+#else
+#warning "locking not implemented for this platform"
+#endif
 }
 
 void VlcPlugin::event_callback(const libvlc_event_t* event, void *param)
 {
     VlcPlugin *plugin = (VlcPlugin*)param;
-#ifdef XP_UNIX
+#if defined(XP_UNIX)
     plugin->events.callback(event);
     NPN_PluginThreadAsyncCall(plugin->getBrowser(), eventAsync, plugin);
 #else
diff --git a/projects/mozilla/vlcplugin.h b/projects/mozilla/vlcplugin.h
index 3e85840..4c9a11c 100644
--- a/projects/mozilla/vlcplugin.h
+++ b/projects/mozilla/vlcplugin.h
@@ -135,8 +135,8 @@ private:
     void *_ud;
 public:
     EventObj(): _em(NULL)  { /* deferred to init() */ }
-    bool init() { return pthread_mutex_init(&mutex, NULL) == 0; }
-    ~EventObj() { pthread_mutex_destroy(&mutex); }
+    bool init();
+    ~EventObj();
 
     void deliver(NPP browser);
     void callback(const libvlc_event_t*);
@@ -151,7 +151,9 @@ private:
     lr_l _llist;
     ev_l _elist;
 
+#if defined(XP_UNIX)
     pthread_mutex_t mutex;
+#endif
 
     bool ask_for_event(event_t e);
     void unask_for_event(event_t e);



More information about the vlc-commits mailing list