History

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@googlemail.com>.

Anton Khirnov committed 11 years ago

Commit 2443e521 parent 675ac561 file · +53 −0Browse files

Unified · Split

libavutil/thread.h+53−0
@@ -0,0 +1,53 @@
1+/*
2+ * This file is part of Libav.
3+ *
4+ * Libav is free software; you can redistribute it and/or
5+ * modify it under the terms of the GNU Lesser General Public
6+ * License as published by the Free Software Foundation; either
7+ * version 2.1 of the License, or (at your option) any later version.
8+ *
9+ * Libav is distributed in the hope that it will be useful,
10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+ * Lesser General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU Lesser General Public
15+ * License along with Libav; if not, write to the Free Software
16+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17+ */
18+
19+// This header should only be used to simplify code where
20+// threading is optional, not as a generic threading abstraction.
21+
22+#ifndef AVUTIL_THREAD_H
23+#define AVUTIL_THREAD_H
24+
25+#include "config.h"
26+
27+#if HAVE_PTHREADS || HAVE_W32THREADS
28+
29+#if HAVE_PTHREADS
30+#include <pthread.h>
31+#else
32+#include <compat/w32pthreads.h>
33+#endif
34+
35+#define AVMutex pthread_mutex_t
36+
37+#define ff_mutex_init pthread_mutex_init
38+#define ff_mutex_lock pthread_mutex_lock
39+#define ff_mutex_unlock pthread_mutex_unlock
40+#define ff_mutex_destroy pthread_mutex_destroy
41+
42+#else
43+
44+#define AVMutex char
45+
46+#define ff_mutex_init(mutex, attr) (0)
47+#define ff_mutex_lock(mutex) (0)
48+#define ff_mutex_unlock(mutex) (0)
49+#define ff_mutex_destroy(mutex) (0)
50+
51+#endif
52+
53+#endif /* AVUTIL_THREAD_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t