}
/* Check end of track */
- while( p_cdda->i_lsn >= p_cdda->lsn[p_cdda->i_track+1] )
+ while( p_cdda->i_lsn >= cdio_get_track_lsn(p_cdda->p_cdio,
+ p_cdda->i_track+1) )
{
if( p_cdda->i_track >= p_cdda->i_first_track + p_cdda->i_titles - 1 )
{
}
/* Possibly adjust i_blocks so we don't read past the end of a track. */
- if( p_cdda->i_lsn + i_blocks >= p_cdda->lsn[p_cdda->i_track+1] )
+ if( p_cdda->i_lsn + i_blocks >=
+ cdio_get_track_lsn(p_cdda->p_cdio, p_cdda->i_track+1) )
{
- i_blocks = p_cdda->lsn[p_cdda->i_track+1 ] - p_cdda->i_lsn;
+ i_blocks = cdio_get_track_lsn( p_cdda->p_cdio, p_cdda->i_track+1 )
+ - p_cdda->i_lsn;
}
/* Do the actual reading */
{
cdda_data_t *p_cdda = (cdda_data_t *) p_access->p_sys;
- p_cdda->i_lsn = p_cdda->lsn[p_cdda->i_track]
+ p_cdda->i_lsn = cdio_get_track_lsn(p_cdda->p_cdio, p_cdda->i_track)
+ (i_pos / CDIO_CD_FRAMESIZE_RAW);
p_access->info.i_pos = i_pos;
p_cdda->b_cdtext_prefer =
config_GetInt( p_access, MODULE_STRING "-cdtext-prefer" );
- p_cdda->b_header = VLC_FALSE;
- p_cdda->p_cdio = p_cdio;
- p_cdda->i_tracks = 0;
- p_cdda->i_titles = 0;
- p_cdda->i_track = i_track;
- p_cdda->i_debug = config_GetInt(p_this, MODULE_STRING "-debug");
+ p_cdda->psz_source = strdup(psz_source);
+ p_cdda->b_header = VLC_FALSE;
+ p_cdda->p_cdio = p_cdio;
+ p_cdda->i_tracks = 0;
+ p_cdda->i_titles = 0;
+ p_cdda->i_track = i_track;
+ p_cdda->i_debug = config_GetInt(p_this, MODULE_STRING "-debug");
p_cdda->i_blocks_per_read
- = config_GetInt(p_this, MODULE_STRING "-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 );
i_rc = CDDAInit( p_access, p_cdda );
if ( VLC_SUCCESS != i_rc ) goto error;
- CDDAFixupPlaylist( p_access, p_cdda, psz_source, b_single_track );
+ CDDAFixupPlaylist( p_access, p_cdda, b_single_track );
/* Build a WAV header to put in front of the output data.
This gets sent back in the Block (read) routine.
cddb_disc_destroy(p_cdda->cddb.disc);
#endif
- if (p_cdda->psz_mcn) free( p_cdda->psz_mcn );
+ if (p_cdda->psz_mcn) free( p_cdda->psz_mcn );
+ if (p_cdda->psz_source) free( p_cdda->psz_source );
free( p_cdda );
p_cdda_input = NULL;
}
case ACCESS_GET_TITLE_INFO:
{
- input_title_t ***ppp_title;
- ppp_title = (input_title_t***)va_arg( args, input_title_t*** );
+ unsigned int psz_mrl_max = strlen(CDDA_MRL_PREFIX)
+ + strlen(p_cdda->psz_source) + 1;
+ input_title_t ***ppp_title =
+ (input_title_t***)va_arg( args, input_title_t*** );
+ char *psz_mrl = malloc( psz_mrl_max );
+
pi_int = (int*)va_arg( args, int* );
*((int*)va_arg( args, int* )) = 1; /* Title offset */
"GET TITLE: i_tracks %d, i_tracks %d",
p_cdda->i_tracks, p_cdda->i_tracks );
+ if( psz_mrl == NULL ) {
+ msg_Warn( p_access, "out of memory" );
+ } else {
+ snprintf(psz_mrl, psz_mrl_max, "%s%s",
+ CDDA_MRL_PREFIX, p_cdda->psz_source);
+ CDDAMetaInfo( p_access, -1, psz_mrl );
+ free(psz_mrl);
+ }
+
/* Duplicate title info */
if( p_cdda->i_titles == 0 )
{
(*ppp_title)[i] =
vlc_input_title_Duplicate( p_cdda->p_title[i] );
}
-
}
break;
}
p_access->info.i_pos = 0;
/* Next sector to read */
- p_cdda->i_lsn = p_cdda->lsn[p_cdda->i_first_track+i];
+ p_cdda->i_lsn =
+ cdio_get_track_lsn(p_cdda->p_cdio, p_cdda->i_first_track+i);
}
break;
}
*****************************************************************************/
static int CDDAInit( access_t *p_access, cdda_data_t *p_cdda )
{
- track_t i;
discmode_t discmode = CDIO_DISC_MODE_NO_INFO;
p_cdda->i_tracks = cdio_get_num_tracks(p_cdda->p_cdio);
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;
- (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];
+ p_cdda->i_lsn = cdio_get_track_lsn(p_cdda->p_cdio, p_cdda->i_track);
return VLC_SUCCESS;
}
# include <errno.h>
#endif
-#define CDDA_MRL_PREFIX "cddax://"
-
#ifdef HAVE_LIBCDDB
#define free_and_dup(var, val) \
if (val) var=strdup(val);
-static void GetCDDBInfo( access_t *p_access, cdda_data_t *p_cdda )
+/* Saves CDDB information about CD-DA via libcddb. */
+static void
+GetCDDBInfo( access_t *p_access, cdda_data_t *p_cdda )
{
int i, i_matches;
cddb_conn_t *conn = cddb_new();
add_cdtext_info_str("Disc", TITLE, 0, FIELD)
+/*
+ Saves Meta Information about the CD-DA.
+
+ Saves information that CDDAMetaInfo uses. Should be called before
+ CDDAMetaInfo is called.
+ */
+void
+CDDAMetaInfoInit( access_t *p_access, int i_track )
+{
+ cdda_data_t *p_cdda = (cdda_data_t *) p_access->p_sys;
+
+ if ( ! p_cdda ) return;
+
+ p_cdda->psz_mcn = cdio_get_mcn(p_cdda->p_cdio);
+ p_cdda->p_meta = vlc_meta_New();
+
+#ifdef HAVE_LIBCDDB
+ if ( p_cdda->b_cddb_enabled )
+ {
+ GetCDDBInfo(p_access, p_cdda);
+ }
+
+#endif /*HAVE_LIBCDDB*/
+
+#define TITLE_MAX 30
+ {
+ unsigned int i;
+ p_cdda->p_cdtext[0] = cdio_get_cdtext(p_cdda->p_cdio, 0);
+
+ for( i = 0 ; i < p_cdda->i_tracks ; i++ )
+ {
+ p_cdda->p_cdtext[i_track] =
+ cdio_get_cdtext(p_cdda->p_cdio, i_track);
+ }
+ }
+}
+
/*
Gets and saves Meta Information about the CD-DA.
media info" or in playlist info. The intialization of CD-Text or CDDB
is done here though.
*/
-void CDDAMetaInfo( access_t *p_access, int i_track, /*const*/ char *psz_mrl )
+void
+CDDAMetaInfo( access_t *p_access, int i_track, /*const*/ char *psz_mrl )
{
cdda_data_t *p_cdda = (cdda_data_t *) p_access->p_sys;
char *psz_meta_title = psz_mrl;
if ( ! p_cdda ) return;
- p_cdda->psz_mcn = cdio_get_mcn(p_cdda->p_cdio);
- p_cdda->p_meta = vlc_meta_New();
-
#ifdef HAVE_LIBCDDB
- if ( p_cdda->b_cddb_enabled )
+ if ( p_cdda->b_cddb_enabled && p_cdda->cddb.disc )
{
- GetCDDBInfo(p_access, p_cdda);
- if ( p_cdda->cddb.disc )
- {
- if( i_track == -1 )
- {
- psz_meta_title = p_cdda->cddb.disc->title;
- psz_meta_artist = p_cdda->cddb.disc->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( VLC_META_TITLE, t->title );
- }
- if( t->artist != NULL )
- {
- add_meta_val( VLC_META_ARTIST, t->artist );
- }
- }
- }
- add_cddb_meta(genre, VLC_META_GENRE);
- add_cddb_meta_fmt(year, "%d", VLC_META_DATE );
+ if( i_track == -1 )
+ {
+ psz_meta_title = p_cdda->cddb.disc->title;
+ psz_meta_artist = p_cdda->cddb.disc->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( VLC_META_TITLE, t->title );
+ }
+ if( t->artist != NULL )
+ {
+ add_meta_val( VLC_META_ARTIST, t->artist );
+ }
+ }
+ }
+ add_cddb_meta(genre, VLC_META_GENRE);
+ add_cddb_meta_fmt(year, "%d", VLC_META_DATE );
}
#endif /*HAVE_LIBCDDB*/
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;
+ unsigned int i_track_frames =
+ cdio_get_track_lba(p_cdda->p_cdio, CDIO_CDROM_LEADOUT_TRACK);
+
+ mtime_t i_duration = i_track_frames / CDIO_CD_FRAMES_PER_SEC;
dbg_print( INPUT_DBG_META, "Duration %ld, tracks %d",
(long int) i_duration, p_cdda->i_tracks );
}
#endif /*HAVE_LIBCDDB*/
- p_cdda->p_cdtext[0] = cdio_get_cdtext(p_cdda->p_cdio, 0);
if (p_cdda->p_cdtext[0])
{
char *psz_field;
{
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;
+ unsigned int i_track_frames =
+ cdio_get_track_lsn(p_cdda->p_cdio, i_track+1) -
+ cdio_get_track_lsn(p_cdda->p_cdio, i_track);
+
+ mtime_t i_duration = i_track_frames / 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)",
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 ) );
+ unsigned int i_track_frames =
+ cdio_get_track_lsn(p_cdda->p_cdio, i_track+1) -
+ cdio_get_track_lsn(p_cdda->p_cdio, i_track);
+ mtime_t i_duration =
+ i_track_frames / CDIO_CD_FRAMES_PER_SEC;
+ add_format_str_info( secstotimestr( psz_buffer,
+ i_duration ) );
} else goto not_special;
break;
#else
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 )
+ track_t i_track, char *psz_mrl, int psz_mrl_max )
{
- mtime_t i_duration = (p_cdda->lsn[i_track+1] - p_cdda->lsn[i_track])
- * (1000000 / CDIO_CD_FRAMES_PER_SEC) ;
+ unsigned int i_track_frames =
+ cdio_get_track_lsn(p_cdda->p_cdio, i_track+1) -
+ cdio_get_track_lsn(p_cdda->p_cdio, i_track);
+ mtime_t i_mduration =
+ i_track_frames * (CLOCK_FREQ / CDIO_CD_FRAMES_PER_SEC) ;
char *psz_title;
char *config_varname = MODULE_STRING "-title-format";
snprintf(psz_mrl, psz_mrl_max, "%s%s@T%u",
- CDDA_MRL_PREFIX, psz_source, i_track);
+ CDDA_MRL_PREFIX, p_cdda->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",
- psz_mrl, psz_title, (long int) i_duration / 1000000 );
+ psz_mrl, psz_title, (long int) i_mduration / 1000000 );
p_child = playlist_ItemNew( p_playlist, psz_mrl, psz_title );
p_child->input.b_fixed_name = VLC_TRUE;
- p_child->input.i_duration = i_duration;
+ p_child->input.i_duration = i_mduration;
if( !p_child ) return NULL;
}
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 )
+ playlist_item_t *p_item, int i_track,
+ vlc_bool_t b_single )
{
vlc_mutex_lock( &p_item->input.lock );
- add_playlist_track_info_str("Source", psz_source);
+ add_playlist_track_info_str("Source", p_cdda->psz_source);
playlist_ItemAddInfo( p_item, _("Track"), _("Track Number"),
"%d", i_track );
}
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,
+ vlc_bool_t b_single_track )
{
int i;
playlist_t * p_playlist;
char * psz_mrl = NULL;
- unsigned int psz_mrl_max = strlen(CDDA_MRL_PREFIX) + strlen(psz_source) +
- strlen("@T") + strlen("100") + 1;
+ unsigned int psz_mrl_max = strlen(CDDA_MRL_PREFIX)
+ + strlen(p_cdda->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;
if( b_single_track )
{
snprintf(psz_mrl, psz_mrl_max, "%s%s@T%u", CDDA_MRL_PREFIX,
- psz_source, p_cdda->i_track);
+ p_cdda->psz_source, p_cdda->i_track);
+ CDDAMetaInfoInit( p_access, p_cdda->i_track );
CDDAMetaInfo( p_access, p_cdda->i_track, psz_mrl );
}
else
{
- snprintf(psz_mrl, psz_mrl_max, "%s%s", CDDA_MRL_PREFIX, psz_source);
+ snprintf(psz_mrl, psz_mrl_max, "%s%s", CDDA_MRL_PREFIX,
+ p_cdda->psz_source);
+ CDDAMetaInfoInit( p_access, -1 );
CDDAMetaInfo( p_access, -1, psz_mrl );
}
more mature.
*/
track_t i_track = p_cdda->i_track;
-
+ unsigned int i_track_frames =
+ cdio_get_track_lsn(p_cdda->p_cdio, i_track+1) -
+ cdio_get_track_lsn(p_cdda->p_cdio, 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_size = p_access->info.i_size =
+ i_track_frames * (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 );
+ CDDAAddMetaToItem( p_access, p_cdda, p_item, i_track, VLC_FALSE );
p_cdda->i_titles = 1;
p_access->info.i_size =
- (p_cdda->lsn[p_cdda->i_track-1]
- - p_cdda->lsn[i_first_track]) * (int64_t) CDIO_CD_FRAMESIZE_RAW;
+ i_track_frames * (int64_t) CDIO_CD_FRAMESIZE_RAW;
p_access->info.i_update |= INPUT_UPDATE_TITLE|INPUT_UPDATE_SIZE;
- p_item->input.i_duration =
- (p_cdda->lsn[p_cdda->i_track]
- - p_cdda->lsn[i_first_track+1]) / CDIO_CD_FRAMES_PER_SEC;
+ p_item->input.i_duration = i_track_frames
+ * (CLOCK_FREQ / CDIO_CD_FRAMES_PER_SEC);
}
else
{
{
playlist_item_t *p_child;
const track_t i_track = i_first_track + i;
+ unsigned int i_track_frames =
+ cdio_get_track_lsn(p_cdda->p_cdio, i_track+1) -
+ cdio_get_track_lsn(p_cdda->p_cdio, i_track);
+
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_size = i_track_frames * (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 );
+ psz_mrl_max ) ;
+ CDDAAddMetaToItem( p_access, p_cdda, p_child, i_track, VLC_TRUE );
}
p_cdda->i_titles = p_cdda->i_tracks; /* should be +1 */
p_access->info.i_size =
- (p_cdda->lsn[p_cdda->i_tracks]
- - p_cdda->lsn[0]) * (int64_t) CDIO_CD_FRAMESIZE_RAW;
+ cdio_get_track_lba(p_cdda->p_cdio, CDIO_CDROM_LEADOUT_TRACK)
+ * (int64_t) CDIO_CD_FRAMESIZE_RAW;
p_access->info.i_update |= INPUT_UPDATE_TITLE|INPUT_UPDATE_SIZE;
p_item->input.i_duration =
- (p_cdda->lsn[p_cdda->i_tracks]
- - p_cdda->lsn[0]) / CDIO_CD_FRAMES_PER_SEC;
+ p_access->info.i_size * (CLOCK_FREQ / CDIO_CD_FRAMES_PER_SEC) ;
}
if( b_play )