+
+ if( NONEMPTY( psz_track_artist ) )
+ input_item_SetArtist( p_input_item, psz_track_artist );
+
+ if( NONEMPTY( psz_track_genre ) )
+ input_item_SetGenre( p_input_item, psz_track_genre );
+
+ if( NONEMPTY( psz_track_description ) )
+ input_item_SetDescription( p_input_item, psz_track_description );
+
+ if( NONEMPTY( psz_album ) )
+ input_item_SetAlbum( p_input_item, psz_album );
+
+ if( NONEMPTY( psz_year ) )
+ input_item_SetDate( p_input_item, psz_year );
+
+ char psz_num[3+1];
+ snprintf( psz_num, sizeof(psz_num), "%d", 1+i );
+ input_item_SetTrackNum( p_input_item, psz_num );
+
+ input_item_node_AppendItem( p_root, p_input_item );
+ vlc_gc_decref( p_input_item );
+ free( psz_uri ); free( psz_opt ); free( psz_name );
+ free( psz_first ); free( psz_last );
+ }
+#undef ON_EMPTY
+#undef NONEMPTY
+
+ input_item_node_PostAndDelete( p_root );
+
+ /* */
+ for( int i = 0; i < i_cd_text; i++ )
+ {
+ vlc_meta_t *p_meta = pp_cd_text[i];
+ if( !p_meta )
+ continue;
+ vlc_meta_Delete( p_meta );
+ }
+ free( pp_cd_text );
+
+#ifdef HAVE_LIBCDDB
+ if( p_disc )
+ cddb_disc_destroy( p_disc );
+#endif
+ return VLC_SUCCESS;
+}
+
+#ifdef HAVE_LIBCDDB
+static cddb_disc_t *GetCDDBInfo( access_t *p_access, int i_titles, int *p_sectors )
+{
+ if( var_InheritInteger( p_access, "album-art" ) == ALBUM_ART_WHEN_ASKED )
+ return NULL;
+
+ /* */
+ cddb_conn_t *p_cddb = cddb_new();
+ if( !p_cddb )
+ {
+ msg_Warn( p_access, "unable to use CDDB" );
+ return NULL;
+ }
+
+ /* */
+ char *psz_tmp = var_InheritString( p_access, "cddb-server" );
+ if( psz_tmp )
+ {
+ cddb_set_server_name( p_cddb, psz_tmp );
+ free( psz_tmp );
+ }
+
+ cddb_set_server_port( p_cddb, var_InheritInteger( p_access, "cddb-port" ) );
+
+ cddb_set_email_address( p_cddb, "vlc@videolan.org" );
+
+ /// \todo
+ cddb_cache_disable( p_cddb );
+
+// cddb_cache_set_dir( p_cddb,
+// var_InheritString( p_access,
+// MODULE_STRING "-cddb-cachedir") );
+
+ cddb_set_timeout( p_cddb, 10 );
+
+ /// \todo
+ cddb_http_disable( p_cddb );
+
+ /* */
+ cddb_disc_t *p_disc = cddb_disc_new();
+ if( !p_disc )
+ {
+ msg_Err( p_access, "unable to create CDDB disc structure." );
+ goto error;