Fixed last track time calculation (thanks Tchi Southivong)
authorSam Lantinga <slouken@libsdl.org>
Sun, 30 Sep 2001 19:07:56 +0000
changeset 201 ddee60057806
parent 200 ec77d3d32201
child 202 401f0134f4f9
Fixed last track time calculation (thanks Tchi Southivong)
src/cdrom/win32/SDL_syscdrom.c
--- 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;
 			}
 		}