Modify input_ressource_RequestVout to allow avoiding recycling.
authorLaurent Aimar <fenrir@videolan.org>
Thu, 5 Feb 2009 22:31:29 +0000 (23:31 +0100)
committerLaurent Aimar <fenrir@videolan.org>
Thu, 5 Feb 2009 22:31:29 +0000 (23:31 +0100)
src/input/decoder.c
src/input/ressource.c
src/input/ressource.h

index bcae5fe..3f7ff47 100644 (file)
@@ -2030,7 +2030,7 @@ static void DeleteDecoder( decoder_t * p_dec )
             vout_ChangePause( p_owner->p_vout, false, mdate() );
 
         /* */
-        input_ressource_RequestVout( p_owner->p_input->p->p_ressource, p_owner->p_vout, NULL );
+        input_ressource_RequestVout( p_owner->p_input->p->p_ressource, p_owner->p_vout, NULL, true );
         input_SendEventVout( p_owner->p_input );
     }
 
@@ -2110,11 +2110,7 @@ static vout_thread_t *aout_request_vout( void *p_private,
     decoder_t *p_dec = p_private;
     input_thread_t *p_input = p_dec->p_owner->p_input;
 
-    p_vout = input_ressource_RequestVout( p_input->p->p_ressource, p_vout, p_fmt );
-    /* TODO it would be better to give b_recyle to input_ressource_RequestVout
-     * as here we are not sure of which vout we destroy */
-    if( !b_recyle )
-        input_ressource_TerminateVout( p_input->p->p_ressource );
+    p_vout = input_ressource_RequestVout( p_input->p->p_ressource, p_vout, p_fmt, b_recyle );
     input_SendEventVout( p_input );
 
     return p_vout;
@@ -2293,7 +2289,7 @@ static picture_t *vout_new_buffer( decoder_t *p_dec )
         vlc_mutex_unlock( &p_owner->lock );
 
         p_vout = input_ressource_RequestVout( p_owner->p_input->p->p_ressource,
-                                              p_vout, &p_dec->fmt_out.video );
+                                              p_vout, &p_dec->fmt_out.video, true );
 
         vlc_mutex_lock( &p_owner->lock );
         p_owner->p_vout = p_vout;
index 0fd1e3b..11003d9 100644 (file)
@@ -177,7 +177,8 @@ static void DisplayVoutTitle( input_ressource_t *p_ressource,
     free( psz_nowplaying );
 }
 static vout_thread_t *RequestVout( input_ressource_t *p_ressource,
-                                   vout_thread_t *p_vout, video_format_t *p_fmt )
+                                   vout_thread_t *p_vout, video_format_t *p_fmt,
+                                   bool b_recycle )
 {
     if( !p_vout && !p_fmt )
     {
@@ -232,9 +233,10 @@ static vout_thread_t *RequestVout( input_ressource_t *p_ressource,
         const int i_vout_active = p_ressource->i_vout;
         vlc_mutex_unlock( &p_ressource->lock_vout );
 
-        if( p_ressource->p_vout_free || i_vout_active > 0 )
+        if( p_ressource->p_vout_free || i_vout_active > 0 || !b_recycle )
         {
-            msg_Dbg( p_ressource->p_input, "detroying vout (already one saved or active)" );
+            if( b_recycle )
+                msg_Dbg( p_ressource->p_input, "detroying vout (already one saved or active)" );
             vout_CloseAndRelease( p_vout );
         }
         else
@@ -388,10 +390,10 @@ void input_ressource_SetInput( input_ressource_t *p_ressource, input_thread_t *p
 }
 
 vout_thread_t *input_ressource_RequestVout( input_ressource_t *p_ressource,
-                                            vout_thread_t *p_vout, video_format_t *p_fmt )
+                                            vout_thread_t *p_vout, video_format_t *p_fmt, bool b_recycle )
 {
     vlc_mutex_lock( &p_ressource->lock );
-    vout_thread_t *p_ret = RequestVout( p_ressource, p_vout, p_fmt );
+    vout_thread_t *p_ret = RequestVout( p_ressource, p_vout, p_fmt, b_recycle );
     vlc_mutex_unlock( &p_ressource->lock );
 
     return p_ret;
@@ -406,7 +408,7 @@ void input_ressource_HoldVouts( input_ressource_t *p_ressource, vout_thread_t **
 }
 void input_ressource_TerminateVout( input_ressource_t *p_ressource )
 {
-    input_ressource_RequestVout( p_ressource, NULL, NULL );
+    input_ressource_RequestVout( p_ressource, NULL, NULL, false );
 }
 bool input_ressource_HasVout( input_ressource_t *p_ressource )
 {
index 4409a88..f0e0aef 100644 (file)
@@ -60,7 +60,7 @@ aout_instance_t *input_ressource_HoldAout( input_ressource_t *p_ressource );
 /**
  * This function handles vout request.
  */
-vout_thread_t *input_ressource_RequestVout( input_ressource_t *, vout_thread_t *, video_format_t * );
+vout_thread_t *input_ressource_RequestVout( input_ressource_t *, vout_thread_t *, video_format_t *, bool b_recycle );
 
 /**
  * This function return one of the current vout if any.