From 12a24b169a92d6c637f9e8c055ef26e9af94437c Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Tue, 12 Jul 2011 13:56:36 +0000 Subject: [PATCH] Improved output of -list_speeds with ROM media and ROM drives. --- xorriso/drive_mgt.c | 92 ++++++++++++++++++++++++++----------- xorriso/xorriso.texi | 18 +++++--- xorriso/xorriso_timestamp.h | 2 +- 3 files changed, 77 insertions(+), 35 deletions(-) diff --git a/xorriso/drive_mgt.c b/xorriso/drive_mgt.c index f9675fd2..95ce3d63 100644 --- a/xorriso/drive_mgt.c +++ b/xorriso/drive_mgt.c @@ -800,7 +800,7 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag) int track_count= 0, session_no, track_no, profile_no= -1, track_size; int last_track_start= 0, last_track_size= -1, num_data= 0, is_data= 0; int is_inout_drive= 0, drive_role, status, num_formats, emul_lba; - int not_reconizable= 0; + int not_recognizable= 0; char profile_name[80],*respt,*devadr, *typetext= ""; struct burn_toc_entry toc_entry; struct burn_drive_info *dinfo; @@ -869,7 +869,7 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag) strcat(respt, "\n"); } else { sprintf(respt+strlen(respt), "is not recognizable\n"); - not_reconizable= 1; + not_recognizable= 1; } Xorriso_toc_line(xorriso, flag & 8); @@ -881,7 +881,7 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag) sprintf(respt, "Media status : "); if (s == BURN_DISC_FULL) { - if(not_reconizable) + if(not_recognizable) sprintf(respt+strlen(respt), "is not recognizable\n"); else sprintf(respt+strlen(respt), "is written , is closed"); @@ -949,7 +949,7 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag) if(ret<=0) { Xorriso_process_msg_queues(xorriso,0); if(flag&1) - {ret= 0; goto ex;} + {ret= 1; goto ex;} sprintf(xorriso->info_text, "Cannot obtain Table Of Content"); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); {ret= 0; goto ex;} @@ -1291,11 +1291,55 @@ ex:; } +int Xorriso_choose_speed_factor(struct XorrisO *xorriso, + int speed, int profile, + double *speed_factor, char **speed_unit, + int flag) +{ + double cd_factor = 75.0 * 2352; + double cd_speed_tolerance= 1.5, cd_speed_add; + int int_cd_speed, i; + static int cd_speed_list[]= {8, 10, 12, 16, 24, 32, 40, 48, 52, 0}; + + *speed_unit= "D"; + *speed_factor= 1385000.0; + + /* Does this look like an integer CD speed ? */ + int_cd_speed= ((double) speed) * 1000.0 / cd_factor; + cd_speed_add= cd_speed_tolerance * (double) int_cd_speed; + int_cd_speed= (((double) speed) + cd_speed_add) + * 1000.0 / cd_factor; + if(abs((int) ((double) int_cd_speed) * cd_factor / 1000.0 - + ((double) speed)) > 2 * cd_speed_add || + int_cd_speed > 64) + int_cd_speed= 0; + if(int_cd_speed > 7) { + for(i= 0; cd_speed_list[i]; i++) + if(int_cd_speed == cd_speed_list[i]) + break; + if(cd_speed_list[i] == 0) + int_cd_speed= 0; + } + + if(((profile < 0x08 || profile >= 0x100 || profile == 0x10 || profile == 0x40) + && int_cd_speed) || + (profile >= 0x08 && profile <= 0x0a)) { + *speed_unit= "C"; + *speed_factor= cd_factor; + } else if(profile >= 0x40 && profile <= 0x43) { + *speed_unit= "B"; + *speed_factor= 4495625.0; + } + return(1); +} + + /* @return <=0 error, 1 success */ int Xorriso_list_speeds(struct XorrisO *xorriso, int flag) { - int ret, high= -1, low= 0x7fffffff, int_cd_speed, is_cd= 0, i; + int ret, high= -1, low= 0x7fffffff, is_cd= 0, i; + int recent_profile= 0; char *respt, *speed_unit= "D"; double speed_factor= 1385000.0, cd_factor= 75.0 * 2352; struct burn_drive_info *dinfo; @@ -1317,12 +1361,18 @@ int Xorriso_list_speeds(struct XorrisO *xorriso, int flag) ret= 0; goto ex; } ret= Xorriso_toc(xorriso, 3); - if(ret<=0) - goto ex; + if(ret<=0) { + sprintf(xorriso->info_text, + "Cannot obtain overview of drive and media content"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + ret= 0; goto ex; + } for (item= speed_list; item != NULL; item= item->next) { if(item->profile_loaded >= 0x08 && item->profile_loaded <= 0x0a) - is_cd= 1; + is_cd= item->profile_loaded; + if(item->profile_loaded > 0) + recent_profile= item->profile_loaded; if(item->source == 1) { /* CD mode page 2Ah : report only if not same speed by GET PERFORMANCE */ for(other= speed_list; other != NULL; other= other->next) @@ -1331,25 +1381,9 @@ int Xorriso_list_speeds(struct XorrisO *xorriso, int flag) if(other != NULL) continue; } - speed_unit= "D"; - speed_factor= 1385000.0; - - /* Does this look like an integer CD speed ? */ - int_cd_speed= ((double) item->write_speed) * 1000.0 / cd_factor; - if(abs((int) ((double) int_cd_speed) * cd_factor / 1000.0 - - ((double) item->write_speed)) > 5 || - int_cd_speed > 64) - int_cd_speed= 0; - - if(((item->profile_loaded < 0x08 || item->profile_loaded >= 0x100) && - int_cd_speed) || - (item->profile_loaded >= 0x08 && item->profile_loaded <= 0x0a)) { - speed_unit= "C"; - speed_factor= 75.0 * 2352.0; - } else if(item->profile_loaded >= 0x40 && item->profile_loaded <= 0x43) { - speed_unit= "B"; - speed_factor= 4495625.0; - } + Xorriso_choose_speed_factor(xorriso, item->write_speed, + item->profile_loaded, + &speed_factor, &speed_unit, 0); sprintf(respt, "Write speed : "); sprintf(respt + strlen(respt), " %5dk , %4.1fx%s\n", item->write_speed, @@ -1393,10 +1427,14 @@ int Xorriso_list_speeds(struct XorrisO *xorriso, int flag) } } if(high > -1) { + Xorriso_choose_speed_factor(xorriso, low, recent_profile, + &speed_factor, &speed_unit, 0); sprintf(respt, "Write speed L: "); sprintf(respt + strlen(respt), " %5dk , %4.1fx%s\n", low, ((double) low) * 1000.0 / speed_factor, speed_unit); Xorriso_result(xorriso,0); + Xorriso_choose_speed_factor(xorriso, low, recent_profile, + &speed_factor, &speed_unit, 0); sprintf(respt, "Write speed H: "); sprintf(respt + strlen(respt), " %5dk , %4.1fx%s\n", high, ((double) high) * 1000.0 / speed_factor, speed_unit); diff --git a/xorriso/xorriso.texi b/xorriso/xorriso.texi index c02aa1bc..e3ff3114 100644 --- a/xorriso/xorriso.texi +++ b/xorriso/xorriso.texi @@ -50,7 +50,7 @@ @c man .\" First parameter, NAME, should be all caps @c man .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection @c man .\" other parameters are allowed: see man(7), man(1) -@c man .TH XORRISO 1 "Version 1.1.3, Jul 08, 2011" +@c man .TH XORRISO 1 "Version 1.1.3, Jul 12, 2011" @c man .\" Please adjust this date whenever revising the manpage. @c man .\" @c man .\" Some roff macros, for reference: @@ -2469,16 +2469,20 @@ Smaller format size with DVD-RAM, BD-RE, or BD-R means more reserve space. @item -list_speeds @kindex -list_speeds lists available write speeds @cindex Media, list write speeds, -list_speeds -Put out a list of speed values as reported by the output drive for -the loaded media. At the end of the list, "Write speed L" and "Write speed H" -are the best guesses for lower and upper speed limit. -@* -"Write speed l" and "Write speed h" may appear only with CD -and eventually override the list of other speed offers. +Put out a list of speed values as reported by the output drive with +the loaded media. This does not necessarily mean that the media is writable +or that these speeds are actually achievable. Especially the +lists reported with empty drive or with ROM media obviously advertise +speeds for other media. @* It is not mandatory to use speed values out of the listed range. The drive is supposed to choose a safe speed that is as near to the desired speed as possible. +@* +At the end of the list, "Write speed L" and "Write speed H" +are the best guesses for lower and upper speed limit. +"Write speed l" and "Write speed h" may appear only with CD +and eventually override the list of other speed offers. @c man .TP @item -close_damaged "as_needed"|"force" @kindex -close_damaged closes damaged track and session diff --git a/xorriso/xorriso_timestamp.h b/xorriso/xorriso_timestamp.h index 4fc0a16d..a03cf983 100644 --- a/xorriso/xorriso_timestamp.h +++ b/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2011.07.12.092010" +#define Xorriso_timestamP "2011.07.12.135452"