Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
3154f441
Commit
3154f441
authored
Nov 24, 2017
by
Rostislav Pehlivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavc/utils.c: use C11 atomics for entangled thread handling
Signed-off-by:
Rostislav Pehlivanov
<
atomnuker@gmail.com
>
parent
abf66947
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
4 deletions
+5
-4
utils.c
libavcodec/utils.c
+5
-4
No files found.
libavcodec/utils.c
View file @
3154f441
...
...
@@ -56,6 +56,7 @@
#include "version.h"
#include <stdlib.h>
#include <stdarg.h>
#include <stdatomic.h>
#include <limits.h>
#include <float.h>
#if CONFIG_ICONV
...
...
@@ -114,7 +115,7 @@ static int (*lockmgr_cb)(void **mutex, enum AVLockOp op) = NULL;
volatile
int
ff_avcodec_locked
;
static
int
volatile
entangled_thread_counter
=
0
;
static
atomic_int
entangled_thread_counter
=
ATOMIC_VAR_INIT
(
0
)
;
static
void
*
codec_mutex
;
static
void
*
avformat_mutex
;
...
...
@@ -1944,11 +1945,11 @@ int ff_lock_avcodec(AVCodecContext *log_ctx, const AVCodec *codec)
return
-
1
;
}
if
(
a
vpriv_atomic_int_add_and_fetch
(
&
entangled_thread_counter
,
1
)
!=
1
)
{
if
(
a
tomic_fetch_add
(
&
entangled_thread_counter
,
1
)
)
{
av_log
(
log_ctx
,
AV_LOG_ERROR
,
"Insufficient thread locking. At least %d threads are "
"calling avcodec_open2() at the same time right now.
\n
"
,
entangled_thread_counter
);
atomic_load
(
&
entangled_thread_counter
)
);
if
(
!
lockmgr_cb
)
av_log
(
log_ctx
,
AV_LOG_ERROR
,
"No lock manager is set, please see av_lockmgr_register()
\n
"
);
ff_avcodec_locked
=
1
;
...
...
@@ -1967,7 +1968,7 @@ int ff_unlock_avcodec(const AVCodec *codec)
av_assert0
(
ff_avcodec_locked
);
ff_avcodec_locked
=
0
;
a
vpriv_atomic_int_add_and_fetch
(
&
entangled_thread_counter
,
-
1
);
a
tomic_fetch_add
(
&
entangled_thread_counter
,
-
1
);
if
(
lockmgr_cb
)
{
if
((
*
lockmgr_cb
)(
&
codec_mutex
,
AV_LOCK_RELEASE
))
return
-
1
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment