+/**
+ * MainLoopInterface
+ * It update the variables used by the interfaces
+ */
+static void MainLoopInterface( input_thread_t *p_input )
+{
+ double f_position = 0.0;
+ mtime_t i_time = 0;
+ mtime_t i_length = 0;
+
+ /* update input status variables */
+ if( demux_Control( p_input->p->input.p_demux,
+ DEMUX_GET_POSITION, &f_position ) )
+ f_position = 0.0;
+
+ if( demux_Control( p_input->p->input.p_demux,
+ DEMUX_GET_TIME, &i_time ) )
+ i_time = 0;
+
+ if( demux_Control( p_input->p->input.p_demux,
+ DEMUX_GET_LENGTH, &i_length ) )
+ i_length = 0;
+
+ es_out_SetTimes( p_input->p->p_es_out, f_position, i_time, i_length );
+
+ /* update current bookmark */
+ vlc_mutex_lock( &p_input->p->p_item->lock );
+ p_input->p->bookmark.i_time_offset = i_time;
+ if( p_input->p->input.p_stream )
+ p_input->p->bookmark.i_byte_offset = stream_Tell( p_input->p->input.p_stream );
+ vlc_mutex_unlock( &p_input->p->p_item->lock );
+}
+
+/**
+ * MainLoopStatistic
+ * It updates the globals statics
+ */
+static void MainLoopStatistic( input_thread_t *p_input )
+{
+ stats_ComputeInputStats( p_input, p_input->p->p_item->p_stats );
+ /* Are we the thread responsible for computing global stats ? */
+ if( libvlc_priv( p_input->p_libvlc )->p_stats_computer == p_input )
+ {
+ stats_ComputeGlobalStats( p_input->p_libvlc,
+ p_input->p_libvlc->p_stats );
+ }
+ input_SendEventStatistics( p_input );
+}
+
+/**
+ * MainLoop
+ * The main input loop.
+ */
+static void MainLoop( input_thread_t *p_input )
+{
+ mtime_t i_start_mdate = mdate();
+ mtime_t i_intf_update = 0;
+ mtime_t i_statistic_update = 0;
+
+ /* Start the timer */
+ stats_TimerStop( p_input, STATS_TIMER_INPUT_LAUNCHING );
+
+ while( vlc_object_alive( p_input ) && !p_input->b_error )
+ {
+ bool b_force_update;
+ int i_type;
+ vlc_value_t val;
+ mtime_t i_current;
+ mtime_t i_deadline;
+ mtime_t i_wakeup;
+ bool b_paused;
+
+ /* Demux data */
+ b_force_update = false;
+ i_wakeup = 0;
+ /* FIXME if p_input->i_state == PAUSE_S the access/access_demux
+ * is paused -> this may cause problem with some of them
+ * The same problem can be seen when seeking while paused */
+ b_paused = p_input->i_state == PAUSE_S &&
+ !es_out_GetBuffering( p_input->p->p_es_out );
+
+ if( !b_paused )
+ {
+ if( !p_input->p->input.b_eof )
+ {
+ MainLoopDemux( p_input, &b_force_update, &i_start_mdate );
+
+ i_wakeup = es_out_GetWakeup( p_input->p->p_es_out );