*****************************************************************************/
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,
- va_list args );
+static int CDDAControl( access_t *p_access, int i_query,
+ va_list args );
static int CDDAInit( access_t *p_access, cdda_data_t *p_cdda ) ;
static void
cddb_log_handler (cddb_log_level_t level, const char message[])
{
- cdda_data_t *p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
- switch (level) {
- case CDDB_LOG_DEBUG:
- case CDDB_LOG_INFO:
- if (!(p_cdda->i_debug & INPUT_DBG_CDDB)) return;
- /* Fall through if to warn case */
- default:
- cdio_log_handler (level, message);
- }
+ cdda_data_t *p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
+ switch (level)
+ {
+ case CDDB_LOG_DEBUG:
+ case CDDB_LOG_INFO:
+ if (!(p_cdda->i_debug & INPUT_DBG_CDDB)) return;
+
+ /* Fall through if to warn case */
+ default:
+ cdio_log_handler (level, message);
+ }
}
#endif /*HAVE_LIBCDDB*/
static void
uninit_log_handler (cdio_log_level_t level, const char message[])
{
- cdda_data_t *p_cdda = NULL;
+ cdda_data_t *p_cdda = NULL;
- if (p_cdda_input)
- p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
+ if (p_cdda_input)
+ p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
- switch (level) {
- case CDIO_LOG_DEBUG:
- case CDIO_LOG_INFO:
- if (!p_cdda || !(p_cdda->i_debug & (INPUT_DBG_CDIO|INPUT_DBG_CDDB)))
- return;
- /* Fall through if to warn case */
- case CDIO_LOG_WARN:
- fprintf(stderr, "WARN: %s\n", message);
- break;
- case CDIO_LOG_ERROR:
- fprintf(stderr, "ERROR: %s\n", message);
- break;
- case CDIO_LOG_ASSERT:
- fprintf(stderr, "ASSERT ERROR: %s\n", message);
- break;
- default:
- fprintf(stderr, "UNKNOWN ERROR: %s\n%s %d\n",
- message,
- "The above message had unknown cdio log level",
- level);
- }
+ switch (level)
+ {
+ case CDIO_LOG_DEBUG:
+ case CDIO_LOG_INFO:
+ if (!p_cdda || !(p_cdda->i_debug & (INPUT_DBG_CDIO|INPUT_DBG_CDDB)))
+ return;
+
+ /* Fall through if to warn case */
+ case CDIO_LOG_WARN:
+ fprintf(stderr, "WARN: %s\n", message);
+ break;
+ case CDIO_LOG_ERROR:
+ fprintf(stderr, "ERROR: %s\n", message);
+ break;
+ case CDIO_LOG_ASSERT:
+ fprintf(stderr, "ASSERT ERROR: %s\n", message);
+ break;
+ default:
+ fprintf(stderr, "UNKNOWN ERROR: %s\n%s %d\n", message,
+ "The above message had unknown cdio log level",
+ level);
+ }
- /* gl_default_cdio_log_handler (level, message); */
+ /* gl_default_cdio_log_handler (level, message); */
}
/*****************************************************************************
* read. It is also possible if we haven't read a RIFF header in which
* case one that we creaded during Open/Initialization is returned.
*****************************************************************************/
-static block_t *
-CDDAReadBlocks( access_t * p_access )
+static block_t * CDDAReadBlocks( access_t * p_access )
{
block_t *p_block;
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), "called %d",
- p_cdda->i_lsn);
+ dbg_print((INPUT_DBG_CALL|INPUT_DBG_EXT|INPUT_DBG_LSN), "called %d",
+ p_cdda->i_lsn);
/* Check end of file */
if( p_access->info.b_eof ) return NULL;
p_access->info.i_update |= INPUT_UPDATE_TITLE | INPUT_UPDATE_SIZE;
p_access->info.i_title++;
- p_access->info.i_size =
- p_cdda->p_title[p_access->info.i_title]->i_size;
+ p_access->info.i_size =
+ p_cdda->p_title[p_access->info.i_title]->i_size;
p_access->info.i_pos = 0;
- p_cdda->i_track++;
+ p_cdda->i_track++;
}
/* Possibly adjust i_blocks so we don't read past the end of a track. */
if( !p_block)
{
msg_Err( p_access, "Cannot get a new block of size: %i",
- i_blocks * CDIO_CD_FRAMESIZE_RAW );
+ i_blocks * CDIO_CD_FRAMESIZE_RAW );
return NULL;
}
if( cdio_read_audio_sectors( p_cdda->p_cdio, p_block->p_buffer,
p_cdda->i_lsn, i_blocks) != 0 )
- {
- msg_Err( p_access, "could not read sector %lu",
- (long unsigned int) p_cdda->i_lsn );
- block_Release( p_block );
-
- /* If we had problems above, assume the problem is with
- the first sector of the read and set to skip it. In
- the future libcdio may have cdparanoia support.
- */
- p_cdda->i_lsn++;
- p_access->info.i_pos += CDIO_CD_FRAMESIZE_RAW;
- return NULL;
- }
-
+ {
+ msg_Err( p_access, "could not read sector %lu",
+ (long unsigned int) p_cdda->i_lsn );
+ block_Release( p_block );
+
+ /* If we had problems above, assume the problem is with
+ the first sector of the read and set to skip it. In
+ the future libcdio may have cdparanoia support.
+ */
+ p_cdda->i_lsn++;
+ p_access->info.i_pos += CDIO_CD_FRAMESIZE_RAW;
+ return NULL;
+ }
+
p_cdda->i_lsn += i_blocks;
p_access->info.i_pos += p_block->i_buffer;
* CDDASeek - change position for subsequent reads. For example, this
* can happen if the user moves a position slider bar in a GUI.
****************************************************************************/
-static int
-CDDASeek( access_t * p_access, int64_t i_pos )
+static int CDDASeek( access_t * p_access, int64_t i_pos )
{
cdda_data_t *p_cdda = (cdda_data_t *) p_access->p_sys;
p_access->info.i_pos = i_pos;
dbg_print( (INPUT_DBG_CALL|INPUT_DBG_EXT|INPUT_DBG_SEEK),
- "lsn %lu, offset: %lld",
- (long unsigned int) p_cdda->i_lsn, i_pos );
+ "lsn %lu, offset: %lld",
+ (long unsigned int) p_cdda->i_lsn, i_pos );
return VLC_SUCCESS;
}
****************************************************************************/
/*****************************************************************************
- * Open: open cdda device or image file and initialize structures
- * for subsequent operations.
+ * Open: open cdda device or image file and initialize structures
+ * for subsequent operations.
*****************************************************************************/
-int
-E_(CDDAOpen)( vlc_object_t *p_this )
+int E_(CDDAOpen)( vlc_object_t *p_this )
{
access_t *p_access = (access_t*)p_this;
char * psz_source = NULL;
if( p_access->psz_path && *p_access->psz_path )
{
- char *psz_parser = psz_source = strdup( p_access->psz_path );
-
- while( *psz_parser && *psz_parser != '@' )
- {
- psz_parser++;
- }
-
- if( *psz_parser == '@' )
- {
- /* Found options */
- *psz_parser = '\0';
- ++psz_parser;
-
- if ('T' == *psz_parser || 't' == *psz_parser )
+ char *psz_parser = psz_source = strdup( p_access->psz_path );
+
+ while( *psz_parser && *psz_parser != '@' )
+ {
+ psz_parser++;
+ }
+
+ if( *psz_parser == '@' )
+ {
+ /* Found options */
+ *psz_parser = '\0';
+ ++psz_parser;
+
+ if ('T' == *psz_parser || 't' == *psz_parser )
++psz_parser;
-
- i_track = (int)strtol( psz_parser, NULL, 10 );
- i_track = i_track ? i_track : 1;
- b_single_track = true;
- }
- }
+
+ i_track = (int)strtol( psz_parser, NULL, 10 );
+ i_track = i_track ? i_track : 1;
+ b_single_track = true;
+ }
+ }
if (!psz_source || !*psz_source)
- {
- /* No device/track given. Continue only when this plugin was
- selected */
+ {
+ /* No device/track given. Continue only when this plugin was
+ selected */
if( !p_this->b_force ) return VLC_EGENERIC;
psz_source = var_CreateGetString( p_this, "cd-audio" );
- if( !psz_source || !*psz_source ) {
- /* Scan for a CD-ROM drive with a CD-DA in it. */
- char **cd_drives =
- cdio_get_devices_with_cap(NULL, CDIO_FS_AUDIO, false);
-
- if (NULL == cd_drives || NULL == cd_drives[0] ) {
- msg_Err( p_access,
- "libcdio couldn't find something with a CD-DA in it" );
- if (cd_drives) cdio_free_device_list(cd_drives);
- return VLC_EGENERIC;
- }
-
- psz_source = strdup(cd_drives[0]);
- cdio_free_device_list(cd_drives);
- }
+ if( !psz_source || !*psz_source )
+ {
+ /* Scan for a CD-ROM drive with a CD-DA in it. */
+ char **cd_drives =
+ cdio_get_devices_with_cap(NULL, CDIO_FS_AUDIO, false);
+
+ if (NULL == cd_drives || NULL == cd_drives[0] )
+ {
+ msg_Err( p_access,
+ "libcdio couldn't find something with a CD-DA in it" );
+ if (cd_drives) cdio_free_device_list(cd_drives);
+ return VLC_EGENERIC;
+ }
+
+ psz_source = strdup(cd_drives[0]);
+ cdio_free_device_list(cd_drives);
+ }
}
cdio_log_set_handler ( cdio_log_handler );
if( !(p_cdio = cdio_open( psz_source, DRIVER_UNKNOWN )) )
{
msg_Warn( p_access, "could not open %s", psz_source );
- goto error2;
+ goto error2;
}
p_cdda = malloc( sizeof(cdda_data_t) );
p_cdda->i_blocks_per_read
= config_GetInt(p_this, MODULE_STRING "-blocks-per-read");
- p_cdda->p_input = vlc_object_find( p_access, VLC_OBJECT_INPUT,
- FIND_PARENT );
+ p_cdda->p_input = vlc_object_find( p_access, VLC_OBJECT_INPUT,
+ FIND_PARENT );
if (0 == p_cdda->i_blocks_per_read)
- p_cdda->i_blocks_per_read = DEFAULT_BLOCKS_PER_READ;
-
- if ( p_cdda->i_blocks_per_read < MIN_BLOCKS_PER_READ
- || p_cdda->i_blocks_per_read > MAX_BLOCKS_PER_READ ) {
- msg_Warn( p_cdda_input,
- "Number of blocks (%d) has to be between %d and %d. "
- "Using %d.",
- p_cdda->i_blocks_per_read,
- MIN_BLOCKS_PER_READ, MAX_BLOCKS_PER_READ,
- DEFAULT_BLOCKS_PER_READ );
- p_cdda->i_blocks_per_read = DEFAULT_BLOCKS_PER_READ;
- }
+ p_cdda->i_blocks_per_read = DEFAULT_BLOCKS_PER_READ;
+ if ( p_cdda->i_blocks_per_read < MIN_BLOCKS_PER_READ
+ || p_cdda->i_blocks_per_read > MAX_BLOCKS_PER_READ )
+ {
+ msg_Warn( p_cdda_input,
+ "Number of blocks (%d) has to be between %d and %d. "
+ "Using %d.",
+ p_cdda->i_blocks_per_read,
+ MIN_BLOCKS_PER_READ, MAX_BLOCKS_PER_READ,
+ DEFAULT_BLOCKS_PER_READ );
+ p_cdda->i_blocks_per_read = DEFAULT_BLOCKS_PER_READ;
+ }
dbg_print( (INPUT_DBG_CALL|INPUT_DBG_EXT), "%s", psz_source );
if ( VLC_SUCCESS != i_rc ) goto error;
CDDAFixupPlaylist( p_access, p_cdda, psz_source, b_single_track );
-
- /* Build a WAV header to put in front of the output data.
+
+ /* Build a WAV header to put in front of the output data.
This gets sent back in the Block (read) routine.
*/
memset( &p_cdda->waveheader, 0, sizeof(WAVEHEADER) );
SetWLE( &p_cdda->waveheader.BytesPerSample,
2 /*Modus*/ * 16 /*BitsPerSample*/ / 8 );
SetDWLE( &p_cdda->waveheader.BytesPerSec,
- 2*16/8 /*BytesPerSample*/ * CDDA_FREQUENCY_SAMPLE );
+ 2*16/8 /*BytesPerSample*/ * CDDA_FREQUENCY_SAMPLE );
p_cdda->waveheader.DataChunkID = VLC_FOURCC('d', 'a', 't', 'a');
p_cdda->waveheader.DataLength = 0; /* we just don't know */
/* PTS delay */
- var_Create( p_access, MODULE_STRING "-caching",
- VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
+ var_Create( p_access, MODULE_STRING "-caching",
+ VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
+ vlc_object_release( p_cdda->p_input );
return VLC_SUCCESS;
error:
free( p_cdda );
error2:
free( psz_source );
+ vlc_object_release( p_cdda->p_input );
return i_rc;
}
/*****************************************************************************
* CDDAClose: closes cdda and frees any resources associded with it.
*****************************************************************************/
-void
-E_(CDDAClose)( vlc_object_t *p_this )
+void E_(CDDAClose)( vlc_object_t *p_this )
{
access_t *p_access = (access_t *) p_this;
cdda_data_t *p_cdda = (cdda_data_t *) p_access->p_sys;
switch( i_query )
{
/* Pass back a copy of meta information that was gathered when we
- during the Open/Initialize call.
- */
+ during the Open/Initialize call.
+ */
case ACCESS_GET_META:
- {
- vlc_meta_t **pp_meta = (vlc_meta_t**)va_arg( args, vlc_meta_t** );
- if ( p_cdda->p_meta ) {
- *pp_meta = vlc_meta_Duplicate( p_cdda->p_meta );
- dbg_print( INPUT_DBG_META, "%s", "Meta copied" );
- } else
- msg_Warn( p_access, "tried to copy NULL meta info" );
-
- return VLC_SUCCESS;
- }
- return VLC_EGENERIC;
+ {
+ vlc_meta_t **pp_meta = (vlc_meta_t**)va_arg( args, vlc_meta_t** );
+ if ( p_cdda->p_meta )
+ {
+ *pp_meta = vlc_meta_Duplicate( p_cdda->p_meta );
+ dbg_print( INPUT_DBG_META, "%s", "Meta copied" );
+ }
+ else
+ msg_Warn( p_access, "tried to copy NULL meta info" );
+
+ return VLC_SUCCESS;
+ }
case ACCESS_CAN_SEEK:
case ACCESS_CAN_FASTSEEK:
case ACCESS_CAN_PAUSE:
- case ACCESS_CAN_CONTROL_PACE:
- {
+ case ACCESS_CAN_CONTROL_PACE:
+ {
vlc_bool_t *pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t* );
*pb_bool = VLC_TRUE;
- break;
- }
+ 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;
break;
+ }
case ACCESS_GET_PTS_DELAY:
- {
- int64_t *pi_64 = (int64_t*)va_arg( args, int64_t * );
+ {
+ int64_t *pi_64 = (int64_t*)va_arg( args, int64_t * );
*pi_64 = var_GetInteger( p_access, MODULE_STRING "-caching" )
- * MILLISECONDS_PER_SEC;
+ * MILLISECONDS_PER_SEC;
break;
- }
+ }
/* */
case ACCESS_SET_PAUSE_STATE:
break;
case ACCESS_GET_TITLE_INFO:
- { input_title_t ***ppp_title;
+ {
+ input_title_t ***ppp_title;
ppp_title = (input_title_t***)va_arg( args, input_title_t*** );
pi_int = (int*)va_arg( args, int* );
- *((int*)va_arg( args, int* )) = 1; /* Title offset */
+ *((int*)va_arg( args, int* )) = 1; /* Title offset */
/* Duplicate title info */
- /*** printf("+++ i_tracks %d, i_titles %d\n",
- p_cdda->i_tracks, p_cdda->i_titles); ***/
+ printf("+++ i_tracks %d, i_titles %d\n",
+ p_cdda->i_tracks, p_cdda->i_titles);
+ if( p_cdda->i_titles == 0 )
+ {
+ *pi_int = 0; ppp_title = NULL;
+ return VLC_SUCCESS;
+ }
*pi_int = p_cdda->i_titles;
*ppp_title = malloc(sizeof( input_title_t **) * p_cdda->i_titles );
- if (!*ppp_title) return VLC_ENOMEM;
+ if (!*ppp_title) return VLC_ENOMEM;
for( i = 0; i < p_cdda->i_titles; i++ )
{
- if ( p_cdda->p_title[i] )
- (*ppp_title)[i] =
- vlc_input_title_Duplicate( p_cdda->p_title[i] );
+ if ( p_cdda->p_title[i] )
+ (*ppp_title)[i] =
+ vlc_input_title_Duplicate( p_cdda->p_title[i] );
}
- }
- break;
+ break;
+ }
case ACCESS_SET_TITLE:
+ {
i = (int)va_arg( args, int );
if( i != p_access->info.i_title )
{
p_cdda->i_lsn = p_cdda->lsn[p_cdda->i_first_track+i];
}
break;
+ }
case ACCESS_SET_SEEKPOINT:
case ACCESS_SET_PRIVATE_ID_STATE:
return VLC_EGENERIC;
default:
- msg_Warn( p_access, "unimplemented query in control" );
+ msg_Warn( p_access, "unimplemented query in control" );
return VLC_EGENERIC;
}
}
/*****************************************************************************
- CDDAInit:
+ CDDAInit:
Initialize information pertaining to the CD: the number of tracks,
first track number, LSNs for each track and the leadout. The leadout
We return the VLC-type status, e.g. VLC_SUCCESS, VLC_ENOMEM, etc.
*****************************************************************************/
-static int
-CDDAInit( access_t *p_access, cdda_data_t *p_cdda )
+static int CDDAInit( access_t *p_access, cdda_data_t *p_cdda )
{
track_t i;
discmode_t discmode = CDIO_DISC_MODE_NO_INFO;
switch(discmode) {
case CDIO_DISC_MODE_CD_DA:
case CDIO_DISC_MODE_CD_MIXED:
- /* These are possible for CD-DA */
- break;
+ /* These are possible for CD-DA */
+ break;
default:
- /* These are not possible for CD-DA */
- msg_Err( p_access,
- "Disc seems not to be CD-DA. libcdio reports it is %s",
- discmode2str[discmode]
- );
- return VLC_EGENERIC;
+ /* These are not possible for CD-DA */
+ msg_Err( p_access,
+ "Disc seems not to be CD-DA. libcdio reports it is %s",
+ discmode2str[discmode]
+ );
+ return VLC_EGENERIC;
}
-
+
/* Fill the lsn array with the track/sector matches.
Note cdio_get_track_lsn when given num_tracks + 1 will return
the leadout LSN.
*/
for( i = 0 ; i <= p_cdda->i_tracks ; i++ )
- {
- track_t i_track = p_cdda->i_first_track + i;
+ {
+ track_t i_track = p_cdda->i_first_track + i;
(p_cdda->lsn)[ i_track ] = cdio_get_track_lsn(p_cdda->p_cdio, i_track);
- }
+ }
/* Set reading start LSN. */
p_cdda->i_lsn = p_cdda->lsn[p_cdda->i_track];
if (val) var=strdup(val);
-static void
-GetCDDBInfo( access_t *p_access, cdda_data_t *p_cdda )
+static void GetCDDBInfo( access_t *p_access, cdda_data_t *p_cdda )
{
+ int i, i_matches;
+ cddb_conn_t *conn = cddb_new();
+ const CdIo *p_cdio = p_cdda->p_cdio;
- int i, i_matches;
- cddb_conn_t *conn = cddb_new();
- const CdIo *p_cdio = p_cdda->p_cdio;
-
- dbg_print( (INPUT_DBG_CALL), "" );
+ dbg_print( (INPUT_DBG_CALL), "" );
#ifdef FIXME_NOW
- cddb_log_set_handler (uninit_log_handler);
+ cddb_log_set_handler (uninit_log_handler);
#endif
-
- if (!conn) {
- msg_Warn( p_access, "Unable to initialize libcddb" );
- goto cddb_destroy;
- }
-
- cddb_set_email_address( conn,
- config_GetPsz( p_access,
- MODULE_STRING "-cddb-email") );
-
- cddb_set_server_name( conn,
- config_GetPsz( p_access,
- MODULE_STRING "-cddb-server") );
-
- cddb_set_server_port(conn,
- config_GetInt( p_access,
- MODULE_STRING "-cddb-port") );
-
+
+ if (!conn)
+ {
+ msg_Warn( p_access, "Unable to initialize libcddb" );
+ goto cddb_destroy;
+ }
+
+ cddb_set_email_address( conn,
+ config_GetPsz( p_access,
+ MODULE_STRING "-cddb-email") );
+ cddb_set_server_name( conn,
+ config_GetPsz( p_access,
+ MODULE_STRING "-cddb-server") );
+ cddb_set_server_port(conn,
+ config_GetInt( p_access,
+ MODULE_STRING "-cddb-port") );
+
/* Set the location of the local CDDB cache directory.
The default location of this directory is */
-
- if (!config_GetInt( p_access, MODULE_STRING "-cddb-enable-cache" ))
- cddb_cache_disable(conn);
-
- cddb_cache_set_dir(conn,
- config_GetPsz( p_access,
- MODULE_STRING "-cddb-cachedir") );
-
- cddb_set_timeout(conn,
- config_GetInt( p_access, MODULE_STRING "-cddb-timeout") );
-
-
- if (config_GetInt( p_access, MODULE_STRING "-cddb-httpd" )) {
- cddb_http_enable(conn);
- } else
- cddb_http_disable(conn);
-
- p_cdda->cddb.disc = cddb_disc_new();
- if (!p_cdda->cddb.disc) {
- msg_Err( p_access, "Unable to create CDDB disc structure." );
- goto cddb_end;
- }
-
- for(i = 0; i < p_cdda->i_tracks; i++) {
- track_t i_track = p_cdda->i_first_track + i;
- cddb_track_t *t = cddb_track_new();
- t->frame_offset = cdio_get_track_lba(p_cdio, i_track);
- cddb_disc_add_track(p_cdda->cddb.disc, t);
- }
-
- p_cdda->cddb.disc->length =
- cdio_get_track_lba(p_cdio, CDIO_CDROM_LEADOUT_TRACK)
- / CDIO_CD_FRAMES_PER_SEC;
-
- if (!cddb_disc_calc_discid(p_cdda->cddb.disc)) {
- msg_Err( p_access, "CDDB disc ID calculation failed" );
- goto cddb_destroy;
- }
-
- i_matches = cddb_query(conn, p_cdda->cddb.disc);
- if (i_matches > 0) {
- if (i_matches > 1)
- msg_Warn( p_access, "Found %d matches in CDDB. Using first one.",
- i_matches);
- cddb_read(conn, p_cdda->cddb.disc);
-
- if (p_cdda->i_debug & INPUT_DBG_CDDB)
- cddb_disc_print(p_cdda->cddb.disc);
-
- } else {
- msg_Warn( p_access, "CDDB error: %s", cddb_error_str(errno));
- }
- cddb_destroy:
- cddb_destroy(conn);
+ if (!config_GetInt( p_access, MODULE_STRING "-cddb-enable-cache" ))
+ cddb_cache_disable(conn);
+
+ cddb_cache_set_dir(conn,
+ config_GetPsz( p_access,
+ MODULE_STRING "-cddb-cachedir") );
+
+ cddb_set_timeout(conn,
+ config_GetInt( p_access, MODULE_STRING "-cddb-timeout") );
+
+
+ if (config_GetInt( p_access, MODULE_STRING "-cddb-httpd" ) )
+ {
+ cddb_http_enable(conn);
+ }
+ else
+ {
+ cddb_http_disable(conn);
+ }
+
+ p_cdda->cddb.disc = cddb_disc_new();
+
+ if (!p_cdda->cddb.disc)
+ {
+ msg_Err( p_access, "Unable to create CDDB disc structure." );
+ goto cddb_end;
+ }
+
+ for(i = 0; i < p_cdda->i_tracks; i++)
+ {
+ track_t i_track = p_cdda->i_first_track + i;
+ cddb_track_t *t = cddb_track_new();
+ t->frame_offset = cdio_get_track_lba(p_cdio, i_track);
+ cddb_disc_add_track(p_cdda->cddb.disc, t);
+ }
+
+ p_cdda->cddb.disc->length =
+ cdio_get_track_lba(p_cdio, CDIO_CDROM_LEADOUT_TRACK)
+ / CDIO_CD_FRAMES_PER_SEC;
+
+ if (!cddb_disc_calc_discid(p_cdda->cddb.disc))
+ {
+ msg_Err( p_access, "CDDB disc ID calculation failed" );
+ goto cddb_destroy;
+ }
+
+ i_matches = cddb_query(conn, p_cdda->cddb.disc);
+
+ if (i_matches > 0)
+ {
+ if (i_matches > 1)
+ msg_Warn( p_access, "Found %d matches in CDDB. Using first one.",
+ i_matches);
+ cddb_read(conn, p_cdda->cddb.disc);
+
+ if (p_cdda->i_debug & INPUT_DBG_CDDB)
+ cddb_disc_print(p_cdda->cddb.disc);
+
+ }
+ else
+ {
+ msg_Warn( p_access, "CDDB error: %s", cddb_error_str(errno));
+ }
- cddb_end: ;
+cddb_destroy:
+ cddb_destroy(conn);
+
+cddb_end: ;
}
#endif /*HAVE_LIBCDDB*/
-#define add_meta_val(FIELD, VLC_META, VAL) \
- if ( p_cdda->p_meta && VAL) { \
- vlc_meta_Add( p_cdda->p_meta, VLC_META, VAL ); \
- dbg_print( INPUT_DBG_META, "field %s: %s\n", VLC_META, VAL ); \
- } \
-
-#define add_cddb_meta(FIELD, VLC_META) \
+#define add_meta_val(FIELD, VLC_META, VAL) \
+ if ( p_cdda->p_meta && VAL) { \
+ vlc_meta_Add( p_cdda->p_meta, VLC_META, VAL ); \
+ dbg_print( INPUT_DBG_META, "field %s: %s\n", VLC_META, VAL ); \
+ } \
+
+#define add_cddb_meta(FIELD, VLC_META) \
add_meta_val(FIELD, VLC_META, p_cdda->cddb.disc->FIELD);
-
-#define add_cddb_meta_fmt(FIELD, FORMAT_SPEC, VLC_META) \
- { \
- char psz_buf[100]; \
- snprintf( psz_buf, sizeof(psz_buf)-1, FORMAT_SPEC, \
- p_cdda->cddb.disc->FIELD ); \
- psz_buf[sizeof(psz_buf)-1] = '\0'; \
- add_meta_val(FIELD, VLC_META, psz_buf); \
- }
+
+#define add_cddb_meta_fmt(FIELD, FORMAT_SPEC, VLC_META) \
+ { \
+ char psz_buf[100]; \
+ snprintf( psz_buf, sizeof(psz_buf)-1, FORMAT_SPEC, \
+ p_cdda->cddb.disc->FIELD ); \
+ psz_buf[sizeof(psz_buf)-1] = '\0'; \
+ add_meta_val(FIELD, VLC_META, psz_buf); \
+ }
/* Adds a string-valued entry to the stream and media information if
the string is not null or the null string.
*/
-#define add_info_str(CATEGORY, TITLE, FIELD) \
- if (FIELD && strlen(FIELD)) { \
- input_Control( p_cdda->p_input, INPUT_ADD_INFO, CATEGORY, \
- _(TITLE), "%s", FIELD ); \
- }
-
-/* Adds a numeric-valued entry to the stream and media information
+#define add_info_str(CATEGORY, TITLE, FIELD) \
+ if (FIELD && strlen(FIELD)) { \
+ input_Control( p_cdda->p_input, INPUT_ADD_INFO, CATEGORY, \
+ _(TITLE), "%s", FIELD ); \
+ }
+
+/* Adds a numeric-valued entry to the stream and media information
if the number is not zero. */
-#define add_info_val(CATEGORY, TITLE, FMT, FIELD) \
- if (FIELD) { \
- input_Control( p_cdda->p_input, INPUT_ADD_INFO, CATEGORY, \
- _(TITLE), FMT, FIELD ); \
- }
+#define add_info_val(CATEGORY, TITLE, FMT, FIELD) \
+ if (FIELD) { \
+ input_Control( p_cdda->p_input, INPUT_ADD_INFO, CATEGORY, \
+ _(TITLE), FMT, FIELD ); \
+ }
/* Adds a CDDB string-valued entry to the stream and media information
under category "Disc" if the string is not null or the null string.
*/
-#define add_cddb_disc_info_str(TITLE, FIELD) \
+#define add_cddb_disc_info_str(TITLE, FIELD) \
add_info_str("Disc", TITLE, p_cdda->cddb.disc->FIELD)
/* Adds a CDDB numeric-valued entry to the stream and media information
under category "Disc" if the string is not null or the null string.
*/
-#define add_cddb_disc_info_val(TITLE, FMT, FIELD) \
+#define add_cddb_disc_info_val(TITLE, FMT, FIELD) \
add_info_val("Disc", TITLE, FMT, p_cdda->cddb.disc->FIELD)
/* Adds a CD-Text string-valued entry to the stream and media information
under category "Disc" if the string is not null or the null string.
*/
-#define add_cdtext_info_str(CATEGORY, TITLE, INDEX, FIELD) \
+#define add_cdtext_info_str(CATEGORY, TITLE, INDEX, FIELD) \
add_info_str(CATEGORY, TITLE, p_cdda->p_cdtext[INDEX]->field[FIELD])
/* Adds a CD-Text string-valued entry to the stream and media information
under category "Disc" if the string is not null or the null string.
*/
-#define add_cdtext_disc_info_str(TITLE, FIELD) \
+#define add_cdtext_disc_info_str(TITLE, FIELD) \
add_cdtext_info_str("Disc", TITLE, 0, FIELD)
Meta information is also used elsewhere such as in "stream and
media info" or in playlist info. The intialization of CD-Text or CDDB
is done here though.
- */
-void
-CDDAMetaInfo( access_t *p_access )
+ */
+void CDDAMetaInfo( access_t *p_access, int i_track )
{
- cdda_data_t *p_cdda = (cdda_data_t *) p_access->p_sys;
+ cdda_data_t *p_cdda = (cdda_data_t *) p_access->p_sys;
- if ( ! p_cdda ) return;
+ if ( ! p_cdda ) return;
+
+ p_cdda->psz_mcn = cdio_get_mcn(p_cdda->p_cdio);
- p_cdda->psz_mcn = cdio_get_mcn(p_cdda->p_cdio);
-
#ifdef HAVE_LIBCDDB
- if ( p_cdda->b_cddb_enabled ) {
-
- GetCDDBInfo(p_access, p_cdda);
-
- if ( p_cdda->cddb.disc ) {
-
- p_cdda->p_meta = vlc_meta_New();
-
- add_cddb_meta(title, VLC_META_CDDB_TITLE);
- add_cddb_meta(artist, VLC_META_CDDB_ARTIST);
- add_cddb_meta(genre, VLC_META_CDDB_GENRE);
- add_cddb_meta(ext_data, VLC_META_CDDB_EXT_DATA);
-
- add_cddb_meta_fmt(year, "%d", VLC_META_CDDB_YEAR);
- add_cddb_meta_fmt(discid, "%x", VLC_META_CDDB_DISCID);
+ if ( p_cdda->b_cddb_enabled )
+ {
+ GetCDDBInfo(p_access, p_cdda);
+ if ( p_cdda->cddb.disc )
+ {
+ p_cdda->p_meta = vlc_meta_New();
+ if( i_track == -1 )
+ {
+ add_cddb_meta(title, VLC_META_TITLE);
+ add_cddb_meta(artist, VLC_META_ARTIST);
+ input_Control( p_cdda->p_input, INPUT_SET_NAME,
+ p_cdda->cddb.disc->artist );
+ }
+ else
+ {
+ cddb_track_t *t=cddb_disc_get_track(p_cdda->cddb.disc,
+ i_track-1);
+ if (t != NULL )
+ {
+ if( t->title != NULL )
+ {
+ add_meta_val( NULL, VLC_META_TITLE, t->title );
+ }
+ if( t->artist != NULL )
+ {
+ add_meta_val( NULL, VLC_META_ARTIST, t->artist );
+ }
+ }
+ }
+ add_cddb_meta(genre, VLC_META_GENRE);
+ add_cddb_meta_fmt(year, "%d", VLC_META_DATE );
+ }
}
- }
#endif /*HAVE_LIBCDDB*/
#define TITLE_MAX 30
-
- {
- track_t i = p_cdda->i_tracks;
- const int i_first_track = p_cdda->i_first_track;
- char psz_buffer[MSTRTIME_MAX_SIZE];
- mtime_t i_duration =
- (p_cdda->lsn[i_first_track+i] - p_cdda->lsn[i_first_track])
- / CDIO_CD_FRAMES_PER_SEC;
-
- dbg_print( INPUT_DBG_META, "Duration %ld", (long int) i_duration );
- input_Control( p_cdda->p_input, INPUT_ADD_INFO,
- _("Disc"), _("Duration"), "%s",
- secstotimestr( psz_buffer, i_duration ) );
-
+ {
+ track_t i = p_cdda->i_tracks;
+ const int i_first_track = p_cdda->i_first_track;
+ char psz_buffer[MSTRTIME_MAX_SIZE];
+ mtime_t i_duration =
+ (p_cdda->lsn[i_first_track+i] - p_cdda->lsn[i_first_track])
+ / CDIO_CD_FRAMES_PER_SEC;
+
+ dbg_print( INPUT_DBG_META, "Duration %ld", (long int) i_duration );
+ input_Control( p_cdda->p_input, INPUT_ADD_INFO,
+ _("Disc"), _("Duration"), "%s",
+ secstotimestr( psz_buffer, i_duration ) );
+
#ifdef HAVE_LIBCDDB
- if (p_cdda->b_cddb_enabled && p_cdda->cddb.disc) {
- add_cddb_disc_info_str("Artist (CDDB)", artist);
- add_cddb_disc_info_str("Genre (CDDB)", genre);
- add_cddb_disc_info_str("Extended Data (CDDB)", ext_data);
- add_cddb_disc_info_val("Year (CDDB)", "%d", year);
- add_cddb_disc_info_val("Disc ID (CDDB)", "%x", discid);
- add_cddb_disc_info_str("Title (CDDB)", title);
- add_info_str("Disc", "Category (CDDB)",
- CDDB_CATEGORY[p_cdda->cddb.disc->category]);
- }
+ if (p_cdda->b_cddb_enabled && p_cdda->cddb.disc)
+ {
+ add_cddb_disc_info_str("Artist (CDDB)", artist);
+ add_cddb_disc_info_str("Genre (CDDB)", genre);
+ add_cddb_disc_info_str("Extended Data (CDDB)", ext_data);
+ add_cddb_disc_info_val("Year (CDDB)", "%d", year);
+ add_cddb_disc_info_val("Disc ID (CDDB)", "%x", discid);
+ add_cddb_disc_info_str("Title (CDDB)", title);
+ add_info_str("Disc", "Category (CDDB)",
+ CDDB_CATEGORY[p_cdda->cddb.disc->category]);
+
+ }
#endif /*HAVE_LIBCDDB*/
- p_cdda->p_cdtext[0] = cdio_get_cdtext(p_cdda->p_cdio, 0);
- if (p_cdda->p_cdtext[0]) {
- add_cdtext_disc_info_str("Arranger (CD-Text)", CDTEXT_ARRANGER);
- add_cdtext_disc_info_str("Composer (CD-Text)", CDTEXT_COMPOSER);
- add_cdtext_disc_info_str("Disc ID (CD-Text)", CDTEXT_DISCID);
- add_cdtext_disc_info_str("Genre (CD-Text)", CDTEXT_GENRE);
- add_cdtext_disc_info_str("Message (CD-Text)", CDTEXT_MESSAGE);
- add_cdtext_disc_info_str("Performer (CD-Text)", CDTEXT_PERFORMER);
- add_cdtext_disc_info_str("Songwriter (CD-Text)", CDTEXT_SONGWRITER);
- add_cdtext_disc_info_str("Title (CD-Text)", CDTEXT_TITLE);
- }
-
- for( i = 0 ; i < p_cdda->i_tracks ; i++ ) {
+ p_cdda->p_cdtext[0] = cdio_get_cdtext(p_cdda->p_cdio, 0);
+ if (p_cdda->p_cdtext[0])
+ {
+ add_cdtext_disc_info_str("Arranger (CD-Text)", CDTEXT_ARRANGER);
+ add_cdtext_disc_info_str("Composer (CD-Text)", CDTEXT_COMPOSER);
+ add_cdtext_disc_info_str("Disc ID (CD-Text)", CDTEXT_DISCID);
+ add_cdtext_disc_info_str("Genre (CD-Text)", CDTEXT_GENRE);
+ add_cdtext_disc_info_str("Message (CD-Text)", CDTEXT_MESSAGE);
+ add_cdtext_disc_info_str("Performer (CD-Text)", CDTEXT_PERFORMER);
+ add_cdtext_disc_info_str("Songwriter (CD-Text)", CDTEXT_SONGWRITER);
+ add_cdtext_disc_info_str("Title (CD-Text)", CDTEXT_TITLE);
+ }
- char psz_track[TITLE_MAX];
- const track_t i_track = i_first_track + i;
- mtime_t i_duration = (p_cdda->lsn[i_track+1] - p_cdda->lsn[i_track])
- / CDIO_CD_FRAMES_PER_SEC;
- snprintf(psz_track, TITLE_MAX, "%s %02d", _("Track"), i_track);
- input_Control( p_cdda->p_input, INPUT_ADD_INFO, psz_track,
- _("Duration"), "%s",
- secstotimestr( psz_buffer, i_duration ) );
-
- p_cdda->p_cdtext[i_track] = cdio_get_cdtext(p_cdda->p_cdio, i_track);
-
- if (p_cdda->p_cdtext[i_track]) {
- add_cdtext_info_str(psz_track, "Arranger (CD-Text)", i_track,
- CDTEXT_ARRANGER);
- add_cdtext_info_str(psz_track, "Composer (CD-Text)", i_track,
- CDTEXT_COMPOSER);
- add_cdtext_info_str(psz_track, "Disc ID (CD-Text)", i_track,
- CDTEXT_DISCID);
- add_cdtext_info_str(psz_track, "Genre (CD-Text)", i_track,
- CDTEXT_GENRE);
- add_cdtext_info_str(psz_track, "Message (CD-Text)", i_track,
- CDTEXT_MESSAGE);
- add_cdtext_info_str(psz_track, "Performer (CD-Text)", i_track,
- CDTEXT_PERFORMER);
- add_cdtext_info_str(psz_track, "Songwriter (CD-Text)", i_track,
- CDTEXT_SONGWRITER);
- add_cdtext_info_str(psz_track, "Title (CD-Text)", i_track,
- CDTEXT_TITLE);
- }
+ if( i_track == -1 )
+ {
+ for( i = 0 ; i < p_cdda->i_tracks ; i++ )
+ {
+ char psz_track[TITLE_MAX];
+ const track_t i_track = i_first_track + i;
+ mtime_t i_duration = (p_cdda->lsn[i_track+1] -
+ p_cdda->lsn[i_track])
+ / CDIO_CD_FRAMES_PER_SEC;
+ snprintf(psz_track, TITLE_MAX, "%s %02d", _("Track"), i_track);
+ input_Control( p_cdda->p_input, INPUT_ADD_INFO, psz_track,
+ _("Duration"), "%s",
+ secstotimestr( psz_buffer, i_duration ) );
+
+ p_cdda->p_cdtext[i_track] =
+ cdio_get_cdtext(p_cdda->p_cdio, i_track);
+
+ if (p_cdda->p_cdtext[i_track])
+ {
+ add_cdtext_info_str( psz_track, "Arranger (CD-Text)",
+ i_track, CDTEXT_ARRANGER);
+ add_cdtext_info_str( psz_track, "Composer (CD-Text)",
+ i_track, CDTEXT_COMPOSER);
+ add_cdtext_info_str( psz_track, "Disc ID (CD-Text)",
+ i_track, CDTEXT_DISCID);
+ add_cdtext_info_str( psz_track, "Genre (CD-Text)",
+ i_track, CDTEXT_GENRE);
+ add_cdtext_info_str( psz_track, "Message (CD-Text)",
+ i_track, CDTEXT_MESSAGE);
+ add_cdtext_info_str( psz_track, "Performer (CD-Text)",
+ i_track, CDTEXT_PERFORMER);
+ add_cdtext_info_str( psz_track, "Songwriter (CD-Text)",
+ i_track, CDTEXT_SONGWRITER);
+ add_cdtext_info_str( psz_track, "Title (CD-Text)",
+ i_track, CDTEXT_TITLE);
+ }
#ifdef HAVE_LIBCDDB
- if (p_cdda->b_cddb_enabled) {
- cddb_track_t *t=cddb_disc_get_track(p_cdda->cddb.disc, i);
- if (t != NULL) {
- add_info_str(psz_track, "Artist (CDDB)", t->artist);
- add_info_str(psz_track, "Title (CDDB)", t->title);
- add_info_str(psz_track, "Extended Data (CDDB)", t->ext_data);
- }
- }
+ if (p_cdda->b_cddb_enabled)
+ {
+ cddb_track_t *t=cddb_disc_get_track(p_cdda->cddb.disc, i);
+ if (t != NULL)
+ {
+ add_info_str(psz_track, "Artist (CDDB)", t->artist);
+ add_info_str(psz_track, "Title (CDDB)", t->title);
+ add_info_str(psz_track, "Extended Data (CDDB)",
+ t->ext_data);
+ }
+ }
#endif /*HAVE_LIBCDDB*/
+ }
+ }
}
- }
}
#define add_format_str_info(val) \
*/
static char *
CDDAFormatStr( const access_t *p_access, cdda_data_t *p_cdda,
- const char format_str[], const char *mrl, track_t i_track)
+ const char format_str[], const char *mrl, track_t i_track)
{
#define TEMP_STR_SIZE 256
#define TEMP_STR_LEN (TEMP_STR_SIZE-1)
- static char temp_str[TEMP_STR_SIZE];
- size_t i;
- char * tp = temp_str;
- vlc_bool_t saw_control_prefix = false;
- size_t format_len = strlen(format_str);
+ static char temp_str[TEMP_STR_SIZE];
+ size_t i;
+ char * tp = temp_str;
+ vlc_bool_t saw_control_prefix = false;
+ size_t format_len = strlen(format_str);
- memset(temp_str, 0, TEMP_STR_SIZE);
+ memset(temp_str, 0, TEMP_STR_SIZE);
- for (i=0; i<format_len; i++) {
+ for (i=0; i<format_len; i++)
+ {
- if (!saw_control_prefix && format_str[i] != '%') {
- *tp++ = format_str[i];
- saw_control_prefix = false;
- continue;
- }
+ if (!saw_control_prefix && format_str[i] != '%')
+ {
+ *tp++ = format_str[i];
+ saw_control_prefix = false;
+ continue;
+ }
- switch(format_str[i]) {
- case '%':
- if (saw_control_prefix) {
- *tp++ = '%';
- }
- saw_control_prefix = !saw_control_prefix;
- break;
+ switch(format_str[i])
+ {
+ case '%':
+ if (saw_control_prefix)
+ {
+ *tp++ = '%';
+ }
+ saw_control_prefix = !saw_control_prefix;
+ break;
#ifdef HAVE_LIBCDDB
- case 'a':
- if (!p_cdda->b_cddb_enabled) goto not_special;
- if (p_cdda->cddb.disc)
- add_format_str_info(p_cdda->cddb.disc->artist);
- break;
- case 'A':
- if (!p_cdda->b_cddb_enabled) goto not_special;
- if (p_cdda->cddb.disc)
- add_format_str_info(p_cdda->cddb.disc->title);
- break;
- case 'C':
- if (!p_cdda->b_cddb_enabled) goto not_special;
- if (p_cdda->cddb.disc)
- add_format_str_info(CDDB_CATEGORY[p_cdda->cddb.disc->category]);
- break;
- case 'G':
- if (!p_cdda->b_cddb_enabled) goto not_special;
- if (p_cdda->cddb.disc)
- add_format_str_info(p_cdda->cddb.disc->genre);
- break;
- case 'I':
- if (!p_cdda->b_cddb_enabled) goto not_special;
- if (p_cdda->cddb.disc)
- add_format_num_info(p_cdda->cddb.disc->discid, "%x");
- break;
- case 'Y':
- if (!p_cdda->b_cddb_enabled) goto not_special;
- if (p_cdda->cddb.disc)
- add_format_num_info(p_cdda->cddb.disc->year, "%5d");
- break;
- case 't':
- if (p_cdda && p_cdda->b_cddb_enabled && p_cdda->cddb.disc) {
- cddb_track_t *t=cddb_disc_get_track(p_cdda->cddb.disc,
- i_track-1);
- if (t != NULL && t->title != NULL)
- add_format_str_info(t->title);
- } else goto not_special;
- break;
- case 'p':
- if (p_cdda->b_cddb_enabled && p_cdda->cddb.disc) {
- cddb_track_t *t=cddb_disc_get_track(p_cdda->cddb.disc,
- i_track-1);
- if (t != NULL && t->artist != NULL)
- add_format_str_info(t->artist);
- } else goto not_special;
- break;
- case 'e':
- if (p_cdda->b_cddb_enabled && p_cdda->cddb.disc) {
- cddb_track_t *t=cddb_disc_get_track(p_cdda->cddb.disc,
- i_track-1);
- if (t != NULL && t->ext_data != NULL)
- add_format_str_info(t->ext_data);
- } else goto not_special;
- break;
- case 's':
- if (p_cdda->b_cddb_enabled) {
- char psz_buffer[MSTRTIME_MAX_SIZE];
- mtime_t i_duration = (p_cdda->lsn[i_track+1] - p_cdda->lsn[i_track])
- / CDIO_CD_FRAMES_PER_SEC;
- add_format_str_info(secstotimestr( psz_buffer, i_duration ) );
- } else
- goto not_special;
- break;
+ case 'a':
+ if (!p_cdda->b_cddb_enabled) goto not_special;
+ if (p_cdda->cddb.disc)
+ add_format_str_info(p_cdda->cddb.disc->artist);
+ break;
+ case 'A':
+ if (!p_cdda->b_cddb_enabled) goto not_special;
+ if (p_cdda->cddb.disc)
+ add_format_str_info(p_cdda->cddb.disc->title);
+ break;
+ case 'C':
+ if (!p_cdda->b_cddb_enabled) goto not_special;
+ if (p_cdda->cddb.disc)
+ add_format_str_info(
+ CDDB_CATEGORY[p_cdda->cddb.disc->category]);
+ break;
+ case 'G':
+ if (!p_cdda->b_cddb_enabled) goto not_special;
+ if (p_cdda->cddb.disc)
+ add_format_str_info(p_cdda->cddb.disc->genre);
+ break;
+ case 'I':
+ if (!p_cdda->b_cddb_enabled) goto not_special;
+ if (p_cdda->cddb.disc)
+ add_format_num_info(p_cdda->cddb.disc->discid, "%x");
+ break;
+ case 'Y':
+ if (!p_cdda->b_cddb_enabled) goto not_special;
+ if (p_cdda->cddb.disc)
+ add_format_num_info(p_cdda->cddb.disc->year, "%5d");
+ break;
+ case 't':
+ if (p_cdda && p_cdda->b_cddb_enabled && p_cdda->cddb.disc)
+ {
+ cddb_track_t *t=cddb_disc_get_track(p_cdda->cddb.disc,
+ i_track-1);
+ if (t != NULL && t->title != NULL)
+ add_format_str_info(t->title);
+ }
+ else goto not_special;
+ break;
+ case 'p':
+ if (p_cdda->b_cddb_enabled && p_cdda->cddb.disc)
+ {
+ cddb_track_t *t=cddb_disc_get_track(p_cdda->cddb.disc,
+ i_track-1);
+ if (t != NULL && t->artist != NULL)
+ add_format_str_info(t->artist);
+ } else goto not_special;
+ break;
+ case 'e':
+ if (p_cdda->b_cddb_enabled && p_cdda->cddb.disc)
+ {
+ cddb_track_t *t=cddb_disc_get_track(p_cdda->cddb.disc,
+ i_track-1);
+ if (t != NULL && t->ext_data != NULL)
+ add_format_str_info(t->ext_data);
+ } else goto not_special;
+ break;
+ case 's':
+ if (p_cdda->b_cddb_enabled)
+ {
+ char psz_buffer[MSTRTIME_MAX_SIZE];
+ mtime_t i_duration = (p_cdda->lsn[i_track+1] -
+ p_cdda->lsn[i_track])
+ / CDIO_CD_FRAMES_PER_SEC;
+ add_format_str_info(secstotimestr( psz_buffer,
+ i_duration ) );
+ } else goto not_special;
+ break;
#endif /*HAVE_LIBCDDB*/
- case 'M':
- add_format_str_info(mrl);
- break;
+ case 'M':
+ add_format_str_info(mrl);
+ break;
- case 'm':
- add_format_str_info(p_cdda->psz_mcn);
- break;
+ case 'm':
+ add_format_str_info(p_cdda->psz_mcn);
+ break;
- case 'n':
- add_format_num_info(p_cdda->i_tracks, "%d");
- break;
+ case 'n':
+ add_format_num_info(p_cdda->i_tracks, "%d");
+ break;
- case 'T':
- add_format_num_info(i_track, "%02d");
- break;
+ case 'T':
+ add_format_num_info(i_track, "%02d");
+ break;
#ifdef HAVE_LIBCDDB
- not_special:
+ not_special:
#endif
- default:
- *tp++ = '%';
- *tp++ = format_str[i];
- saw_control_prefix = false;
+ default:
+ *tp++ = '%';
+ *tp++ = format_str[i];
+ saw_control_prefix = false;
+ }
}
- }
- return strdup(temp_str);
+ return strdup(temp_str);
}
/* Adds a string-valued entry to the playlist information under "Track"
if the string is not null or the null string.
*/
-#define add_playlist_track_info_str(TITLE, FIELD) \
- if (FIELD && strlen(FIELD)) { \
- playlist_ItemAddInfo( p_item, _("Track"), _(TITLE), \
- "%s", FIELD); \
- }
-
-void
-CDDACreatePlaylistItem(const access_t *p_access, cdda_data_t *p_cdda,
- playlist_t *p_playlist, track_t i_track,
- char *psz_mrl, int psz_mrl_max,
- const char *psz_source, int playlist_operation,
- int i_pos)
+#define add_playlist_track_info_str(TITLE, FIELD) \
+ if (FIELD && strlen(FIELD)) \
+ { \
+ playlist_ItemAddInfo( p_item, _("Track"), _(TITLE), \
+ "%s", FIELD); \
+ }
+
+playlist_item_t *
+CDDACreatePlaylistItem( const access_t *p_access, cdda_data_t *p_cdda,
+ playlist_t *p_playlist, playlist_item_t *p_item,
+ track_t i_track, char *psz_mrl, int psz_mrl_max,
+ const char *psz_source )
{
- mtime_t i_duration = (p_cdda->lsn[i_track+1] - p_cdda->lsn[i_track])
- * (1000000 / CDIO_CD_FRAMES_PER_SEC) ;
- char *psz_title;
- char *config_varname = MODULE_STRING "-title-format";
- playlist_item_t *p_item;
+ mtime_t i_duration = (p_cdda->lsn[i_track+1] - p_cdda->lsn[i_track])
+ * (1000000 / CDIO_CD_FRAMES_PER_SEC) ;
+ char *psz_title;
+ char *config_varname = MODULE_STRING "-title-format";
+
+ playlist_item_t *p_child = NULL;
+
+ if( !p_item )
+ {
+ return NULL;
+ }
#ifdef HAVE_LIBCDDB
- if (p_cdda->b_cddb_enabled) {
- config_varname = MODULE_STRING "-cddb-title-format";
- }
+ if (p_cdda->b_cddb_enabled)
+ {
+ config_varname = MODULE_STRING "-cddb-title-format";
+ }
#endif /*HAVE_LIBCDDB*/
- snprintf(psz_mrl, psz_mrl_max, "%s%s@T%u",
- CDDA_MRL_PREFIX, psz_source, i_track);
-
- psz_title = CDDAFormatStr(p_access, p_cdda,
- config_GetPsz( p_access, config_varname ),
- psz_mrl, i_track);
-
- dbg_print( INPUT_DBG_META, "mrl: %s, title: %s, duration, %ld, pos %d",
- psz_mrl, psz_title, (long int) i_duration / 1000000 , i_pos );
- playlist_AddExt( p_playlist, psz_mrl, psz_title, playlist_operation,
- i_pos, i_duration , NULL, 0);
-
- if( i_pos == PLAYLIST_END ) i_pos = p_playlist->i_size - 1;
-
- vlc_mutex_lock( &p_playlist->object_lock );
- p_item = playlist_ItemGetByPos( p_playlist, i_pos );
- vlc_mutex_unlock( &p_playlist->object_lock );
- if( !p_item )
- return;
-
- vlc_mutex_lock( &p_item->input.lock );
-
- add_playlist_track_info_str("Source", psz_source);
- playlist_ItemAddInfo( p_item, _("Track"), _("Track Number"), "%d", i_track );
-
- if (p_cdda->p_cdtext[0]) {
- const cdtext_t *p = p_cdda->p_cdtext[0];
- add_playlist_track_info_str("Disc Arranger (CD-Text)",
- p->field[CDTEXT_ARRANGER]);
- add_playlist_track_info_str("Disc Composer (CD-Text)",
- p->field[CDTEXT_COMPOSER]);
- add_playlist_track_info_str("Disc ID (CD-Text)",
- p->field[CDTEXT_DISCID]);
- add_playlist_track_info_str("Disc Genre (CD-Text)",
- p->field[CDTEXT_GENRE]);
- add_playlist_track_info_str("Disc Message (CD-Text)",
- p->field[CDTEXT_MESSAGE]);
- add_playlist_track_info_str("Disc Performer (CD-Text)",
- p->field[CDTEXT_PERFORMER]);
- add_playlist_track_info_str("Disc Songwriter (CD-Text)",
- p->field[CDTEXT_SONGWRITER]);
- add_playlist_track_info_str("Disc Title (CD-Text)",
- p->field[CDTEXT_TITLE]);
- }
- if (p_cdda->p_cdtext[i_track]) {
- const cdtext_t *p = p_cdda->p_cdtext[i_track];
- add_playlist_track_info_str("Arranger (CD-Text)",
- p->field[CDTEXT_ARRANGER]);
- add_playlist_track_info_str("Composer (CD-Text)",
- p->field[CDTEXT_COMPOSER]);
- add_playlist_track_info_str("Genre (CD-Text)",
- p->field[CDTEXT_GENRE]);
- add_playlist_track_info_str("Message (CD-Text)",
- p->field[CDTEXT_MESSAGE]);
- add_playlist_track_info_str("Performer (CD-Text)",
- p->field[CDTEXT_PERFORMER]);
- add_playlist_track_info_str("Songwriter (CD-Text)",
- p->field[CDTEXT_SONGWRITER]);
- add_playlist_track_info_str("Title (CD-Text)",
- p->field[CDTEXT_TITLE]);
- }
-
+ psz_title = CDDAFormatStr( p_access, p_cdda,
+ config_GetPsz( p_access, config_varname ),
+ psz_mrl, i_track);
-#ifdef HAVE_LIBCDDB
- if (p_cdda->b_cddb_enabled) {
- cddb_track_t *t=cddb_disc_get_track(p_cdda->cddb.disc,
- i_track-p_cdda->i_first_track);
-
- add_playlist_track_info_str("Disc Album (CDDB)",
- p_cdda->cddb.disc->title);
- add_playlist_track_info_str("Disc Artist(s) (CDDB)",
- p_cdda->cddb.disc->artist);
- add_playlist_track_info_str("Disc Category (CDDB)",
- CDDB_CATEGORY[p_cdda->cddb.disc->category]);
- add_playlist_track_info_str("Disc Genre (CDDB)",
- p_cdda->cddb.disc->genre);
- if ( p_cdda->cddb.disc->discid ) {
- playlist_ItemAddInfo( p_item, _("Track"), _("Disc ID (CDDB)"),
- "%x", p_cdda->cddb.disc->discid );
+ snprintf(psz_mrl, psz_mrl_max, "%s%s@T%u",
+ CDDA_MRL_PREFIX, psz_source, i_track);
+
+ dbg_print( INPUT_DBG_META, "mrl: %s, title: %s, duration, %ld",
+ psz_mrl, psz_title, (long int) i_duration / 1000000 );
+
+ p_child = playlist_ItemNew( p_playlist, psz_mrl, psz_title );
+ p_child->input.b_fixed_name = VLC_TRUE;
+
+ if( !p_child ) return NULL;
+
+ playlist_NodeAddItem( p_playlist, p_child,
+ p_item->pp_parents[0]->i_view,
+ p_item, PLAYLIST_APPEND, PLAYLIST_END );
+ playlist_CopyParents( p_item, p_child );
+
+ return p_child;
+}
+
+int CDDAAddMetaToItem( access_t *p_access, cdda_data_t *p_cdda,
+ playlist_item_t *p_item, const char *psz_source,
+ int i_track, vlc_bool_t b_single )
+{
+ vlc_mutex_lock( &p_item->input.lock );
+
+ add_playlist_track_info_str("Source", psz_source);
+ playlist_ItemAddInfo( p_item, _("Track"), _("Track Number"),
+ "%d", i_track );
+
+ if (p_cdda->p_cdtext[0])
+ {
+ const cdtext_t *p = p_cdda->p_cdtext[0];
+ add_playlist_track_info_str("Disc Arranger (CD-Text)",
+ p->field[CDTEXT_ARRANGER]);
+ add_playlist_track_info_str("Disc Composer (CD-Text)",
+ p->field[CDTEXT_COMPOSER]);
+ add_playlist_track_info_str("Disc ID (CD-Text)",
+ p->field[CDTEXT_DISCID]);
+ add_playlist_track_info_str("Disc Genre (CD-Text)",
+ p->field[CDTEXT_GENRE]);
+ add_playlist_track_info_str("Disc Message (CD-Text)",
+ p->field[CDTEXT_MESSAGE]);
+ add_playlist_track_info_str("Disc Performer (CD-Text)",
+ p->field[CDTEXT_PERFORMER]);
+ add_playlist_track_info_str("Disc Songwriter (CD-Text)",
+ p->field[CDTEXT_SONGWRITER]);
+ add_playlist_track_info_str("Disc Title (CD-Text)",
+ p->field[CDTEXT_TITLE]);
}
- if (p_cdda->cddb.disc->year != 0) {
- playlist_ItemAddInfo( p_item, _("Track"), _("Year (CDDB)"),
- "%5d", p_cdda->cddb.disc->year );
+
+ if (p_cdda->p_cdtext[i_track])
+ {
+ const cdtext_t *p = p_cdda->p_cdtext[i_track];
+ add_playlist_track_info_str("Arranger (CD-Text)",
+ p->field[CDTEXT_ARRANGER]);
+ add_playlist_track_info_str("Composer (CD-Text)",
+ p->field[CDTEXT_COMPOSER]);
+ add_playlist_track_info_str("Genre (CD-Text)",
+ p->field[CDTEXT_GENRE]);
+ add_playlist_track_info_str("Message (CD-Text)",
+ p->field[CDTEXT_MESSAGE]);
+ add_playlist_track_info_str("Performer (CD-Text)",
+ p->field[CDTEXT_PERFORMER]);
+ add_playlist_track_info_str("Songwriter (CD-Text)",
+ p->field[CDTEXT_SONGWRITER]);
+ add_playlist_track_info_str("Title (CD-Text)",
+ p->field[CDTEXT_TITLE]);
}
-
- if (t) {
- if (t->artist)
- add_playlist_track_info_str("Track Artist (CDDB)",
- t->artist);
- if (t->title)
- add_playlist_track_info_str("Track Title (CDDB)",
- t->title);
+
+#ifdef HAVE_LIBCDDB
+ if (p_cdda->b_cddb_enabled)
+ {
+ cddb_track_t *t=cddb_disc_get_track(p_cdda->cddb.disc,
+ i_track-p_cdda->i_first_track);
+
+ add_playlist_track_info_str("Disc Album (CDDB)",
+ p_cdda->cddb.disc->title);
+ add_playlist_track_info_str("Disc Artist(s) (CDDB)",
+ p_cdda->cddb.disc->artist);
+ add_playlist_track_info_str("Disc Category (CDDB)",
+ CDDB_CATEGORY[p_cdda->cddb.disc->category]);
+ add_playlist_track_info_str("Disc Genre (CDDB)",
+ p_cdda->cddb.disc->genre);
+
+ if ( p_cdda->cddb.disc->discid )
+ {
+ playlist_ItemAddInfo( p_item, _("Track"), _("Disc ID (CDDB)"),
+ "%x", p_cdda->cddb.disc->discid );
+ }
+ if (p_cdda->cddb.disc->year != 0)
+ {
+ playlist_ItemAddInfo( p_item, _("Track"), _("Year (CDDB)"),
+ "%5d", p_cdda->cddb.disc->year );
+ }
+
+ if (t)
+ {
+ if (t->artist)
+ add_playlist_track_info_str("Track Artist (CDDB)",
+ t->artist);
+ if (t->title)
+ add_playlist_track_info_str("Track Title (CDDB)",
+ t->title);
+ }
}
- }
#endif /*HAVE_LIBCDDB*/
- vlc_mutex_unlock( &p_item->input.lock );
+ vlc_mutex_unlock( &p_item->input.lock );
+
+ return VLC_SUCCESS;
}
int
-CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda,
- const char *psz_source, vlc_bool_t b_single_track )
+CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda,
+ const char *psz_source, vlc_bool_t b_single_track )
{
- int i;
- playlist_t * p_playlist;
- char * psz_mrl;
- unsigned int psz_mrl_max = strlen(CDDA_MRL_PREFIX) + strlen(psz_source) +
- strlen("@T") + strlen("100") + 1;
- const track_t i_first_track = p_cdda->i_first_track;
+ int i;
+ playlist_t * p_playlist;
+ char * psz_mrl;
+ unsigned int psz_mrl_max = strlen(CDDA_MRL_PREFIX) + strlen(psz_source) +
+ strlen("@T") + strlen("100") + 1;
+ const track_t i_first_track = p_cdda->i_first_track;
+ playlist_item_t *p_item;
+ vlc_bool_t b_play = VLC_FALSE;
#ifdef HAVE_LIBCDDB
- p_cdda->b_cddb_enabled =
- config_GetInt( p_access, MODULE_STRING "-cddb-enabled" );
- if( b_single_track && !p_cdda->b_cddb_enabled ) return VLC_SUCCESS;
+ p_cdda->b_cddb_enabled =
+ config_GetInt( p_access, MODULE_STRING "-cddb-enabled" );
+ if( b_single_track && !p_cdda->b_cddb_enabled )
+ return VLC_SUCCESS;
#else
- if( b_single_track ) return VLC_SUCCESS;
+ if( b_single_track )
+ return VLC_SUCCESS;
#endif
- psz_mrl = malloc( psz_mrl_max );
+ psz_mrl = malloc( psz_mrl_max );
- if( psz_mrl == NULL )
+ if( psz_mrl == NULL )
{
- msg_Warn( p_access, "out of memory" );
- return VLC_ENOMEM;
+ msg_Warn( p_access, "out of memory" );
+ return VLC_ENOMEM;
}
- p_playlist = (playlist_t *) vlc_object_find( p_access, VLC_OBJECT_PLAYLIST,
+ p_playlist = (playlist_t *) vlc_object_find( p_access, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
- if( !p_playlist )
+ if( !p_playlist )
{
- msg_Warn( p_access, "can't find playlist" );
- free(psz_mrl);
- return VLC_EGENERIC;
+ msg_Warn( p_access, "can't find playlist" );
+ free(psz_mrl);
+ return VLC_EGENERIC;
}
- CDDAMetaInfo(p_access);
-
- if (b_single_track) {
- /* May fill out more information when the playlist user interface becomes
- more mature.
- */
- track_t i_track = p_cdda->i_track;
-
- input_title_t *t = p_cdda->p_title[i_track-i_first_track] =
- vlc_input_title_New();
-
- asprintf( &t->psz_name, _("Track %i"), i_track );
- t->i_size = p_access->info.i_size =
- ( p_cdda->lsn[i_track+1] - p_cdda->lsn[i_track] ) *
- (int64_t) CDIO_CD_FRAMESIZE_RAW;
-
- t->i_length = I64C(1000000) * t->i_size / CDDA_FREQUENCY_SAMPLE / 4;
- CDDACreatePlaylistItem(p_access, p_cdda, p_playlist, i_track,
- psz_mrl, psz_mrl_max, psz_source, PLAYLIST_REPLACE,
- p_playlist->i_index);
- p_cdda->i_titles = 1;
- } else {
-
- for( i = 0 ; i < p_cdda->i_tracks ; i++ )
- {
- const track_t i_track = i_first_track + i;
- input_title_t *t = p_cdda->p_title[i] = vlc_input_title_New();
-
- asprintf( &t->psz_name, _("Track %i"), i_track );
- t->i_size = ( p_cdda->lsn[i_track+1] - p_cdda->lsn[i_track] ) *
- (int64_t) CDIO_CD_FRAMESIZE_RAW;
-
- t->i_length = I64C(1000000) * t->i_size / CDDA_FREQUENCY_SAMPLE / 4;
- CDDACreatePlaylistItem(p_access, p_cdda, p_playlist, i_track,
- psz_mrl, psz_mrl_max, psz_source,
- PLAYLIST_APPEND, PLAYLIST_END);
- }
- p_cdda->i_titles = p_cdda->i_tracks; /* should be +1 */
- p_access->info.i_size =
- (p_cdda->lsn[i_first_track + p_cdda->i_tracks]
- - p_cdda->lsn[i_first_track]) * (int64_t) CDIO_CD_FRAMESIZE_RAW;
- }
+ if( b_single_track )
+ {
+ CDDAMetaInfo( p_access, p_cdda->i_track );
+ }
+ else
+ {
+ CDDAMetaInfo( p_access, -1 );
+ }
+
+ p_item = playlist_ItemGetByInput( p_playlist,
+ ((input_thread_t *)p_access->p_parent)->input.p_item );
+
+ if( p_item == p_playlist->status.p_item && !b_single_track )
+ {
+ b_play = VLC_TRUE;
+ }
+ else
+ {
+ b_play = VLC_FALSE;
+ }
+
+ if( b_single_track )
+ {
+ /*May fill out more information when the playlist user interface becomes
+ more mature.
+ */
+ track_t i_track = p_cdda->i_track;
+
+ input_title_t *t = p_cdda->p_title[0] = //i_track-i_first_track] =
+ vlc_input_title_New();
+
+ asprintf( &t->psz_name, _("Track %i"), i_track );
+ t->i_size = p_access->info.i_size =
+ ( p_cdda->lsn[i_track+1] - p_cdda->lsn[i_track] ) *
+ (int64_t) CDIO_CD_FRAMESIZE_RAW;
+
+ t->i_length = I64C(1000000) * t->i_size / CDDA_FREQUENCY_SAMPLE / 4;
+
+
+ CDDAAddMetaToItem( p_access, p_cdda, p_item, psz_source, i_track,
+ VLC_FALSE );
+
+ p_cdda->i_titles = 1;
+ }
+ else
+ {
+ playlist_ItemToNode( p_playlist, p_item );
+ for( i = 0 ; i < p_cdda->i_tracks ; i++ )
+ {
+ playlist_item_t *p_child;
+ const track_t i_track = i_first_track + i;
+ input_title_t *t = p_cdda->p_title[i] = vlc_input_title_New();
+
+ asprintf( &t->psz_name, _("Track %i"), i_track );
+ t->i_size = ( p_cdda->lsn[i_track+1] - p_cdda->lsn[i_track] ) *
+ (int64_t) CDIO_CD_FRAMESIZE_RAW;
+
+ t->i_length = I64C(1000000) * t->i_size / CDDA_FREQUENCY_SAMPLE / 4;
+
+ p_child = CDDACreatePlaylistItem( p_access, p_cdda, p_playlist,
+ p_item,
+ i_track, psz_mrl,
+ psz_mrl_max, psz_source );
+ CDDAAddMetaToItem( p_access, p_cdda, p_child, psz_source,
+ i_track, VLC_TRUE );
+ }
+ p_cdda->i_titles = p_cdda->i_tracks; /* should be +1 */
+ p_access->info.i_size =
+ (p_cdda->lsn[i_first_track + p_cdda->i_tracks]
+ - p_cdda->lsn[i_first_track]) * (int64_t) CDIO_CD_FRAMESIZE_RAW;
+ }
+
+ if( b_play )
+ {
+ playlist_Control( p_playlist, PLAYLIST_VIEWPLAY,
+ p_playlist->status.i_view,
+ p_playlist->status.p_item, NULL );
+ }
+
+ vlc_object_release( p_playlist );
- return VLC_SUCCESS;
+ return VLC_SUCCESS;
}