[vlc-commits] Split locking header functions from the common.h

Jean-Baptiste Kempf git at videolan.org
Wed Apr 23 19:20:40 CEST 2014


npapi-vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Wed Apr 23 18:10:14 2014 +0200| [d1624059257127d937a0cb4f6ca127d44d068e76] | committer: Jean-Baptiste Kempf

Split locking header functions from the common.h

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

 npapi/Makefile.am |    1 +
 npapi/common.h    |   73 +------------------------------------
 npapi/locking.h   |  105 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 107 insertions(+), 72 deletions(-)

diff --git a/npapi/Makefile.am b/npapi/Makefile.am
index e222a6c..736953c 100644
--- a/npapi/Makefile.am
+++ b/npapi/Makefile.am
@@ -17,6 +17,7 @@ AM_CPPFLAGS = $(LIBVLC_CFLAGS) -Inpapi-sdk $(MOZILLA_CFLAGS)
 
 libvlcplugin_la_SOURCES = \
 	common.h \
+	locking.h \
 	events.h \
 	events.cpp \
 	vlcshell.h \
diff --git a/npapi/common.h b/npapi/common.h
index 3a3f1e1..7e49100 100644
--- a/npapi/common.h
+++ b/npapi/common.h
@@ -77,77 +77,6 @@
     typedef int32_t NPint32_t;
 #endif
 
-/* Lock includes */
-#ifdef XP_WIN
-#   include <windows.h>
-#elif defined(HAVE_PTHREAD)
-#   include <pthread.h>
-#endif
-#include <assert.h>
-
-typedef struct {
-#if defined(HAVE_PTHREAD)
-    pthread_mutex_t mutex;
-#elif defined(XP_WIN)
-    CRITICAL_SECTION cs;
-#else
-# warning "locking not implemented in this platform"
-#endif
-} plugin_lock_t;
-
-/*****************************************************************************
- * Lock utility functions
- *****************************************************************************/
-static void plugin_lock_init(plugin_lock_t *lock)
-{
-    assert(lock);
-
-#if defined(HAVE_PTHREAD)
-    pthread_mutex_init(&lock->mutex, NULL);
-#elif defined(XP_WIN)
-    InitializeCriticalSection(&lock->cs);
-#else
-#warning "locking not implemented in this platform"
-#endif
-}
-
-static void plugin_lock_destroy(plugin_lock_t *lock)
-{
-    assert(lock);
-
-#if defined(HAVE_PTHREAD)
-    pthread_mutex_destroy(&lock->mutex);
-#elif defined(XP_WIN)
-    DeleteCriticalSection(&lock->cs);
-#else
-#warning "locking not implemented in this platform"
-#endif
-}
-
-static void plugin_lock(plugin_lock_t *lock)
-{
-    assert(lock);
-
-#if defined(HAVE_PTHREAD)
-    pthread_mutex_lock(&lock->mutex);
-#elif defined(XP_WIN)
-    EnterCriticalSection(&lock->cs);
-#else
-#warning "locking not implemented in this platform"
-#endif
-}
-
-static void plugin_unlock(plugin_lock_t *lock)
-{
-    assert(lock);
-
-#if defined(HAVE_PTHREAD)
-    pthread_mutex_unlock(&lock->mutex);
-#elif defined(XP_WIN)
-    LeaveCriticalSection(&lock->cs);
-#else
-#warning "locking not implemented in this platform"
-#endif
-}
+#include "locking.h"
 
 #endif /* __VLCPLUGIN_H__ */
diff --git a/npapi/locking.h b/npapi/locking.h
new file mode 100644
index 0000000..975c744
--- /dev/null
+++ b/npapi/locking.h
@@ -0,0 +1,105 @@
+/*****************************************************************************
+ * locking.h: a VLC plugin for Mozilla
+ *****************************************************************************
+ * Copyright (C) 2002-2012 VideoLAN
+ * $Id$
+ *
+ * Authors: Samuel Hocevar <sam at zoy.org>
+ *          Damien Fouilleul <damienf.fouilleul at laposte.net>
+ *          Jean-Paul Saman <jpsaman at videolan.org>
+ *          Sergey Radionov <rsatom at gmail.com>
+ *          Jean-Baptiste Kempf <jb at videolan.org>
+ *          Cheng Sun <chengsun9 at gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifndef __VLCPLUGIN_LOCKING_H__
+#define __VLCPLUGIN_LOCKING_H__
+
+/* Lock includes */
+#ifdef XP_WIN
+#   include <windows.h>
+#elif defined(HAVE_PTHREAD)
+#   include <pthread.h>
+#endif
+#include <assert.h>
+
+typedef struct {
+#if defined(HAVE_PTHREAD)
+    pthread_mutex_t mutex;
+#elif defined(XP_WIN)
+    CRITICAL_SECTION cs;
+#else
+# warning "locking not implemented in this platform"
+#endif
+} plugin_lock_t;
+
+/*****************************************************************************
+ * Lock utility functions
+ *****************************************************************************/
+static void plugin_lock_init(plugin_lock_t *lock)
+{
+    assert(lock);
+
+#if defined(HAVE_PTHREAD)
+    pthread_mutex_init(&lock->mutex, NULL);
+#elif defined(XP_WIN)
+    InitializeCriticalSection(&lock->cs);
+#else
+#warning "locking not implemented in this platform"
+#endif
+}
+
+static void plugin_lock_destroy(plugin_lock_t *lock)
+{
+    assert(lock);
+
+#if defined(HAVE_PTHREAD)
+    pthread_mutex_destroy(&lock->mutex);
+#elif defined(XP_WIN)
+    DeleteCriticalSection(&lock->cs);
+#else
+#warning "locking not implemented in this platform"
+#endif
+}
+
+static void plugin_lock(plugin_lock_t *lock)
+{
+    assert(lock);
+
+#if defined(HAVE_PTHREAD)
+    pthread_mutex_lock(&lock->mutex);
+#elif defined(XP_WIN)
+    EnterCriticalSection(&lock->cs);
+#else
+#warning "locking not implemented in this platform"
+#endif
+}
+
+static void plugin_unlock(plugin_lock_t *lock)
+{
+    assert(lock);
+
+#if defined(HAVE_PTHREAD)
+    pthread_mutex_unlock(&lock->mutex);
+#elif defined(XP_WIN)
+    LeaveCriticalSection(&lock->cs);
+#else
+#warning "locking not implemented in this platform"
+#endif
+}
+
+#endif



More information about the vlc-commits mailing list