Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
7f972e43
Commit
7f972e43
authored
10 years ago
by
Guillaume Roguez
Browse files
Options
Downloads
Patches
Plain Diff
daemon: use C++11 std thread than pthread
Refs #61640 Change-Id: Ib33e915fbdd7596c4c17320659bfd8abbd4515b0
parent
cac91e03
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
daemon/src/video/libav_utils.cpp
+15
-11
15 additions, 11 deletions
daemon/src/video/libav_utils.cpp
with
15 additions
and
11 deletions
daemon/src/video/libav_utils.cpp
+
15
−
11
View file @
7f972e43
...
@@ -38,6 +38,9 @@
...
@@ -38,6 +38,9 @@
#include
<algorithm>
#include
<algorithm>
#include
<string>
#include
<string>
#include
<iostream>
#include
<iostream>
#include
<thread>
#include
<mutex>
#include
<exception>
std
::
map
<
std
::
string
,
std
::
string
>
encoders_
;
std
::
map
<
std
::
string
,
std
::
string
>
encoders_
;
std
::
vector
<
std
::
string
>
installed_video_codecs_
;
std
::
vector
<
std
::
string
>
installed_video_codecs_
;
...
@@ -68,28 +71,29 @@ std::vector<std::string> getVideoCodecList()
...
@@ -68,28 +71,29 @@ std::vector<std::string> getVideoCodecList()
return
installed_video_codecs_
;
return
installed_video_codecs_
;
}
}
// protect libav/ffmpeg access
with pthreads
// protect libav/ffmpeg access
static
int
static
int
avcodecManageMutex
(
void
**
data
,
enum
AVLockOp
op
)
avcodecManageMutex
(
void
**
data
,
enum
AVLockOp
op
)
{
{
pthread_mutex_t
**
mutex
=
reinterpret_cast
<
pthread_
mutex
_t
**>
(
data
);
auto
mutex
=
reinterpret_cast
<
std
::
mutex
**>
(
data
);
int
ret
=
0
;
int
ret
=
0
;
switch
(
op
)
{
switch
(
op
)
{
case
AV_LOCK_CREATE
:
case
AV_LOCK_CREATE
:
*
mutex
=
static_cast
<
pthread_mutex_t
*>
(
av_malloc
(
sizeof
(
pthread_mutex_t
)));
try
{
if
(
!*
mutex
)
*
mutex
=
new
std
::
mutex
;
}
catch
(
const
std
::
bad_alloc
&
e
)
{
return
AVERROR
(
ENOMEM
);
return
AVERROR
(
ENOMEM
);
ret
=
pthread_mutex_init
(
*
mutex
,
NULL
);
}
break
;
break
;
case
AV_LOCK_OBTAIN
:
case
AV_LOCK_OBTAIN
:
ret
=
pthread_
mutex
_
lock
(
*
mutex
);
(
*
mutex
)
->
lock
();
break
;
break
;
case
AV_LOCK_RELEASE
:
case
AV_LOCK_RELEASE
:
ret
=
pthread_
mutex
_
unlock
(
*
mutex
);
(
*
mutex
)
->
unlock
();
break
;
break
;
case
AV_LOCK_DESTROY
:
case
AV_LOCK_DESTROY
:
ret
=
pthread_mutex_destroy
(
*
mutex
)
;
delete
*
mutex
;
av_freep
(
mutex
)
;
*
mutex
=
nullptr
;
break
;
break
;
default
:
default
:
#ifdef AVERROR_BUG
#ifdef AVERROR_BUG
...
@@ -145,11 +149,11 @@ static void init_once()
...
@@ -145,11 +149,11 @@ static void init_once()
findInstalledVideoCodecs
();
findInstalledVideoCodecs
();
}
}
static
pthread_
once_
t
already_called
=
PTHREAD_ONCE_INIT
;
static
std
::
once_
flag
already_called
;
void
sfl_avcodec_init
()
void
sfl_avcodec_init
()
{
{
(
void
)
pthread
_once
(
&
already_called
,
init_once
);
std
::
call
_once
(
already_called
,
init_once
);
}
}
std
::
vector
<
std
::
map
<
std
::
string
,
std
::
string
>
>
std
::
vector
<
std
::
map
<
std
::
string
,
std
::
string
>
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment