[MPlayer-cvslog] r20599 - trunk/stream/stream_cddb.c
reimar
subversion at mplayerhq.hu
Wed Nov 1 20:41:03 CET 2006
Author: reimar
Date: Wed Nov 1 20:41:03 2006
New Revision: 20599
Modified:
trunk/stream/stream_cddb.c
Log:
Avoid code duplication for "last" toc entry.
Modified: trunk/stream/stream_cddb.c
==============================================================================
--- trunk/stream/stream_cddb.c (original)
+++ trunk/stream/stream_cddb.c Wed Nov 1 20:41:03 2006
@@ -78,20 +78,14 @@
ioctl(drive, CDROMREADTOCHDR, &tochdr);
first = tochdr.cdth_trk0 - 1; last = tochdr.cdth_trk1;
- for (i = first; i < last; i++) {
- tocentry.cdte_track = i;
+ for (i = first; i <= last; i++) {
+ tocentry.cdte_track = (i == last) ? 0xAA : i;
tocentry.cdte_format = CDROM_MSF;
ioctl(drive, CDROMREADTOCENTRY, &tocentry);
cdtoc[i].min = tocentry.cdte_addr.msf.minute;
cdtoc[i].sec = tocentry.cdte_addr.msf.second;
cdtoc[i].frame = tocentry.cdte_addr.msf.frame;
}
- tocentry.cdte_track = 0xAA;
- tocentry.cdte_format = CDROM_MSF;
- ioctl(drive, CDROMREADTOCENTRY, &tocentry);
- cdtoc[last].min = tocentry.cdte_addr.msf.minute;
- cdtoc[last].sec = tocentry.cdte_addr.msf.second;
- cdtoc[last].frame = tocentry.cdte_addr.msf.frame;
close(drive);
#elif defined(WIN32)
@@ -109,14 +103,11 @@
}
first = toc.FirstTrack - 1; last = toc.LastTrack;
- for (i = first; i < last; i++) {
+ for (i = first; i <= last; i++) {
cdtoc[i].min = toc.TrackData[i].Address[1];
cdtoc[i].sec = toc.TrackData[i].Address[2];
cdtoc[i].frame = toc.TrackData[i].Address[3];
}
- cdtoc[last].min = toc.TrackData[last].Address[1];
- cdtoc[last].sec = toc.TrackData[last].Address[2];
- cdtoc[last].frame = toc.TrackData[last].Address[3];
CloseHandle(drive);
#elif defined(__FreeBSD__) || defined(__DragonFly__)
@@ -131,20 +122,14 @@
ioctl(drive, CDIOREADTOCHEADER, &tochdr);
first = tochdr.starting_track; last = tochdr.ending_track;
- for (i = first; i < last; i++) {
- tocentry.track = i;
+ for (i = first; i <= last; i++) {
+ tocentry.track = (i == last) ? 0xAA : i;
tocentry.address_format = CD_MSF_FORMAT;
ioctl(drive, CDIOREADTOCENTRY, &tocentry);
cdtoc[i].min = tocentry.entry.addr.msf.minute;
cdtoc[i].sec = tocentry.entry.addr.msf.second;
cdtoc[i].frame = tocentry.entry.addr.msf.frame;
}
- tocentry.track = 0xAA;
- tocentry.address_format = CD_MSF_FORMAT;
- ioctl(drive, CDIOREADTOCENTRY, &tocentry);
- cdtoc[last].min = tocentry.entry.addr.msf.minute;
- cdtoc[last].sec = tocentry.entry.addr.msf.second;
- cdtoc[last].frame = tocentry.entry.addr.msf.frame;
close(drive);
#elif defined(__NetBSD__) || defined(__OpenBSD__)
@@ -160,8 +145,8 @@
ioctl(drive, CDIOREADTOCHEADER, &tochdr);
first = tochdr.starting_track - 1; last = tochdr.ending_track;
- for (i = first; i < last; i++) {
- tocentry.starting_track = i;
+ for (i = first; i <= last; i++) {
+ tocentry.starting_track = (i == last) ? 0xAA : i;
tocentry.address_format = CD_MSF_FORMAT;
tocentry.data = &toc_buffer;
tocentry.data_len = sizeof(toc_buffer);
@@ -170,12 +155,6 @@
cdtoc[i].sec = toc_buffer.addr.msf.second;
cdtoc[i].frame = toc_buffer.addr.msf.frame;
}
- tocentry.starting_track = 0xAA;
- tocentry.address_format = CD_MSF_FORMAT;
- ioctl(drive, CDIOREADTOCENTRYS, &tocentry);
- cdtoc[last].min = toc_buffer.addr.msf.minute;
- cdtoc[last].sec = toc_buffer.addr.msf.second;
- cdtoc[last].frame = toc_buffer.addr.msf.frame;
close(drive);
#endif
for (i = first; i <= last; i++)
More information about the MPlayer-cvslog
mailing list