]> git.sesse.net Git - vlc/blobdiff - modules/demux/playlist/asx.c
Use mwait and remove silly msleep usage
[vlc] / modules / demux / playlist / asx.c
index f79ada6bce2e93361276599cfda11a47f228abae..a66e2287583c84761f902515311aa124e38e0148 100644 (file)
@@ -232,7 +232,6 @@ static int Demux( demux_t *p_demux )
     char        *psz_parse = NULL;
     char        *psz_backup = NULL;
     bool  b_entry = false;
-    input_item_t *p_input;
     INIT_PLAYLIST_STUFF;
 
     /* init txt */
@@ -247,7 +246,7 @@ static int Demux( demux_t *p_demux )
         for( ;; )
         {
             int i_read = stream_Read( p_demux->s, &p_sys->psz_data[i_pos], p_sys->i_data_len - i_pos );
-            p_sys->psz_data[i_read] = '\0';
+            p_sys->psz_data[i_pos + i_read] = '\0';
 
             if( i_read < p_sys->i_data_len - i_pos ) break; /* Done */
 
@@ -459,9 +458,11 @@ static int Demux( demux_t *p_demux )
                             psz_string = malloc( i_strlen*sizeof( char ) +1);
                             memcpy( psz_string, psz_backup, i_strlen );
                             psz_string[i_strlen] = '\0';
-                            p_input = input_ItemNew( p_playlist, psz_string, psz_title_asx );
-                            input_ItemCopyOptions( p_current_input, p_input );
-                            input_ItemAddSubItem( p_current_input, p_input );
+                            input_item_t *p_input;
+                            p_input = input_item_New( p_demux, psz_string, psz_title_asx );
+                            input_item_CopyOptions( p_current_input, p_input );
+                            input_item_AddSubItem( p_current_input, p_input );
+                            vlc_gc_decref( p_input );
                             free( psz_string );
                         }
                         else continue;
@@ -503,35 +504,42 @@ static int Demux( demux_t *p_demux )
                 {
                     if( i_starttime || i_duration )
                     {
-                        if( i_starttime ) {
-                            asprintf(ppsz_options+i_options, ":start-time=%d", i_starttime);
-                            ++i_options;
+                        if( i_starttime )
+                        {
+                            if( asprintf(ppsz_options+i_options, ":start-time=%d", i_starttime) == -1 )
+                                *(ppsz_options+i_options) = NULL;
+                            else
+                                ++i_options;
                         }
-                        if( i_duration ) {
-                            asprintf(ppsz_options+i_options, ":stop-time=%d", i_starttime + i_duration);
-                            ++i_options;
+                        if( i_duration )
+                        {
+                            if( asprintf(ppsz_options+i_options, ":stop-time=%d", i_starttime + i_duration) == -1 )
+                                *(ppsz_options+i_options) = NULL;
+                            else
+                                ++i_options;
                         }
                     }
 
                     /* create the new entry */
-                    asprintf( &psz_name, "%d %s", i_entry_count, ( psz_title_entry ? psz_title_entry : p_current_input->psz_name ) );
-
-                    p_entry = input_ItemNewExt( p_playlist, psz_href, psz_name, i_options, (const char * const *)ppsz_options, -1 );
-                    FREENULL( psz_name );
-                    input_ItemCopyOptions( p_current_input, p_entry );
-                    while( i_options )
+                    if( asprintf( &psz_name, "%d %s", i_entry_count, ( psz_title_entry ? psz_title_entry : p_current_input->psz_name ) ) != -1 )
                     {
-                        psz_name = ppsz_options[--i_options];
-                        FREENULL(psz_name);
-                    }
+                        p_entry = input_item_NewExt( p_demux, psz_href, psz_name, i_options, (const char * const *)ppsz_options, -1 );
+                        FREENULL( psz_name );
+                        input_item_CopyOptions( p_current_input, p_entry );
+                        while( i_options )
+                        {
+                            psz_name = ppsz_options[--i_options];
+                            FREENULL( psz_name );
+                        }
 
-                    if( psz_title_entry ) input_item_SetTitle( p_entry, psz_title_entry );
-                    if( psz_artist_entry ) input_item_SetArtist( p_entry, psz_artist_entry );
-                    if( psz_copyright_entry ) input_item_SetCopyright( p_entry, psz_copyright_entry );
-                    if( psz_moreinfo_entry ) input_item_SetURL( p_entry, psz_moreinfo_entry );
-                    if( psz_abstract_entry ) input_item_SetDescription( p_entry, psz_abstract_entry );
-                    input_ItemAddSubItem( p_current_input, p_entry );
-                    vlc_gc_decref( p_entry );
+                        if( psz_title_entry ) input_item_SetTitle( p_entry, psz_title_entry );
+                        if( psz_artist_entry ) input_item_SetArtist( p_entry, psz_artist_entry );
+                        if( psz_copyright_entry ) input_item_SetCopyright( p_entry, psz_copyright_entry );
+                        if( psz_moreinfo_entry ) input_item_SetURL( p_entry, psz_moreinfo_entry );
+                        if( psz_abstract_entry ) input_item_SetDescription( p_entry, psz_abstract_entry );
+                        input_item_AddSubItem( p_current_input, p_entry );
+                        vlc_gc_decref( p_entry );
+                    }
                 }
 
                 /* cleanup entry */;