PATCH: Fixes problems with the cdrom driver not reporting certain
data correctly
Waldeck Schutzer
schutzer at math.rutgers.edu
Tue Jan 28 23:34:24 CST 2003
Some applications I tested failed to work correctly because of
incomplete/missing data received from the cdrom driver. The following
issues are addressed and should be fixed by this patch:
1. The field Length in CDROM_TOC was not being reported at all (it could
contain garbage).
2. GetDiskData would incorrectly report as audio for a cd with mixed
content.
3. IOCTL_CDROM_GET_DRIVE_GEOMETRY was unimplemented.
I appologize that the cdrom patch I sent before was incorrect, but now
I'm pretty sure that this one is fine. I'm still working on the mci
driver regarding this issue involving applications being unable to play
sounds in MSF.
Best,
Waldeck
-------------- next part --------------
Index: wine/dlls/ntdll/cdrom.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/cdrom.c,v
retrieving revision 1.24
diff -u -p -r1.24 cdrom.c
--- wine/dlls/ntdll/cdrom.c 23 Jan 2003 21:32:36 -0000 1.24
+++ wine/dlls/ntdll/cdrom.c 29 Jan 2003 05:17:56 -0000
@@ -74,6 +74,11 @@
WINE_DEFAULT_DEBUG_CHANNEL(cdrom);
+#define FRAME_OF_ADDR(a) (((int)(a)[1] * CD_SECS + (a)[2]) * CD_FRAMES + (a)[3])
+#define FRAME_OF_TOC(toc, idx) FRAME_OF_ADDR((toc).TrackData[idx - (toc).FirstTrack].Address)
+static DWORD CDROM_ReadTOC(int, CDROM_TOC*);
+
+
#ifdef linux
# ifndef IDE6_MAJOR
@@ -380,15 +385,22 @@ static DWORD CDROM_GetDeviceNumber(int d
static DWORD CDROM_GetDriveGeometry(int dev, DISK_GEOMETRY* dg)
{
-#if 0
- dg->Cylinders.s.LowPart = 1; /* FIXME */
- dg->Cylinders.s.HighPart = 0; /* FIXME */
- dg->MediaType = 1; /* FIXME */
- dg->TracksPerCylinder = 1; /* FIXME */
- dg->SectorsPerTrack = 1; /* FIXME */
- dg->BytesPerSector= 1; /* FIXME */
-#endif
- return STATUS_NOT_SUPPORTED;
+ CDROM_TOC toc;
+ DWORD ret = 0;
+ int fsize=0;
+
+ if ((ret = CDROM_ReadTOC(dev, &toc)) != 0) return ret;
+
+ fsize = FRAME_OF_TOC(toc, toc.LastTrack+1)
+ - FRAME_OF_TOC(toc, 1); /* Total size in frames */
+
+ dg->Cylinders.s.LowPart = fsize / (64 * 32);
+ dg->Cylinders.s.HighPart = 0;
+ dg->MediaType = RemovableMedia;
+ dg->TracksPerCylinder = 64;
+ dg->SectorsPerTrack = 32;
+ dg->BytesPerSector= 2048;
+ return ret;
}
/**************************************************************************
@@ -449,7 +461,7 @@ static DWORD CDROM_ReadTOC(int dev, CDRO
DWORD ret = STATUS_NOT_SUPPORTED;
#if defined(linux)
- int i, io = -1;
+ int i, io = -1, tsz;
struct cdrom_tochdr hdr;
struct cdrom_tocentry entry;
@@ -461,6 +473,10 @@ static DWORD CDROM_ReadTOC(int dev, CDRO
}
toc->FirstTrack = hdr.cdth_trk0;
toc->LastTrack = hdr.cdth_trk1;
+ tsz = sizeof(toc->FirstTrack) + sizeof(toc->LastTrack)
+ + sizeof(TRACK_DATA) * (hdr.cdth_trk1-hdr.cdth_trk0+2);
+ toc->Length[0] = tsz >> 8;
+ toc->Length[1] = tsz;
TRACE("from=%d to=%d\n", toc->FirstTrack, toc->LastTrack);
@@ -555,7 +571,7 @@ static DWORD CDROM_GetDiskData(int dev,
if ((ret = CDROM_ReadTOC(dev, &toc)) != 0) return ret;
data->DiskData = 0;
for (i = toc.FirstTrack; i <= toc.LastTrack; i++) {
- if (toc.TrackData[i].Control & 0x04)
+ if (toc.TrackData[i-toc.FirstTrack].Control & 0x04)
data->DiskData |= CDROM_DISK_DATA_TRACK;
else
data->DiskData |= CDROM_DISK_AUDIO_TRACK;
More information about the wine-patches
mailing list