From b4b9303e0775f836c8279316f772e9cb73154802 Mon Sep 17 00:00:00 2001
From: Eric Pouech <Eric.Pouech@wanadoo.fr>
Date: Sat, 25 Dec 1999 22:54:54 +0000
Subject: [PATCH] Fixed first/last playable frame referencing.

---
 include/cdrom.h | 14 +++++++++-----
 misc/cdrom.c    | 15 +++++++++------
 msdos/int2f.c   |  4 ++--
 3 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/include/cdrom.h b/include/cdrom.h
index e263dd2cb85..660325ce5d8 100644
--- a/include/cdrom.h
+++ b/include/cdrom.h
@@ -30,17 +30,21 @@ typedef struct {
 #elif defined(__FreeBSD__) || defined(__NetBSD__)
     struct cd_sub_channel_info	sc;
 #endif
-    int				cdaMode;
-    UINT16			nCurTrack;
-    DWORD			dwCurFrame;
+    /* those data reflect the cdaudio structure and
+     * don't change while playing
+     */
     UINT16			nTracks;
     UINT16			nFirstTrack;
     UINT16			nLastTrack;
-    DWORD			dwTotalLen;
     LPDWORD			lpdwTrackLen;
     LPDWORD			lpdwTrackPos;
     LPBYTE			lpbTrackFlags;
-    DWORD			dwFirstOffset;
+    DWORD			dwFirstFrame;
+    DWORD			dwLastFrame;
+    /* those data change while playing */
+    int				cdaMode;
+    UINT16			nCurTrack;
+    DWORD			dwCurFrame;
 } WINE_CDAUDIO;
 
 #define	WINE_CDA_DONTKNOW		0x00
diff --git a/misc/cdrom.c b/misc/cdrom.c
index 633bc7a7c7e..098737c56cb 100644
--- a/misc/cdrom.c
+++ b/misc/cdrom.c
@@ -39,8 +39,8 @@ int	CDAUDIO_Open(WINE_CDAUDIO* wcda)
     wcda->cdaMode = WINE_CDA_OPEN;	/* to force reading tracks info */
     wcda->nCurTrack = 0;
     wcda->nTracks = 0;
-    wcda->dwTotalLen = 0;
-    wcda->dwFirstOffset = 0;
+    wcda->dwFirstFrame = 0;
+    wcda->dwLastFrame = 0;
     wcda->lpdwTrackLen = NULL;
     wcda->lpdwTrackPos = NULL;
     wcda->lpbTrackFlags = NULL;
@@ -152,7 +152,7 @@ BOOL CDAUDIO_GetTracksInfo(WINE_CDAUDIO* wcda)
 #endif
 	else
 #ifdef linux
-	    entry.cdte_track = i + 1;
+	entry.cdte_track = i + 1;
 #else
 	entry.starting_track = i + 1;
 #endif
@@ -187,7 +187,7 @@ BOOL CDAUDIO_GetTracksInfo(WINE_CDAUDIO* wcda)
 #endif
 	if (i == 0) {
 	    last_start = start;
-	    wcda->dwFirstOffset = start;
+	    wcda->dwFirstFrame = start;
 	    TRACE("dwFirstOffset=%u\n", start);
 	} else {
 	    length = start - last_start;
@@ -207,7 +207,7 @@ BOOL CDAUDIO_GetTracksInfo(WINE_CDAUDIO* wcda)
 #endif 
 	TRACE("track #%u flags=%02x\n", i + 1, wcda->lpbTrackFlags[i]);
     }
-    wcda->dwTotalLen = total_length;
+    wcda->dwLastFrame = last_start;
     TRACE("total_len=%u\n", total_length);
     return TRUE;
 #else
@@ -425,6 +425,9 @@ int	CDAUDIO_Pause(WINE_CDAUDIO* wcda, int pauseOn)
 #endif
 }
 
+/**************************************************************************
+ * 				CDAUDIO_Seek			[internal]
+ */
 int	CDAUDIO_Seek(WINE_CDAUDIO* wcda, DWORD at)
 {
 #if defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__)
@@ -435,7 +438,7 @@ int	CDAUDIO_Seek(WINE_CDAUDIO* wcda, DWORD at)
     msf.second = (at % CDFRAMES_PERMIN) / CDFRAMES_PERSEC;
     msf.frame  = at % CDFRAMES_PERSEC;
 
-   ret = ioctl(wcda->unixdev, CDROMSEEK, &msf);
+    ret = ioctl(wcda->unixdev, CDROMSEEK, &msf);
 #else
    /* FIXME: the current end for play is lost 
     * use end of CD ROM instead
diff --git a/msdos/int2f.c b/msdos/int2f.c
index 2b77bf9b23d..517185f511c 100644
--- a/msdos/int2f.c
+++ b/msdos/int2f.c
@@ -620,7 +620,7 @@ static void MSCDEX_Handler(CONTEXT86* context)
 		    break;
 		    
 		case 8: /* Volume size */
-		    PTR_AT(io_stru, 1, DWORD) = wcda.dwTotalLen;
+		    PTR_AT(io_stru, 1, DWORD) = wcda.dwLastFrame;
 		    TRACE(" ----> VOLUME SIZE <%ld>\n", PTR_AT(io_stru, 1, DWORD));
 		    break;
 		    
@@ -633,7 +633,7 @@ static void MSCDEX_Handler(CONTEXT86* context)
 		case 10: /* audio disk info */
 		    io_stru[1] = wcda.nFirstTrack; /* starting track of the disc */
 		    io_stru[2] = wcda.nLastTrack;  /* ending track */
-		    MSCDEX_StoreMSF(wcda.dwTotalLen, io_stru + 3);
+		    MSCDEX_StoreMSF(wcda.dwLastFrame, io_stru + 3);
 		    
 		    TRACE(" ----> AUDIO DISK INFO <%d-%d/%08lx>\n",
 			  io_stru[1], io_stru[2], PTR_AT(io_stru, 3, DWORD));
-- 
GitLab