Mercurial > mplayer.hg
changeset 20583:47d5d63e8214
Avoid code duplication for "last" toc entry.
author | reimar |
---|---|
date | Wed, 01 Nov 2006 19:41:03 +0000 |
parents | 04b535afeaea |
children | 200ec2faa4e1 |
files | stream/stream_cddb.c |
diffstat | 1 files changed, 7 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/stream/stream_cddb.c Wed Nov 01 19:24:54 2006 +0000 +++ b/stream/stream_cddb.c Wed Nov 01 19:41:03 2006 +0000 @@ -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++)