Commit 8689e8be authored by Ilkka Ollakka's avatar Ilkka Ollakka

stats-change variable for statistics/removing stats timer from qt4 interface

- Add stats-change variable for input to inform when statistics are computed
- Use that variable in qt4 interface to update statistics so no need to loop
  with timer ( ticket #1365)
parent 77a5fef9
......@@ -546,6 +546,8 @@ InputStatsPanel::InputStatsPanel( QWidget *parent,
StatsTree->setColumnWidth( 1 , 200 );
layout->addWidget(StatsTree, 1, 0 );
CONNECT( THEMIM->getIM() , statisticsUpdated( input_item_t* ),
this, update( input_item_t* ) );
}
InputStatsPanel::~InputStatsPanel()
......
......@@ -162,9 +162,9 @@ void MediaInfoDialog::update( input_thread_t *p_input )
void MediaInfoDialog::updateOnTimeOut()
{
/* Timer runs at 150 ms, dont' update more than 2 times per second */
/* Timer runs at 150 ms, dont' update more than 2 times per second
i_runs++;
if( i_runs % 4 != 0 ) return;
if( i_runs % 4 != 0 ) return;*/
/* Get Input and clear if non-existant */
input_thread_t *p_input = THEMIM->getInput();
......
......@@ -42,6 +42,8 @@ static int PLItemChanged( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * );
static int InterfaceChanged( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * );
static int StatisticsUpdated( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * );
static int InterfaceVoutChanged( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * );
static int ItemStateChanged( vlc_object_t *, const char *,
......@@ -158,6 +160,8 @@ void InputManager::addCallbacks()
var_AddCallback( p_input, "title", ItemTitleChanged, this );
/* src/input/input.c:734 for timers update*/
var_AddCallback( p_input, "intf-change", InterfaceChanged, this );
/* src/input/input.c:710 for statistics update*/
var_AddCallback( p_input, "stats-change", StatisticsUpdated, this );
/* src/input/input.c for vout creation/destruction */
var_AddCallback( p_input, "intf-change-vout", InterfaceVoutChanged, this );
}
......@@ -172,6 +176,7 @@ void InputManager::delCallbacks()
var_DelCallback( p_input, "rate-change", ItemRateChanged, this );
var_DelCallback( p_input, "title", ItemTitleChanged, this );
var_DelCallback( p_input, "intf-change", InterfaceChanged, this );
var_DelCallback( p_input, "stats-change", StatisticsUpdated, this );
var_DelCallback( p_input, "intf-change-vout", InterfaceVoutChanged, this );
}
......@@ -188,6 +193,7 @@ void InputManager::customEvent( QEvent *event )
type != ItemSpuChanged_Type &&
type != ItemTeletextChanged_Type &&
type != ItemStateChanged_Type &&
type != StatisticsUpdate_Type &&
type != InterfaceVoutUpdate_Type )
return;
......@@ -204,12 +210,14 @@ void InputManager::customEvent( QEvent *event )
type != ItemSpuChanged_Type &&
type != ItemTeletextChanged_Type &&
type != ItemStateChanged_Type &&
type != StatisticsUpdate_Type &&
type != InterfaceVoutUpdate_Type
)
&& ( i_input_id != ple->i_id ) )
return;
if( type != PositionUpdate_Type )
if( type != PositionUpdate_Type &&
type != StatisticsUpdate_Type )
msg_Dbg( p_intf, "New Event: type %i", type );
/* Actions */
......@@ -218,6 +226,9 @@ void InputManager::customEvent( QEvent *event )
case PositionUpdate_Type:
UpdatePosition();
break;
case StatisticsUpdate_Type:
UpdateStats();
break;
case ItemChanged_Type:
UpdateMeta();
UpdateStatus();
......@@ -247,6 +258,11 @@ void InputManager::customEvent( QEvent *event )
}
}
void InputManager::UpdateStats()
{
emit statisticsUpdated( input_GetItem( p_input ) );
}
void InputManager::UpdatePosition()
{
/* Update position */
......@@ -726,6 +742,16 @@ static int InterfaceChanged( vlc_object_t *p_this, const char *psz_var,
return VLC_SUCCESS;
}
static int StatisticsUpdated( vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *param )
{
InputManager *im = (InputManager*)param;
IMEvent *event = new IMEvent( StatisticsUpdate_Type, 0 );
QApplication::postEvent( im, static_cast<QEvent*>(event) );
return VLC_SUCCESS;
}
static int InterfaceVoutChanged( vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *param )
{
......
......@@ -45,11 +45,12 @@ static int const VolumeChanged_Type = QEvent::User + IMEventType + 6;
static int const ItemSpuChanged_Type = QEvent::User + IMEventType + 7;
static int const ItemTeletextChanged_Type= QEvent::User + IMEventType + 8;
static int const InterfaceVoutUpdate_Type= QEvent::User + IMEventType + 9;
static int const StatisticsUpdate_Type = QEvent::User + IMEventType + 10;
static int const FullscreenControlToggle_Type = QEvent::User + IMEventType + 10;
static int const FullscreenControlShow_Type = QEvent::User + IMEventType + 11;
static int const FullscreenControlHide_Type = QEvent::User + IMEventType + 12;
static int const FullscreenControlPlanHide_Type = QEvent::User + IMEventType + 13;
static int const FullscreenControlToggle_Type = QEvent::User + IMEventType + 11;
static int const FullscreenControlShow_Type = QEvent::User + IMEventType + 12;
static int const FullscreenControlHide_Type = QEvent::User + IMEventType + 13;
static int const FullscreenControlPlanHide_Type = QEvent::User + IMEventType + 14;
class IMEvent : public QEvent
{
......@@ -98,6 +99,7 @@ private:
void UpdateTeletext();
void UpdateArt();
void UpdateVout();
void UpdateStats();
public slots:
void setInput( input_thread_t * ); ///< Our controlled input changed
......@@ -122,6 +124,8 @@ signals:
void nameChanged( QString );
/// Used to signal whether we should show navigation buttons
void navigationChanged( int );
/// Statistics are updated
void statisticsUpdated( input_item_t* );
/// Play/pause status
void statusChanged( int );
void artChanged( input_item_t* );
......
......@@ -2261,6 +2261,7 @@ static void ToggleFullScreen ( vout_thread_t *p_vout )
EnablePixelDoubling( p_vout );
#endif
#if 0
/* Activate the window (give it the focus) */
XClientMessageEvent event;
......@@ -2282,6 +2283,7 @@ static void ToggleFullScreen ( vout_thread_t *p_vout )
DefaultRootWindow( p_vout->p_sys->p_display ),
False, SubstructureRedirectMask,
(XEvent*)&event );
#endif
}
else
{
......@@ -2307,6 +2309,7 @@ static void ToggleFullScreen ( vout_thread_t *p_vout )
* window has already been mapped because the XMapWindow() request
* has not necessarily been sent directly to our window (remember,
* the call is first redirected to the window manager) */
#if 0
do
{
XWindowEvent( p_vout->p_sys->p_display,
......@@ -2320,6 +2323,9 @@ static void ToggleFullScreen ( vout_thread_t *p_vout )
p_vout->p_sys->p_win->base_window,
RevertToParent,
CurrentTime);
#else
XSync( p_vout->p_sys->p_display, False );
#endif
/* signal that the size needs to be updated */
p_vout->i_changes |= VOUT_SIZE_CHANGE;
......
......@@ -123,6 +123,7 @@ static void SubtitleAdd( input_thread_t *p_input, char *psz_subtitle, bool b_for
* - intf-change
* - intf-change-vout for when a vout is created or destroyed
* - rate-change for when playback rate changes
* - stats-change for when statistics are updated
* TODO explain when Callback is called
* TODO complete this list (?)
*****************************************************************************/
......@@ -706,6 +707,7 @@ static void MainLoopStatistic( input_thread_t *p_input )
stats_ComputeGlobalStats( p_input->p_libvlc,
p_input->p_libvlc->p_stats );
}
var_SetBool( p_input, "stats-change", true );
}
/**
......
......@@ -223,11 +223,15 @@ void input_ControlVarInit ( input_thread_t *p_input )
*
* Add rate-change to inform about rate changin
*
* stats-change to inform when statistics are computed
*
* TODO list all changes warn by this callbacks */
var_Create( p_input, "intf-change", VLC_VAR_BOOL );
var_SetBool( p_input, "intf-change", true );
var_Create( p_input, "rate-change", VLC_VAR_BOOL );
var_SetBool( p_input, "rate-change", true );
var_Create( p_input, "stats-change", VLC_VAR_BOOL );
var_SetBool( p_input, "stats-change", true );
var_Create( p_input, "intf-change-vout", VLC_VAR_BOOL );
var_SetBool( p_input, "intf-change-vout", true );
......
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