X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Faccess%2Fcdda.c;h=a5d93adb9e4338e7f7c9b58063b8ae4a26f197b1;hb=d2348d98b49475c0868d43bf79639a5980d75c84;hp=bc54f686e93073d6d801133c7c8b88c8466a8361;hpb=27d483e9ef7a451397d7857251c8d67097661f1d;p=vlc diff --git a/modules/access/cdda.c b/modules/access/cdda.c index bc54f686e9..a5d93adb9e 100644 --- a/modules/access/cdda.c +++ b/modules/access/cdda.c @@ -36,7 +36,7 @@ # include "config.h" #endif -#include +#include #include #include #include @@ -46,6 +46,7 @@ #include /* For WAVEHEADER */ #include "vcd/cdrom.h" +#warning playlist code must not be used here. #include #ifdef HAVE_LIBCDDB @@ -68,8 +69,8 @@ static void Close( vlc_object_t * ); "value should be set in milliseconds." ) vlc_module_begin(); - set_shortname( _("Audio CD")); - set_description( _("Audio CD input") ); + set_shortname( N_("Audio CD")); + set_description( N_("Audio CD input") ); set_capability( "access", 10 ); set_category( CAT_INPUT ); set_subcategory( SUBCAT_INPUT_ACCESS ); @@ -200,7 +201,7 @@ static int Open( vlc_object_t *p_this ) if( p_playlist->status.p_item->p_input == p_current ) p_item = p_playlist->status.p_item; else - p_item = playlist_ItemGetByInput( p_playlist, p_current, false ); + p_item = playlist_ItemGetByInput( p_playlist, p_current, pl_Unlocked ); if( p_item ) i_ret = GetTracks( p_access, p_playlist, p_item ); @@ -208,7 +209,7 @@ static int Open( vlc_object_t *p_this ) msg_Dbg( p_playlist, "unable to find item in playlist"); vlc_object_release( p_input ); } - vlc_object_release( p_playlist ); + pl_Release( p_access ); } if( i_ret < 0 ) goto error; @@ -419,7 +420,7 @@ static int GetTracks( access_t *p_access, return VLC_EGENERIC; } - p_item_in_category = playlist_ItemToNode( p_playlist, p_parent, false ); + p_item_in_category = playlist_ItemToNode( p_playlist, p_parent, pl_Unlocked ); playlist_ItemSetName( p_parent, "Audio CD" ); var_SetInteger( p_playlist, "item-change", p_parent->p_input->i_id ); @@ -442,34 +443,36 @@ static int GetTracks( access_t *p_access, { 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( asprintf( &psz_uri, "cdda://%s", p_access->psz_path ? 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( 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 */); +// { + if( asprintf( &psz_last, "cdda-last-sector=%i", p_sys->p_sectors[i+1] ) == -1 ) + psz_last = NULL; +// } +// else +// { +// if( asprintf( &psz_last, "cdda-last-sector=%i", 1242 /* FIXME */) == -1 ) +// psz_last = NULL; +// } /* Define a "default name" */ - sprintf( psz_name, _("Audio CD - Track %i"), (i+1) ); + if( asprintf( &psz_name, _("Audio CD - Track %i"), (i+1) ) == -1 ) + psz_name = NULL; /* Create playlist items */ - p_input_item = input_ItemNewWithType( VLC_OBJECT( p_playlist ), + p_input_item = input_item_NewWithType( 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 ); + input_item_AddOption( p_input_item, psz_first ); + input_item_AddOption( p_input_item, psz_last ); + input_item_AddOption( p_input_item, psz_opt ); #ifdef HAVE_LIBCDDB /* If we have CDDB info, change the name */ @@ -494,7 +497,7 @@ static int GetTracks( access_t *p_access, int i_ret = playlist_BothAddInput( p_playlist, p_input_item, p_item_in_category, PLAYLIST_APPEND, PLAYLIST_END, NULL, NULL, - false ); + pl_Unlocked ); vlc_gc_decref( p_input_item ); free( psz_uri ); free( psz_opt ); free( psz_name ); free( psz_first ); free( psz_last ); @@ -517,9 +520,11 @@ static void GetCDDBInfo( access_t *p_access, int i_titles, int *p_sectors ) goto cddb_destroy; } + char* psz_tmp = config_GetPsz( p_access, "cddb-server" ); cddb_set_email_address( p_cddb, "vlc@videolan.org" ); - cddb_set_server_name( p_cddb, config_GetPsz( p_access, "cddb-server" ) ); + cddb_set_server_name( p_cddb, psz_tmp ); cddb_set_server_port( p_cddb, config_GetInt( p_access, "cddb-port" ) ); + free( psz_tmp ); /// \todo cddb_cache_disable( p_cddb );