[xiph-commits] r15179 - in trunk/cdparanoia: . interface

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Wed Aug 13 12:02:49 PDT 2008


Author: xiphmont
Date: 2008-08-13 12:02:48 -0700 (Wed, 13 Aug 2008)
New Revision: 15179

Modified:
   trunk/cdparanoia/interface/common_interface.c
   trunk/cdparanoia/interface/scsi_interface.c
   trunk/cdparanoia/main.c
Log:
Commit some more cache testing code.  NOT FOR PRODUCTION


Modified: trunk/cdparanoia/interface/common_interface.c
===================================================================
--- trunk/cdparanoia/interface/common_interface.c	2008-08-13 07:53:13 UTC (rev 15178)
+++ trunk/cdparanoia/interface/common_interface.c	2008-08-13 19:02:48 UTC (rev 15179)
@@ -174,7 +174,7 @@
    drives have a FUA facility, but it's not clear how many ignore it.
    For that reason, we need to empirically determine cache size used
    for reads */
-#if 0
+
 int cdda_cache_sectors(cdrom_drive *d){
 
   /* Some assumptions about timing: 
@@ -198,7 +198,7 @@
      moment only abounts to 100x-200x,
 
   /* let's assume the (physically) fastest drives are 60x; this is true in practice, and drives that fast are usually only that fast out at the rim */
-  float ms_per_sector = 1./75./100.;
+  float ms_per_sector = 1./75./100.*1000;
   int i;
   int lo = 75;
   int current = lo;
@@ -280,13 +280,14 @@
 	snprintf(buffer,80," %d:%fms/sec",i,(float)fulltime/current);
 	cdmessage(d,buffer);
       }
-      if(fulltime/current < ms_per_sector) under=1;
+      if((float)fulltime/current < ms_per_sector) under=1;
     }
     cdmessage(d,"\n");
 
     current*=2;
   } 
 
+#if 0
   if(current > max){
     cdmessage(d,"\nGiving up; drive cache is too large to defeat using overflow.\n");
     cdmessage(d,"\n(Drives should not cache redbook reads, this drive does anyway."
@@ -295,10 +296,9 @@
 
     return INT_MAX;
   }
-
+#endif
   return 0;
 }
-#endif
 
 
 /************************************************************************/

Modified: trunk/cdparanoia/interface/scsi_interface.c
===================================================================
--- trunk/cdparanoia/interface/scsi_interface.c	2008-08-13 07:53:13 UTC (rev 15178)
+++ trunk/cdparanoia/interface/scsi_interface.c	2008-08-13 19:02:48 UTC (rev 15179)
@@ -611,6 +611,46 @@
   return(0);
 }
 
+static int set_read_ahead (cdrom_drive *d, int start, int end){
+  int err;
+  unsigned char sense[SG_MAX_SENSE];
+  unsigned char cmd[12]={0xA7, /* SET READ AHEAD */
+			0x00, /* reserved */
+			0x00, /* lba */
+			0x00, /* lba */
+			0x00, /* lba */
+			0x00, /* lba */
+			0x00, /* lba */
+			0x00, /* lba */
+			0x00, /* lba */
+			0x00, /* lba */
+			0,    /* reserved */
+			0};   /* control */ 
+  
+  cmd[2] = (start>>24)&0xff;
+  cmd[3] = (start>>16)&0xff;
+  cmd[4] = (start>>8)&0xff;
+  cmd[5] = (start)&0xff;
+
+  cmd[6] = (end>>24)&0xff;
+  cmd[7] = (end>>16)&0xff;
+  cmd[8] = (end>>8)&0xff;
+  cmd[9] = (end)&0xff;
+  
+  if (err=handle_scsi_cmd (d, cmd, 12, 0, 0, 0, 0, sense)){
+    fprintf(stderr,"Unable to disable cache\n");
+    fprintf(stderr,"                 Sense key: %x ASC: %x ASCQ: %x\n",
+	    (int)(sense[2]&0xf),
+	    (int)(sense[12]),
+	    (int)(sense[13]));
+    fprintf(stderr,"                 Transport error: %s\n",strerror_tr[err]);
+    fprintf(stderr,"                 System error: %s\n",strerror(errno));
+    
+  }
+
+  return(0);
+}
+
 typedef struct scsi_TOC {  /* structure of scsi table of contents (cdrom) */
   unsigned char reserved1;
   unsigned char bFlags;
@@ -1037,6 +1077,8 @@
 
   retry_count=0;
   
+  set_read_ahead(d,begin-1,begin+sectors);
+
   while(1) {
     if((err=map(d,(p?buffer:NULL),begin,sectors,sense))){
       if(d->report_all){

Modified: trunk/cdparanoia/main.c
===================================================================
--- trunk/cdparanoia/main.c	2008-08-13 07:53:13 UTC (rev 15178)
+++ trunk/cdparanoia/main.c	2008-08-13 19:02:48 UTC (rev 15179)
@@ -928,6 +928,8 @@
     exit(1);
   }
 
+  cdda_cache_sectors(d);
+
   /* Dump the TOC */
   if(query_only || verbose)display_toc(d);
   if(query_only)exit(0);



More information about the commits mailing list