+ /* CD-Text */
+ vlc_meta_t **pp_cd_text;
+ int i_cd_text;
+
+ if( ioctl_GetCdText( VLC_OBJECT(p_access), p_sys->vcddev, &pp_cd_text, &i_cd_text ) )
+ {
+ msg_Dbg( p_access, "CD-TEXT information missing" );
+ i_cd_text = 0;
+ pp_cd_text = NULL;
+ }
+
+ /* Retrieve CD-TEXT informations but prefer CDDB */
+ if( i_cd_text > 0 && pp_cd_text[0] )
+ {
+ const vlc_meta_t *p_disc = pp_cd_text[0];
+ ON_EMPTY( psz_album, vlc_meta_Get( p_disc, vlc_meta_Album ) );
+ ON_EMPTY( psz_genre, vlc_meta_Get( p_disc, vlc_meta_Genre ) );
+ ON_EMPTY( psz_artist, vlc_meta_Get( p_disc, vlc_meta_Artist ) );
+ ON_EMPTY( psz_description, vlc_meta_Get( p_disc, vlc_meta_Description ) );
+ }
+
+ if( NONEMPTY( psz_album ) )
+ {
+ input_item_SetName( p_current, psz_album );
+ input_item_SetAlbum( p_current, psz_album );
+ }
+
+ if( NONEMPTY( psz_genre ) )
+ input_item_SetGenre( p_current, psz_genre );
+
+ if( NONEMPTY( psz_artist ) )
+ input_item_SetArtist( p_current, psz_artist );
+
+ if( NONEMPTY( psz_year ) )
+ input_item_SetDate( p_current, psz_year );
+
+ if( NONEMPTY( psz_description ) )
+ input_item_SetDescription( p_current, psz_description );
+
+ const mtime_t i_duration = (int64_t)( p_sys->p_sectors[i_titles] - p_sys->p_sectors[0] ) *
+ CDDA_DATA_SIZE * 1000000 / 44100 / 2 / 2;
+ input_item_SetDuration( p_current, i_duration );
+
+ input_item_node_t *p_root = input_item_node_Create( p_current );
+
+ /* Build title table */
+ for( int i = 0; i < i_titles; i++ )
+ {
+ input_item_t *p_input_item;
+
+ char *psz_uri, *psz_opt, *psz_first, *psz_last;
+ char *psz_name;
+
+ msg_Dbg( p_access, "track[%d] start=%d", i, p_sys->p_sectors[i] );
+
+ /* */
+ if( asprintf( &psz_uri, "cdda://%s", p_access->psz_path ) == -1 )
+ psz_uri = NULL;
+ if( asprintf( &psz_opt, "cdda-track=%i", i+1 ) == -1 )
+ psz_opt = NULL;
+ if( asprintf( &psz_first, "cdda-first-sector=%i",p_sys->p_sectors[i] ) == -1 )
+ psz_first = NULL;
+ if( asprintf( &psz_last, "cdda-last-sector=%i", p_sys->p_sectors[i+1] ) == -1 )
+ psz_last = NULL;
+
+ /* Define a "default name" */
+ if( asprintf( &psz_name, _("Audio CD - Track %02i"), (i+1) ) == -1 )
+ psz_name = NULL;
+
+ /* Create playlist items */
+ const mtime_t i_duration = (int64_t)( p_sys->p_sectors[i+1] - p_sys->p_sectors[i] ) *
+ CDDA_DATA_SIZE * 1000000 / 44100 / 2 / 2;
+ p_input_item = input_item_NewWithType( VLC_OBJECT( p_access ),
+ psz_uri, psz_name, 0, NULL, 0, i_duration,
+ ITEM_TYPE_DISC );
+ input_item_CopyOptions( p_current, p_input_item );
+ input_item_AddOption( p_input_item, psz_first, VLC_INPUT_OPTION_TRUSTED );
+ input_item_AddOption( p_input_item, psz_last, VLC_INPUT_OPTION_TRUSTED );
+ input_item_AddOption( p_input_item, psz_opt, VLC_INPUT_OPTION_TRUSTED );
+
+ const char *psz_track_title = NULL;
+ const char *psz_track_artist = NULL;
+ const char *psz_track_genre = NULL;
+ const char *psz_track_description = NULL;
+
+#ifdef HAVE_LIBCDDB
+ /* Retreive CDDB informations */
+ if( p_disc )
+ {
+ cddb_track_t *t = cddb_disc_get_track( p_disc, i );
+ if( t != NULL )