[vlc-devel] [PATCH] statistics for libvlc

Ilkka Ollakka ileoo at videolan.org
Wed Jul 14 17:45:47 CEST 2010


On Wed, Jul 14, 2010 at 04:36:11PM +0200, Frank Enderle wrote:

>  /**************************************************************************
> + * Returns the statistics
> + **************************************************************************/
> +int libvlc_media_player_get_statistics( libvlc_media_player_t *p_mi, libvlc_statistics_t *p_stats )
> +{
> +    assert( p_mi != NULL && p_stats != NULL );
> +
> +    input_thread_t * p_input_thread = libvlc_get_input_thread( p_mi );
> +    if( !p_input_thread )
> +        return 0;
> +
> +    input_item_t *p_item = input_GetItem( p_input_thread );
> +    if( !p_item )
> +    {
> +        vlc_object_release( p_input_thread );
> +        return 0;
> +    }

That mutex lock and stat-copying could be replaced with just
stats_ComputeInputStats( p_input_thread, p_stats ); 

> +    vlc_mutex_lock( &p_item->p_stats->lock );
> +
> +    /* Input */
> +    p_stats->i_read_packets = p_item->p_stats->i_read_packets;
> +    p_stats->i_read_bytes = p_item->p_stats->i_read_bytes;
> +    p_stats->f_input_bitrate = p_item->p_stats->f_input_bitrate;
> +    p_stats->f_average_input_bitrate = p_item->p_stats->f_average_input_bitrate;
> +
> +    /* Demux */
> +    p_stats->i_demux_read_packets = p_item->p_stats->i_demux_read_packets;
> +    p_stats->i_demux_read_bytes = p_item->p_stats->i_demux_read_bytes;
> +    p_stats->f_demux_bitrate = p_item->p_stats->f_demux_bitrate;
> +    p_stats->f_average_demux_bitrate = p_item->p_stats->f_average_demux_bitrate;
> +    p_stats->i_demux_corrupted = p_item->p_stats->i_demux_corrupted;
> +    p_stats->i_demux_discontinuity = p_item->p_stats->i_demux_discontinuity;
> +
> +    /* Decoders */
> +    p_stats->i_decoded_audio = p_item->p_stats->i_decoded_audio;
> +    p_stats->i_decoded_video = p_item->p_stats->i_decoded_video;
> +
> +    /* Vout */
> +    p_stats->i_displayed_pictures = p_item->p_stats->i_displayed_pictures;
> +    p_stats->i_lost_pictures = p_item->p_stats->i_lost_pictures;
> +
> +    /* Sout */
> +    p_stats->i_sent_packets = p_item->p_stats->i_sent_packets;
> +    p_stats->i_sent_bytes = p_item->p_stats->i_sent_bytes;
> +    p_stats->f_send_bitrate = p_item->p_stats->f_send_bitrate;
> +
> +    /* Aout */
> +    p_stats->i_played_abuffers = p_item->p_stats->i_played_abuffers;
> +    p_stats->i_lost_abuffers = p_item->p_stats->i_lost_abuffers;
> +
> +    vlc_mutex_unlock( &p_item->p_stats->lock );



-- 
Ilkka Ollakka
If I traveled to the end of the rainbow
As Dame Fortune did intend,
Murphy would be there to tell me
The pot's at the other end.
		-- Bert Whitney
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20100714/5102e346/attachment.sig>


More information about the vlc-devel mailing list