]> git.sesse.net Git - vlc/commitdiff
* modules/demux/m3u.c: should manage entries with relative paths.
authorGildas Bazin <gbazin@videolan.org>
Mon, 18 Nov 2002 13:08:35 +0000 (13:08 +0000)
committerGildas Bazin <gbazin@videolan.org>
Mon, 18 Nov 2002 13:08:35 +0000 (13:08 +0000)
* src/playlist/playlist.c: fixed playlist_Next().

modules/demux/m3u.c
src/playlist/playlist.c

index dbc406e9c751951a7a35ab9b1b3dac46ae747d36..eb016bc6e092fbe3f5a244cd0d72fec537c85f1d 100644 (file)
@@ -2,7 +2,7 @@
  * m3u.c: a meta demux to parse m3u and asx playlists
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: m3u.c,v 1.3 2002/11/13 12:58:19 gbazin Exp $
+ * $Id: m3u.c,v 1.4 2002/11/18 13:08:35 gbazin Exp $
  *
  * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
  *          Gildas Bazin <gbazin@netcourrier.com>
@@ -134,7 +134,7 @@ static void Deactivate( vlc_object_t *p_this )
 static int Demux ( input_thread_t *p_input )
 {
     data_packet_t *p_data;
-    char          *p_buf, psz_line[MAX_LINE], *psz_bol, eol_tok;
+    char          *p_buf, psz_line[MAX_LINE], *psz_bol, *psz_name, eol_tok;
     int           i_size, i_bufpos, i_linepos = 0;
     playlist_t    *p_playlist;
     vlc_bool_t    b_discard = VLC_FALSE;
@@ -237,9 +237,38 @@ static int Demux ( input_thread_t *p_input )
             /*
              * From now on, we know we've got a meaningful line
              */
-            playlist_Add( p_playlist, psz_bol,
+
+           /* Check if the line has an absolute or relative path */
+           psz_name = psz_bol;
+            while( *psz_name && strncmp( psz_bol, "://", sizeof("://") - 1 ) )
+           {
+               psz_name++;
+           }
+
+           if( !*psz_name )
+           {
+               /* the line doesn't specify a protocol name.
+                * If this line doesn't begin with a '/' then assume the path
+                * is relative to the path of the m3u file. */
+               char *psz_path = strdup( p_input->psz_name );
+
+               psz_name = strrchr( psz_path, '/' );
+               if( psz_name ) *psz_name = '\0';
+               else *psz_path = '\0';
+               psz_name = malloc( strlen(psz_path) + strlen(psz_bol) + 2 );
+               sprintf( psz_name, "%s/%s", psz_path, psz_bol );
+               free( psz_path );
+           }
+           else
+           {
+               psz_name = strdup( psz_bol );
+           }
+
+            playlist_Add( p_playlist, psz_name,
                           PLAYLIST_APPEND, PLAYLIST_END );
 
+           free( psz_name );
+
             continue;
         }
 
index d048e45c26779f43e571aee11fc210cb44bf034b..ee3196c5fccc544e892248482b0ca42e3c312682 100644 (file)
@@ -2,7 +2,7 @@
  * playlist.c : Playlist management functions
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: playlist.c,v 1.21 2002/11/13 20:51:05 sam Exp $
+ * $Id: playlist.c,v 1.22 2002/11/18 13:08:35 gbazin Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -305,15 +305,6 @@ static void RunThread ( playlist_t *p_playlist )
                  * in input_DestroyThread() for some time. */
                 vlc_mutex_unlock( &p_playlist->object_lock );
 
-                /* Check for autodeletion */
-                if( p_playlist->pp_items[p_playlist->i_index]->b_autodeletion )
-                {
-                    playlist_Delete( p_playlist, p_playlist->i_index );
-                }
-
-                /* Select the next playlist item */
-                SkipItem( p_playlist, 1 );
-
                 /* Destroy input */
                 input_DestroyThread( p_input );
                 vlc_object_destroy( p_input );
@@ -328,6 +319,15 @@ static void RunThread ( playlist_t *p_playlist )
             else if( p_playlist->p_input->b_error
                       || p_playlist->p_input->b_eof )
             {
+                /* Check for autodeletion */
+                if( p_playlist->pp_items[p_playlist->i_index]->b_autodeletion )
+                {
+                    playlist_Delete( p_playlist, p_playlist->i_index );
+                }
+
+                /* Select the next playlist item */
+                SkipItem( p_playlist, 1 );
+
                 /* Release the playlist lock, because we may get stuck
                  * in input_StopThread() for some time. */
                 vlc_mutex_unlock( &p_playlist->object_lock );