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,
...
@@ -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
)
AVCodec
*
p_codec
,
int
i_codec_id
,
const
char
*
psz_namecodec
)
{
{
decoder_sys_t
*
p_sys
;
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
);
if
(
lock
==
NULL
)
var_Get
(
p_dec
->
p_libvlc_global
,
"avcodec"
,
&
lockval
)
;
return
VLC_EGENERIC
;
/* Allocate the memory needed to store the decoder's structure */
/* Allocate the memory needed to store the decoder's structure */
if
(
(
p_dec
->
p_sys
=
p_sys
=
if
(
(
p_dec
->
p_sys
=
p_sys
=
(
decoder_sys_t
*
)
malloc
(
sizeof
(
decoder_sys_t
))
)
==
NULL
)
(
decoder_sys_t
*
)
malloc
(
sizeof
(
decoder_sys_t
))
)
==
NULL
)
{
{
msg_Err
(
p_dec
,
"out of memory"
);
msg_Err
(
p_dec
,
"out of memory"
);
return
VLC_E
GENERIC
;
return
VLC_E
NOMEM
;
}
}
p_sys
->
p_context
=
p_context
;
p_sys
->
p_context
=
p_context
;
...
@@ -134,15 +134,15 @@ int E_(InitAudioDec)( decoder_t *p_dec, AVCodecContext *p_context,
...
@@ -134,15 +134,15 @@ int E_(InitAudioDec)( decoder_t *p_dec, AVCodecContext *p_context,
}
}
/* ***** Open the codec ***** */
/* ***** 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
)
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
);
msg_Err
(
p_dec
,
"cannot open codec (%s)"
,
p_sys
->
psz_namecodec
);
free
(
p_sys
);
free
(
p_sys
);
return
VLC_EGENERIC
;
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
);
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 )
...
@@ -195,10 +195,7 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
int
i_codec_id
,
i_cat
;
int
i_codec_id
,
i_cat
;
const
char
*
psz_namecodec
;
const
char
*
psz_namecodec
;
vlc_value_t
val
;
vlc_value_t
val
;
vlc_value_t
lockval
;
vlc_mutex_t
*
lock
=
var_GetGlobalMutex
(
"avcodec"
);
var_Create
(
p_enc
->
p_libvlc_global
,
"avcodec"
,
VLC_VAR_MUTEX
);
var_Get
(
p_enc
->
p_libvlc_global
,
"avcodec"
,
&
lockval
);
if
(
!
E_
(
GetFfmpegCodec
)(
p_enc
->
fmt_out
.
i_codec
,
&
i_cat
,
&
i_codec_id
,
if
(
!
E_
(
GetFfmpegCodec
)(
p_enc
->
fmt_out
.
i_codec
,
&
i_cat
,
&
i_codec_id
,
&
psz_namecodec
)
)
&
psz_namecodec
)
)
...
@@ -533,10 +530,10 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
...
@@ -533,10 +530,10 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
p_context
->
extradata
=
NULL
;
p_context
->
extradata
=
NULL
;
p_context
->
flags
|=
CODEC_FLAG_GLOBAL_HEADER
;
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
)
)
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
&&
if
(
p_enc
->
fmt_in
.
i_cat
==
AUDIO_ES
&&
(
p_context
->
channels
>
2
||
i_codec_id
==
CODEC_ID_MP2
(
p_context
->
channels
>
2
||
i_codec_id
==
CODEC_ID_MP2
||
i_codec_id
==
CODEC_ID_MP3
)
)
||
i_codec_id
==
CODEC_ID_MP3
)
)
...
@@ -586,10 +583,10 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
...
@@ -586,10 +583,10 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
}
}
p_context
->
codec
=
NULL
;
p_context
->
codec
=
NULL
;
vlc_mutex_lock
(
lock
val
.
p_address
);
vlc_mutex_lock
(
lock
);
if
(
avcodec_open
(
p_context
,
p_codec
)
)
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"
);
msg_Err
(
p_enc
,
"cannot open encoder"
);
intf_UserFatal
(
p_enc
,
VLC_FALSE
,
_
(
"Streaming / Transcoding failed"
),
intf_UserFatal
(
p_enc
,
VLC_FALSE
,
_
(
"Streaming / Transcoding failed"
),
_
(
"VLC could not open the encoder."
)
);
_
(
"VLC could not open the encoder."
)
);
...
@@ -606,7 +603,7 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
...
@@ -606,7 +603,7 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
}
}
vlc_mutex_unlock
(
lock
val
.
p_address
);
vlc_mutex_unlock
(
lock
);
p_enc
->
fmt_out
.
i_extra
=
p_context
->
extradata_size
;
p_enc
->
fmt_out
.
i_extra
=
p_context
->
extradata_size
;
if
(
p_enc
->
fmt_out
.
i_extra
)
if
(
p_enc
->
fmt_out
.
i_extra
)
...
@@ -1005,9 +1002,7 @@ void E_(CloseEncoder)( vlc_object_t *p_this )
...
@@ -1005,9 +1002,7 @@ void E_(CloseEncoder)( vlc_object_t *p_this )
{
{
encoder_t
*
p_enc
=
(
encoder_t
*
)
p_this
;
encoder_t
*
p_enc
=
(
encoder_t
*
)
p_this
;
encoder_sys_t
*
p_sys
=
p_enc
->
p_sys
;
encoder_sys_t
*
p_sys
=
p_enc
->
p_sys
;
vlc_value_t
lockval
;
vlc_mutex_t
*
lock
=
var_GetGlobalMutex
(
"avcodec"
);
var_Get
(
p_enc
->
p_libvlc_global
,
"avcodec"
,
&
lockval
);
if
(
p_sys
->
b_inited
&&
p_enc
->
i_threads
>=
1
)
if
(
p_sys
->
b_inited
&&
p_enc
->
i_threads
>=
1
)
{
{
...
@@ -1027,9 +1022,9 @@ void E_(CloseEncoder)( vlc_object_t *p_this )
...
@@ -1027,9 +1022,9 @@ void E_(CloseEncoder)( vlc_object_t *p_this )
free
(
pp_contexts
);
free
(
pp_contexts
);
}
}
vlc_mutex_lock
(
lock
val
.
p_address
);
vlc_mutex_lock
(
lock
);
avcodec_close
(
p_sys
->
p_context
);
avcodec_close
(
p_sys
->
p_context
);
vlc_mutex_unlock
(
lock
val
.
p_address
);
vlc_mutex_unlock
(
lock
);
av_free
(
p_sys
->
p_context
);
av_free
(
p_sys
->
p_context
);
if
(
p_sys
->
p_buffer
)
free
(
p_sys
->
p_buffer
);
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 )
...
@@ -335,9 +335,7 @@ static void CloseDecoder( vlc_object_t *p_this )
{
{
decoder_t
*
p_dec
=
(
decoder_t
*
)
p_this
;
decoder_t
*
p_dec
=
(
decoder_t
*
)
p_this
;
decoder_sys_t
*
p_sys
=
p_dec
->
p_sys
;
decoder_sys_t
*
p_sys
=
p_dec
->
p_sys
;
vlc_value_t
lockval
;
vlc_mutex_t
*
lock
=
var_GetGlobalMutex
(
"avcodec"
);
var_Get
(
p_dec
->
p_libvlc_global
,
"avcodec"
,
&
lockval
);
switch
(
p_sys
->
i_cat
)
switch
(
p_sys
->
i_cat
)
{
{
...
@@ -354,9 +352,9 @@ static void CloseDecoder( vlc_object_t *p_this )
...
@@ -354,9 +352,9 @@ static void CloseDecoder( vlc_object_t *p_this )
if
(
p_sys
->
p_context
->
extradata
)
if
(
p_sys
->
p_context
->
extradata
)
free
(
p_sys
->
p_context
->
extradata
);
free
(
p_sys
->
p_context
->
extradata
);
p_sys
->
p_context
->
extradata
=
NULL
;
p_sys
->
p_context
->
extradata
=
NULL
;
vlc_mutex_lock
(
lock
val
.
p_address
);
vlc_mutex_lock
(
lock
);
avcodec_close
(
p_sys
->
p_context
);
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
);
msg_Dbg
(
p_dec
,
"ffmpeg codec (%s) stopped"
,
p_sys
->
psz_namecodec
);
av_free
(
p_sys
->
p_context
);
av_free
(
p_sys
->
p_context
);
}
}
...
@@ -424,11 +422,9 @@ void E_(LibavcodecCallback)( void *p_opaque, int i_level,
...
@@ -424,11 +422,9 @@ void E_(LibavcodecCallback)( void *p_opaque, int i_level,
void
E_
(
InitLibavcodec
)(
vlc_object_t
*
p_object
)
void
E_
(
InitLibavcodec
)(
vlc_object_t
*
p_object
)
{
{
static
int
b_ffmpeginit
=
0
;
static
int
b_ffmpeginit
=
0
;
vlc_
value_t
lockval
;
vlc_
mutex_t
*
lock
;
var_Create
(
p_object
->
p_libvlc_global
,
"avcodec"
,
VLC_VAR_MUTEX
);
vlc_mutex_lock
(
lock
);
var_Get
(
p_object
->
p_libvlc_global
,
"avcodec"
,
&
lockval
);
vlc_mutex_lock
(
lockval
.
p_address
);
/* *** init ffmpeg library (libavcodec) *** */
/* *** init ffmpeg library (libavcodec) *** */
if
(
!
b_ffmpeginit
)
if
(
!
b_ffmpeginit
)
...
@@ -446,7 +442,7 @@ void E_(InitLibavcodec)( vlc_object_t *p_object )
...
@@ -446,7 +442,7 @@ void E_(InitLibavcodec)( vlc_object_t *p_object )
msg_Dbg
(
p_object
,
"libavcodec already initialized"
);
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,
...
@@ -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
)
AVCodec
*
p_codec
,
int
i_codec_id
,
const
char
*
psz_namecodec
)
{
{
decoder_sys_t
*
p_sys
;
decoder_sys_t
*
p_sys
;
vlc_
value_t
lockval
;
vlc_
mutex_t
*
lock
=
var_GetGlobalMutex
(
"avcodec"
)
;
vlc_value_t
val
;
vlc_value_t
val
;
var_Create
(
p_dec
->
p_libvlc_global
,
"avcodec"
,
VLC_VAR_MUTEX
);
if
(
lock
==
NULL
)
var_Get
(
p_dec
->
p_libvlc_global
,
"avcodec"
,
&
lockval
)
;
return
VLC_EGENERIC
;
/* Allocate the memory needed to store the decoder's structure */
/* Allocate the memory needed to store the decoder's structure */
if
(
(
p_dec
->
p_sys
=
p_sys
=
if
(
(
p_dec
->
p_sys
=
p_sys
=
(
decoder_sys_t
*
)
malloc
(
sizeof
(
decoder_sys_t
))
)
==
NULL
)
(
decoder_sys_t
*
)
malloc
(
sizeof
(
decoder_sys_t
))
)
==
NULL
)
{
{
msg_Err
(
p_dec
,
"out of memory"
);
msg_Err
(
p_dec
,
"out of memory"
);
return
VLC_E
GENERIC
;
return
VLC_E
NOMEM
;
}
}
p_dec
->
p_sys
->
p_context
=
p_context
;
p_dec
->
p_sys
->
p_context
=
p_context
;
...
@@ -330,15 +330,15 @@ int E_(InitVideoDec)( decoder_t *p_dec, AVCodecContext *p_context,
...
@@ -330,15 +330,15 @@ int E_(InitVideoDec)( decoder_t *p_dec, AVCodecContext *p_context,
p_sys
->
p_context
->
palctrl
=
&
palette_control
;
p_sys
->
p_context
->
palctrl
=
&
palette_control
;
/* ***** Open the codec ***** */
/* ***** 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
)
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
);
msg_Err
(
p_dec
,
"cannot open codec (%s)"
,
p_sys
->
psz_namecodec
);
free
(
p_sys
);
free
(
p_sys
);
return
VLC_EGENERIC
;
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
);
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