changeset 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 ec77d3d32201
children 401f0134f4f9
files src/cdrom/win32/SDL_syscdrom.c
diffstat 1 files changed, 7 insertions(+), 6 deletions(-) [+]
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;
 			}
 		}