Commit 2bffade0 authored by Laurent Aimar's avatar Laurent Aimar

Moved out video statistics to its own file and use a dedicated lock.

parent a7a12139
......@@ -346,6 +346,7 @@ SOURCES_libvlc_common = \
input/var.c \
video_output/snapshot.c \
video_output/snapshot.h \
video_output/statistic.h \
video_output/video_output.c \
video_output/vout_pictures.c \
video_output/vout_pictures.h \
......
/*****************************************************************************
* statistic.c : vout statistic
*****************************************************************************
* Copyright (C) 2009 Laurent Aimar
* $Id$
*
* Authors: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#if defined(__PLUGIN__) || defined(__BUILTIN__) || !defined(__LIBVLC__)
# error This header file can only be included from LibVLC.
#endif
#ifndef _VOUT_STATISTIC_H
#define _VOUT_STATISTIC_H
typedef struct {
vlc_spinlock_t spin;
int displayed;
int lost;
} vout_statistic_t;
static inline void vout_statistic_Init(vout_statistic_t *stat)
{
vlc_spin_init(&stat->spin);
}
static inline void vout_statistic_Clean(vout_statistic_t *stat)
{
vlc_spin_destroy(&stat->spin);
}
static inline void vout_statistic_GetReset(vout_statistic_t *stat, int *displayed, int *lost)
{
vlc_spin_lock(&stat->spin);
*displayed = stat->displayed;
*lost = stat->lost;
stat->displayed = 0;
stat->lost = 0;
vlc_spin_unlock(&stat->spin);
}
static inline void vout_statistic_Update(vout_statistic_t *stat, int displayed, int lost)
{
vlc_spin_lock(&stat->spin);
stat->displayed += displayed;
stat->lost += lost;
vlc_spin_unlock(&stat->spin);
}
#endif
......@@ -384,8 +384,7 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent, video_format_t *p_fmt )
p_vout->i_alignment = 0;
p_vout->p->render_time = 10;
p_vout->p->c_fps_samples = 0;
p_vout->p->i_picture_lost = 0;
p_vout->p->i_picture_displayed = 0;
vout_statistic_Init( &p_vout->p->statistic );
p_vout->p->b_filter_change = 0;
p_vout->p->b_paused = false;
p_vout->p->i_pause_date = 0;
......@@ -585,6 +584,9 @@ static void vout_Destructor( vlc_object_t * p_this )
vlc_mutex_destroy( &p_vout->change_lock );
vlc_mutex_destroy( &p_vout->p->vfilter_lock );
/* */
vout_statistic_Clean( &p_vout->p->statistic );
/* */
vout_snapshot_Clean( &p_vout->p->snapshot );
......@@ -652,15 +654,8 @@ void vout_ChangePause( vout_thread_t *p_vout, bool b_paused, mtime_t i_date )
void vout_GetResetStatistic( vout_thread_t *p_vout, int *pi_displayed, int *pi_lost )
{
vlc_mutex_lock( &p_vout->change_lock );
*pi_displayed = p_vout->p->i_picture_displayed;
*pi_lost = p_vout->p->i_picture_lost;
p_vout->p->i_picture_displayed = 0;
p_vout->p->i_picture_lost = 0;
vlc_mutex_unlock( &p_vout->change_lock );
vout_statistic_GetReset( &p_vout->p->statistic,
pi_displayed, pi_lost );
}
void vout_Flush( vout_thread_t *p_vout, mtime_t i_date )
......@@ -1052,7 +1047,7 @@ static void* RunThread( void *p_this )
/* Picture is late: it will be destroyed and the thread
* will directly choose the next picture */
vout_UsePictureLocked( p_vout, p_pic );
p_vout->p->i_picture_lost++;
vout_statistic_Update( &p_vout->p->statistic, 0, 1 );
msg_Warn( p_vout, "late picture skipped (%"PRId64" > %d)",
current_date - p_pic->date, - p_vout->p->render_time );
......@@ -1167,7 +1162,7 @@ static void* RunThread( void *p_this )
/*
* Perform rendering
*/
p_vout->p->i_picture_displayed++;
vout_statistic_Update( &p_vout->p->statistic, 1, 0 );
p_directbuffer = vout_RenderPicture( p_vout,
p_filtered_picture, p_subpic,
spu_render_time );
......
......@@ -32,6 +32,7 @@
#include "vout_control.h"
#include "snapshot.h"
#include "statistic.h"
/* Number of pictures required to computes the FPS rate */
#define VOUT_FPS_SAMPLES 20
......@@ -72,8 +73,7 @@ struct vout_thread_sys_t
mtime_t p_fps_sample[VOUT_FPS_SAMPLES]; /**< FPS samples dates */
/* Statistics */
int i_picture_lost;
int i_picture_displayed;
vout_statistic_t statistic;
/* Pause */
bool b_paused;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment