[libav-commits] lavu: add wrappers for the pthreads mutex API

Anton Khirnov git at libav.org
Thu Nov 27 13:50:49 CET 2014

Module: libav
Branch: release/10
Commit: 7fe5d0a78df537542732aa7bd45962f7505255d0

Author:    Anton Khirnov <anton at khirnov.net>
Committer: Anton Khirnov <anton at khirnov.net>
Date:      Sun Nov 23 21:25:05 2014 +0100

lavu: add wrappers for the pthreads mutex API

Also add no-op fallbacks when threading is disabled.

This helps keeping the code clean if Libav is compiled for targets
without threading. Since we assume that no threads of any kind are used
in such configurations, doing nothing is ok by definition.

Based on a patch by wm4 <nfxjfg at googlemail.com>.

(cherry picked from commit 2443e522f0059176ff8717c9c753eb6fe7e7bbf1)
Signed-off-by: Anton Khirnov <anton at khirnov.net>
(cherry picked from commit 46a17d886b8559723c40b9f5cdf0e0c6b1c95180)
Signed-off-by: Anton Khirnov <anton at khirnov.net>


 libavutil/thread.h |   53 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/libavutil/thread.h b/libavutil/thread.h
new file mode 100644
index 0000000..07e3d4a
--- /dev/null
+++ b/libavutil/thread.h
@@ -0,0 +1,53 @@
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+// This header should only be used to simplify code where
+// threading is optional, not as a generic threading abstraction.
+#include "config.h"
+#include <pthread.h>
+#include <compat/w32pthreads.h>
+#define AVMutex pthread_mutex_t
+#define ff_mutex_init    pthread_mutex_init
+#define ff_mutex_lock    pthread_mutex_lock
+#define ff_mutex_unlock  pthread_mutex_unlock
+#define ff_mutex_destroy pthread_mutex_destroy
+#define AVMutex char
+#define ff_mutex_init(mutex, attr) (0)
+#define ff_mutex_lock(mutex) (0)
+#define ff_mutex_unlock(mutex) (0)
+#define ff_mutex_destroy(mutex) (0)
+#endif /* AVUTIL_THREAD_H */

More information about the libav-commits mailing list