Commit 3a9b48da authored by Clément Stenac's avatar Clément Stenac

CDDAX:

    - coding style fixes
    - adapted to new playlist API
    - only put generic things in Meta-information

wxWidgets:
    - Fixed playlist updating

core:
    - added playlist_ItemGetByInput
    - implemented input_item_t.b_fixed name : if this is set, the interface should not try to "improve" the display string.
parent 180ca722
......@@ -62,6 +62,8 @@ struct input_item_t
int i_es; /**< Number of es format descriptions */
es_format_t **es; /**< Pointer to an array of es formats */
vlc_bool_t b_fixed_name; /**< Can the interface change the name ?*/
vlc_mutex_t lock; /**< Item cannot be changed without this lock */
};
......@@ -85,6 +87,7 @@ static inline void vlc_input_item_Init( vlc_object_t *p_o, input_item_t *p_i )
p_i->pp_categories = 0;
p_i->es = 0;
p_i->i_type = ITEM_TYPE_UNKNOWN;
p_i->b_fixed_name = VLC_TRUE;
vlc_mutex_init( p_o, &p_i->lock );
}
......
......@@ -112,10 +112,12 @@ 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) {
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);
......@@ -135,11 +137,13 @@ uninit_log_handler (cdio_log_level_t level, const char message[])
if (p_cdda_input)
p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
switch (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);
......@@ -151,8 +155,7 @@ uninit_log_handler (cdio_log_level_t level, const char message[])
fprintf(stderr, "ASSERT ERROR: %s\n", message);
break;
default:
fprintf(stderr, "UNKNOWN ERROR: %s\n%s %d\n",
message,
fprintf(stderr, "UNKNOWN ERROR: %s\n%s %d\n", message,
"The above message had unknown cdio log level",
level);
}
......@@ -166,8 +169,7 @@ uninit_log_handler (cdio_log_level_t level, const char 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;
......@@ -246,8 +248,7 @@ CDDAReadBlocks( access_t * p_access )
* 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;
......@@ -269,8 +270,7 @@ CDDASeek( access_t * p_access, int64_t i_pos )
* 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;
......@@ -319,12 +319,14 @@ E_(CDDAOpen)( vlc_object_t *p_this )
psz_source = var_CreateGetString( p_this, "cd-audio" );
if( !psz_source || !*psz_source ) {
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] ) {
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);
......@@ -382,7 +384,8 @@ E_(CDDAOpen)( vlc_object_t *p_this )
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 ) {
|| 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.",
......@@ -392,7 +395,6 @@ E_(CDDAOpen)( vlc_object_t *p_this )
p_cdda->i_blocks_per_read = DEFAULT_BLOCKS_PER_READ;
}
dbg_print( (INPUT_DBG_CALL|INPUT_DBG_EXT), "%s", psz_source );
/* Set up p_access */
......@@ -439,6 +441,7 @@ E_(CDDAOpen)( vlc_object_t *p_this )
/* PTS delay */
var_Create( p_access, MODULE_STRING "-caching",
VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
vlc_object_release( p_cdda->p_input );
return VLC_SUCCESS;
error:
......@@ -446,6 +449,7 @@ E_(CDDAOpen)( vlc_object_t *p_this )
free( p_cdda );
error2:
free( psz_source );
vlc_object_release( p_cdda->p_input );
return i_rc;
}
......@@ -453,8 +457,7 @@ E_(CDDAOpen)( vlc_object_t *p_this )
/*****************************************************************************
* 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;
......@@ -505,15 +508,16 @@ static int CDDAControl( access_t *p_access, int i_query, va_list args )
case ACCESS_GET_META:
{
vlc_meta_t **pp_meta = (vlc_meta_t**)va_arg( args, vlc_meta_t** );
if ( p_cdda->p_meta ) {
if ( p_cdda->p_meta )
{
*pp_meta = vlc_meta_Duplicate( p_cdda->p_meta );
dbg_print( INPUT_DBG_META, "%s", "Meta copied" );
} else
}
else
msg_Warn( p_access, "tried to copy NULL meta info" );
return VLC_SUCCESS;
}
return VLC_EGENERIC;
case ACCESS_CAN_SEEK:
case ACCESS_CAN_FASTSEEK:
......@@ -522,14 +526,16 @@ static int CDDAControl( access_t *p_access, int i_query, va_list args )
{
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:
{
......@@ -544,14 +550,20 @@ static int CDDAControl( access_t *p_access, int i_query, va_list args )
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 */
/* 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 );
......@@ -563,10 +575,11 @@ static int CDDAControl( access_t *p_access, int i_query, va_list args )
(*ppp_title)[i] =
vlc_input_title_Duplicate( p_cdda->p_title[i] );
}
}
break;
}
case ACCESS_SET_TITLE:
{
i = (int)va_arg( args, int );
if( i != p_access->info.i_title )
{
......@@ -581,6 +594,7 @@ static int CDDAControl( access_t *p_access, int i_query, va_list args )
p_cdda->i_lsn = p_cdda->lsn[p_cdda->i_first_track+i];
}
break;
}
case ACCESS_SET_SEEKPOINT:
case ACCESS_SET_PRIVATE_ID_STATE:
......@@ -607,8 +621,7 @@ static int CDDAControl( access_t *p_access, int i_query, va_list args )
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;
......
......@@ -34,7 +34,8 @@ E_(CDDADebugCB) ( vlc_object_t *p_this, const char *psz_name,
p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
if (p_cdda->i_debug & (INPUT_DBG_CALL|INPUT_DBG_EXT)) {
if (p_cdda->i_debug & (INPUT_DBG_CALL|INPUT_DBG_EXT))
{
msg_Dbg( p_cdda_input, "Old debug (x%0x) %d, new debug (x%0x) %d",
p_cdda->i_debug, p_cdda->i_debug, val.i_int, val.i_int);
}
......@@ -55,7 +56,8 @@ E_(CDDBEnabledCB) ( vlc_object_t *p_this, const char *psz_name,
p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
#ifdef HAVE_LIBCDDB
if (p_cdda->i_debug & (INPUT_DBG_CALL|INPUT_DBG_EXT)) {
if (p_cdda->i_debug & (INPUT_DBG_CALL|INPUT_DBG_EXT))
{
msg_Dbg( p_cdda_input, "Old CDDB Enabled (x%0x) %d, new (x%0x) %d",
p_cdda->b_cddb_enabled, p_cdda->b_cddb_enabled,
val.b_bool, val.b_bool);
......@@ -75,7 +77,8 @@ E_(CDTextEnabledCB) ( vlc_object_t *p_this, const char *psz_name,
p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
if (p_cdda->i_debug & (INPUT_DBG_CALL|INPUT_DBG_EXT)) {
if (p_cdda->i_debug & (INPUT_DBG_CALL|INPUT_DBG_EXT))
{
msg_Dbg( p_cdda_input, "Old CDText Enabled (x%0x) %d, new (x%0x) %d",
p_cdda->b_cdtext_enabled, p_cdda->b_cdtext_enabled,
val.b_bool, val.b_bool);
......@@ -95,7 +98,8 @@ E_(CDTextPreferCB) ( vlc_object_t *p_this, const char *psz_name,
p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
#ifdef HAVE_LIBCDDB
if (p_cdda->i_debug & (INPUT_DBG_CALL|INPUT_DBG_EXT)) {
if ( p_cdda->i_debug & (INPUT_DBG_CALL|INPUT_DBG_EXT))
{
msg_Dbg( p_cdda_input, "Old CDText Prefer (x%0x) %d, new (x%0x) %d",
p_cdda->b_cdtext_prefer, p_cdda->b_cdtext_prefer,
val.b_bool, val.b_bool);
......@@ -115,7 +119,8 @@ E_(CDDABlocksPerReadCB) ( vlc_object_t *p_this, const char *psz_name,
p_cdda = (cdda_data_t *)p_cdda_input->p_sys;
if (p_cdda->i_debug & (INPUT_DBG_CALL|INPUT_DBG_EXT)) {
if (p_cdda->i_debug & (INPUT_DBG_CALL|INPUT_DBG_EXT))
{
msg_Dbg( p_cdda_input, "Old blocks per read: %d, new %d",
p_cdda->i_blocks_per_read, val.i_int);
}
......@@ -123,11 +128,11 @@ E_(CDDABlocksPerReadCB) ( vlc_object_t *p_this, const char *psz_name,
if (0 == val.i_int) val.i_int = DEFAULT_BLOCKS_PER_READ;
if ( val.i_int >= MIN_BLOCKS_PER_READ && val.i_int <= MAX_BLOCKS_PER_READ )
p_cdda->i_blocks_per_read = val.i_int;
else {
else
{
msg_Warn( p_cdda_input,
"Number of blocks (%d) has to be between %d and %d. No change.",
val.i_int, MIN_BLOCKS_PER_READ, MAX_BLOCKS_PER_READ );
}
return VLC_SUCCESS;
}
......@@ -47,10 +47,8 @@
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;
......@@ -61,7 +59,8 @@ GetCDDBInfo( access_t *p_access, cdda_data_t *p_cdda )
cddb_log_set_handler (uninit_log_handler);
#endif
if (!conn) {
if (!conn)
{
msg_Warn( p_access, "Unable to initialize libcddb" );
goto cddb_destroy;
}
......@@ -69,11 +68,9 @@ GetCDDBInfo( access_t *p_access, cdda_data_t *p_cdda )
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") );
......@@ -92,18 +89,25 @@ GetCDDBInfo( access_t *p_access, cdda_data_t *p_cdda )
config_GetInt( p_access, MODULE_STRING "-cddb-timeout") );
if (config_GetInt( p_access, MODULE_STRING "-cddb-httpd" )) {
if (config_GetInt( p_access, MODULE_STRING "-cddb-httpd" ) )
{
cddb_http_enable(conn);
} else
}
else
{
cddb_http_disable(conn);
}
p_cdda->cddb.disc = cddb_disc_new();
if (!p_cdda->cddb.disc) {
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++) {
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);
......@@ -114,13 +118,16 @@ GetCDDBInfo( access_t *p_access, cdda_data_t *p_cdda )
cdio_get_track_lba(p_cdio, CDIO_CDROM_LEADOUT_TRACK)
/ CDIO_CD_FRAMES_PER_SEC;
if (!cddb_disc_calc_discid(p_cdda->cddb.disc)) {
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 > 0)
{
if (i_matches > 1)
msg_Warn( p_access, "Found %d matches in CDDB. Using first one.",
i_matches);
......@@ -129,14 +136,16 @@ GetCDDBInfo( access_t *p_access, cdda_data_t *p_cdda )
if (p_cdda->i_debug & INPUT_DBG_CDDB)
cddb_disc_print(p_cdda->cddb.disc);
} else {
}
else
{
msg_Warn( p_access, "CDDB error: %s", cddb_error_str(errno));
}
cddb_destroy:
cddb_destroy:
cddb_destroy(conn);
cddb_end: ;
cddb_end: ;
}
#endif /*HAVE_LIBCDDB*/
......@@ -210,8 +219,7 @@ GetCDDBInfo( access_t *p_access, cdda_data_t *p_cdda )
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;
......@@ -220,27 +228,42 @@ CDDAMetaInfo( access_t *p_access )
p_cdda->psz_mcn = cdio_get_mcn(p_cdda->p_cdio);
#ifdef HAVE_LIBCDDB
if ( p_cdda->b_cddb_enabled ) {
if ( p_cdda->b_cddb_enabled )
{
GetCDDBInfo(p_access, p_cdda);
if ( p_cdda->cddb.disc ) {
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( 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;
......@@ -255,7 +278,8 @@ CDDAMetaInfo( access_t *p_access )
secstotimestr( psz_buffer, i_duration ) );
#ifdef HAVE_LIBCDDB
if (p_cdda->b_cddb_enabled && p_cdda->cddb.disc) {
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);
......@@ -264,11 +288,13 @@ CDDAMetaInfo( access_t *p_access )
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]) {
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);
......@@ -279,50 +305,59 @@ CDDAMetaInfo( access_t *p_access )
add_cdtext_disc_info_str("Title (CD-Text)", CDTEXT_TITLE);
}
for( i = 0 ; i < p_cdda->i_tracks ; i++ ) {
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])
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);
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) {
if (p_cdda->b_cddb_enabled)
{
cddb_track_t *t=cddb_disc_get_track(p_cdda->cddb.disc, i);
if (t != NULL) {
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);
add_info_str(psz_track, "Extended Data (CDDB)",
t->ext_data);
}
}
#endif /*HAVE_LIBCDDB*/
}
}
}
}
#define add_format_str_info(val) \
......@@ -386,17 +421,21 @@ CDDAFormatStr( const access_t *p_access, cdda_data_t *p_cdda,
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] != '%') {
if (!saw_control_prefix && format_str[i] != '%')
{
*tp++ = format_str[i];
saw_control_prefix = false;
continue;
}
switch(format_str[i]) {
switch(format_str[i])
{
case '%':
if (saw_control_prefix) {
if (saw_control_prefix)
{
*tp++ = '%';
}
saw_control_prefix = !saw_control_prefix;
......@@ -415,7 +454,8 @@ CDDAFormatStr( const access_t *p_access, cdda_data_t *p_cdda,
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]);
add_format_str_info(
CDDB_CATEGORY[p_cdda->cddb.disc->category]);
break;
case 'G':
if (!p_cdda->b_cddb_enabled) goto not_special;
......@@ -433,15 +473,18 @@ CDDAFormatStr( const access_t *p_access, cdda_data_t *p_cdda,
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) {
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;
}
else goto not_special;
break;
case 'p':
if (p_cdda->b_cddb_enabled && p_cdda->cddb.disc) {
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)
......@@ -449,7 +492,8 @@ CDDAFormatStr( const access_t *p_access, cdda_data_t *p_cdda,
} else goto not_special;
break;
case 'e':
if (p_cdda->b_cddb_enabled && p_cdda->cddb.disc) {
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)
......@@ -457,13 +501,15 @@ CDDAFormatStr( const access_t *p_access, cdda_data_t *p_cdda,
} else goto not_special;
break;
case 's':
if (p_cdda->b_cddb_enabled) {
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])
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;