+ /* Build title table */
+ for( i = 0; i < i_titles; i++ )
+ {
+ msg_Dbg( p_access, "track[%d] start=%d", i, p_sys->p_sectors[i] );
+ char *psz_uri, *psz_opt, *psz_first, *psz_last;
+ int i_path_len = p_access->psz_path ? strlen( p_access->psz_path ) : 0;
+
+ psz_name = (char*)malloc( strlen( _("Audio CD - Track ") ) + 5 );
+ psz_opt = (char*)malloc( strlen( "cdda-track=" ) + 3 );
+ psz_first = (char*)malloc( strlen( "cdda-first-sector=" ) + 7 );
+ psz_last = (char*)malloc( strlen( "cdda-last-sector=" ) + 7 );
+ psz_uri = (char*)malloc( i_path_len + 13 );
+
+ snprintf( psz_uri, i_path_len + 13, "cdda://%s",
+ p_access->psz_path ? p_access->psz_path : "" );
+ sprintf( psz_opt, "cdda-track=%i", i+1 );
+ sprintf( psz_first, "cdda-first-sector=%i",p_sys->p_sectors[i] );
+
+// if( i != i_titles -1 )
+ sprintf( psz_last, "cdda-last-sector=%i", p_sys->p_sectors[i+1] );
+// else
+// sprintf( psz_last, "cdda-last-sector=%i", 1242 /* FIXME */);
+
+ /* Define a "default name" */
+ sprintf( psz_name, _("Audio CD - Track %i"), (i+1) );
+
+ /* Create playlist items */
+ p_input_item = input_ItemNewWithType( VLC_OBJECT( p_playlist ),
+ psz_uri, psz_name, 0, NULL, -1,
+ ITEM_TYPE_DISC );
+ input_ItemAddOption( p_input_item, psz_first );
+ input_ItemAddOption( p_input_item, psz_last );
+ input_ItemAddOption( p_input_item, psz_opt );
+
+#ifdef HAVE_LIBCDDB
+ /* If we have CDDB info, change the name */
+ if( p_sys->p_disc )
+ {
+ cddb_track_t *t = cddb_disc_get_track( p_sys->p_disc, i );
+ if( t!= NULL )
+ {
+ if( cddb_track_get_title( t ) != NULL )
+ {
+ free( p_input_item->psz_name );
+ p_input_item->psz_name = strdup( cddb_track_get_title( t ) );
+ input_item_SetTitle( p_input_item, cddb_track_get_title( t ) );
+ }
+ if( cddb_track_get_artist( t ) != NULL )
+ {
+ input_item_SetArtist( p_input_item, cddb_track_get_artist( t ) );
+ }
+ }
+ }
+#endif
+ int i_ret = playlist_BothAddInput( p_playlist, p_input_item,
+ p_item_in_category,
+ PLAYLIST_APPEND, PLAYLIST_END, NULL, NULL,
+ pl_Unlocked );
+ vlc_gc_decref( p_input_item );
+ free( psz_uri ); free( psz_opt ); free( psz_name );
+ free( psz_first ); free( psz_last );
+ if( i_ret != VLC_SUCCESS )
+ return VLC_EGENERIC;
+ }