Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
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
Commits
9df28485
Commit
9df28485
authored
May 04, 2008
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add long overdue private libvlc object pointer...
...and use it for stats and the config lock
parent
aebd6a43
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
128 additions
and
94 deletions
+128
-94
include/vlc_main.h
include/vlc_main.h
+0
-7
src/config/core.c
src/config/core.c
+3
-2
src/config/file.c
src/config/file.c
+12
-9
src/input/es_out.c
src/input/es_out.c
+1
-1
src/input/input.c
src/input/input.c
+4
-4
src/input/stream.c
src/input/stream.c
+1
-1
src/libvlc-common.c
src/libvlc-common.c
+16
-9
src/libvlc.h
src/libvlc.h
+29
-1
src/misc/stats.c
src/misc/stats.c
+61
-59
src/stream_output/stream_output.c
src/stream_output/stream_output.c
+1
-1
No files found.
include/vlc_main.h
View file @
9df28485
...
...
@@ -68,13 +68,6 @@ struct libvlc_int_t
module_t
*
p_memcpy_module
;
///< Fast memcpy plugin used
bool
b_stats
;
///< Should we collect stats ?
vlc_mutex_t
timer_lock
;
///< Lock to protect timers
int
i_timers
;
///< Number of timers
counter_t
**
pp_timers
;
///< Array of all timers
vlc_mutex_t
config_lock
;
///< Lock for the config file
/* Structure storing the action name / key associations */
struct
hotkey
{
...
...
src/config/core.c
View file @
9df28485
...
...
@@ -557,12 +557,13 @@ void config_UnsetCallbacks( module_config_t *p_new, size_t n )
*****************************************************************************/
void
__config_ResetAll
(
vlc_object_t
*
p_this
)
{
libvlc_priv_t
*
priv
=
libvlc_priv
(
p_this
->
p_libvlc
);
int
i_index
;
vlc_list_t
*
p_list
;
module_t
*
p_module
;
/* Acquire config file lock */
vlc_mutex_lock
(
&
p
_this
->
p_libvlc
->
config_lock
);
vlc_mutex_lock
(
&
p
riv
->
config_lock
);
p_list
=
vlc_list_find
(
p_this
,
VLC_OBJECT_MODULE
,
FIND_ANYWHERE
);
...
...
@@ -589,7 +590,7 @@ void __config_ResetAll( vlc_object_t *p_this )
}
vlc_list_release
(
p_list
);
vlc_mutex_unlock
(
&
p
_this
->
p_libvlc
->
config_lock
);
vlc_mutex_unlock
(
&
p
riv
->
config_lock
);
}
/**
...
...
src/config/file.c
View file @
9df28485
...
...
@@ -139,6 +139,7 @@ static int strtoi (const char *str)
*****************************************************************************/
int
__config_LoadConfigFile
(
vlc_object_t
*
p_this
,
const
char
*
psz_module_name
)
{
libvlc_priv_t
*
priv
=
libvlc_priv
(
p_this
->
p_libvlc
);
vlc_list_t
*
p_list
;
FILE
*
file
;
...
...
@@ -147,7 +148,7 @@ int __config_LoadConfigFile( vlc_object_t *p_this, const char *psz_module_name )
return
VLC_EGENERIC
;
/* Acquire config file lock */
vlc_mutex_lock
(
&
p
_this
->
p_libvlc
->
config_lock
);
vlc_mutex_lock
(
&
p
riv
->
config_lock
);
/* Look for the selected module, if NULL then save everything */
p_list
=
vlc_list_find
(
p_this
,
VLC_OBJECT_MODULE
,
FIND_ANYWHERE
);
...
...
@@ -296,7 +297,7 @@ int __config_LoadConfigFile( vlc_object_t *p_this, const char *psz_module_name )
vlc_list_release
(
p_list
);
vlc_mutex_unlock
(
&
p
_this
->
p_libvlc
->
config_lock
);
vlc_mutex_unlock
(
&
p
riv
->
config_lock
);
return
0
;
}
...
...
@@ -386,6 +387,7 @@ config_Write (FILE *file, const char *type, const char *desc,
static
int
SaveConfigFile
(
vlc_object_t
*
p_this
,
const
char
*
psz_module_name
,
bool
b_autosave
)
{
libvlc_priv_t
*
priv
=
libvlc_priv
(
p_this
->
p_libvlc
);
module_t
*
p_parser
;
vlc_list_t
*
p_list
;
FILE
*
file
;
...
...
@@ -396,7 +398,7 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
int
i_index
;
/* Acquire config file lock */
vlc_mutex_lock
(
&
p
_this
->
p_libvlc
->
config_lock
);
vlc_mutex_lock
(
&
p
riv
->
config_lock
);
if
(
p_this
->
p_libvlc
->
psz_configfile
==
NULL
)
{
...
...
@@ -404,7 +406,7 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
if
(
!
psz_configdir
)
/* XXX: This should never happen */
{
msg_Err
(
p_this
,
"no configuration directory defined"
);
vlc_mutex_unlock
(
&
p
_this
->
p_libvlc
->
config_lock
);
vlc_mutex_unlock
(
&
p
riv
->
config_lock
);
return
-
1
;
}
...
...
@@ -424,7 +426,7 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
if
(
!
p_bigbuffer
)
{
if
(
file
)
fclose
(
file
);
vlc_mutex_unlock
(
&
p
_this
->
p_libvlc
->
config_lock
);
vlc_mutex_unlock
(
&
p
riv
->
config_lock
);
return
-
1
;
}
p_bigbuffer
[
0
]
=
0
;
...
...
@@ -498,7 +500,7 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
{
vlc_list_release
(
p_list
);
free
(
p_bigbuffer
);
vlc_mutex_unlock
(
&
p
_this
->
p_libvlc
->
config_lock
);
vlc_mutex_unlock
(
&
p
riv
->
config_lock
);
return
-
1
;
}
...
...
@@ -619,20 +621,21 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
free
(
p_bigbuffer
);
fclose
(
file
);
vlc_mutex_unlock
(
&
p
_this
->
p_libvlc
->
config_lock
);
vlc_mutex_unlock
(
&
p
riv
->
config_lock
);
return
0
;
}
int
config_AutoSaveConfigFile
(
vlc_object_t
*
p_this
)
{
libvlc_priv_t
*
priv
=
libvlc_priv
(
p_this
->
p_libvlc
);
vlc_list_t
*
p_list
;
int
i_index
,
i_count
;
assert
(
p_this
);
/* Check if there's anything to save */
vlc_mutex_lock
(
&
p
_this
->
p_libvlc
->
config_lock
);
vlc_mutex_lock
(
&
p
riv
->
config_lock
);
p_list
=
vlc_list_find
(
p_this
,
VLC_OBJECT_MODULE
,
FIND_ANYWHERE
);
i_count
=
p_list
->
i_count
;
for
(
i_index
=
0
;
i_index
<
i_count
;
i_index
++
)
...
...
@@ -651,7 +654,7 @@ int config_AutoSaveConfigFile( vlc_object_t *p_this )
if
(
p_item
<
p_end
)
break
;
}
vlc_list_release
(
p_list
);
vlc_mutex_unlock
(
&
p
_this
->
p_libvlc
->
config_lock
);
vlc_mutex_unlock
(
&
p
riv
->
config_lock
);
if
(
i_index
==
i_count
)
return
VLC_SUCCESS
;
return
SaveConfigFile
(
p_this
,
0
,
true
);
...
...
src/input/es_out.c
View file @
9df28485
...
...
@@ -1362,7 +1362,7 @@ static int EsOutSend( es_out_t *out, es_out_id_t *es, block_t *p_block )
else
i_delay
=
0
;
if
(
p_input
->
p_libvlc
->
b_stats
)
if
(
libvlc_stats
(
p_input
)
)
{
vlc_mutex_lock
(
&
p_input
->
p
->
counters
.
counters_lock
);
stats_UpdateInteger
(
p_input
,
p_input
->
p
->
counters
.
p_demux_read
,
...
...
src/input/input.c
View file @
9df28485
...
...
@@ -795,7 +795,7 @@ static void InitStatistics( input_thread_t * p_input )
/* Prepare statistics */
#define INIT_COUNTER( c, type, compute ) p_input->p->counters.p_##c = \
stats_CounterCreate( p_input, VLC_VAR_##type, STATS_##compute);
if
(
p_input
->
p_libvlc
->
b_stats
)
if
(
libvlc_stats
(
p_input
)
)
{
INIT_COUNTER
(
read_bytes
,
INTEGER
,
COUNTER
);
INIT_COUNTER
(
read_packets
,
INTEGER
,
COUNTER
);
...
...
@@ -863,7 +863,7 @@ static int InitSout( input_thread_t * p_input )
return
VLC_EGENERIC
;
}
}
if
(
p_input
->
p_libvlc
->
b_stats
)
if
(
libvlc_stats
(
p_input
)
)
{
INIT_COUNTER
(
sout_sent_packets
,
INTEGER
,
COUNTER
);
INIT_COUNTER
(
sout_sent_bytes
,
INTEGER
,
COUNTER
);
...
...
@@ -1260,7 +1260,7 @@ error:
}
#endif
if
(
!
p_input
->
b_preparsing
&&
p_input
->
p_libvlc
->
b_stats
)
if
(
!
p_input
->
b_preparsing
&&
libvlc_stats
(
p_input
)
)
{
#define EXIT_COUNTER( c ) do { if( p_input->p->counters.p_##c ) \
stats_CounterClean( p_input->p->counters.p_##c );\
...
...
@@ -1343,7 +1343,7 @@ static void End( input_thread_t * p_input )
if
(
!
p_input
->
b_preparsing
)
{
#define CL_CO( c ) stats_CounterClean( p_input->p->counters.p_##c ); p_input->p->counters.p_##c = NULL;
if
(
p_input
->
p_libvlc
->
b_stats
)
if
(
libvlc_stats
(
p_input
)
)
{
/* make sure we are up to date */
stats_ComputeInputStats
(
p_input
,
p_input
->
p
->
input
.
p_item
->
p_stats
);
...
...
src/input/stream.c
View file @
9df28485
...
...
@@ -1752,7 +1752,7 @@ static block_t *AReadBlock( stream_t *s, bool *pb_eof )
{
p_block
=
p_access
->
pf_block
(
p_access
);
if
(
pb_eof
)
*
pb_eof
=
p_access
->
info
.
b_eof
;
if
(
p_input
&&
p_block
&&
p_access
->
p_libvlc
->
b_stats
)
if
(
p_input
&&
p_block
&&
libvlc_stats
(
p_access
)
)
{
vlc_mutex_lock
(
&
p_input
->
p
->
counters
.
counters_lock
);
stats_UpdateInteger
(
s
,
p_input
->
p
->
counters
.
p_read_bytes
,
...
...
src/libvlc-common.c
View file @
9df28485
...
...
@@ -146,7 +146,8 @@ libvlc_int_t * vlc_current_object( int i_object )
*/
libvlc_int_t
*
libvlc_InternalCreate
(
void
)
{
libvlc_int_t
*
p_libvlc
=
NULL
;
libvlc_int_t
*
p_libvlc
;
libvlc_priv_t
*
priv
;
char
*
psz_env
=
NULL
;
/* vlc_threads_init *must* be the first internal call! No other call is
...
...
@@ -167,7 +168,9 @@ libvlc_int_t * libvlc_InternalCreate( void )
}
/* Allocate a libvlc instance object */
p_libvlc
=
vlc_object_create
(
p_libvlc_global
,
VLC_OBJECT_LIBVLC
);
p_libvlc
=
vlc_custom_create
(
VLC_OBJECT
(
p_libvlc_global
),
sizeof
(
*
p_libvlc
)
+
sizeof
(
libvlc_priv_t
),
VLC_OBJECT_LIBVLC
,
"libvlc"
);
if
(
p_libvlc
!=
NULL
)
i_instances
++
;
vlc_mutex_unlock
(
lock
);
...
...
@@ -179,6 +182,7 @@ libvlc_int_t * libvlc_InternalCreate( void )
p_libvlc
->
p_interaction
=
NULL
;
p_libvlc
->
p_vlm
=
NULL
;
p_libvlc
->
psz_object_name
=
strdup
(
"libvlc"
);
priv
=
libvlc_priv
(
p_libvlc
);
/* Initialize message queue */
msg_Create
(
p_libvlc
);
...
...
@@ -200,8 +204,8 @@ libvlc_int_t * libvlc_InternalCreate( void )
msg_Dbg
(
p_libvlc
,
"libvlc was configured with %s"
,
CONFIGURE_LINE
);
/* Initialize mutexes */
vlc_mutex_init
(
&
p
_libvlc
->
timer_lock
);
vlc_mutex_init
(
&
p
_libvlc
->
config_lock
);
vlc_mutex_init
(
&
p
riv
->
timer_lock
);
vlc_mutex_init
(
&
p
riv
->
config_lock
);
#ifdef __APPLE__
vlc_thread_set_priority
(
p_libvlc
,
VLC_THREAD_PRIORITY_LOW
);
#endif
...
...
@@ -223,6 +227,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
const
char
*
ppsz_argv
[]
)
{
libvlc_global_data_t
*
p_libvlc_global
=
vlc_global
();
libvlc_priv_t
*
priv
=
libvlc_priv
(
p_libvlc
);
char
p_capabilities
[
200
];
char
*
p_tmp
=
NULL
;
char
*
psz_modules
=
NULL
;
...
...
@@ -705,9 +710,9 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
*/
p_libvlc
->
p_memcpy_module
=
module_Need
(
p_libvlc
,
"memcpy"
,
"$memcpy"
,
0
);
p
_libvlc
->
b_stats
=
config_GetInt
(
p_libvlc
,
"stats"
)
>
0
;
p
_libvlc
->
i_timers
=
0
;
p
_libvlc
->
pp_timers
=
NULL
;
p
riv
->
b_stats
=
config_GetInt
(
p_libvlc
,
"stats"
)
>
0
;
p
riv
->
i_timers
=
0
;
p
riv
->
pp_timers
=
NULL
;
/* Init stats */
p_libvlc
->
p_stats
=
(
global_stats_t
*
)
malloc
(
sizeof
(
global_stats_t
)
);
...
...
@@ -1030,6 +1035,8 @@ int libvlc_InternalDestroy( libvlc_int_t *p_libvlc, bool b_release )
if
(
!
p_libvlc
)
return
VLC_EGENERIC
;
libvlc_priv_t
*
priv
=
libvlc_priv
(
p_libvlc
);
#ifndef WIN32
char
*
psz_pidfile
=
NULL
;
...
...
@@ -1081,8 +1088,8 @@ int libvlc_InternalDestroy( libvlc_int_t *p_libvlc, bool b_release )
msg_Destroy
(
p_libvlc
);
/* Destroy mutexes */
vlc_mutex_destroy
(
&
p
_libvlc
->
config_lock
);
vlc_mutex_destroy
(
&
p
_libvlc
->
timer_lock
);
vlc_mutex_destroy
(
&
p
riv
->
config_lock
);
vlc_mutex_destroy
(
&
p
riv
->
timer_lock
);
if
(
b_release
)
vlc_object_release
(
p_libvlc
);
vlc_object_release
(
p_libvlc
);
...
...
src/libvlc.h
View file @
9df28485
...
...
@@ -130,7 +130,9 @@ typedef struct libvlc_global_data_t
libvlc_global_data_t
*
vlc_global
(
void
);
libvlc_int_t
*
vlc_current_object
(
int
i_object
);
/* Private LibVLC data for each objects */
/**
* Private LibVLC data for each object.
*/
struct
vlc_object_internals_t
{
/* Object variables */
...
...
@@ -163,6 +165,32 @@ static inline vlc_object_internals_t *vlc_internals( vlc_object_t *obj )
return
((
vlc_object_internals_t
*
)
obj
)
-
1
;
}
/**
* Private LibVLC instance data.
*/
typedef
struct
libvlc_priv_t
{
vlc_mutex_t
config_lock
;
///< config file lock
vlc_mutex_t
timer_lock
;
///< Lock to protect timers
counter_t
**
pp_timers
;
///< Array of all timers
int
i_timers
;
///< Number of timers
bool
b_stats
;
///< Whether to collect stats
}
libvlc_priv_t
;
static
inline
libvlc_priv_t
*
libvlc_priv
(
libvlc_int_t
*
libvlc
)
{
return
(
libvlc_priv_t
*
)(
libvlc
+
1
);
}
static
inline
bool
libvlc_stats
(
vlc_object_t
*
obj
)
{
return
libvlc_priv
(
obj
->
p_libvlc
)
->
b_stats
;
}
/**
* LibVLC "main module" configuration settings array.
*/
extern
module_config_t
libvlc_config
[];
extern
const
size_t
libvlc_config_count
;
...
...
src/misc/stats.c
View file @
9df28485
...
...
@@ -85,7 +85,7 @@ counter_t * __stats_CounterCreate( vlc_object_t *p_this,
int
__stats_Update
(
vlc_object_t
*
p_this
,
counter_t
*
p_counter
,
vlc_value_t
val
,
vlc_value_t
*
val_new
)
{
if
(
!
p_this
->
p_libvlc
->
b_stats
||
!
p_counter
)
return
VLC_EGENERIC
;
if
(
!
libvlc_stats
(
p_this
)
||
!
p_counter
)
return
VLC_EGENERIC
;
return
CounterUpdate
(
p_this
,
p_counter
,
val
,
val_new
);
}
...
...
@@ -98,7 +98,7 @@ int __stats_Update( vlc_object_t *p_this, counter_t *p_counter,
*/
int
__stats_Get
(
vlc_object_t
*
p_this
,
counter_t
*
p_counter
,
vlc_value_t
*
val
)
{
if
(
!
p_this
->
p_libvlc
->
b_stats
||
!
p_counter
||
p_counter
->
i_samples
==
0
)
if
(
!
libvlc_stats
(
p_this
)
||
!
p_counter
||
p_counter
->
i_samples
==
0
)
{
val
->
i_int
=
val
->
f_float
=
0
.
0
;
return
VLC_EGENERIC
;
...
...
@@ -157,7 +157,7 @@ input_stats_t *stats_NewInputStats( input_thread_t *p_input )
void
stats_ComputeInputStats
(
input_thread_t
*
p_input
,
input_stats_t
*
p_stats
)
{
if
(
!
p_input
->
p_libvlc
->
b_stats
)
return
;
if
(
!
libvlc_stats
(
p_input
)
)
return
;
vlc_mutex_lock
(
&
p_input
->
p
->
counters
.
counters_lock
);
vlc_mutex_lock
(
&
p_stats
->
lock
);
...
...
@@ -245,7 +245,7 @@ void __stats_ComputeGlobalStats( vlc_object_t *p_obj, global_stats_t *p_stats )
vlc_list_t
*
p_list
;
int
i_index
;
if
(
!
p_obj
->
p_libvlc
->
b_stats
)
return
;
if
(
!
libvlc_stats
(
p_obj
)
)
return
;
vlc_mutex_lock
(
&
p_stats
->
lock
);
...
...
@@ -280,17 +280,19 @@ void __stats_ComputeGlobalStats( vlc_object_t *p_obj, global_stats_t *p_stats )
void
__stats_TimerStart
(
vlc_object_t
*
p_obj
,
const
char
*
psz_name
,
unsigned
int
i_id
)
{
int
i
;
libvlc_priv_t
*
priv
=
libvlc_priv
(
p_obj
->
p_libvlc
)
;
counter_t
*
p_counter
=
NULL
;
if
(
!
p_obj
->
p_libvlc
->
b_stats
)
return
;
vlc_mutex_lock
(
&
p_obj
->
p_libvlc
->
timer_lock
);
for
(
i
=
0
;
i
<
p_obj
->
p_libvlc
->
i_timers
;
i
++
)
if
(
!
priv
->
b_stats
)
return
;
vlc_mutex_lock
(
&
priv
->
timer_lock
);
for
(
int
i
=
0
;
i
<
priv
->
i_timers
;
i
++
)
{
if
(
p
_obj
->
p_libvlc
->
pp_timers
[
i
]
->
i_id
==
i_id
&&
p
_obj
->
p_libvlc
->
pp_timers
[
i
]
->
p_obj
==
p_obj
)
if
(
p
riv
->
pp_timers
[
i
]
->
i_id
==
i_id
&&
p
riv
->
pp_timers
[
i
]
->
p_obj
==
p_obj
)
{
p_counter
=
p
_obj
->
p_libvlc
->
pp_timers
[
i
];
p_counter
=
p
riv
->
pp_timers
[
i
];
break
;
}
}
...
...
@@ -300,15 +302,12 @@ void __stats_TimerStart( vlc_object_t *p_obj, const char *psz_name,
p_counter
=
stats_CounterCreate
(
p_obj
->
p_libvlc
,
VLC_VAR_TIME
,
STATS_TIMER
);
if
(
!
p_counter
)
{
vlc_mutex_unlock
(
&
p_obj
->
p_libvlc
->
timer_lock
);
return
;
}
goto
out
;
p_counter
->
psz_name
=
strdup
(
psz_name
);
p_counter
->
i_id
=
i_id
;
p_counter
->
p_obj
=
p_obj
;
INSERT_ELEM
(
p
_obj
->
p_libvlc
->
pp_timers
,
p_obj
->
p_libvlc
->
i_timers
,
p
_obj
->
p_libvlc
->
i_timers
,
p_counter
);
INSERT_ELEM
(
p
riv
->
pp_timers
,
priv
->
i_timers
,
p
riv
->
i_timers
,
p_counter
);
/* 1st sample : if started: start_date, else last_time, b_started */
p_sample
=
(
counter_sample_t
*
)
malloc
(
sizeof
(
counter_sample_t
)
);
...
...
@@ -324,107 +323,110 @@ void __stats_TimerStart( vlc_object_t *p_obj, const char *psz_name,
if
(
p_counter
->
pp_samples
[
0
]
->
value
.
b_bool
==
true
)
{
msg_Warn
(
p_obj
,
"timer '%s' was already started !"
,
psz_name
);
vlc_mutex_unlock
(
&
p_obj
->
p_libvlc
->
timer_lock
);
return
;
goto
out
;
}
p_counter
->
pp_samples
[
0
]
->
value
.
b_bool
=
true
;
p_counter
->
pp_samples
[
0
]
->
date
=
mdate
();
vlc_mutex_unlock
(
&
p_obj
->
p_libvlc
->
timer_lock
);
out:
vlc_mutex_unlock
(
&
priv
->
timer_lock
);
}
void
__stats_TimerStop
(
vlc_object_t
*
p_obj
,
unsigned
int
i_id
)
{
counter_t
*
p_counter
=
NULL
;
int
i
;
if
(
!
p_obj
->
p_libvlc
->
b_stats
)
return
;
vlc_mutex_lock
(
&
p_obj
->
p_libvlc
->
timer_lock
);
for
(
i
=
0
;
i
<
p_obj
->
p_libvlc
->
i_timers
;
i
++
)
libvlc_priv_t
*
priv
=
libvlc_priv
(
p_obj
->
p_libvlc
);
if
(
!
priv
->
b_stats
)
return
;
vlc_mutex_lock
(
&
priv
->
timer_lock
);
for
(
int
i
=
0
;
i
<
priv
->
i_timers
;
i
++
)
{
if
(
p
_obj
->
p_libvlc
->
pp_timers
[
i
]
->
i_id
==
i_id
&&
p
_obj
->
p_libvlc
->
pp_timers
[
i
]
->
p_obj
==
p_obj
)
if
(
p
riv
->
pp_timers
[
i
]
->
i_id
==
i_id
&&
p
riv
->
pp_timers
[
i
]
->
p_obj
==
p_obj
)
{
p_counter
=
p
_obj
->
p_libvlc
->
pp_timers
[
i
];
p_counter
=
p
riv
->
pp_timers
[
i
];
break
;
}
}
if
(
!
p_counter
||
p_counter
->
i_samples
!=
2
)
{
msg_Err
(
p_obj
,
"timer does not exist"
);
vlc_mutex_unlock
(
&
p_obj
->
p_libvlc
->
timer_lock
);
return
;
goto
out
;
}
p_counter
->
pp_samples
[
0
]
->
value
.
b_bool
=
false
;
p_counter
->
pp_samples
[
1
]
->
value
.
i_int
+=
1
;
p_counter
->
pp_samples
[
0
]
->
date
=
mdate
()
-
p_counter
->
pp_samples
[
0
]
->
date
;
p_counter
->
pp_samples
[
1
]
->
date
+=
p_counter
->
pp_samples
[
0
]
->
date
;
vlc_mutex_unlock
(
&
p_obj
->
p_libvlc
->
timer_lock
);
out:
vlc_mutex_unlock
(
&
priv
->
timer_lock
);
}
void
__stats_TimerDump
(
vlc_object_t
*
p_obj
,
unsigned
int
i_id
)
{
counter_t
*
p_counter
=
NULL
;
int
i
;
if
(
!
p_obj
->
p_libvlc
->
b_stats
)
return
;
vlc_mutex_lock
(
&
p_obj
->
p_libvlc
->
timer_lock
);
for
(
i
=
0
;
i
<
p_obj
->
p_libvlc
->
i_timers
;
i
++
)
libvlc_priv_t
*
priv
=
libvlc_priv
(
p_obj
->
p_libvlc
);
if
(
!
priv
->
b_stats
)
return
;
vlc_mutex_lock
(
&
priv
->
timer_lock
);
for
(
int
i
=
0
;
i
<
priv
->
i_timers
;
i
++
)
{
if
(
p
_obj
->
p_libvlc
->
pp_timers
[
i
]
->
i_id
==
i_id
&&
p
_obj
->
p_libvlc
->
pp_timers
[
i
]
->
p_obj
==
p_obj
)
if
(
p
riv
->
pp_timers
[
i
]
->
i_id
==
i_id
&&
p
riv
->
pp_timers
[
i
]
->
p_obj
==
p_obj
)
{
p_counter
=
p
_obj
->
p_libvlc
->
pp_timers
[
i
];
p_counter
=
p
riv
->
pp_timers
[
i
];
break
;
}
}
TimerDump
(
p_obj
,
p_counter
,
true
);
vlc_mutex_unlock
(
&
p
_obj
->
p_libvlc
->
timer_lock
);
vlc_mutex_unlock
(
&
p
riv
->
timer_lock
);
}
void
__stats_TimersDumpAll
(
vlc_object_t
*
p_obj
)
{
int
i
;
if
(
!
p_obj
->
p_libvlc
->
b_stats
)
return
;
vlc_mutex_lock
(
&
p_obj
->
p_libvlc
->
timer_lock
);
for
(
i
=
0
;
i
<
p_obj
->
p_libvlc
->
i_timers
;
i
++
)
TimerDump
(
p_obj
,
p_obj
->
p_libvlc
->
pp_timers
[
i
],
false
);
vlc_mutex_unlock
(
&
p_obj
->
p_libvlc
->
timer_lock
);
libvlc_priv_t
*
priv
=
libvlc_priv
(
p_obj
->
p_libvlc
);
if
(
!
priv
->
b_stats
)
return
;
vlc_mutex_lock
(
&
priv
->
timer_lock
);
for
(
int
i
=
0
;
i
<
priv
->
i_timers
;
i
++
)
TimerDump
(
p_obj
,
priv
->
pp_timers
[
i
],
false
);
vlc_mutex_unlock
(
&
priv
->
timer_lock
);
}
void
__stats_TimerClean
(
vlc_object_t
*
p_obj
,
unsigned
int
i_id
)
{
int
i
;
vlc_mutex_lock
(
&
p_obj
->
p_libvlc
->
timer_lock
);
for
(
i
=
p_obj
->
p_libvlc
->
i_timers
-
1
;
i
>=
0
;
i
--
)
libvlc_priv_t
*
priv
=
libvlc_priv
(
p_obj
->
p_libvlc
);
vlc_mutex_lock
(
&
priv
->
timer_lock
);
for
(
int
i
=
priv
->
i_timers
-
1
;
i
>=
0
;
i
--
)
{
counter_t
*
p_counter
=
p
_obj
->
p_libvlc
->
pp_timers
[
i
];
counter_t
*
p_counter
=
p
riv
->
pp_timers
[
i
];
if
(
p_counter
->
i_id
==
i_id
&&
p_counter
->
p_obj
==
p_obj
)
{
REMOVE_ELEM
(
p_obj
->
p_libvlc
->
pp_timers
,
p_obj
->
p_libvlc
->
i_timers
,
i
);
REMOVE_ELEM
(
priv
->
pp_timers
,
priv
->
i_timers
,
i
);
stats_CounterClean
(
p_counter
);
}
}
vlc_mutex_unlock
(
&
p
_obj
->
p_libvlc
->
timer_lock
);
vlc_mutex_unlock
(
&
p
riv
->
timer_lock
);
}
void
__stats_TimersCleanAll
(
vlc_object_t
*
p_obj
)
{
int
i
;
vlc_mutex_lock
(
&
p_obj
->
p_libvlc
->
timer_lock
);
for
(
i
=
p_obj
->
p_libvlc
->
i_timers
-
1
;
i
>=
0
;
i
--
)
libvlc_priv_t
*
priv
=
libvlc_priv
(
p_obj
->
p_libvlc
);
vlc_mutex_lock
(
&
priv
->
timer_lock
);
for
(
int
i
=
priv
->
i_timers
-
1
;
i
>=
0
;
i
--
)
{
counter_t
*
p_counter
=
p
_obj
->
p_libvlc
->
pp_timers
[
i
];
REMOVE_ELEM
(
p
_obj
->
p_libvlc
->
pp_timers
,
p_obj
->
p_libvlc
->
i_timers
,
i
);
counter_t
*
p_counter
=
p
riv
->
pp_timers
[
i
];
REMOVE_ELEM
(
p
riv
->
pp_timers
,
priv
->
i_timers
,
i
);
stats_CounterClean
(
p_counter
);
}
vlc_mutex_unlock
(
&
p
_obj
->
p_libvlc
->
timer_lock
);
vlc_mutex_unlock
(
&
p
riv
->
timer_lock
);
}
void
stats_CounterClean
(
counter_t
*
p_c
)
{
int
i
;
if
(
p_c
)
{
i
=
p_c
->
i_samples
-
1
;
i
nt
i
=
p_c
->
i_samples
-
1
;
while
(
i
>=
0
)
{
counter_sample_t
*
p_s
=
p_c
->
pp_samples
[
i
];
...
...
src/stream_output/stream_output.c
View file @
9df28485
...
...
@@ -160,7 +160,7 @@ void sout_UpdateStatistic( sout_instance_t *p_sout, sout_statistic_t i_type, int
int
i_bytes
;
/* That's pretty stupid to define it as an integer, it will overflow
really fast ... */
if
(
!
p_sout
->
p_libvlc
->
b_stats
)
if
(
!
libvlc_stats
(
p_sout
)
)
return
;
/* FIXME that's ugly
...
...
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