]> git.sesse.net Git - vlc/blobdiff - src/input/input.c
For consistency, remove references to vlc from libvlc
[vlc] / src / input / input.c
index 6a01622fa5eb8d7675146cc4c7afc06de80a1901..5df9377903031f096b8cfb71820cfb355d379214 100644 (file)
@@ -324,7 +324,7 @@ int __input_Preparse( vlc_object_t *p_parent, input_item_t *p_item )
 
     /* Allocate descriptor */
     p_input = Create( p_parent, p_item, NULL, VLC_TRUE );
-    p_input->i_flags |= OBJECT_FLAGS_NODBG;
+    p_input->i_flags |= OBJECT_FLAGS_QUIET;
     p_input->i_flags |= OBJECT_FLAGS_NOINTERACT;
 
     /* Now we can attach our new input */
@@ -447,7 +447,7 @@ static int Run( input_thread_t *p_input )
         p_input->b_eof = VLC_TRUE;
     }
 
-    /* Wait we are asked to die */
+    /* Wait until we are asked to die */
     if( !p_input->b_die )
     {
         Error( p_input );
@@ -479,7 +479,7 @@ static int RunAndClean( input_thread_t *p_input )
 
     if( !p_input->b_eof && !p_input->b_error && p_input->input.b_eof )
     {
-        /* We have finish to demux data but not to play them */
+        /* We have finished demuxing data but not playing it */
         while( !p_input->b_die )
         {
             if( input_EsOutDecodersEmpty( p_input->p_es_out ) )
@@ -489,6 +489,7 @@ static int RunAndClean( input_thread_t *p_input )
 
             msleep( INPUT_IDLE_SLEEP );
         }
+
         /* We have finished */
         p_input->b_eof = VLC_TRUE;
     }
@@ -684,7 +685,7 @@ static int Init( input_thread_t * p_input, vlc_bool_t b_quick )
         /* Prepare statistics */
 #define INIT_COUNTER( p, type, compute ) p_input->counters.p_##p = \
      stats_CounterCreate( p_input, VLC_VAR_##type, STATS_##compute);
-        if( p_input->p_libvlc->b_stats )
+        if( p_input->p_libvlc_global->b_stats )
         {
             INIT_COUNTER( read_bytes, INTEGER, COUNTER );
             INIT_COUNTER( read_packets, INTEGER, COUNTER );
@@ -720,7 +721,7 @@ static int Init( input_thread_t * p_input, vlc_bool_t b_quick )
                 free( psz );
                 return VLC_EGENERIC;
             }
-            if( p_input->p_libvlc->b_stats )
+            if( p_input->p_libvlc_global->b_stats )
             {
                 INIT_COUNTER( sout_sent_packets, INTEGER, COUNTER );
                 INIT_COUNTER (sout_sent_bytes, INTEGER, COUNTER );
@@ -1047,10 +1048,7 @@ static int Init( input_thread_t * p_input, vlc_bool_t b_quick )
     }
 
     /* initialization is complete */
-    p_input->i_state = PLAYING_S;
-
-    val.i_int = PLAYING_S;
-    var_Change( p_input, "state", VLC_VAR_SETVALUE, &val, NULL );
+    input_ChangeState(p_input, PLAYING_S);
 
     return VLC_SUCCESS;
 
@@ -1090,16 +1088,12 @@ static void Error( input_thread_t *p_input )
  *****************************************************************************/
 static void End( input_thread_t * p_input )
 {
-    vlc_value_t val;
     int i;
 
     msg_Dbg( p_input, "closing input" );
 
     /* We are at the end */
-    p_input->i_state = END_S;
-
-    val.i_int = END_S;
-    var_Change( p_input, "state", VLC_VAR_SETVALUE, &val, NULL );
+    input_ChangeState(p_input, END_S);
 
     /* Clean control variables */
     input_ControlVarClean( p_input );
@@ -1119,8 +1113,10 @@ static void End( input_thread_t * p_input )
     if( p_input->p_es_out )
         input_EsOutDelete( p_input->p_es_out );
 
-#define CL_CO( c ) stats_CounterClean( p_input->counters.p_##c )
-
+#define CL_CO( c ) stats_CounterClean( p_input->counters.p_##c ); p_input->counters.p_##c = NULL;
+    if( p_input->p_libvlc_global->b_stats )
+    {
+        vlc_mutex_lock( &p_input->counters.counters_lock );
         CL_CO( read_bytes );
         CL_CO( read_packets );
         CL_CO( demux_read );
@@ -1133,6 +1129,8 @@ static void End( input_thread_t * p_input )
         CL_CO( decoded_audio) ;
         CL_CO( decoded_video );
         CL_CO( decoded_sub) ;
+        vlc_mutex_unlock( &p_input->counters.counters_lock );
+    }
 
     /* Close optional stream output instance */
     if( p_input->p_sout )
@@ -1141,9 +1139,11 @@ static void End( input_thread_t * p_input )
             vlc_object_find( p_input, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
         vlc_value_t keep;
 
+        vlc_mutex_lock( &p_input->counters.counters_lock );
         CL_CO( sout_sent_packets );
         CL_CO( sout_sent_bytes );
         CL_CO( sout_send_bitrate );
+        vlc_mutex_unlock( &p_input->counters.counters_lock );
 
         if( var_Get( p_input, "sout-keep", &keep ) >= 0 && keep.b_bool && p_pl )
         {
@@ -1976,6 +1976,8 @@ static int InputSourceInit( input_thread_t *p_input,
     {
         int64_t i_pts_delay;
 
+        input_ChangeState( p_input, OPENING_S);
+
         /* Now try a real access */
         in->p_access = access2_New( p_input, psz_access, psz_demux, psz_path,
                                     b_quick );
@@ -2018,8 +2020,10 @@ static int InputSourceInit( input_thread_t *p_input,
         if( in->p_access == NULL )
         {
             msg_Err( p_input, "no suitable access module for `%s'", psz_mrl );
-            intf_UserFatal( VLC_OBJECT( p_input),
-                            _("Errors"),"Unable to open '%s'", psz_mrl );
+            intf_UserFatal( VLC_OBJECT( p_input), VLC_FALSE,
+                            _("Your input can't be opened"),
+                            _("VLC is unable to open the MRL '%s'."
+                            " Check the log for details."), psz_mrl );
             goto error;
         }
 
@@ -2070,6 +2074,8 @@ static int InputSourceInit( input_thread_t *p_input,
             var_Set( p_input, "seekable", val );
         }
 
+        input_ChangeState( p_input, BUFFERING_S);
+
         /* Create the stream_t */
         in->p_stream = stream_AccessNew( in->p_access, b_quick );
         if( in->p_stream == NULL )
@@ -2089,8 +2095,10 @@ static int InputSourceInit( input_thread_t *p_input,
         {
             msg_Err( p_input, "no suitable demux module for `%s/%s://%s'",
                      psz_access, psz_demux, psz_path );
-            intf_UserFatal( VLC_OBJECT( p_input), _("Errors"),
-                            "Unrecognized format for '%s'", psz_mrl );
+            intf_UserFatal( VLC_OBJECT( p_input), VLC_FALSE, 
+                            _("Can't recognize the input's format"),
+                            _("The format of '%s' can't be detected. "
+                            "Have a look the log for details."), psz_mrl );
             goto error;
         }