[xiph-commits] r15202 - in trunk/cdparanoia: . interface
xiphmont at svn.xiph.org
xiphmont at svn.xiph.org
Tue Aug 26 02:55:23 PDT 2008
Author: xiphmont
Date: 2008-08-26 02:55:22 -0700 (Tue, 26 Aug 2008)
New Revision: 15202
Modified:
trunk/cdparanoia/cachetest.c
trunk/cdparanoia/interface/cooked_interface.c
trunk/cdparanoia/interface/low_interface.h
trunk/cdparanoia/interface/scan_devices.c
trunk/cdparanoia/interface/scsi_interface.c
Log:
refinements/compat fixes to fisrt-stage cache/timing tests
CLOCK_MONOTONIC not supported on 2.4 (grrrr)
don't rely on roundoff falling right for spinup test
base spinup test on amount of time stable, not number of iterations
Modified: trunk/cdparanoia/cachetest.c
===================================================================
--- trunk/cdparanoia/cachetest.c 2008-08-26 07:24:36 UTC (rev 15201)
+++ trunk/cdparanoia/cachetest.c 2008-08-26 09:55:22 UTC (rev 15202)
@@ -107,8 +107,9 @@
double sum;
double sumsq;
int sofar;
- double best=0;
+ int best=0;
int bestcount=0;
+ int iterating=0;
offset = lastsector-firstsector-current-1;
@@ -118,7 +119,7 @@
int m = offset/4500;
int s = (offset-m*4500)/75;
int f = offset-m*4500-s*75;
- if(bestcount==10){
+ if(iterating){
reportC("\n");
}else{
printC("\r");
@@ -167,7 +168,7 @@
{
double mean = sum/(float)(current-1);
double stddev = sqrt( (sumsq/(float)(current-1) - mean*mean));
- double upper= mean+((isnan(stddev) || stddev<1.)?1.:stddev);
+ double upper= mean+((isnan(stddev) || stddev*2<1.)?1.:stddev*2);
int j;
mean=0;
@@ -186,17 +187,21 @@
logC("\n\tAverage read latency: %.2fms/sector (raw speed: %.1fx)",mean,1000./75./mean);
logC("\n\tRead latency standard deviation: %.2fms/sector",stddev);
- if(bestcount<10){
- if(1./mean>best){
- best=1./mean;
+ sofar=mean*current;
+ if(!iterating){
+ if(-sofar<best){
+ best=-sofar;
bestcount=0;
- }else
- bestcount++;
+ }else{
+ bestcount+=sofar;
+ if(bestcount>sofar && bestcount>2000)
+ iterating=1;
+ }
}
}
next:
- if(bestcount==10){
+ if(iterating){
offset = (offset-firstsector+44999)/45000*45000+firstsector;
offset-=45000;
printC(" ");
@@ -216,7 +221,7 @@
int hi=15000;
int current=0;
int under=1;
- offset = firstsector+1000;
+ offset = firstsector;
while(current <= hi && under){
int i,j;
@@ -262,16 +267,18 @@
logC("seek_read=%d:%d\n",ret2,cdda_milliseconds(d));
if(ret1<=0 || ret2<=0){
- if(j==2){
- reportC("\n\tRead error while performing drive cache checks; aborting test.\n");
+ offset+=current+100;
+ if(j==10 || offset+current>lastsector){
+ reportC("\n\tToo many read errors while performing drive cache checks;"
+ "\n\t aborting test.\n\n");
return(-1);
}
+ reportC("\n\tRead error while performing drive cache checks;"
+ "\n\t choosing new offset and trying again.\n");
}else{
if(cdda_milliseconds(d)==-1){
- if(j==2){
- reportC("\n\tTiming error while performing drive cache checks; aborting test.\n");
- return(-1);
- }
+ reportC("\n\tTiming error while performing drive cache checks; aborting test.\n");
+ return(-1);
}else{
if(cdda_milliseconds(d)<9)under=1;
break;
Modified: trunk/cdparanoia/interface/cooked_interface.c
===================================================================
--- trunk/cdparanoia/interface/cooked_interface.c 2008-08-26 07:24:36 UTC (rev 15201)
+++ trunk/cdparanoia/interface/cooked_interface.c 2008-08-26 09:55:22 UTC (rev 15202)
@@ -13,9 +13,9 @@
static int timed_ioctl(cdrom_drive *d, int fd, int command, void *arg){
struct timespec tv1;
struct timespec tv2;
- int ret1=clock_gettime(CLOCK_MONOTONIC,&tv1);
+ int ret1=clock_gettime(d->private->clock,&tv1);
int ret2=ioctl(fd, command,arg);
- int ret3=clock_gettime(CLOCK_MONOTONIC,&tv2);
+ int ret3=clock_gettime(d->private->clock,&tv2);
if(ret1<0 || ret3<0){
d->private->last_milliseconds=-1;
}else{
Modified: trunk/cdparanoia/interface/low_interface.h
===================================================================
--- trunk/cdparanoia/interface/low_interface.h 2008-08-26 07:24:36 UTC (rev 15201)
+++ trunk/cdparanoia/interface/low_interface.h 2008-08-26 09:55:22 UTC (rev 15202)
@@ -16,6 +16,7 @@
#include <string.h>
#include <errno.h>
#include <fcntl.h>
+#include <time.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
@@ -99,6 +100,7 @@
struct cdda_private_data {
struct sg_header *sg_hd;
unsigned char *sg_buffer; /* points into sg_hd */
+ clockid_t clock;
int last_milliseconds;
int (*cache_clear) (struct cdrom_drive *d, int lba, int sectors);
Modified: trunk/cdparanoia/interface/scan_devices.c
===================================================================
--- trunk/cdparanoia/interface/scan_devices.c 2008-08-26 07:24:36 UTC (rev 15201)
+++ trunk/cdparanoia/interface/scan_devices.c 2008-08-26 09:55:22 UTC (rev 15202)
@@ -14,6 +14,7 @@
#include <stdlib.h>
#include <ctype.h>
#include <pwd.h>
+#include <time.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "cdda_interface.h"
@@ -264,6 +265,11 @@
d->bigendianp=-1; /* We don't know yet... */
d->nsectors=-1;
d->private=calloc(1,sizeof(*d->private));
+ {
+ /* goddamnit */
+ struct timespec tv;
+ d->private->clock=(clock_gettime(CLOCK_MONOTONIC,&tv)<0?CLOCK_REALTIME:CLOCK_MONOTONIC);
+ }
idmessage(messagedest,messages,"\t\tCDROM sensed: %s\n",description);
return(d);
}
@@ -669,6 +675,11 @@
d->nsectors=-1;
d->messagedest = messagedest;
d->private=calloc(1,sizeof(*d->private));
+ {
+ /* goddamnit */
+ struct timespec tv;
+ d->private->clock=(clock_gettime(CLOCK_MONOTONIC,&tv)<0?CLOCK_REALTIME:CLOCK_MONOTONIC);
+ }
if(use_sgio){
d->interface=SGIO_SCSI;
d->private->sg_buffer=(unsigned char *)(d->private->sg_hd=malloc(MAX_BIG_BUFF_SIZE));
Modified: trunk/cdparanoia/interface/scsi_interface.c
===================================================================
--- trunk/cdparanoia/interface/scsi_interface.c 2008-08-26 07:24:36 UTC (rev 15201)
+++ trunk/cdparanoia/interface/scsi_interface.c 2008-08-26 09:55:22 UTC (rev 15202)
@@ -15,9 +15,9 @@
static int timed_ioctl(cdrom_drive *d, int fd, int command, void *arg){
struct timespec tv1;
struct timespec tv2;
- int ret1=clock_gettime(CLOCK_MONOTONIC,&tv1);
+ int ret1=clock_gettime(d->private->clock,&tv1);
int ret2=ioctl(fd, command,arg);
- int ret3=clock_gettime(CLOCK_MONOTONIC,&tv2);
+ int ret3=clock_gettime(d->private->clock,&tv2);
if(ret1<0 || ret3<0){
d->private->last_milliseconds=-1;
}else{
@@ -247,7 +247,7 @@
}
sigprocmask (SIG_BLOCK, &(d->sigset), NULL );
- tret1=clock_gettime(CLOCK_MONOTONIC,&tv1);
+ tret1=clock_gettime(d->private->clock,&tv1);
errno=0;
status = write(d->cdda_fd, sg_hd, writebytes );
@@ -293,7 +293,7 @@
}
}
- tret2=clock_gettime(CLOCK_MONOTONIC,&tv2);
+ tret2=clock_gettime(d->private->clock,&tv2);
errno=0;
status = read(d->cdda_fd, sg_hd, SG_OFF + out_size);
sigprocmask ( SIG_UNBLOCK, &(d->sigset), NULL );
More information about the commits
mailing list