X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Faccess%2Fcdda.c;h=e798d2191e06b5eb808a279a11b0463fedf2d401;hb=943b5ccc082784273bc21baa216527a605fc8e04;hp=e75899efe8888eb7d39af5e2d22cbdc57fe34e02;hpb=f360931e6659530396ed9ae6bd9bc95718404268;p=vlc diff --git a/modules/access/cdda.c b/modules/access/cdda.c index e75899efe8..e798d2191e 100644 --- a/modules/access/cdda.c +++ b/modules/access/cdda.c @@ -32,13 +32,21 @@ * Preamble *****************************************************************************/ -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include #include #include +#include +#include #include /* For WAVEHEADER */ #include "vcd/cdrom.h" +#warning playlist code must not be used here. #include #ifdef HAVE_LIBCDDB @@ -61,30 +69,30 @@ 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_capability( "access2", 10 ); + set_shortname( N_("Audio CD")); + set_description( N_("Audio CD input") ); + set_capability( "access", 10 ); set_category( CAT_INPUT ); set_subcategory( SUBCAT_INPUT_ACCESS ); set_callbacks( Open, Close ); add_usage_hint( N_("[cdda:][device][@[track]]") ); add_integer( "cdda-caching", DEFAULT_PTS_DELAY / 1000, NULL, CACHING_TEXT, - CACHING_LONGTEXT, VLC_TRUE ); + CACHING_LONGTEXT, true ); - add_integer( "cdda-track", -1 , NULL, NULL, NULL, VLC_TRUE ); + add_integer( "cdda-track", -1 , NULL, NULL, NULL, true ); change_internal(); - add_integer( "cdda-first-sector", -1, NULL, NULL, NULL, VLC_TRUE ); + add_integer( "cdda-first-sector", -1, NULL, NULL, NULL, true ); change_internal(); - add_integer( "cdda-last-sector", -1, NULL, NULL, NULL, VLC_TRUE ); + add_integer( "cdda-last-sector", -1, NULL, NULL, NULL, true ); change_internal(); add_string( "cddb-server", "freedb.freedb.org", NULL, N_( "CDDB Server" ), N_( "Address of the CDDB server to use." ), - VLC_TRUE ); + true ); add_integer( "cddb-port", 8880, NULL, N_( "CDDB port" ), N_( "CDDB Server port to use." ), - VLC_TRUE ); + true ); add_shortcut( "cdda" ); add_shortcut( "cddasimple" ); vlc_module_end(); @@ -107,7 +115,7 @@ struct access_sys_t /* Wave header for the output data */ WAVEHEADER waveheader; - vlc_bool_t b_header; + bool b_header; int i_track; int i_first_sector; @@ -149,11 +157,11 @@ static int Open( vlc_object_t *p_this ) psz_name = var_CreateGetString( p_this, "cd-audio" ); if( !psz_name || !*psz_name ) { - if( psz_name ) free( psz_name ); + free( psz_name ); return VLC_EGENERIC; } } - else psz_name = strdup( p_access->psz_path ); + else psz_name = ToLocaleDup( p_access->psz_path ); #ifdef WIN32 if( psz_name[0] && psz_name[1] == ':' && @@ -193,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, VLC_FALSE ); + p_item = playlist_ItemGetByInput( p_playlist, p_current, pl_Unlocked ); if( p_item ) i_ret = GetTracks( p_access, p_playlist, p_item ); @@ -201,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; @@ -280,7 +288,7 @@ static block_t *Block( access_t *p_access ) int i_blocks = CDDA_BLOCKS_ONCE; block_t *p_block; - if( p_sys->i_track < 0 ) p_access->info.b_eof = VLC_TRUE; + if( p_sys->i_track < 0 ) p_access->info.b_eof = true; /* Check end of file */ if( p_access->info.b_eof ) return NULL; @@ -290,13 +298,13 @@ static block_t *Block( access_t *p_access ) /* Return only the header */ p_block = block_New( p_access, sizeof( WAVEHEADER ) ); memcpy( p_block->p_buffer, &p_sys->waveheader, sizeof(WAVEHEADER) ); - p_sys->b_header = VLC_TRUE; + p_sys->b_header = true; return p_block; } if( p_sys->i_sector >= p_sys->i_last_sector ) { - p_access->info.b_eof = VLC_TRUE; + p_access->info.b_eof = true; return NULL; } @@ -350,7 +358,7 @@ static int Seek( access_t *p_access, int64_t i_pos ) *****************************************************************************/ static int Control( access_t *p_access, int i_query, va_list args ) { - vlc_bool_t *pb_bool; + bool *pb_bool; int *pi_int; int64_t *pi_64; @@ -360,8 +368,8 @@ static int Control( access_t *p_access, int i_query, va_list args ) case ACCESS_CAN_FASTSEEK: case ACCESS_CAN_PAUSE: case ACCESS_CAN_CONTROL_PACE: - pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t* ); - *pb_bool = VLC_TRUE; + pb_bool = (bool*)va_arg( args, bool* ); + *pb_bool = true; break; case ACCESS_GET_MTU: @@ -412,7 +420,7 @@ static int GetTracks( access_t *p_access, return VLC_EGENERIC; } - p_item_in_category = playlist_ItemToNode( p_playlist, p_parent, VLC_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 ); @@ -468,34 +476,31 @@ static int GetTracks( access_t *p_access, /* If we have CDDB info, change the name */ if( p_sys->p_disc ) { - const char *psz_result; cddb_track_t *t = cddb_disc_get_track( p_sys->p_disc, i ); if( t!= NULL ) { if( cddb_track_get_title( t ) != NULL ) { - input_ItemAddInfo( p_input_item, _(VLC_META_INFO_CAT), - _(VLC_META_TITLE), - "%s", cddb_track_get_title( t ) ); - if( p_input_item->psz_name ) - free( p_input_item->psz_name ); + 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 ) ); } - psz_result = cddb_track_get_artist( t ); - if( psz_result ) + if( cddb_track_get_artist( t ) != NULL ) { - input_ItemAddInfo( p_input_item, _(VLC_META_INFO_CAT), - _(VLC_META_ARTIST), "%s", psz_result ); + input_item_SetArtist( p_input_item, cddb_track_get_artist( t ) ); } } } #endif - playlist_BothAddInput( p_playlist, p_input_item, p_item_in_category, + int i_ret = playlist_BothAddInput( p_playlist, p_input_item, + p_item_in_category, PLAYLIST_APPEND, PLAYLIST_END, NULL, NULL, - VLC_FALSE ); + 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; } return VLC_SUCCESS; } @@ -513,9 +518,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 ); @@ -544,7 +551,7 @@ static void GetCDDBInfo( access_t *p_access, int i_titles, int *p_sectors ) cddb_disc_add_track( p_access->p_sys->p_disc, t ); i_size = ( p_sectors[i+1] - p_sectors[i] ) * (int64_t)CDDA_DATA_SIZE; - i_length += I64C(1000000) * i_size / 44100 / 4 ; + i_length += INT64_C(1000000) * i_size / 44100 / 4 ; } cddb_disc_set_length( p_access->p_sys->p_disc, (int)(i_length/1000000) );