Fixed last track time calculation (thanks Tchi Southivong)
authorSam Lantinga <slouken@libsdl.org>
Sun, 30 Sep 2001 19:07:56 +0000
changeset 201ddee60057806
parent 200 ec77d3d32201
child 202 401f0134f4f9
Fixed last track time calculation (thanks Tchi Southivong)
src/cdrom/win32/SDL_syscdrom.c
     1.1 --- a/src/cdrom/win32/SDL_syscdrom.c	Sun Sep 30 18:55:08 2001 +0000
     1.2 +++ b/src/cdrom/win32/SDL_syscdrom.c	Sun Sep 30 19:07:56 2001 +0000
     1.3 @@ -215,18 +215,19 @@
     1.4  			}
     1.5  		}
     1.6  		if ( i == cdrom->numtracks ) {
     1.7 -			flags &= ~MCI_TRACK;
     1.8 +			mci_status.dwTrack = cdrom->track[i - 1].id;
     1.9  			mci_status.dwItem = MCI_STATUS_LENGTH;
    1.10  			if ( SDL_SYS_CDioctl(cdrom->id, MCI_STATUS, flags,
    1.11  							&mci_status) == 0 ) {
    1.12 -				cdrom->track[i].offset = MSF_TO_FRAMES(
    1.13 +				cdrom->track[i - 1].length = MSF_TO_FRAMES(
    1.14  					MCI_MSF_MINUTE(mci_status.dwReturn),
    1.15  					MCI_MSF_SECOND(mci_status.dwReturn),
    1.16 -					MCI_MSF_FRAME(mci_status.dwReturn));
    1.17 +					MCI_MSF_FRAME(mci_status.dwReturn)) + 1; /* +1 to fix */
    1.18 +											/* MCI last track length bug */
    1.19 +				/* compute lead-out offset */
    1.20 +				cdrom->track[i].offset = cdrom->track[i - 1].offset +
    1.21 +					cdrom->track[i - 1].length;
    1.22  				cdrom->track[i].length = 0;
    1.23 -				cdrom->track[i-1].length =
    1.24 -						cdrom->track[i].offset-
    1.25 -						cdrom->track[i-1].offset;
    1.26  				okay = 1;
    1.27  			}
    1.28  		}