diff src/cdrom/win32/SDL_syscdrom.c @ 201:ddee60057806

Fixed last track time calculation (thanks Tchi Southivong)
author Sam Lantinga <slouken@libsdl.org>
date Sun, 30 Sep 2001 19:07:56 +0000
parents e31f8d815aaa
children e8157fcb3114
line wrap: on
line diff
--- a/src/cdrom/win32/SDL_syscdrom.c	Sun Sep 30 18:55:08 2001 +0000
+++ b/src/cdrom/win32/SDL_syscdrom.c	Sun Sep 30 19:07:56 2001 +0000
@@ -215,18 +215,19 @@
 			}
 		}
 		if ( i == cdrom->numtracks ) {
-			flags &= ~MCI_TRACK;
+			mci_status.dwTrack = cdrom->track[i - 1].id;
 			mci_status.dwItem = MCI_STATUS_LENGTH;
 			if ( SDL_SYS_CDioctl(cdrom->id, MCI_STATUS, flags,
 							&mci_status) == 0 ) {
-				cdrom->track[i].offset = MSF_TO_FRAMES(
+				cdrom->track[i - 1].length = MSF_TO_FRAMES(
 					MCI_MSF_MINUTE(mci_status.dwReturn),
 					MCI_MSF_SECOND(mci_status.dwReturn),
-					MCI_MSF_FRAME(mci_status.dwReturn));
+					MCI_MSF_FRAME(mci_status.dwReturn)) + 1; /* +1 to fix */
+											/* MCI last track length bug */
+				/* compute lead-out offset */
+				cdrom->track[i].offset = cdrom->track[i - 1].offset +
+					cdrom->track[i - 1].length;
 				cdrom->track[i].length = 0;
-				cdrom->track[i-1].length =
-						cdrom->track[i].offset-
-						cdrom->track[i-1].offset;
 				okay = 1;
 			}
 		}