]> git.sesse.net Git - vlc/blobdiff - src/playlist/playlist.c
Don't print debug messages and don't do interaction on preparsing
[vlc] / src / playlist / playlist.c
index 93c2bd901ab8bae3fe81ab77e759b828c46464fb..bde17ab55b84535e64fa111bea195e1f1b38e67d 100644 (file)
@@ -19,7 +19,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 #include <stdlib.h>                                      /* free(), strtol() */
 #include <stdio.h>                                              /* sprintf() */
@@ -198,7 +198,7 @@ playlist_t * __playlist_Create ( vlc_object_t *p_parent )
 
     // Preparse
     p_playlist->p_preparse->i_waiting = 0;
-    p_playlist->p_preparse->pp_waiting = NULL;
+    p_playlist->p_preparse->pi_waiting = NULL;
 
     // Interaction
     p_playlist->p_interaction = NULL;
@@ -486,10 +486,10 @@ int playlist_PreparseEnqueue( playlist_t *p_playlist,
                               input_item_t *p_item )
 {
     vlc_mutex_lock( &p_playlist->p_preparse->object_lock );
-    INSERT_ELEM( p_playlist->p_preparse->pp_waiting,
+    INSERT_ELEM( p_playlist->p_preparse->pi_waiting,
                  p_playlist->p_preparse->i_waiting,
                  p_playlist->p_preparse->i_waiting,
-                 p_item );
+                 p_item->i_id );
     vlc_mutex_unlock( &p_playlist->p_preparse->object_lock );
     return VLC_SUCCESS;
 }
@@ -501,10 +501,10 @@ void playlist_PreparseEnqueueItemSub( playlist_t *p_playlist,
     int i;
     if( p_item->i_children == -1 )
     {
-        INSERT_ELEM( p_playlist->p_preparse->pp_waiting,
+        INSERT_ELEM( p_playlist->p_preparse->pi_waiting,
                      p_playlist->p_preparse->i_waiting,
                      p_playlist->p_preparse->i_waiting,
-                     &(p_item->input) );
+                     (p_item->input.i_id) );
     }
     else
     {
@@ -581,6 +581,8 @@ static void RunThread ( playlist_t *p_playlist )
     mtime_t    i_vout_destroyed_date = 0;
     mtime_t    i_sout_destroyed_date = 0;
 
+    int i_loops = 0;
+
     playlist_item_t *p_autodelete_item = NULL;
 
     /* Tell above that we're ready */
@@ -588,9 +590,12 @@ static void RunThread ( playlist_t *p_playlist )
 
     while( !p_playlist->b_die )
     {
+        i_loops++;
         if( p_playlist->p_interaction )
         {
+            stats_TimerStart( p_playlist, "Interaction thread" );
             intf_InteractionManage( p_playlist );
+            stats_TimerStop( p_playlist, "Interaction thread" );
         }
 
         vlc_mutex_lock( &p_playlist->object_lock );
@@ -618,6 +623,14 @@ static void RunThread ( playlist_t *p_playlist )
         /* If there is an input, check that it doesn't need to die. */
         if( p_playlist->p_input )
         {
+            if( i_loops % 5 == 0 )
+            {
+                stats_ComputeInputStats( p_playlist->p_input,
+                                  p_playlist->p_input->input.p_item->p_stats );
+//                stats_DumpInputStats(
+//                            p_playlist->p_input->input.p_item->p_stats );
+            }
+
             /* This input is dead. Remove it ! */
             if( p_playlist->p_input->b_dead )
             {
@@ -689,7 +702,9 @@ static void RunThread ( playlist_t *p_playlist )
         {
             /* Start another input.
              * Get the next item to play */
+            stats_TimerStart( p_playlist, "Playlist walk" );
             p_item = NextItem( p_playlist );
+            stats_TimerStop( p_playlist, "Playlist walk" );
 
             /* We must stop */
             if( p_item == NULL )
@@ -831,11 +846,39 @@ static void RunPreparse ( playlist_preparse_t *p_obj )
 
         if( p_obj->i_waiting > 0 )
         {
-            input_item_t *p_current = p_obj->pp_waiting[0];
-            REMOVE_ELEM( p_obj->pp_waiting, p_obj->i_waiting, 0 );
+            int i_current_id = p_obj->pi_waiting[0];
+            playlist_item_t *p_current;
+            REMOVE_ELEM( p_obj->pi_waiting, p_obj->i_waiting, 0 );
             vlc_mutex_unlock( &p_obj->object_lock );
-            input_Preparse( p_playlist, p_current );
-            var_SetInteger( p_playlist, "item-change", p_current->i_id );
+            vlc_mutex_lock( &p_playlist->object_lock );
+
+            p_current = playlist_ItemGetById( p_playlist, i_current_id );
+            if( p_current )
+            {
+                vlc_bool_t b_preparsed = VLC_FALSE;
+                if( strncmp( p_current->input.psz_uri, "http:", 5 ) &&
+                    strncmp( p_current->input.psz_uri, "rtsp:", 5 ) &&
+                    strncmp( p_current->input.psz_uri, "udp:", 4 ) &&
+                    strncmp( p_current->input.psz_uri, "mms:", 4 ) &&
+                    strncmp( p_current->input.psz_uri, "cdda:", 4 ) &&
+                    strncmp( p_current->input.psz_uri, "dvd:", 4 ) &&
+                    strncmp( p_current->input.psz_uri, "v4l:", 4 ) &&
+                    strncmp( p_current->input.psz_uri, "dshow:", 6 ) )
+                {
+                    b_preparsed = VLC_TRUE;
+                    stats_TimerStart( p_playlist, "Preparse run" );
+                    input_Preparse( p_playlist, &p_current->input );
+                    stats_TimerStop( p_playlist, "Preparse run" );
+                }
+                vlc_mutex_unlock( &p_playlist->object_lock );
+                if( b_preparsed )
+                {
+                    var_SetInteger( p_playlist, "item-change",
+                                    p_current->input.i_id );
+                }
+            }
+            else
+                vlc_mutex_unlock( &p_playlist->object_lock );
             vlc_mutex_lock( &p_obj->object_lock );
         }
         b_sleep = ( p_obj->i_waiting == 0 );
@@ -870,7 +913,6 @@ static playlist_item_t * NextItem( playlist_t *p_playlist )
     /* Calculate time needed */
     int64_t start = mdate();
 #endif
-
     /* Handle quickly a few special cases */
 
     /* No items to play */
@@ -988,6 +1030,10 @@ static playlist_item_t * NextItem( playlist_t *p_playlist )
                 }
                 p_playlist->request.i_skip = 0;
             }
+            if( !( p_new->i_flags & PLAYLIST_SKIP_FLAG ) )
+            {
+                return NULL;
+            }
         }
         else
         {
@@ -1140,6 +1186,7 @@ static playlist_item_t * NextItem( playlist_t *p_playlist )
     {
         msg_Info( p_playlist, "nothing to play" );
     }
+
     return p_new;
 }