X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fvideo_output%2Fvideo_output.c;h=3511ccb6f3a1bb8f657fc17f335d94ae101f0468;hb=7ca4e3eb624251feb1f97cfc25104cce473e04a0;hp=bd22a4d3c4eef4a2fd891c8910be5716ad5ba651;hpb=86c7e74f879b65a640ade8af1a7facdc73af36a8;p=vlc diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c index bd22a4d3c4..3511ccb6f3 100644 --- a/src/video_output/video_output.c +++ b/src/video_output/video_output.c @@ -179,7 +179,7 @@ vout_thread_t *__vout_Request( vlc_object_t *p_this, vout_thread_t *p_vout, p_vout->b_filter_change ) { /* We are not interested in this format, close this vout */ - vlc_object_release( p_vout ); + vout_CloseAndRelease( p_vout ); vlc_object_release( p_vout ); p_vout = NULL; } @@ -510,6 +510,7 @@ static void vout_Destructor( vlc_object_t * p_this ) *****************************************************************************/ static int ChromaCreate( 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 ) { @@ -744,7 +745,7 @@ static void RunThread( vout_thread_t *p_vout) * Main loop - it is not executed if an error occurred during * initialization */ - while( (vlc_object_alive( p_vout )) && (!p_vout->b_error) ) + while( vlc_object_alive( p_vout ) && !p_vout->b_error ) { /* Initialize loop variables */ p_picture = NULL; @@ -752,24 +753,24 @@ static void RunThread( vout_thread_t *p_vout) current_date = mdate(); i_loops++; - if( !p_input ) - { - p_input = vlc_object_find( p_vout, VLC_OBJECT_INPUT, - FIND_PARENT ); - } - if( p_input ) - { - vlc_mutex_lock( &p_input->p->counters.counters_lock ); - stats_UpdateInteger( p_vout, p_input->p->counters.p_lost_pictures, - i_lost , NULL); - stats_UpdateInteger( p_vout, - p_input->p->counters.p_displayed_pictures, - i_displayed , NULL); - i_displayed = i_lost = 0; - vlc_mutex_unlock( &p_input->p->counters.counters_lock ); - vlc_object_release( p_input ); - p_input = NULL; - } + if( !p_input ) + { + p_input = vlc_object_find( p_vout, VLC_OBJECT_INPUT, + FIND_PARENT ); + } + if( p_input ) + { + vlc_mutex_lock( &p_input->p->counters.counters_lock ); + stats_UpdateInteger( p_vout, p_input->p->counters.p_lost_pictures, + i_lost , NULL); + stats_UpdateInteger( p_vout, + p_input->p->counters.p_displayed_pictures, + i_displayed , NULL); + i_displayed = i_lost = 0; + vlc_mutex_unlock( &p_input->p->counters.counters_lock ); + vlc_object_release( p_input ); + p_input = NULL; + } #if 0 p_vout->c_loops++; if( !(p_vout->c_loops % VOUT_STATS_NB_LOOPS) ) @@ -816,17 +817,7 @@ static void RunThread( vout_thread_t *p_vout) /* If we found better than the last picture, destroy it */ if( p_last_picture && p_picture != p_last_picture ) { - vlc_mutex_lock( &p_vout->picture_lock ); - 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 ); + DropPicture( p_vout, p_last_picture ); p_last_picture = NULL; } @@ -841,24 +832,10 @@ static void RunThread( vout_thread_t *p_vout) { /* Picture is late: it will be destroyed and the thread * will directly choose the next 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--; - } + DropPicture( p_vout, p_picture ); + i_lost++; msg_Warn( p_vout, "late picture skipped (%"PRId64")", current_date - display_date ); - i_lost++; - vlc_mutex_unlock( &p_vout->picture_lock ); - continue; } @@ -866,25 +843,11 @@ static void RunThread( vout_thread_t *p_vout) current_date + p_vout->i_pts_delay + VOUT_BOGUS_DELAY ) { /* Picture is waaay too early: it will be destroyed */ - 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--; - } + DropPicture( p_vout, p_picture ); i_lost++; msg_Warn( p_vout, "vout warning: early picture skipped " "(%"PRId64")", display_date - current_date - p_vout->i_pts_delay ); - vlc_mutex_unlock( &p_vout->picture_lock ); - continue; } @@ -1299,6 +1262,24 @@ static void ChromaDestroy( vout_thread_t *p_vout ) 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 */