diff options
author | gpoirier <gpoirier@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2005-09-19 18:22:09 +0000 |
---|---|---|
committer | gpoirier <gpoirier@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2005-09-19 18:22:09 +0000 |
commit | 55b7fc210e0fc227027fbdfb9788fa230f6a137f (patch) | |
tree | 98848ee8460479178f0d29e0503041e35757f279 /libmpdemux/cddb.c | |
parent | b6428259886a10e1c18801c9ead54bdb31e51a4e (diff) | |
download | mpv-55b7fc210e0fc227027fbdfb9788fa230f6a137f.tar.bz2 mpv-55b7fc210e0fc227027fbdfb9788fa230f6a137f.tar.xz |
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
Diffstat (limited to 'libmpdemux/cddb.c')
-rw-r--r-- | libmpdemux/cddb.c | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/libmpdemux/cddb.c b/libmpdemux/cddb.c index 6bca6a87ca..8fe59db0be 100644 --- a/libmpdemux/cddb.c +++ b/libmpdemux/cddb.c @@ -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 |