Commit afffa217 authored by Laurent Aimar's avatar Laurent Aimar

Cosmetics (factorize code).

parent a95520f9
...@@ -510,6 +510,7 @@ static void vout_Destructor( vlc_object_t * p_this ) ...@@ -510,6 +510,7 @@ static void vout_Destructor( vlc_object_t * p_this )
*****************************************************************************/ *****************************************************************************/
static int ChromaCreate( vout_thread_t *p_vout ); static int ChromaCreate( vout_thread_t *p_vout );
static void ChromaDestroy( vout_thread_t *p_vout ); static void ChromaDestroy( vout_thread_t *p_vout );
static void DropPicture( vout_thread_t *p_vout, picture_t *p_picture );
static int InitThread( vout_thread_t *p_vout ) static int InitThread( vout_thread_t *p_vout )
{ {
...@@ -744,7 +745,7 @@ static void RunThread( vout_thread_t *p_vout) ...@@ -744,7 +745,7 @@ static void RunThread( vout_thread_t *p_vout)
* Main loop - it is not executed if an error occurred during * Main loop - it is not executed if an error occurred during
* initialization * initialization
*/ */
while( (vlc_object_alive( p_vout )) && (!p_vout->b_error) ) while( vlc_object_alive( p_vout ) && !p_vout->b_error )
{ {
/* Initialize loop variables */ /* Initialize loop variables */
p_picture = NULL; p_picture = NULL;
...@@ -752,24 +753,24 @@ static void RunThread( vout_thread_t *p_vout) ...@@ -752,24 +753,24 @@ static void RunThread( vout_thread_t *p_vout)
current_date = mdate(); current_date = mdate();
i_loops++; i_loops++;
if( !p_input ) if( !p_input )
{ {
p_input = vlc_object_find( p_vout, VLC_OBJECT_INPUT, p_input = vlc_object_find( p_vout, VLC_OBJECT_INPUT,
FIND_PARENT ); FIND_PARENT );
} }
if( p_input ) if( p_input )
{ {
vlc_mutex_lock( &p_input->p->counters.counters_lock ); vlc_mutex_lock( &p_input->p->counters.counters_lock );
stats_UpdateInteger( p_vout, p_input->p->counters.p_lost_pictures, stats_UpdateInteger( p_vout, p_input->p->counters.p_lost_pictures,
i_lost , NULL); i_lost , NULL);
stats_UpdateInteger( p_vout, stats_UpdateInteger( p_vout,
p_input->p->counters.p_displayed_pictures, p_input->p->counters.p_displayed_pictures,
i_displayed , NULL); i_displayed , NULL);
i_displayed = i_lost = 0; i_displayed = i_lost = 0;
vlc_mutex_unlock( &p_input->p->counters.counters_lock ); vlc_mutex_unlock( &p_input->p->counters.counters_lock );
vlc_object_release( p_input ); vlc_object_release( p_input );
p_input = NULL; p_input = NULL;
} }
#if 0 #if 0
p_vout->c_loops++; p_vout->c_loops++;
if( !(p_vout->c_loops % VOUT_STATS_NB_LOOPS) ) if( !(p_vout->c_loops % VOUT_STATS_NB_LOOPS) )
...@@ -816,17 +817,7 @@ static void RunThread( vout_thread_t *p_vout) ...@@ -816,17 +817,7 @@ static void RunThread( vout_thread_t *p_vout)
/* If we found better than the last picture, destroy it */ /* If we found better than the last picture, destroy it */
if( p_last_picture && p_picture != p_last_picture ) if( p_last_picture && p_picture != p_last_picture )
{ {
vlc_mutex_lock( &p_vout->picture_lock ); DropPicture( p_vout, p_last_picture );
if( p_last_picture->i_refcount )
{
p_last_picture->i_status = DISPLAYED_PICTURE;
}
else
{
p_last_picture->i_status = DESTROYED_PICTURE;
p_vout->i_heap_size--;
}
vlc_mutex_unlock( &p_vout->picture_lock );
p_last_picture = NULL; p_last_picture = NULL;
} }
...@@ -841,24 +832,10 @@ static void RunThread( vout_thread_t *p_vout) ...@@ -841,24 +832,10 @@ static void RunThread( vout_thread_t *p_vout)
{ {
/* Picture is late: it will be destroyed and the thread /* Picture is late: it will be destroyed and the thread
* will directly choose the next picture */ * will directly choose the next picture */
vlc_mutex_lock( &p_vout->picture_lock ); DropPicture( p_vout, p_picture );
if( p_picture->i_refcount ) i_lost++;
{
/* Pretend we displayed the picture, but don't destroy
* it since the decoder might still need it. */
p_picture->i_status = DISPLAYED_PICTURE;
}
else
{
/* Destroy the picture without displaying it */
p_picture->i_status = DESTROYED_PICTURE;
p_vout->i_heap_size--;
}
msg_Warn( p_vout, "late picture skipped (%"PRId64")", msg_Warn( p_vout, "late picture skipped (%"PRId64")",
current_date - display_date ); current_date - display_date );
i_lost++;
vlc_mutex_unlock( &p_vout->picture_lock );
continue; continue;
} }
...@@ -866,25 +843,11 @@ static void RunThread( vout_thread_t *p_vout) ...@@ -866,25 +843,11 @@ static void RunThread( vout_thread_t *p_vout)
current_date + p_vout->i_pts_delay + VOUT_BOGUS_DELAY ) current_date + p_vout->i_pts_delay + VOUT_BOGUS_DELAY )
{ {
/* Picture is waaay too early: it will be destroyed */ /* Picture is waaay too early: it will be destroyed */
vlc_mutex_lock( &p_vout->picture_lock ); DropPicture( p_vout, p_picture );
if( p_picture->i_refcount )
{
/* Pretend we displayed the picture, but don't destroy
* it since the decoder might still need it. */
p_picture->i_status = DISPLAYED_PICTURE;
}
else
{
/* Destroy the picture without displaying it */
p_picture->i_status = DESTROYED_PICTURE;
p_vout->i_heap_size--;
}
i_lost++; i_lost++;
msg_Warn( p_vout, "vout warning: early picture skipped " msg_Warn( p_vout, "vout warning: early picture skipped "
"(%"PRId64")", display_date - current_date "(%"PRId64")", display_date - current_date
- p_vout->i_pts_delay ); - p_vout->i_pts_delay );
vlc_mutex_unlock( &p_vout->picture_lock );
continue; continue;
} }
...@@ -1299,6 +1262,24 @@ static void ChromaDestroy( vout_thread_t *p_vout ) ...@@ -1299,6 +1262,24 @@ static void ChromaDestroy( vout_thread_t *p_vout )
p_vout->p_chroma = NULL; p_vout->p_chroma = NULL;
} }
static void DropPicture( vout_thread_t *p_vout, picture_t *p_picture )
{
vlc_mutex_lock( &p_vout->picture_lock );
if( p_picture->i_refcount )
{
/* Pretend we displayed the picture, but don't destroy
* it since the decoder might still need it. */
p_picture->i_status = DISPLAYED_PICTURE;
}
else
{
/* Destroy the picture without displaying it */
p_picture->i_status = DESTROYED_PICTURE;
p_vout->i_heap_size--;
}
vlc_mutex_unlock( &p_vout->picture_lock );
}
/* following functions are local */ /* following functions are local */
......
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