mirror of
https://github.com/mpv-player/mpv.git
synced 2024-09-20 12:02:23 +02:00
Prints the number of tracks and MSF length for each track of an audio CD,
prints ID_CDDA_TRACK=N output showing the currently played track number when -identify is given. Patch by kiriuja < mplayer TIRET patches CHEZ en TIRET directo POIS net > Doxygen comments by Guillaume POIRIER Original thread: Date: Sep 11, 2005 10:49 PM Subject: Re: [MPlayer-dev-eng] [PATCH] -identify audio CD tracks git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@16525 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
b642825988
commit
55b7fc210e
@ -81,6 +81,7 @@ m_option_t cdda_opts[] = {
|
||||
{NULL, NULL, 0, 0, 0, 0, NULL}
|
||||
};
|
||||
|
||||
extern int cdd_identify(const char *dev);
|
||||
extern int cddb_resolve(const char *dev, char **xmcd_file);
|
||||
extern cd_info_t* cddb_parse_xmcd(char *xmcd_file);
|
||||
|
||||
@ -112,7 +113,9 @@ static int open_cdda(stream_t *st,int m, void* opts, int* file_format) {
|
||||
}
|
||||
|
||||
#ifdef MPLAYER_NETWORK
|
||||
if(strncmp(st->url,"cddb",4) == 0) {
|
||||
// cdd_identify returns -1 if it cannot read the TOC,
|
||||
// in which case there is no point in calling cddb_resolve
|
||||
if(cdd_identify(p->device) >= 0 && strncmp(st->url,"cddb",4) == 0) {
|
||||
i = cddb_resolve(p->device, &xmcd_file);
|
||||
if(i == 0) {
|
||||
cddb_info = cddb_parse_xmcd(xmcd_file);
|
||||
@ -274,7 +277,9 @@ static int fill_buffer(stream_t* s, char* buffer, int max_len) {
|
||||
cd_track = cd_info_get_track(p->cd_info, i+1);
|
||||
//printf("Track %d, sector=%d\n", i, p->sector-1);
|
||||
if( cd_track!=NULL ) {
|
||||
printf("\n%s\n", cd_track->name );
|
||||
mp_msg(MSGT_SEEK, MSGL_INFO, "\n%s\n", cd_track->name);
|
||||
if (identify)
|
||||
mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_CDDA_TRACK=%d\n", cd_track->track_nb);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -315,7 +320,9 @@ static int seek(stream_t* s,off_t newpos) {
|
||||
//printf("Track %d, sector=%d\n", seeked_track, sec);
|
||||
cd_track = cd_info_get_track(p->cd_info, seeked_track+1);
|
||||
if( cd_track!=NULL ) {
|
||||
printf("\n%s\n", cd_track->name );
|
||||
mp_msg(MSGT_SEEK, MSGL_INFO, "\n%s\n", cd_track->name);
|
||||
if (identify)
|
||||
mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_CDDA_TRACK=%d\n", cd_track->track_nb);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -45,6 +45,7 @@
|
||||
stream_t* open_cdda(char *dev, char *track);
|
||||
|
||||
static cd_toc_t cdtoc[100];
|
||||
static int cdtoc_last_track;
|
||||
|
||||
#if defined(__linux__)
|
||||
int
|
||||
@ -158,6 +159,39 @@ read_toc(const char *dev) {
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
\brief Reads TOC from CD in the given device and prints the number of tracks
|
||||
and the length of each track in minute:second:frame format.
|
||||
\param *dev the device to analyse
|
||||
\return if the command line -identify is given, returns the last track of
|
||||
the TOC or -1 if the TOC can't be read,
|
||||
otherwise just returns 0 and let cddb_resolve the TOC
|
||||
*/
|
||||
int cdd_identify(const char *dev)
|
||||
{
|
||||
cdtoc_last_track = 0;
|
||||
if (identify)
|
||||
{
|
||||
int i, min, sec, frame;
|
||||
cdtoc_last_track = read_toc(dev);
|
||||
if (cdtoc_last_track < 0) {
|
||||
mp_msg(MSGT_OPEN, MSGL_ERR, "Failed to open %s device.\n", dev);
|
||||
return -1;
|
||||
}
|
||||
mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_CDDA_TRACKS=%d\n", cdtoc_last_track);
|
||||
for (i = 1; i <= cdtoc_last_track; i++)
|
||||
{
|
||||
frame = cdtoc[i].frame - cdtoc[i-1].frame;
|
||||
sec = frame / 75;
|
||||
frame -= sec * 75;
|
||||
min = sec / 60;
|
||||
sec -= min * 60;
|
||||
mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_CDDA_TRACK_%d_MSF=%02d:%02d:%02d\n", i, min, sec, frame);
|
||||
}
|
||||
}
|
||||
return cdtoc_last_track;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
cddb_sum(int n) {
|
||||
unsigned int ret;
|
||||
@ -619,14 +653,16 @@ cddb_resolve(const char *dev, char **xmcd_file) {
|
||||
char cddb_cache_dir[] = DEFAULT_CACHE_DIR;
|
||||
char *home_dir = NULL;
|
||||
cddb_data_t cddb_data;
|
||||
int ret;
|
||||
|
||||
ret = read_toc(dev);
|
||||
if( ret<0 ) {
|
||||
if (cdtoc_last_track <= 0)
|
||||
{
|
||||
cdtoc_last_track = read_toc(dev);
|
||||
if (cdtoc_last_track < 0) {
|
||||
printf("Failed to open %s device.\n", dev);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
cddb_data.tracks = ret;
|
||||
cddb_data.tracks = cdtoc_last_track;
|
||||
cddb_data.disc_id = cddb_discid(cddb_data.tracks);
|
||||
cddb_data.anonymous = 1; // Don't send user info by default
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user