[vlc-devel] commit: Fixed INPUT_GET_VIDEO_FPS thread safety. (Laurent Aimar )

git version control git at videolan.org
Thu Dec 4 20:48:05 CET 2008


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Wed Dec  3 23:10:04 2008 +0100| [23eae0262de009be8bc92386df61920f3bf29602] | committer: Laurent Aimar 

Fixed INPUT_GET_VIDEO_FPS thread safety.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=23eae0262de009be8bc92386df61920f3bf29602
---

 src/input/control.c        |    8 ++------
 src/input/input.c          |    9 ++++-----
 src/input/input_internal.h |    6 ++++--
 3 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/src/input/control.c b/src/input/control.c
index ee54ec8..c01b6b6 100644
--- a/src/input/control.c
+++ b/src/input/control.c
@@ -409,16 +409,12 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
         }
 
         case INPUT_GET_VIDEO_FPS:
-        {
-            int i;
             pf = (double*)va_arg( args, double * );
+
             vlc_mutex_lock( &p_input->p->p_item->lock );
-            *pf = p_input->p->input.f_fps;
-            for( i = 0; i < p_input->p->i_slave && *pf <= 0.001; i++ )
-                *pf = p_input->p->slave[i]->f_fps;
+            *pf = p_input->p->f_fps;
             vlc_mutex_unlock( &p_input->p->p_item->lock );
             return VLC_SUCCESS;
-        }
 
         case INPUT_ADD_SLAVE:
             psz = (char*)va_arg( args, char * );
diff --git a/src/input/input.c b/src/input/input.c
index 0a2454e..51bde83 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -1006,9 +1006,8 @@ static void LoadSubtitles( input_thread_t *p_input )
 {
     /* Load subtitles */
     /* Get fps and set it if not already set */
-    double f_fps;
-    if( !demux_Control( p_input->p->input.p_demux, DEMUX_GET_FPS, &f_fps ) &&
-        f_fps > 1.0 )
+    const double f_fps = p_input->p->f_fps;
+    if( f_fps > 1.0 )
     {
         float f_requested_fps;
 
@@ -2587,10 +2586,10 @@ static int InputSourceInit( input_thread_t *p_input,
             vlc_mutex_unlock( &p_input->p->p_item->lock );
         }
     }
-    if( !demux_Control( in->p_demux, DEMUX_GET_FPS, &f_fps ) )
+    if( !demux_Control( in->p_demux, DEMUX_GET_FPS, &f_fps ) && f_fps > 0.0 )
     {
         vlc_mutex_lock( &p_input->p->p_item->lock );
-        in->f_fps = f_fps;
+        p_input->p->f_fps = f_fps;
         vlc_mutex_unlock( &p_input->p->p_item->lock );
     }
 
diff --git a/src/input/input_internal.h b/src/input/input_internal.h
index 111f547..b0b43a8 100644
--- a/src/input/input_internal.h
+++ b/src/input/input_internal.h
@@ -69,7 +69,6 @@ typedef struct
     bool b_rescale_ts;
 
     bool       b_eof;   /* eof of demuxer */
-    double     f_fps;
 
 } input_source_t;
 
@@ -82,10 +81,13 @@ struct input_thread_private_t
     /* Global properties */
     bool        b_can_pause;
     bool        b_can_rate_control;
+    double      f_fps;
 
+    /* Current state */
     int         i_rate;
     bool        b_recording;
-    /* */
+
+    /* Playtime configuration */
     int64_t     i_start;    /* :start-time,0 by default */
     int64_t     i_stop;     /* :stop-time, 0 if none */
     int64_t     i_run;      /* :run-time, 0 if none */




More information about the vlc-devel mailing list