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 */
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 */
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",
ddm.quot, (unsigned int)ddm.rem,
dout.quot, (unsigned int)dout.rem );
fflush( p_intf->p_sys->p_rrd );
- vlc_object_release( p_playlist );
}
}
/* 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;
{
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 );
}
}
}
{
/* 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 );
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;
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;
}
{
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 */
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 ) );