X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Faccess%2Fcdda%2Faccess.c;h=da76ede67f3f641e802e62f058527e897c7e405d;hb=72fa5a9d8e8f5a1bbe0d83ffd1f30b3265a531c7;hp=07b3992b6b5c09c61f4a5346349ddeaa571c4270;hpb=9e595c955f1aebae18435f0f5c740802ce347852;p=vlc diff --git a/modules/access/cdda/access.c b/modules/access/cdda/access.c index 07b3992b6b..da76ede67f 100644 --- a/modules/access/cdda/access.c +++ b/modules/access/cdda/access.c @@ -30,7 +30,6 @@ #include "cdda.h" /* private structures. Also #includes vlc things */ #include "info.h" /* headers for meta info retrieval */ #include "access.h" -#include /* Has to come *after* cdda.h */ #include "vlc_keys.h" #include @@ -40,16 +39,11 @@ /* #ifdef variables below are defined via config.h via #include vlc above. */ -#ifdef HAVE_STDLIB_H -#endif #ifdef HAVE_SYS_TYPES_H #include #endif -#ifdef HAVE_STRING_H -#endif - #ifdef HAVE_UNISTD_H # include #endif @@ -60,7 +54,7 @@ access_t *p_cdda_input = NULL; /***************************************************************************** * Local prototypes *****************************************************************************/ -static int CDDARead( access_t *, uint8_t *, int ); +static ssize_t CDDARead( access_t *, uint8_t *, size_t ); static block_t *CDDAReadBlocks( access_t * p_access ); static int CDDASeek( access_t * p_access, int64_t i_pos ); static int CDDAControl( access_t *p_access, int i_query, @@ -73,7 +67,7 @@ static int CDDAInit( access_t *p_access, cdda_data_t *p_cdda ) ; * Private functions ****************************************************************************/ -/* process messages that originate from libcdio. +/* process messages that originate from libcdio. called by CDDAOpen */ static void @@ -165,7 +159,7 @@ uninit_log_handler( cdio_log_level_t level, const char message[] ) /* gl_default_cdio_log_handler (level, message); */ } -/* Only used in audio control mode. Gets the current LSN from the +/* Only used in audio control mode. Gets the current LSN from the CD-ROM drive. */ static int64_t get_audio_position ( access_t *p_access ) { @@ -220,7 +214,7 @@ static block_t * CDDAReadBlocks( access_t * p_access ) cdda_data_t *p_cdda = (cdda_data_t *) p_access->p_sys; int i_blocks = p_cdda->i_blocks_per_read; - dbg_print( (INPUT_DBG_CALL|INPUT_DBG_EXT|INPUT_DBG_LSN), + dbg_print( (INPUT_DBG_CALL|INPUT_DBG_EXT|INPUT_DBG_LSN), "called i_lsn: %d i_pos: %lld, size: %lld", p_cdda->i_lsn, p_access->info.i_pos, p_access->info.i_size ); @@ -233,7 +227,7 @@ static block_t * CDDAReadBlocks( access_t * p_access ) /* Return only the dummy RIFF header we created in Open/Init */ p_block = block_New( p_access, sizeof( WAVEHEADER ) ); memcpy( p_block->p_buffer, &p_cdda->waveheader, sizeof(WAVEHEADER) ); - p_cdda->b_header = VLC_TRUE; + p_cdda->b_header = true; return p_block; } @@ -251,7 +245,7 @@ static block_t * CDDAReadBlocks( access_t * p_access ) if( go_on ) { dbg_print( (INPUT_DBG_LSN), "EOF"); - p_access->info.b_eof = VLC_TRUE; + p_access->info.b_eof = true; return NULL; } @@ -288,8 +282,8 @@ static block_t * CDDAReadBlocks( access_t * p_access ) { msg_Err( p_access, "cannot get a new block of size: %i", i_blocks * CDIO_CD_FRAMESIZE_RAW ); - intf_UserFatal( p_access, VLC_FALSE, _("CD reading failed"), - _("VLC could not get a new block of size: %i."), + intf_UserFatal( p_access, false, _("CD reading failed"), + _("VLC could not get a new block of size: %i."), i_blocks * CDIO_CD_FRAMESIZE_RAW ); return NULL; } @@ -308,14 +302,14 @@ static block_t * CDDAReadBlocks( access_t * p_access ) char *psz_mes = cdio_cddap_messages( p_cdda->paranoia_cd ); if( psz_mes || psz_err ) - msg_Err( p_access, "%s%s\n", psz_mes ? psz_mes: "", + msg_Err( p_access, "%s%s", psz_mes ? psz_mes: "", psz_err ? psz_err: "" ); - if( psz_err ) free( psz_err ); - if( psz_mes ) free( psz_mes ); + free( psz_err ); + free( psz_mes ); if( !p_readbuf ) { - msg_Err( p_access, "paranoia read error on frame %i\n", + msg_Err( p_access, "paranoia read error on frame %i", p_cdda->i_lsn+i ); } else @@ -359,8 +353,8 @@ static block_t * CDDAReadBlocks( access_t * p_access ) /***************************************************************************** * CDDARead: Handler for audio control reads the CD-DA. *****************************************************************************/ -static int -CDDARead( access_t * p_access, uint8_t *p_buffer, int i_len ) +static ssize_t +CDDARead( access_t * p_access, uint8_t *p_buffer, size_t i_len ) { cdda_data_t *p_cdda = (cdda_data_t *) p_access->p_sys; @@ -394,7 +388,7 @@ CDDARead( access_t * p_access, uint8_t *p_buffer, int i_len ) if( p_cdda->i_track >= p_cdda->i_first_track + p_cdda->i_titles - 1 ) { dbg_print( (INPUT_DBG_LSN), "EOF"); - p_access->info.b_eof = VLC_TRUE; + p_access->info.b_eof = true; return 0; } p_access->info.i_update |= INPUT_UPDATE_TITLE; @@ -405,7 +399,7 @@ CDDARead( access_t * p_access, uint8_t *p_buffer, int i_len ) { char *psz_title = CDDAFormatTitle( p_access, p_cdda->i_track ); input_Control( p_cdda->p_input, INPUT_SET_NAME, psz_title ); - free(psz_title); + free( psz_title ); } else { @@ -510,7 +504,7 @@ static int CDDASeek( access_t * p_access, int64_t i_pos ) } p_access->info.i_pos = i_pos; - p_access->info.b_eof = VLC_FALSE; + p_access->info.b_eof = false; return VLC_SUCCESS; } @@ -534,7 +528,7 @@ static bool cdda_play_track( access_t *p_access, track_t i_track ) p_cdda->i_track = i_track; /* set up the frame boundaries for this particular track */ - p_cdda->first_frame = p_cdda->i_lsn = + p_cdda->first_frame = p_cdda->i_lsn = cdio_get_track_lsn( p_cdda->p_cdio, i_track ); p_cdda->last_frame = cdio_get_track_lsn( p_cdda->p_cdio, i_track+1 ) - 1; @@ -568,7 +562,7 @@ int CDDAOpen( vlc_object_t *p_this ) cdda_data_t *p_cdda = NULL; CdIo_t *p_cdio; track_t i_track = 1; - vlc_bool_t b_single_track = false; + bool b_single_track = false; int i_rc = VLC_EGENERIC; p_access->p_sys = NULL; @@ -603,6 +597,7 @@ int CDDAOpen( vlc_object_t *p_this ) if( !psz_source || !*psz_source ) { + free( psz_source ); /* No device/track given. Continue only when this plugin was selected */ if( !p_this->b_force ) @@ -611,6 +606,7 @@ int CDDAOpen( vlc_object_t *p_this ) psz_source = var_CreateGetString( p_this, "cd-audio" ); if( !psz_source || !*psz_source ) { + free( psz_source ); /* Scan for a CD-ROM drive with a CD-DA in it. */ char **ppsz_drives = cdio_get_devices_with_cap( NULL, CDIO_FS_AUDIO, false ); @@ -633,15 +629,13 @@ int CDDAOpen( vlc_object_t *p_this ) if( !(p_cdio = cdio_open( psz_source, DRIVER_UNKNOWN )) ) { msg_Warn( p_access, "could not open %s", psz_source ); - if ( psz_source ) - free( psz_source ); + free( psz_source ); return VLC_EGENERIC; } p_cdda = calloc( 1, sizeof(cdda_data_t) ); if( p_cdda == NULL ) { - msg_Err( p_access, "out of memory" ); free( psz_source ); return VLC_ENOMEM; } @@ -662,7 +656,7 @@ int CDDAOpen( vlc_object_t *p_this ) #endif p_cdda->psz_source = strdup( psz_source ); - p_cdda->b_header = VLC_FALSE; + p_cdda->b_header = false; p_cdda->p_cdio = p_cdio; p_cdda->i_tracks = 0; p_cdda->i_titles = 0; @@ -722,7 +716,7 @@ int CDDAOpen( vlc_object_t *p_this ) } p_access->info.i_update = 0; - p_access->info.b_eof = VLC_FALSE; + p_access->info.b_eof = false; p_access->info.i_title = 0; p_access->info.i_seekpoint = 0; @@ -779,6 +773,7 @@ int CDDAOpen( vlc_object_t *p_this ) } } } + free( psz_paranoia ); } #endif @@ -810,11 +805,12 @@ int CDDAOpen( vlc_object_t *p_this ) var_Create( p_access, MODULE_STRING "-caching", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT ); vlc_object_release( p_cdda->p_input ); + free( psz_source ); return VLC_SUCCESS; error: cdio_destroy( p_cdda->p_cdio ); - if( psz_source) free( psz_source ); + free( psz_source ); if( p_cdda ) { if ( p_cdda->p_input ) @@ -862,8 +858,8 @@ void CDDAClose (vlc_object_t *p_this ) cdio_cddap_close_no_free_cdio( p_cdda->paranoia_cd ); #endif - if( p_cdda->psz_mcn ) free( p_cdda->psz_mcn ); - if( p_cdda->psz_source ) free( p_cdda->psz_source ); + free( p_cdda->psz_mcn ); + free( p_cdda->psz_source ); #if LIBCDDB_VERSION_NUM >= 1 libcddb_shutdown(); @@ -912,8 +908,8 @@ static int CDDAControl( access_t *p_access, int i_query, va_list args ) case ACCESS_CAN_CONTROL_PACE: { - vlc_bool_t *pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t* ); - *pb_bool = p_cdda->b_audio_ctl ? VLC_FALSE : VLC_TRUE; + bool *pb_bool = (bool*)va_arg( args, bool* ); + *pb_bool = p_cdda->b_audio_ctl ? false : true; dbg_print( INPUT_DBG_META, "can control pace? %d", *pb_bool); return VLC_SUCCESS; } @@ -928,20 +924,11 @@ static int CDDAControl( access_t *p_access, int i_query, va_list args ) dbg_print( INPUT_DBG_META, "can pause?"); common: { - vlc_bool_t *pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t* ); - *pb_bool = VLC_TRUE; + bool *pb_bool = (bool*)va_arg( args, bool* ); + *pb_bool = true; return VLC_SUCCESS; } - /* */ - case ACCESS_GET_MTU: - { - pi_int = (int*)va_arg( args, int * ); - *pi_int = p_cdda-> i_blocks_per_read * CDIO_CD_FRAMESIZE_RAW; - dbg_print( INPUT_DBG_META, "Get MTU %d", *pi_int); - break; - } - case ACCESS_GET_PTS_DELAY: { int64_t *pi_64 = (int64_t*)va_arg( args, int64_t * ); @@ -1011,7 +998,7 @@ static int CDDAControl( access_t *p_access, int i_query, va_list args ) char *psz_title = CDDAFormatTitle( p_access, i_track ); input_Control( p_cdda->p_input, INPUT_SET_NAME, psz_title ); - free(psz_title); + free( psz_title ); p_cdda->i_track = i_track; i_last_lsn = cdio_get_track_lsn( p_cdda->p_cdio, CDIO_CDROM_LEADOUT_TRACK ); @@ -1099,7 +1086,7 @@ static int CDDAInit( access_t *p_access, cdda_data_t *p_cdda ) return VLC_SUCCESS; } -/* +/* * Local variables: * mode: C * style: gnu