Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-1.1
Commits
dd5f0b9f
Commit
dd5f0b9f
authored
Aug 16, 2007
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ffmpeg: use var_GetGlobalMutex
parent
48d06067
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
38 deletions
+29
-38
modules/codec/ffmpeg/audio.c
modules/codec/ffmpeg/audio.c
+7
-7
modules/codec/ffmpeg/encoder.c
modules/codec/ffmpeg/encoder.c
+9
-14
modules/codec/ffmpeg/ffmpeg.c
modules/codec/ffmpeg/ffmpeg.c
+6
-10
modules/codec/ffmpeg/video.c
modules/codec/ffmpeg/video.c
+7
-7
No files found.
modules/codec/ffmpeg/audio.c
View file @
dd5f0b9f
...
...
@@ -89,17 +89,17 @@ int E_(InitAudioDec)( decoder_t *p_dec, AVCodecContext *p_context,
AVCodec
*
p_codec
,
int
i_codec_id
,
const
char
*
psz_namecodec
)
{
decoder_sys_t
*
p_sys
;
vlc_
value_t
lockval
;
vlc_
mutex_t
*
lock
=
var_GetGlobalMutex
(
"avcodec"
)
;
var_Create
(
p_dec
->
p_libvlc_global
,
"avcodec"
,
VLC_VAR_MUTEX
);
var_Get
(
p_dec
->
p_libvlc_global
,
"avcodec"
,
&
lockval
)
;
if
(
lock
==
NULL
)
return
VLC_EGENERIC
;
/* Allocate the memory needed to store the decoder's structure */
if
(
(
p_dec
->
p_sys
=
p_sys
=
(
decoder_sys_t
*
)
malloc
(
sizeof
(
decoder_sys_t
))
)
==
NULL
)
{
msg_Err
(
p_dec
,
"out of memory"
);
return
VLC_E
GENERIC
;
return
VLC_E
NOMEM
;
}
p_sys
->
p_context
=
p_context
;
...
...
@@ -134,15 +134,15 @@ int E_(InitAudioDec)( decoder_t *p_dec, AVCodecContext *p_context,
}
/* ***** Open the codec ***** */
vlc_mutex_lock
(
lock
val
.
p_address
);
vlc_mutex_lock
(
lock
);
if
(
avcodec_open
(
p_sys
->
p_context
,
p_sys
->
p_codec
)
<
0
)
{
vlc_mutex_unlock
(
lock
val
.
p_address
);
vlc_mutex_unlock
(
lock
);
msg_Err
(
p_dec
,
"cannot open codec (%s)"
,
p_sys
->
psz_namecodec
);
free
(
p_sys
);
return
VLC_EGENERIC
;
}
vlc_mutex_unlock
(
lock
val
.
p_address
);
vlc_mutex_unlock
(
lock
);
msg_Dbg
(
p_dec
,
"ffmpeg codec (%s) started"
,
p_sys
->
psz_namecodec
);
...
...
modules/codec/ffmpeg/encoder.c
View file @
dd5f0b9f
...
...
@@ -195,10 +195,7 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
int
i_codec_id
,
i_cat
;
const
char
*
psz_namecodec
;
vlc_value_t
val
;
vlc_value_t
lockval
;
var_Create
(
p_enc
->
p_libvlc_global
,
"avcodec"
,
VLC_VAR_MUTEX
);
var_Get
(
p_enc
->
p_libvlc_global
,
"avcodec"
,
&
lockval
);
vlc_mutex_t
*
lock
=
var_GetGlobalMutex
(
"avcodec"
);
if
(
!
E_
(
GetFfmpegCodec
)(
p_enc
->
fmt_out
.
i_codec
,
&
i_cat
,
&
i_codec_id
,
&
psz_namecodec
)
)
...
...
@@ -533,10 +530,10 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
p_context
->
extradata
=
NULL
;
p_context
->
flags
|=
CODEC_FLAG_GLOBAL_HEADER
;
vlc_mutex_lock
(
lock
val
.
p_address
);
vlc_mutex_lock
(
lock
);
if
(
avcodec_open
(
p_context
,
p_codec
)
)
{
vlc_mutex_unlock
(
lock
val
.
p_address
);
vlc_mutex_unlock
(
lock
);
if
(
p_enc
->
fmt_in
.
i_cat
==
AUDIO_ES
&&
(
p_context
->
channels
>
2
||
i_codec_id
==
CODEC_ID_MP2
||
i_codec_id
==
CODEC_ID_MP3
)
)
...
...
@@ -586,10 +583,10 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
}
p_context
->
codec
=
NULL
;
vlc_mutex_lock
(
lock
val
.
p_address
);
vlc_mutex_lock
(
lock
);
if
(
avcodec_open
(
p_context
,
p_codec
)
)
{
vlc_mutex_unlock
(
lock
val
.
p_address
);
vlc_mutex_unlock
(
lock
);
msg_Err
(
p_enc
,
"cannot open encoder"
);
intf_UserFatal
(
p_enc
,
VLC_FALSE
,
_
(
"Streaming / Transcoding failed"
),
_
(
"VLC could not open the encoder."
)
);
...
...
@@ -606,7 +603,7 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
return
VLC_EGENERIC
;
}
}
vlc_mutex_unlock
(
lock
val
.
p_address
);
vlc_mutex_unlock
(
lock
);
p_enc
->
fmt_out
.
i_extra
=
p_context
->
extradata_size
;
if
(
p_enc
->
fmt_out
.
i_extra
)
...
...
@@ -1005,9 +1002,7 @@ void E_(CloseEncoder)( vlc_object_t *p_this )
{
encoder_t
*
p_enc
=
(
encoder_t
*
)
p_this
;
encoder_sys_t
*
p_sys
=
p_enc
->
p_sys
;
vlc_value_t
lockval
;
var_Get
(
p_enc
->
p_libvlc_global
,
"avcodec"
,
&
lockval
);
vlc_mutex_t
*
lock
=
var_GetGlobalMutex
(
"avcodec"
);
if
(
p_sys
->
b_inited
&&
p_enc
->
i_threads
>=
1
)
{
...
...
@@ -1027,9 +1022,9 @@ void E_(CloseEncoder)( vlc_object_t *p_this )
free
(
pp_contexts
);
}
vlc_mutex_lock
(
lock
val
.
p_address
);
vlc_mutex_lock
(
lock
);
avcodec_close
(
p_sys
->
p_context
);
vlc_mutex_unlock
(
lock
val
.
p_address
);
vlc_mutex_unlock
(
lock
);
av_free
(
p_sys
->
p_context
);
if
(
p_sys
->
p_buffer
)
free
(
p_sys
->
p_buffer
);
...
...
modules/codec/ffmpeg/ffmpeg.c
View file @
dd5f0b9f
...
...
@@ -335,9 +335,7 @@ static void CloseDecoder( vlc_object_t *p_this )
{
decoder_t
*
p_dec
=
(
decoder_t
*
)
p_this
;
decoder_sys_t
*
p_sys
=
p_dec
->
p_sys
;
vlc_value_t
lockval
;
var_Get
(
p_dec
->
p_libvlc_global
,
"avcodec"
,
&
lockval
);
vlc_mutex_t
*
lock
=
var_GetGlobalMutex
(
"avcodec"
);
switch
(
p_sys
->
i_cat
)
{
...
...
@@ -354,9 +352,9 @@ static void CloseDecoder( vlc_object_t *p_this )
if
(
p_sys
->
p_context
->
extradata
)
free
(
p_sys
->
p_context
->
extradata
);
p_sys
->
p_context
->
extradata
=
NULL
;
vlc_mutex_lock
(
lock
val
.
p_address
);
vlc_mutex_lock
(
lock
);
avcodec_close
(
p_sys
->
p_context
);
vlc_mutex_unlock
(
lock
val
.
p_address
);
vlc_mutex_unlock
(
lock
);
msg_Dbg
(
p_dec
,
"ffmpeg codec (%s) stopped"
,
p_sys
->
psz_namecodec
);
av_free
(
p_sys
->
p_context
);
}
...
...
@@ -424,11 +422,9 @@ void E_(LibavcodecCallback)( void *p_opaque, int i_level,
void
E_
(
InitLibavcodec
)(
vlc_object_t
*
p_object
)
{
static
int
b_ffmpeginit
=
0
;
vlc_
value_t
lockval
;
vlc_
mutex_t
*
lock
;
var_Create
(
p_object
->
p_libvlc_global
,
"avcodec"
,
VLC_VAR_MUTEX
);
var_Get
(
p_object
->
p_libvlc_global
,
"avcodec"
,
&
lockval
);
vlc_mutex_lock
(
lockval
.
p_address
);
vlc_mutex_lock
(
lock
);
/* *** init ffmpeg library (libavcodec) *** */
if
(
!
b_ffmpeginit
)
...
...
@@ -446,7 +442,7 @@ void E_(InitLibavcodec)( vlc_object_t *p_object )
msg_Dbg
(
p_object
,
"libavcodec already initialized"
);
}
vlc_mutex_unlock
(
lock
val
.
p_address
);
vlc_mutex_unlock
(
lock
);
}
/*****************************************************************************
...
...
modules/codec/ffmpeg/video.c
View file @
dd5f0b9f
...
...
@@ -214,18 +214,18 @@ int E_(InitVideoDec)( decoder_t *p_dec, AVCodecContext *p_context,
AVCodec
*
p_codec
,
int
i_codec_id
,
const
char
*
psz_namecodec
)
{
decoder_sys_t
*
p_sys
;
vlc_
value_t
lockval
;
vlc_
mutex_t
*
lock
=
var_GetGlobalMutex
(
"avcodec"
)
;
vlc_value_t
val
;
var_Create
(
p_dec
->
p_libvlc_global
,
"avcodec"
,
VLC_VAR_MUTEX
);
var_Get
(
p_dec
->
p_libvlc_global
,
"avcodec"
,
&
lockval
)
;
if
(
lock
==
NULL
)
return
VLC_EGENERIC
;
/* Allocate the memory needed to store the decoder's structure */
if
(
(
p_dec
->
p_sys
=
p_sys
=
(
decoder_sys_t
*
)
malloc
(
sizeof
(
decoder_sys_t
))
)
==
NULL
)
{
msg_Err
(
p_dec
,
"out of memory"
);
return
VLC_E
GENERIC
;
return
VLC_E
NOMEM
;
}
p_dec
->
p_sys
->
p_context
=
p_context
;
...
...
@@ -330,15 +330,15 @@ int E_(InitVideoDec)( decoder_t *p_dec, AVCodecContext *p_context,
p_sys
->
p_context
->
palctrl
=
&
palette_control
;
/* ***** Open the codec ***** */
vlc_mutex_lock
(
lock
val
.
p_address
);
vlc_mutex_lock
(
lock
);
if
(
avcodec_open
(
p_sys
->
p_context
,
p_sys
->
p_codec
)
<
0
)
{
vlc_mutex_unlock
(
lock
val
.
p_address
);
vlc_mutex_unlock
(
lock
);
msg_Err
(
p_dec
,
"cannot open codec (%s)"
,
p_sys
->
psz_namecodec
);
free
(
p_sys
);
return
VLC_EGENERIC
;
}
vlc_mutex_unlock
(
lock
val
.
p_address
);
vlc_mutex_unlock
(
lock
);
msg_Dbg
(
p_dec
,
"ffmpeg codec (%s) started"
,
p_sys
->
psz_namecodec
);
...
...
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