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
97dcb939
Commit
97dcb939
authored
Sep 30, 2007
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename var_GetGlobalMutex to var_AcquireMutex and make it lock the mutex automatically
parent
736981af
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
48 additions
and
54 deletions
+48
-54
include/vlc_variables.h
include/vlc_variables.h
+1
-1
modules/codec/ffmpeg/audio.c
modules/codec/ffmpeg/audio.c
+11
-5
modules/codec/ffmpeg/encoder.c
modules/codec/ffmpeg/encoder.c
+3
-4
modules/codec/ffmpeg/ffmpeg.c
modules/codec/ffmpeg/ffmpeg.c
+5
-5
modules/codec/ffmpeg/video.c
modules/codec/ffmpeg/video.c
+7
-5
modules/codec/quicktime.c
modules/codec/quicktime.c
+6
-15
modules/misc/gnutls.c
modules/misc/gnutls.c
+2
-4
modules/misc/gtk_main.c
modules/misc/gtk_main.c
+2
-5
modules/misc/qte_main.cpp
modules/misc/qte_main.cpp
+2
-4
modules/video_output/sdl.c
modules/video_output/sdl.c
+4
-3
src/libvlc.sym
src/libvlc.sym
+1
-1
src/misc/variables.c
src/misc/variables.c
+4
-2
No files found.
include/vlc_variables.h
View file @
97dcb939
...
...
@@ -126,7 +126,7 @@ VLC_EXPORT( void, __var_OptionParse, ( vlc_object_t *, const char * ) );
#define var_Command(a,b,c,d,e) __var_Command( VLC_OBJECT( a ), b, c, d, e )
VLC_EXPORT
(
int
,
__var_Command
,
(
vlc_object_t
*
,
const
char
*
,
const
char
*
,
const
char
*
,
char
**
)
);
VLC_EXPORT
(
vlc_mutex_t
*
,
var_
GetGlobal
Mutex
,
(
const
char
*
)
);
VLC_EXPORT
(
vlc_mutex_t
*
,
var_
Acquire
Mutex
,
(
const
char
*
)
);
/**
* __var_Create() with automatic casting.
...
...
modules/codec/ffmpeg/audio.c
View file @
97dcb939
...
...
@@ -89,10 +89,6 @@ 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_mutex_t
*
lock
=
var_GetGlobalMutex
(
"avcodec"
);
if
(
lock
==
NULL
)
return
VLC_EGENERIC
;
/* Allocate the memory needed to store the decoder's structure */
if
(
(
p_dec
->
p_sys
=
p_sys
=
...
...
@@ -132,13 +128,23 @@ int E_(InitAudioDec)( decoder_t *p_dec, AVCodecContext *p_context,
p_sys
->
p_context
->
extradata_size
,
0
,
FF_INPUT_BUFFER_PADDING_SIZE
);
}
else
p_sys
->
p_context
->
extradata
=
NULL
;
/* ***** Open the codec ***** */
vlc_mutex_lock
(
lock
);
vlc_mutex_t
*
lock
=
var_AcquireMutex
(
"avcodec"
);
if
(
lock
==
NULL
)
{
free
(
p_sys
->
p_context
->
extradata
);
free
(
p_sys
);
return
VLC_ENOMEM
;
}
if
(
avcodec_open
(
p_sys
->
p_context
,
p_sys
->
p_codec
)
<
0
)
{
vlc_mutex_unlock
(
lock
);
msg_Err
(
p_dec
,
"cannot open codec (%s)"
,
p_sys
->
psz_namecodec
);
free
(
p_sys
->
p_context
->
extradata
);
free
(
p_sys
);
return
VLC_EGENERIC
;
}
...
...
modules/codec/ffmpeg/encoder.c
View file @
97dcb939
...
...
@@ -195,7 +195,6 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
int
i_codec_id
,
i_cat
;
const
char
*
psz_namecodec
;
vlc_value_t
val
;
vlc_mutex_t
*
lock
=
var_GetGlobalMutex
(
"avcodec"
);
if
(
!
E_
(
GetFfmpegCodec
)(
p_enc
->
fmt_out
.
i_codec
,
&
i_cat
,
&
i_codec_id
,
&
psz_namecodec
)
)
...
...
@@ -530,7 +529,8 @@ int E_(OpenEncoder)( vlc_object_t *p_this )
p_context
->
extradata
=
NULL
;
p_context
->
flags
|=
CODEC_FLAG_GLOBAL_HEADER
;
vlc_mutex_lock
(
lock
);
vlc_mutex_t
*
lock
=
var_AcquireMutex
(
"avcodec"
);
if
(
avcodec_open
(
p_context
,
p_codec
)
)
{
vlc_mutex_unlock
(
lock
);
...
...
@@ -1003,7 +1003,6 @@ 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_mutex_t
*
lock
=
var_GetGlobalMutex
(
"avcodec"
);
if
(
p_sys
->
b_inited
&&
p_enc
->
i_threads
>=
1
)
{
...
...
@@ -1023,7 +1022,7 @@ void E_(CloseEncoder)( vlc_object_t *p_this )
free
(
pp_contexts
);
}
vlc_mutex_
lock
(
lock
);
vlc_mutex_
t
*
lock
=
var_AcquireMutex
(
"avcodec"
);
avcodec_close
(
p_sys
->
p_context
);
vlc_mutex_unlock
(
lock
);
av_free
(
p_sys
->
p_context
);
...
...
modules/codec/ffmpeg/ffmpeg.c
View file @
97dcb939
...
...
@@ -341,7 +341,6 @@ 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_mutex_t
*
lock
=
var_GetGlobalMutex
(
"avcodec"
);
switch
(
p_sys
->
i_cat
)
{
...
...
@@ -355,10 +354,13 @@ static void CloseDecoder( vlc_object_t *p_this )
if
(
p_sys
->
p_context
)
{
vlc_mutex_t
*
lock
;
if
(
p_sys
->
p_context
->
extradata
)
free
(
p_sys
->
p_context
->
extradata
);
p_sys
->
p_context
->
extradata
=
NULL
;
vlc_mutex_lock
(
lock
);
lock
=
var_AcquireMutex
(
"avcodec"
);
avcodec_close
(
p_sys
->
p_context
);
vlc_mutex_unlock
(
lock
);
msg_Dbg
(
p_dec
,
"ffmpeg codec (%s) stopped"
,
p_sys
->
psz_namecodec
);
...
...
@@ -428,9 +430,7 @@ void E_(LibavcodecCallback)( void *p_opaque, int i_level,
void
E_
(
InitLibavcodec
)(
vlc_object_t
*
p_object
)
{
static
int
b_ffmpeginit
=
0
;
vlc_mutex_t
*
lock
=
var_GetGlobalMutex
(
"avcodec"
);
vlc_mutex_lock
(
lock
);
vlc_mutex_t
*
lock
=
var_AcquireMutex
(
"avcodec"
);
/* *** init ffmpeg library (libavcodec) *** */
if
(
!
b_ffmpeginit
)
...
...
modules/codec/ffmpeg/video.c
View file @
97dcb939
...
...
@@ -215,12 +215,8 @@ 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_mutex_t
*
lock
=
var_GetGlobalMutex
(
"avcodec"
);
vlc_value_t
val
;
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
)
...
...
@@ -382,7 +378,13 @@ int E_(InitVideoDec)( decoder_t *p_dec, AVCodecContext *p_context,
p_sys
->
p_context
->
palctrl
=
&
palette_control
;
/* ***** Open the codec ***** */
vlc_mutex_lock
(
lock
);
vlc_mutex_t
*
lock
=
var_GetAcquireMutex
(
"avcodec"
);
if
(
lock
==
NULL
)
{
free
(
p_sys
);
return
VLC_ENOMEM
;
}
if
(
avcodec_open
(
p_sys
->
p_context
,
p_sys
->
p_codec
)
<
0
)
{
vlc_mutex_unlock
(
lock
);
...
...
modules/codec/quicktime.c
View file @
97dcb939
...
...
@@ -221,10 +221,7 @@ static int QTVideoInit( decoder_t * );
static
int
Open
(
vlc_object_t
*
p_this
)
{
decoder_t
*
p_dec
=
(
decoder_t
*
)
p_this
;
if
(
var_GetGlobalMutex
(
"qt_mutex"
)
==
NULL
)
return
VLC_EGENERIC
;
/* create a mutex */
switch
(
p_dec
->
fmt_in
.
i_codec
)
{
case
VLC_FOURCC
(
'S'
,
'V'
,
'Q'
,
'3'
):
/* Sorenson v3 */
...
...
@@ -287,8 +284,7 @@ static void Close( vlc_object_t *p_this )
vlc_mutex_t
*
lock
;
/* get lock, avoid segfault */
lock
=
var_GetGlobalMutex
(
"qt_mutex"
);
vlc_mutex_lock
(
lock
);
lock
=
var_AcquireMutex
(
"qt_mutex"
);
if
(
p_dec
->
fmt_out
.
i_cat
==
AUDIO_ES
)
{
...
...
@@ -338,7 +334,6 @@ static void Close( vlc_object_t *p_this )
static
int
OpenAudio
(
decoder_t
*
p_dec
)
{
decoder_sys_t
*
p_sys
;
vlc_mutex_t
*
lock
=
var_GetGlobalMutex
(
"qt_mutex"
);
int
i_error
;
char
fcc
[
4
];
...
...
@@ -346,6 +341,8 @@ static int OpenAudio( decoder_t *p_dec )
unsigned
long
InputBufferSize
=
0
;
unsigned
long
OutputBufferSize
=
0
;
/* get lock, avoid segfault */
vlc_mutex_t
*
lock
=
var_AcquireMutex
(
"qt_mutex"
);
if
(
lock
==
NULL
)
return
VLC_EGENERIC
;
...
...
@@ -355,9 +352,6 @@ static int OpenAudio( decoder_t *p_dec )
memcpy
(
fcc
,
&
p_dec
->
fmt_in
.
i_codec
,
4
);
/* get lock, avoid segfault */
vlc_mutex_lock
(
lock
);
#ifdef __APPLE__
EnterMovies
();
#endif
...
...
@@ -546,9 +540,8 @@ static aout_buffer_t *DecodeAudio( decoder_t *p_dec, block_t **pp_block )
{
int
i_frames
=
p_sys
->
i_buffer
/
p_sys
->
InFrameSize
;
unsigned
long
i_out_frames
,
i_out_bytes
;
vlc_mutex_t
*
lock
=
var_
GetGlobal
Mutex
(
"qt_mutex "
);
vlc_mutex_t
*
lock
=
var_
Acquire
Mutex
(
"qt_mutex "
);
vlc_mutex_lock
(
lock
);
i_error
=
p_sys
->
SoundConverterConvertBuffer
(
p_sys
->
myConverter
,
p_sys
->
p_buffer
,
i_frames
,
...
...
@@ -653,8 +646,7 @@ static int OpenVideo( decoder_t *p_dec )
fcc
,
p_dec
->
fmt_in
.
video
.
i_width
,
p_dec
->
fmt_in
.
video
.
i_height
);
/* get lock, avoid segfault */
lock
=
var_GetGlobalMutex
(
"qt_mutex"
);
vlc_mutex_lock
(
lock
);
lock
=
var_AcquireMutex
(
"qt_mutex"
);
#ifdef __APPLE__
EnterMovies
();
...
...
@@ -860,8 +852,7 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
return
NULL
;
}
lock
=
var_GetGlobalMutex
(
"qt_mutex"
);
vlc_mutex_lock
(
lock
);
lock
=
var_AcquireMutex
(
"qt_mutex"
);
if
(
(
p_pic
=
p_dec
->
pf_vout_buffer_new
(
p_dec
)
)
)
{
...
...
modules/misc/gnutls.c
View file @
97dcb939
...
...
@@ -172,8 +172,7 @@ static int gnutls_Init (vlc_object_t *p_this)
{
int
ret
=
VLC_EGENERIC
;
vlc_mutex_t
*
lock
=
var_GetGlobalMutex
(
"gnutls_mutex"
);
vlc_mutex_lock
(
lock
);
vlc_mutex_t
*
lock
=
var_AcquireMutex
(
"gnutls_mutex"
);
/* This should probably be removed/fixed. It will screw up with multiple
* LibVLC instances. */
...
...
@@ -210,8 +209,7 @@ error:
*/
static
void
gnutls_Deinit
(
vlc_object_t
*
p_this
)
{
vlc_mutex_t
*
lock
=
var_GetGlobalMutex
(
"gnutls_mutex"
);
vlc_mutex_lock
(
lock
);
vlc_mutex_t
*
lock
=
var_AcquireMutex
(
"gnutls_mutex"
);
gnutls_global_deinit
();
msg_Dbg
(
p_this
,
"GnuTLS deinitialized"
);
...
...
modules/misc/gtk_main.c
View file @
97dcb939
...
...
@@ -84,9 +84,7 @@ static int Open( vlc_object_t *p_this )
{
vlc_mutex_t
*
lock
;
/* FIXME: put this in the module (de)initialization ASAP */
lock
=
var_GetGlobalCreate
(
"gtk"
);
vlc_mutex_lock
(
lock
);
lock
=
var_AcquireMutex
(
"gtk"
);
if
(
i_refcount
>
0
)
{
...
...
@@ -128,8 +126,7 @@ static void Close( vlc_object_t *p_this )
{
vlc_mutex_t
*
lock
;
lock
=
var_GetGlobalMutex
(
"gtk"
);
vlc_mutex_lock
(
lock
);
lock
=
var_AcquireMutex
(
"gtk"
);
i_refcount
--
;
...
...
modules/misc/qte_main.cpp
View file @
97dcb939
...
...
@@ -84,8 +84,7 @@ static int Open( vlc_object_t *p_this )
{
vlc_mutex_t
*
lock
;
lock
=
var_GetGlobalMutex
(
"qte"
);
vlc_mutex_lock
(
lockval
);
lock
=
var_AcquireMutex
(
"qte"
);
if
(
i_refcount
>
0
)
{
...
...
@@ -124,8 +123,7 @@ static void Close( vlc_object_t *p_this )
{
vlc_mutex_t
*
lock
;
lock
=
var_GetGlobalMutex
(
"qte"
);
vlc_mutex_lock
(
lock
);
lock
=
var_AcquireMutex
(
"qte"
);
i_refcount
--
;
...
...
modules/video_output/sdl.c
View file @
97dcb939
...
...
@@ -130,12 +130,15 @@ static int Open ( vlc_object_t *p_this )
{
vout_thread_t
*
p_vout
=
(
vout_thread_t
*
)
p_this
;
/* XXX: check for conflicts with the SDL audio output */
vlc_mutex_t
*
lock
=
var_
GetGlobal
Mutex
(
"sdl"
);
vlc_mutex_t
*
lock
=
var_
Acquire
Mutex
(
"sdl"
);
#ifdef HAVE_SETENV
char
*
psz_method
;
#endif
if
(
lock
==
NULL
)
return
VLC_ENOMEM
;
p_vout
->
p_sys
=
malloc
(
sizeof
(
vout_sys_t
)
);
if
(
p_vout
->
p_sys
==
NULL
)
{
...
...
@@ -143,8 +146,6 @@ static int Open ( vlc_object_t *p_this )
return
VLC_ENOMEM
;
}
vlc_mutex_lock
(
lock
);
if
(
SDL_WasInit
(
SDL_INIT_VIDEO
)
!=
0
)
{
vlc_mutex_unlock
(
lock
);
...
...
src/libvlc.sym
View file @
97dcb939
...
...
@@ -341,7 +341,7 @@ __var_Create
__var_DelCallback
__var_Destroy
__var_Get
var_
GetGlobal
Mutex
var_
Acquire
Mutex
__var_OptionParse
__var_Set
__var_Type
...
...
src/misc/variables.c
View file @
97dcb939
...
...
@@ -834,9 +834,10 @@ int __var_Get( vlc_object_t *p_this, const char *psz_name, vlc_value_t *p_val )
/**
* Gets a process-wide mutex, creates it if needed.
* Finds a process-wide mutex, creates it if needed, and locks it.
* Unlock with vlc_mutex_unlock().
*/
vlc_mutex_t
*
var_
GetGlobal
Mutex
(
const
char
*
name
)
vlc_mutex_t
*
var_
Acquire
Mutex
(
const
char
*
name
)
{
libvlc_global_data_t
*
p_global
=
vlc_global
();
vlc_value_t
val
;
...
...
@@ -845,6 +846,7 @@ vlc_mutex_t *var_GetGlobalMutex( const char *name )
return
NULL
;
var_Get
(
p_global
,
name
,
&
val
);
vlc_mutex_lock
(
&
val
.
p_address
);
return
val
.
p_address
;
}
...
...
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