Commit 9fbb4ad3 authored by Rocky Bernstein's avatar Rocky Bernstein

Set duration in playlist.

Allow for CD-Text in custom format
%t now defaults to MRL when we can't get CD-Text or CDDB info
Default "title" format when CDDB not enabled now is %t rather than %m (MRL)
parent 6bc65afd
/***************************************************************************** /*****************************************************************************
* cddax.c : CD digital audio input module for vlc using libcdio * access.c : CD digital audio input module for vlc using libcdio
***************************************************************************** *****************************************************************************
* Copyright (C) 2000, 2003, 2004 VideoLAN * Copyright (C) 2000, 2003, 2004 VideoLAN
* $Id$ * $Id$
...@@ -372,6 +372,7 @@ int E_(CDDAOpen)( vlc_object_t *p_this ) ...@@ -372,6 +372,7 @@ int E_(CDDAOpen)( vlc_object_t *p_this )
p_cdda->b_header = VLC_FALSE; p_cdda->b_header = VLC_FALSE;
p_cdda->p_cdio = p_cdio; p_cdda->p_cdio = p_cdio;
p_cdda->i_tracks = 0;
p_cdda->i_titles = 0; p_cdda->i_titles = 0;
p_cdda->i_track = i_track; p_cdda->i_track = i_track;
p_cdda->i_debug = config_GetInt(p_this, MODULE_STRING "-debug"); p_cdda->i_debug = config_GetInt(p_this, MODULE_STRING "-debug");
...@@ -561,10 +562,11 @@ static int CDDAControl( access_t *p_access, int i_query, va_list args ) ...@@ -561,10 +562,11 @@ static int CDDAControl( access_t *p_access, int i_query, va_list args )
pi_int = (int*)va_arg( args, int* ); 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 */
dbg_print ( INPUT_DBG_EVENT, dbg_print ( INPUT_DBG_EVENT,
"GET TITLE: i_tracks %d, i_titles %d", "GET TITLE: i_tracks %d, i_tracks %d",
p_cdda->i_tracks, p_cdda->i_titles ); p_cdda->i_tracks, p_cdda->i_tracks );
/* Duplicate title info */
if( p_cdda->i_titles == 0 ) if( p_cdda->i_titles == 0 )
{ {
*pi_int = 0; ppp_title = NULL; *pi_int = 0; ppp_title = NULL;
...@@ -587,6 +589,8 @@ static int CDDAControl( access_t *p_access, int i_query, va_list args ) ...@@ -587,6 +589,8 @@ static int CDDAControl( access_t *p_access, int i_query, va_list args )
case ACCESS_SET_TITLE: case ACCESS_SET_TITLE:
{ {
i = (int)va_arg( args, int ); i = (int)va_arg( args, int );
dbg_print( INPUT_DBG_EVENT, "set title %d", i );
if( i != p_access->info.i_title ) if( i != p_access->info.i_title )
{ {
/* Update info */ /* Update info */
...@@ -665,3 +669,10 @@ static int CDDAInit( access_t *p_access, cdda_data_t *p_cdda ) ...@@ -665,3 +669,10 @@ static int CDDAInit( access_t *p_access, cdda_data_t *p_cdda )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
/*
* Local variables:
* mode: C
* style: gnu
* End:
*/
/***************************************************************************** /*****************************************************************************
* cddax.c : CD digital audio input module for vlc using libcdio * cdda.c : CD digital audio input module for vlc using libcdio
***************************************************************************** *****************************************************************************
* Copyright (C) 2000, 2003, 2004 VideoLAN * Copyright (C) 2000, 2003, 2004 VideoLAN
* $Id$ * $Id$
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
" %p : The artist/performer/composer in the track\n" \ " %p : The artist/performer/composer in the track\n" \
" %T : The track number\n" \ " %T : The track number\n" \
" %s : Number of seconds in this track \n" \ " %s : Number of seconds in this track \n" \
" %t : The title\n" \ " %t : The track title or MRL if no title\n" \
" %Y : The year 19xx or 20xx\n" \ " %Y : The year 19xx or 20xx\n" \
" %% : a % \n") " %% : a % \n")
...@@ -85,6 +85,7 @@ ...@@ -85,6 +85,7 @@
" %n : The number of tracks on the CD\n" \ " %n : The number of tracks on the CD\n" \
" %T : The track number\n" \ " %T : The track number\n" \
" %s : Number of seconds in this track \n" \ " %s : Number of seconds in this track \n" \
" %t : The track title or MRL if no title\n" \
" %% : a % \n") " %% : a % \n")
/***************************************************************************** /*****************************************************************************
...@@ -120,7 +121,7 @@ vlc_module_begin(); ...@@ -120,7 +121,7 @@ vlc_module_begin();
TITLE_FMT_LONGTEXT, VLC_TRUE ); TITLE_FMT_LONGTEXT, VLC_TRUE );
add_string( MODULE_STRING "-title-format", add_string( MODULE_STRING "-title-format",
"%T %M", NULL, "Track %T. %t", NULL,
N_("Format to use in playlist \"title\" field when no CDDB"), N_("Format to use in playlist \"title\" field when no CDDB"),
TITLE_FMT_LONGTEXT, VLC_TRUE ); TITLE_FMT_LONGTEXT, VLC_TRUE );
......
...@@ -384,7 +384,6 @@ void CDDAMetaInfo( access_t *p_access, int i_track, /*const*/ char *psz_mrl ) ...@@ -384,7 +384,6 @@ void CDDAMetaInfo( access_t *p_access, int i_track, /*const*/ char *psz_mrl )
add_meta_val( VLC_META_TITLE, psz_meta_title ); add_meta_val( VLC_META_TITLE, psz_meta_title );
if (psz_meta_artist) if (psz_meta_artist)
add_meta_val( VLC_META_ARTIST, psz_meta_artist ); add_meta_val( VLC_META_ARTIST, psz_meta_artist );
} }
} }
...@@ -446,13 +445,13 @@ cdda_data_t *p_cdda, char *psz_cdtext) ...@@ -446,13 +445,13 @@ cdda_data_t *p_cdda, char *psz_cdtext)
%p : The artist/performer/composer in the track ** %p : The artist/performer/composer in the track **
%T : The track number ** %T : The track number **
%s : Number of seconds in this track %s : Number of seconds in this track
%t : The name ** %t : The track name or MRL if no name **
%Y : The year 19xx or 20xx ** %Y : The year 19xx or 20xx **
%% : a % %% : a %
*/ */
static char * static char *
CDDAFormatStr( const access_t *p_access, cdda_data_t *p_cdda, 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 *psz_mrl, track_t i_track)
{ {
#define TEMP_STR_SIZE 256 #define TEMP_STR_SIZE 256
#define TEMP_STR_LEN (TEMP_STR_SIZE-1) #define TEMP_STR_LEN (TEMP_STR_SIZE-1)
...@@ -531,10 +530,19 @@ CDDAFormatStr( const access_t *p_access, cdda_data_t *p_cdda, ...@@ -531,10 +530,19 @@ CDDAFormatStr( const access_t *p_access, cdda_data_t *p_cdda,
{ {
cddb_track_t *t=cddb_disc_get_track(p_cdda->cddb.disc, cddb_track_t *t=cddb_disc_get_track(p_cdda->cddb.disc,
i_track-1); i_track-1);
if (t != NULL && t->title != NULL) if (t != NULL && t->title != NULL) {
add_format_str_info(t->title); add_format_str_info(t->title);
} } else {
else goto not_special; add_format_str_info(psz_mrl);
}
} else {
if (p_cdda->p_cdtext[i_track]
&& p_cdda->p_cdtext[i_track]->field[CDTEXT_TITLE]) {
add_format_str_info(p_cdda->p_cdtext[i_track]->field[CDTEXT_TITLE]);
} else
add_format_str_info(psz_mrl);
}
break; break;
case 'p': case 'p':
if (p_cdda->p_cdtext[i_track] if (p_cdda->p_cdtext[i_track]
...@@ -598,6 +606,13 @@ CDDAFormatStr( const access_t *p_access, cdda_data_t *p_cdda, ...@@ -598,6 +606,13 @@ CDDAFormatStr( const access_t *p_access, cdda_data_t *p_cdda,
&& p_cdda->p_cdtext[i_track]->field[CDTEXT_PERFORMER]) && p_cdda->p_cdtext[i_track]->field[CDTEXT_PERFORMER])
psz = p_cdda->p_cdtext[i_track]->field[CDTEXT_PERFORMER]; psz = p_cdda->p_cdtext[i_track]->field[CDTEXT_PERFORMER];
goto format_str; goto format_str;
case 't':
if (p_cdda->p_cdtext[i_track]
&& p_cdda->p_cdtext[i_track]->field[CDTEXT_TITLE])
psz = p_cdda->p_cdtext[i_track]->field[CDTEXT_TITLE];
else
psz = psz_mrl;
goto format_str;
case 'e': case 'e':
if (p_cdda->p_cdtext[i_track] if (p_cdda->p_cdtext[i_track]
&& p_cdda->p_cdtext[i_track]->field[CDTEXT_MESSAGE]) && p_cdda->p_cdtext[i_track]->field[CDTEXT_MESSAGE])
...@@ -607,7 +622,7 @@ CDDAFormatStr( const access_t *p_access, cdda_data_t *p_cdda, ...@@ -607,7 +622,7 @@ CDDAFormatStr( const access_t *p_access, cdda_data_t *p_cdda,
#endif /*HAVE_LIBCDDB*/ #endif /*HAVE_LIBCDDB*/
case 'M': case 'M':
add_format_str_info(mrl); add_format_str_info(psz_mrl);
break; break;
case 'm': case 'm':
...@@ -673,18 +688,19 @@ CDDACreatePlaylistItem( const access_t *p_access, cdda_data_t *p_cdda, ...@@ -673,18 +688,19 @@ CDDACreatePlaylistItem( const access_t *p_access, cdda_data_t *p_cdda,
#endif /*HAVE_LIBCDDB*/ #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, psz_title = CDDAFormatStr( p_access, p_cdda,
config_GetPsz( p_access, config_varname ), config_GetPsz( p_access, config_varname ),
psz_mrl, i_track); psz_mrl, i_track);
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", dbg_print( INPUT_DBG_META, "mrl: %s, title: %s, duration, %ld",
psz_mrl, psz_title, (long int) i_duration / 1000000 ); psz_mrl, psz_title, (long int) i_duration / 1000000 );
p_child = playlist_ItemNew( p_playlist, psz_mrl, psz_title ); p_child = playlist_ItemNew( p_playlist, psz_mrl, psz_title );
p_child->input.b_fixed_name = VLC_TRUE; p_child->input.b_fixed_name = VLC_TRUE;
p_child->input.i_duration = i_duration;
if( !p_child ) return NULL; if( !p_child ) return NULL;
...@@ -795,7 +811,7 @@ CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda, ...@@ -795,7 +811,7 @@ CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda,
{ {
int i; int i;
playlist_t * p_playlist; playlist_t * p_playlist;
char * psz_mrl; char * psz_mrl = NULL;
unsigned int psz_mrl_max = strlen(CDDA_MRL_PREFIX) + strlen(psz_source) + unsigned int psz_mrl_max = strlen(CDDA_MRL_PREFIX) + strlen(psz_source) +
strlen("@T") + strlen("100") + 1; strlen("@T") + strlen("100") + 1;
const track_t i_first_track = p_cdda->i_first_track; const track_t i_first_track = p_cdda->i_first_track;
...@@ -831,10 +847,13 @@ CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda, ...@@ -831,10 +847,13 @@ CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda,
if( b_single_track ) if( b_single_track )
{ {
snprintf(psz_mrl, psz_mrl_max, "%s%s@T%u", CDDA_MRL_PREFIX,
psz_source, p_cdda->i_track);
CDDAMetaInfo( p_access, p_cdda->i_track, psz_mrl ); CDDAMetaInfo( p_access, p_cdda->i_track, psz_mrl );
} }
else else
{ {
snprintf(psz_mrl, psz_mrl_max, "%s%s", CDDA_MRL_PREFIX, psz_source);
CDDAMetaInfo( p_access, -1, psz_mrl ); CDDAMetaInfo( p_access, -1, psz_mrl );
} }
...@@ -872,6 +891,12 @@ CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda, ...@@ -872,6 +891,12 @@ CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda,
VLC_FALSE ); VLC_FALSE );
p_cdda->i_titles = 1; p_cdda->i_titles = 1;
p_access->info.i_size =
(p_cdda->lsn[p_cdda->i_track]
- p_cdda->lsn[i_first_track+1]) * (int64_t) CDIO_CD_FRAMESIZE_RAW;
p_item->input.i_duration =
(p_cdda->lsn[p_cdda->i_track]
- p_cdda->lsn[i_first_track+1]) / CDIO_CD_FRAMES_PER_SEC;
} }
else else
{ {
...@@ -897,8 +922,11 @@ CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda, ...@@ -897,8 +922,11 @@ CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda,
} }
p_cdda->i_titles = p_cdda->i_tracks; /* should be +1 */ p_cdda->i_titles = p_cdda->i_tracks; /* should be +1 */
p_access->info.i_size = p_access->info.i_size =
(p_cdda->lsn[i_first_track + p_cdda->i_tracks] (p_cdda->lsn[i_first_track + p_cdda->i_tracks]
- p_cdda->lsn[i_first_track]) * (int64_t) CDIO_CD_FRAMESIZE_RAW; - p_cdda->lsn[i_first_track]) * (int64_t) CDIO_CD_FRAMESIZE_RAW;
p_item->input.i_duration =
(p_cdda->lsn[i_first_track + p_cdda->i_tracks]
- p_cdda->lsn[i_first_track]) / CDIO_CD_FRAMES_PER_SEC;
} }
if( b_play ) if( b_play )
...@@ -913,3 +941,10 @@ CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda, ...@@ -913,3 +941,10 @@ CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda,
return VLC_SUCCESS; return VLC_SUCCESS;
} }
/*
* Local variables:
* mode: C
* style: gnu
* End:
*/
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment