From e5e8b160f5b90e5aa9de85769402e5abbfef18bf Mon Sep 17 00:00:00 2001 From: xiphmont Date: Thu, 28 Aug 2008 16:41:43 +0000 Subject: [PATCH] Ignore and certainly do not use this commit-- code refactoring, move cache test into paranoia lib (so that the analysis will always match the paranoia version) git-svn-id: http://svn.xiph.org/trunk@15214 0101bb08-14d6-0310-b084-bc0e0c8e3800 --- cdparanoia/cachetest.h | 22 ------ cdparanoia/interface/cdda_interface.h | 1 + cdparanoia/interface/interface.c | 5 ++ cdparanoia/main.c | 28 +++++++- cdparanoia/{ => paranoia}/cachetest.c | 125 +++++++++++++++++++++++++--------- cdparanoia/paranoia/cdda_paranoia.h | 4 ++ cdparanoia/paranoia/p_block.h | 1 + cdparanoia/paranoia/paranoia.c | 4 ++ cdparanoia/version.h | 3 +- 9 files changed, 133 insertions(+), 60 deletions(-) delete mode 100644 cdparanoia/cachetest.h rename cdparanoia/{ => paranoia}/cachetest.c (71%) diff --git a/cdparanoia/cachetest.h b/cdparanoia/cachetest.h deleted file mode 100644 index 00255a841..000000000 --- a/cdparanoia/cachetest.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright: GNU Public License 2 applies - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * cdparanoia (C) 2008 Monty - * - */ - -extern int analyze_timing_and_cache(cdrom_drive *d); diff --git a/cdparanoia/interface/cdda_interface.h b/cdparanoia/interface/cdda_interface.h index 9f1aab8ca..901382e01 100644 --- a/cdparanoia/interface/cdda_interface.h +++ b/cdparanoia/interface/cdda_interface.h @@ -121,6 +121,7 @@ extern cdrom_drive *cdda_identify_test(const char *filename, /******** Drive oriented functions */ +extern char *cdda_version(); extern int cdda_speed_set(cdrom_drive *d, int speed); extern void cdda_verbose_set(cdrom_drive *d,int err_action, int mes_action); extern char *cdda_messages(cdrom_drive *d); diff --git a/cdparanoia/interface/interface.c b/cdparanoia/interface/interface.c index ee52635ff..a8068928b 100644 --- a/cdparanoia/interface/interface.c +++ b/cdparanoia/interface/interface.c @@ -12,6 +12,11 @@ #include "low_interface.h" #include "common_interface.h" #include "utils.h" +#include "../version.h" + +char *cdda_version(void){ + return VERSIONNUM; +} static void _clean_messages(cdrom_drive *d){ if(d){ diff --git a/cdparanoia/main.c b/cdparanoia/main.c index 14e96860d..dfb8e835b 100644 --- a/cdparanoia/main.c +++ b/cdparanoia/main.c @@ -37,7 +37,6 @@ #include "report.h" #include "version.h" #include "header.h" -#include "cachetest.h" static long parse_offset(cdrom_drive *d, char *offset, int begin){ long track=-1; @@ -892,6 +891,8 @@ int main(int argc,char *argv[]){ if(reportfile!=logfile){ fprintf(logfile,VERSION); fprintf(logfile,"\n"); + fprintf(logfile,"Using cdda library version: %s\n",cdda_version()); + fprintf(logfile,"Using paranoia library version: %s\n",paranoia_version()); } fflush(logfile); } @@ -917,6 +918,8 @@ int main(int argc,char *argv[]){ span=copystring(argv[optind]); report(VERSION); + report("Using cdda library version: %s",cdda_version()); + report("Using paranoia library version: %s",paranoia_version()); /* Query the cdrom/disc; we may need to override some settings */ @@ -1034,8 +1037,27 @@ int main(int argc,char *argv[]){ report("\tdrive returned OK."); } - if(run_cache_test) - return analyze_timing_and_cache(d); + if(run_cache_test){ + int warn=paranoia_analyze_verify(d, stderr, reportfile); + + if(warn==0){ + reportC("\nDrive tests OK with Paranoia.\n"); + return 0; + } + + if(warn==1) + reportC("\nWARNING! PARANOIA MAY NOT BE TRUSTWORTHY WITH THIS DRIVE!\n" + "\nThe Paranoia library may not model this CDROM drive's cache" + "\ncorrectly according to this analysis run. Analysis is not" + "\nalways accurate (it can be fooled by machine load or random" + "\nkernel latencies), but if a failed result happens more often" + "\nthan one time in twenty on an unloaded machine, please mail" + "\nthe %s file produced by this failed analysis to" + "\nparanoia-dev@xiph.org to assist developers in extending" + "\nParanoia to handle this CDROM properly.\n\n",reportfile_name); + return 1; + } + /* Dump the TOC */ if(query_only || verbose)display_toc(d); diff --git a/cdparanoia/cachetest.c b/cdparanoia/paranoia/cachetest.c similarity index 71% rename from cdparanoia/cachetest.c rename to cdparanoia/paranoia/cachetest.c index 514bdedd9..49d30fa31 100644 --- a/cdparanoia/cachetest.c +++ b/cdparanoia/paranoia/cachetest.c @@ -1,40 +1,36 @@ /* - * Copyright: GNU Public License 2 applies - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * cdparanoia (C) 2008 Monty + * GNU Lesser General Public License 2.1 applies + * Copyright (C) 2008 Monty * */ +/* this is in the paranoia library because the analysis is matched to + cache modelling of a specific library version, not matched to the + specific application (eg, cdparanoia version, which is simply a + wrapper around the libs) */ + /* we can ask most drives what their various caches' sizes are, but no drive will tell if it caches redbook data. None should, many do, - and there's no way in (eg) MMAC/ATAPI to tell a drive not to. SCSI - drives have a FUA facility, but it's not clear how many ignore it. - MMC does specify some cache side effect as part of SET READ AHEAD, - but it's not clear we can rely on them. For that reason, we need - to empirically determine cache size and strategy used for reads. */ + and there's no way in (eg) MMC/ATAPI to tell a cdrom drive not to + cache when accessing audio. SCSI drives have a FUA facility, but + it's not clear how many ignore it. MMC does specify some cache + side effect as part of SET READ AHEAD, but it's not clear we can + rely on them. For that reason, we need to empirically determine + cache size and strategy used for reads. */ #include #include #include -#include "interface/cdda_interface.h" -#include "report.h" -#include "cachetest.h" +#include "../interface/cdda_interface.h" +#include "p_block.h" + +#define reportC(...) {if(progress){fprintf(progress, __VA_ARGS__);} \ + if(log){fprintf(log, __VA_ARGS__);}} +#define printC(...) {if(progress){fprintf(progress, __VA_ARGS__);}} +#define logC(...) {if(log){fprintf(log, __VA_ARGS__);}} -int analyze_timing_and_cache(cdrom_drive *d){ + +int paranoia_analyze_verify(cdrom_drive *d, FILE *progress, FILE *log){ /* Some assumptions about timing: @@ -68,6 +64,7 @@ int analyze_timing_and_cache(cdrom_drive *d){ int max_retries=20; float median; int offset; + int warn=0; /* set up a default pessimal take on drive behavior */ //d->private->cache_backseekflush=0; @@ -289,7 +286,10 @@ int analyze_timing_and_cache(cdrom_drive *d){ } printC("\r"); - if(current>1){ + if(current==hi){ + reportC("\tWARNING: Cannot determine drive cache size or behavior! \n"); + return 1; + }else if(current>1){ reportC("\tApproximate random access cache size: %d sectors \n",current-1); }else{ reportC("\tDrive does not cache nonlinear access \n"); @@ -299,19 +299,76 @@ int analyze_timing_and_cache(cdrom_drive *d){ /* this drive caches; Determine if the detailed caching behavior fits our model. */ /* does the readahead cache exceed the maximum Paranoia currently expects? */ + if(current-1 > CACHEMODEL_SECTORS){ + reportC("\nWARNING: This drive appears to be caching more sectors of\n" + " readahead than Paranoia can currently handle!\n"); + warn=1; + + } + + /* This is similar to the Fast search above, but just in case the + cache is being tracked as multiple areas that are treated + differently if non-contiguous.... */ + { + int seekoff = current*3; + reportC("\nVerifying that readahead cache is contiguous"); + under=0; + + for(i=0;i<30 && !under;i++){ + printC("."); + for(j=0;;j++){ + int ret1,ret2; + + if(offset+seekoff>lastsector){ + reportC("\n\tOut of readable space on CDROM while performing drive checks;" + "\n\t aborting test.\n\n"); + return(-1); + } + + + ret1 = cdda_read(d,NULL,offset+seekoff,1); + logC("\t\t>>> %d:%d ",offset+current,cdda_milliseconds(d)); + ret2 = cdda_read(d,NULL,offset,1); + logC("%d:%d\n",offset,cdda_milliseconds(d)); + + if(ret1<=0 || ret2<=0){ + offset+=current+100; + if(j==10){ + 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){ + reportC("\n\tTiming error while performing drive cache checks; aborting test.\n"); + return(-1); + }else{ + if(cdda_milliseconds(d)<9)under=1; + break; + } + } + } + } + if(under){ + reportC("\nWARNING: Drive cache does not appear to be contiguous!\n"); + warn=1; + }else{ + reportC("\n\tdone. Drive cache tests as contiguous.\n"); + } + } + + /* does a read beyond shift the cache or dump it? */ /* Verify that a read that begins before the cached readahead dumps the entire readahead cache */ - /* Verify that reads that begin after the apparently cached - readahead either dump the cache *or* cause the cached area to - shift later in one contiguous piece */ - /* Check to see that cdda_clear_cache clears the specified cache area */ - /* XXXXXX IN PROGRESS */ - reportC("\n"); - return 0; + /* Does cdda_clear_cache result in noncontiguous cache areas? */ + + return warn; } diff --git a/cdparanoia/paranoia/cdda_paranoia.h b/cdparanoia/paranoia/cdda_paranoia.h index d3d78e124..4a814cf38 100644 --- a/cdparanoia/paranoia/cdda_paranoia.h +++ b/cdparanoia/paranoia/cdda_paranoia.h @@ -37,6 +37,9 @@ typedef void cdrom_paranoia; #endif +#include + +extern char *paranoia_version(); extern cdrom_paranoia *paranoia_init(cdrom_drive *d); extern void paranoia_modeset(cdrom_paranoia *p,int mode); extern long paranoia_seek(cdrom_paranoia *p,long seek,int mode); @@ -44,5 +47,6 @@ extern int16_t *paranoia_read(cdrom_paranoia *p,void(*callback)(long,int)); extern int16_t *paranoia_read_limited(cdrom_paranoia *p,void(*callback)(long,int),int maxretries); extern void paranoia_free(cdrom_paranoia *p); extern void paranoia_overlapset(cdrom_paranoia *p,long overlap); +extern int paranoia_analyze_verify(cdrom_drive *d, FILE *progress, FILE *log); #endif diff --git a/cdparanoia/paranoia/p_block.h b/cdparanoia/paranoia/p_block.h index 507495047..ec0bb8ccc 100644 --- a/cdparanoia/paranoia/p_block.h +++ b/cdparanoia/paranoia/p_block.h @@ -16,6 +16,7 @@ #define MIN_SECTOR_BACKUP 16 /* sectors */ #define JIGGLE_MODULO 15 /* sectors */ #define MIN_SILENCE_BOUNDARY 1024 /* 16 bit words */ +#define CACHEMODEL_SECTORS 1200 #define min(x,y) ((x)>(y)?(y):(x)) #define max(x,y) ((x)<(y)?(y):(x)) diff --git a/cdparanoia/paranoia/paranoia.c b/cdparanoia/paranoia/paranoia.c index 4c402683d..6d9ed9e6e 100644 --- a/cdparanoia/paranoia/paranoia.c +++ b/cdparanoia/paranoia/paranoia.c @@ -2710,3 +2710,7 @@ void paranoia_overlapset(cdrom_paranoia *p, long overlap){ p->dynoverlap=overlap*CD_FRAMEWORDS; p->stage1.offpoints=-1; } + +char *paranoia_version(void){ + return VERSIONNUM; +} diff --git a/cdparanoia/version.h b/cdparanoia/version.h index 7ad770390..2ce7a1f0c 100644 --- a/cdparanoia/version.h +++ b/cdparanoia/version.h @@ -7,4 +7,5 @@ ******************************************************************/ -#define VERSION "cdparanoia III release 10.2pre (August 11, 2008)\n" +#define VERSIONNUM "10.2pre" +#define VERSION "cdparanoia III release " VERSIONNUM " (August 11, 2008)\n" -- 2.11.4.GIT