Improved output of -list_speeds with CD drives. Empty list now cause SORRY.

This commit is contained in:
Thomas Schmitt 2011-07-12 09:21:28 +00:00
parent 00fcf43a47
commit 364361e228
2 changed files with 32 additions and 29 deletions

View File

@ -1295,7 +1295,7 @@ ex:;
*/
int Xorriso_list_speeds(struct XorrisO *xorriso, int flag)
{
int ret, high= -1, low= 0x7fffffff, int_cd_speed, is_cd= 0;
int ret, high= -1, low= 0x7fffffff, int_cd_speed, is_cd= 0, i;
char *respt, *speed_unit= "D";
double speed_factor= 1385000.0, cd_factor= 75.0 * 2352;
struct burn_drive_info *dinfo;
@ -1311,9 +1311,9 @@ int Xorriso_list_speeds(struct XorrisO *xorriso, int flag)
if(ret == 2)
goto ex;
ret= burn_drive_get_speedlist(drive, &speed_list);
if(ret <= 0) {
if(ret < 0) {
sprintf(xorriso->info_text, "Cannot obtain speed list info");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
ret= 0; goto ex;
}
ret= Xorriso_toc(xorriso, 3);
@ -1346,7 +1346,7 @@ int Xorriso_list_speeds(struct XorrisO *xorriso, int flag)
(item->profile_loaded >= 0x08 && item->profile_loaded <= 0x0a)) {
speed_unit= "C";
speed_factor= 75.0 * 2352.0;
} else if(item->profile_loaded >= 0x41 && item->profile_loaded <= 0x43) {
} else if(item->profile_loaded >= 0x40 && item->profile_loaded <= 0x43) {
speed_unit= "B";
speed_factor= 4495625.0;
}
@ -1368,30 +1368,28 @@ int Xorriso_list_speeds(struct XorrisO *xorriso, int flag)
if(ret < 0)
goto ex;
if(ret > 0) {
ret= burn_drive_get_min_write_speed(drive);
if(ret > 0) {
if(ret > low) {
sprintf(respt, "Write speed l: ");
sprintf(respt + strlen(respt), " %5dk , %4.1fx%s\n",
ret, ((double) ret) * 1000.0 / cd_factor, "C");
Xorriso_result(xorriso,0);
}
if(ret > high)
high= ret;
low= ret;
}
ret= burn_drive_get_write_speed(drive);
if(ret > 0) {
if(ret < high) {
sprintf(respt, "Write speed h: ");
sprintf(respt + strlen(respt), " %5dk , %4.1fx%s\n",
ret, ((double) ret) * 1000.0 / cd_factor, "C");
Xorriso_result(xorriso,0);
}
high= ret;
if(ret < low)
low= ret;
}
for(i= 0; i < 2; i++) {
if(i == 0)
ret= burn_drive_get_min_write_speed(drive);
else
ret= burn_drive_get_write_speed(drive);
if(ret > 0) {
if(ret < low || (i == 0 && ret != low)) {
sprintf(respt, "Write speed l: ");
sprintf(respt + strlen(respt), " %5dk , %4.1fx%s\n",
ret, ((double) ret) * 1000.0 / cd_factor, "C");
Xorriso_result(xorriso,0);
low= ret;
}
if(ret > high || (i == 1 && ret != high)) {
sprintf(respt, "Write speed h: ");
sprintf(respt + strlen(respt), " %5dk , %4.1fx%s\n",
ret, ((double) ret) * 1000.0 / cd_factor, "C");
Xorriso_result(xorriso,0);
high= ret;
}
}
}
}
}
if(high > -1) {
@ -1403,6 +1401,11 @@ int Xorriso_list_speeds(struct XorrisO *xorriso, int flag)
sprintf(respt + strlen(respt), " %5dk , %4.1fx%s\n",
high, ((double) high) * 1000.0 / speed_factor, speed_unit);
Xorriso_result(xorriso,0);
} else {
sprintf(xorriso->info_text,
"Could not get any write speed information from drive");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
ret= 0; goto ex;
}
ret= 1;
ex:;

View File

@ -1 +1 @@
#define Xorriso_timestamP "2011.07.11.175609"
#define Xorriso_timestamP "2011.07.12.092010"