Mercurial > mplayer.hg
changeset 20586:d9558d78179d
cosmetics: move WIN32 read_toc code to allow for summarizing more common
code of the other variants.
author | reimar |
---|---|
date | Wed, 01 Nov 2006 19:57:44 +0000 |
parents | 68b55a823fd4 |
children | 128b2dc39f57 |
files | stream/stream_cddb.c |
diffstat | 1 files changed, 24 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/stream/stream_cddb.c Wed Nov 01 19:52:42 2006 +0000 +++ b/stream/stream_cddb.c Wed Nov 01 19:57:44 2006 +0000 @@ -66,6 +66,29 @@ read_toc(const char *dev) { int first, last; int i; +#ifdef WIN32 + HANDLE drive; + DWORD r; + CDROM_TOC toc; + char device[10]; + + sprintf(device, "\\\\.\\%s", dev); + drive = CreateFile(device, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0); + + if(!DeviceIoControl(drive, IOCTL_CDROM_READ_TOC, NULL, 0, &toc, sizeof(CDROM_TOC), &r, 0)) { + mp_msg(MSGT_OPEN, MSGL_ERR, MSGTR_MPDEMUX_CDDB_FailedToReadTOC); + return 0; + } + + first = toc.FirstTrack - 1; last = toc.LastTrack; + 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]; + } + CloseHandle(drive); + +#else #if defined(__linux__) || defined(__bsdi__) int drive; struct cdrom_tochdr tochdr; @@ -88,28 +111,6 @@ } close(drive); -#elif defined(WIN32) - HANDLE drive; - DWORD r; - CDROM_TOC toc; - char device[10]; - - sprintf(device, "\\\\.\\%s", dev); - drive = CreateFile(device, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0); - - if(!DeviceIoControl(drive, IOCTL_CDROM_READ_TOC, NULL, 0, &toc, sizeof(CDROM_TOC), &r, 0)) { - mp_msg(MSGT_OPEN, MSGL_ERR, MSGTR_MPDEMUX_CDDB_FailedToReadTOC); - return 0; - } - - first = toc.FirstTrack - 1; last = toc.LastTrack; - 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]; - } - CloseHandle(drive); - #elif defined(__FreeBSD__) || defined(__DragonFly__) int drive; struct ioc_toc_header tochdr; @@ -157,6 +158,7 @@ } close(drive); #endif +#endif for (i = first; i <= last; i++) cdtoc[i].frame += (cdtoc[i].min * 60 + cdtoc[i].sec) * 75; return last;