[vlc-devel] commit: stats: Move the stat to libvlc instead of the playlist. As stated in the code it is not playlist related. (Pierre d'Herbemont )
git version control
git at videolan.org
Sat Mar 29 21:53:18 CET 2008
vlc | branch: master | Pierre d'Herbemont <pdherbemont at free.fr> | Sat Mar 29 21:53:12 2008 +0100| [719f576184819f07b1807f8cc3e814ee4321fbaf]
stats: Move the stat to libvlc instead of the playlist. As stated in the code it is not playlist related.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=719f576184819f07b1807f8cc3e814ee4321fbaf
---
include/main.h | 5 ++++-
include/vlc_playlist.h | 4 ----
modules/misc/logger.c | 12 ++++--------
src/input/input.c | 24 ++++++++++++------------
src/libvlc-common.c | 14 ++++++++++++++
src/playlist/engine.c | 5 -----
src/playlist/thread.c | 10 ----------
7 files changed, 34 insertions(+), 40 deletions(-)
diff --git a/include/main.h b/include/main.h
index c798a60..11908ef 100644
--- a/include/main.h
+++ b/include/main.h
@@ -47,7 +47,10 @@ struct libvlc_int_t
playlist_t *p_playlist; ///< playlist object
- vlc_object_t *p_interaction; ///< interface interaction object
+ vlc_object_t *p_interaction; ///< interface interaction object
+
+ void *p_stats_computer; ///< Input thread computing stats (needs cleanup)
+ global_stats_t *p_stats; ///< Global statistics
/* There is no real reason to keep a list of items, but not to break
* everything, let's keep it */
diff --git a/include/vlc_playlist.h b/include/vlc_playlist.h
index b7f33a9..9e88a68 100644
--- a/include/vlc_playlist.h
+++ b/include/vlc_playlist.h
@@ -231,10 +231,6 @@ struct playlist_t
when processing the request */
vlc_mutex_t lock; /**< Lock to protect request */
} request;
-
- // Playlist-unrelated fields
- input_thread_t *p_stats_computer; /**< Input thread computing stats */
- global_stats_t *p_stats; /**< Global statistics */
};
/** Helper to add an item */
diff --git a/modules/misc/logger.c b/modules/misc/logger.c
index c22860b..c68271f 100644
--- a/modules/misc/logger.c
+++ b/modules/misc/logger.c
@@ -454,20 +454,17 @@ static void HtmlPrint( const msg_item_t *p_msg, FILE *p_file )
static void DoRRD( intf_thread_t *p_intf )
{
- playlist_t *p_playlist;
if( mdate() - p_intf->p_sys->last_update < 1000000 )
return;
p_intf->p_sys->last_update = mdate();
- p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
- FIND_ANYWHERE );
- if( p_playlist && p_playlist->p_stats )
+ if( p_intf->p_libvlc->p_stats )
{
- lldiv_t din = lldiv( p_playlist->p_stats->f_input_bitrate * 1000000,
+ lldiv_t din = lldiv( p_intf->p_libvlc->p_stats->f_input_bitrate * 1000000,
1000 );
- lldiv_t ddm = lldiv( p_playlist->p_stats->f_demux_bitrate * 1000000,
+ lldiv_t ddm = lldiv( p_intf->p_libvlc->p_stats->f_demux_bitrate * 1000000,
1000 );
- lldiv_t dout = lldiv( p_playlist->p_stats->f_output_bitrate * 1000000,
+ lldiv_t dout = lldiv( p_intf->p_libvlc->p_stats->f_output_bitrate * 1000000,
1000 );
fprintf( p_intf->p_sys->p_rrd,
I64Fi":%lld.%03u:%lld.%03u:%lld.%03u\n",
@@ -476,6 +473,5 @@ static void DoRRD( intf_thread_t *p_intf )
ddm.quot, (unsigned int)ddm.rem,
dout.quot, (unsigned int)dout.rem );
fflush( p_intf->p_sys->p_rrd );
- vlc_object_release( p_playlist );
}
}
diff --git a/src/input/input.c b/src/input/input.c
index 3fdae93..ca1510e 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -142,14 +142,14 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
/* One "randomly" selected input thread is responsible for computing
* the global stats. Check if there is already someone doing this */
- if( p_input->p_libvlc->p_playlist->p_stats && !b_quick )
+ if( p_input->p_libvlc->p_stats && !b_quick )
{
- vlc_mutex_lock( &p_input->p_libvlc->p_playlist->p_stats->lock );
- if( p_input->p_libvlc->p_playlist->p_stats_computer == NULL )
+ vlc_mutex_lock( &p_input->p_libvlc->p_stats->lock );
+ if( p_input->p_libvlc->p_stats_computer == NULL )
{
- p_input->p_libvlc->p_playlist->p_stats_computer = p_input;
+ p_input->p_libvlc->p_stats_computer = p_input;
}
- vlc_mutex_unlock( &p_input->p_libvlc->p_playlist->p_stats->lock );
+ vlc_mutex_unlock( &p_input->p_libvlc->p_stats->lock );
}
p_input->b_preparsing = b_quick;
@@ -748,10 +748,10 @@ static void MainLoop( input_thread_t *p_input )
{
stats_ComputeInputStats( p_input, p_input->p->input.p_item->p_stats );
/* Are we the thread responsible for computing global stats ? */
- if( p_input->p_libvlc->p_playlist->p_stats_computer == p_input )
+ if( p_input->p_libvlc->p_stats_computer == p_input )
{
- stats_ComputeGlobalStats( p_input->p_libvlc->p_playlist,
- p_input->p_libvlc->p_playlist->p_stats );
+ stats_ComputeGlobalStats( p_input->p_libvlc,
+ p_input->p_libvlc->p_stats );
}
}
}
@@ -1298,11 +1298,11 @@ static void End( input_thread_t * p_input )
{
/* make sure we are up to date */
stats_ComputeInputStats( p_input, p_input->p->input.p_item->p_stats );
- if( p_input->p_libvlc->p_playlist->p_stats_computer == p_input )
+ if( p_input->p_libvlc->p_stats_computer == p_input )
{
- stats_ComputeGlobalStats( p_input->p_libvlc->p_playlist,
- p_input->p_libvlc->p_playlist->p_stats );
- p_input->p_libvlc->p_playlist->p_stats_computer = NULL;
+ stats_ComputeGlobalStats( p_input->p_libvlc,
+ p_input->p_libvlc->p_stats );
+ p_input->p_libvlc->p_stats_computer = NULL;
}
CL_CO( read_bytes );
CL_CO( read_packets );
diff --git a/src/libvlc-common.c b/src/libvlc-common.c
index e7755d5..c3e9f01 100644
--- a/src/libvlc-common.c
+++ b/src/libvlc-common.c
@@ -726,6 +726,16 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
p_libvlc->i_timers = 0;
p_libvlc->pp_timers = NULL;
+ /* Init stats */
+ p_libvlc->p_stats = (global_stats_t *)malloc( sizeof( global_stats_t ) );
+ if( !p_libvlc->p_stats )
+ {
+ vlc_object_release( p_libvlc );
+ return VLC_ENOMEM;
+ }
+ vlc_mutex_init( p_libvlc, &p_libvlc->p_stats->lock );
+ p_libvlc->p_stats_computer = NULL;
+
/* Init the array that holds every input item */
ARRAY_INIT( p_libvlc->input_items );
p_libvlc->i_last_input_id = 0;
@@ -992,6 +1002,10 @@ int libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
FOREACH_END();
ARRAY_RESET( p_libvlc->input_items );
+ msg_Dbg( p_libvlc, "removing stats" );
+ vlc_mutex_destroy( &p_libvlc->p_stats->lock );
+ FREENULL( p_libvlc->p_stats );
+
return VLC_SUCCESS;
}
diff --git a/src/playlist/engine.c b/src/playlist/engine.c
index 55c084b..444932d 100644
--- a/src/playlist/engine.c
+++ b/src/playlist/engine.c
@@ -202,11 +202,6 @@ static void playlist_Destructor( vlc_object_t * p_this )
{
vlc_object_release( p_playlist->p_fetcher );
}
-
- // Stats
- vlc_mutex_destroy( &p_playlist->p_stats->lock );
- if( p_playlist->p_stats )
- free( p_playlist->p_stats );
}
/* Destroy remaining objects */
diff --git a/src/playlist/thread.c b/src/playlist/thread.c
index 69f62a3..8d2bd71 100644
--- a/src/playlist/thread.c
+++ b/src/playlist/thread.c
@@ -58,16 +58,6 @@ void __playlist_ThreadCreate( vlc_object_t *p_parent )
playlist_t *p_playlist = playlist_Create( p_parent );
if( !p_playlist ) return;
- // Stats
- p_playlist->p_stats = (global_stats_t *)malloc( sizeof( global_stats_t ) );
- if( !p_playlist->p_stats )
- {
- vlc_object_release( p_playlist );
- return;
- }
- vlc_mutex_init( p_playlist, &p_playlist->p_stats->lock );
- p_playlist->p_stats_computer = NULL;
-
// Preparse
p_playlist->p_preparse = vlc_object_create( p_playlist,
sizeof( playlist_preparse_t ) );
More information about the vlc-devel
mailing list