Reporting speed with -check_media

This commit is contained in:
Thomas Schmitt 2012-01-23 10:38:48 +00:00
parent e16695de4d
commit 9caa063957
6 changed files with 53 additions and 15 deletions

View File

@ -343,6 +343,7 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag)
m->pacifier_style= 0; m->pacifier_style= 0;
m->pacifier_interval= 1.0; m->pacifier_interval= 1.0;
m->pacifier_count= 0; m->pacifier_count= 0;
m->pacifier_prev_count= 0;
m->pacifier_total= 0; m->pacifier_total= 0;
m->pacifier_byte_count= 0; m->pacifier_byte_count= 0;
m->pacifier_fifo= NULL; m->pacifier_fifo= NULL;

View File

@ -2419,8 +2419,8 @@ failed_to_write:;
xorriso->pacifier_count+= to_read; xorriso->pacifier_count+= to_read;
if(post_read_time - xorriso->last_update_time >= if(post_read_time - xorriso->last_update_time >=
xorriso->pacifier_interval) xorriso->pacifier_interval)
Xorriso_pacifier_callback(xorriso, "sectors examined", Xorriso_pacifier_callback(xorriso, "blocks read",
xorriso->pacifier_count, xorriso->pacifier_total, "", 0); xorriso->pacifier_count, xorriso->pacifier_total, "", 8 | 16);
} }
} }
if(prev_quality >= 0) { if(prev_quality >= 0) {
@ -2647,8 +2647,9 @@ libburn_whole_disc:;
goto ex; goto ex;
} }
Xorriso_pacifier_callback(xorriso, "sectors examined", Xorriso_pacifier_callback(xorriso, "blocks read",
xorriso->pacifier_count, xorriso->pacifier_total, "", 1); xorriso->pacifier_count, xorriso->pacifier_total, "",
1 | 8 | 16 | 32);
ret= 1; ret= 1;
ex:; ex:;

View File

@ -1863,8 +1863,8 @@ int Xorriso_extract_cut(struct XorrisO *xorriso,
goto ex; goto ex;
if(mem_lut != xorriso->last_update_time) if(mem_lut != xorriso->last_update_time)
Xorriso_pacifier_callback(xorriso, "sectors examined", Xorriso_pacifier_callback(xorriso, "blocks read",
xorriso->pacifier_count, 0, "", 1); xorriso->pacifier_count, 0, "", 1 | 8 | 16 | 32);
ret= 1; ret= 1;
ex:; ex:;
Xorriso_free_meM(eff_img_path); Xorriso_free_meM(eff_img_path);

View File

@ -1301,11 +1301,12 @@ int Xorriso_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag)
if(xorriso->allow_restore == -1) if(xorriso->allow_restore == -1)
sprintf(line,"-osirrox %s\n", mode_pt); sprintf(line,"-osirrox %s\n", mode_pt);
else else
sprintf(line,"-osirrox %s:%s:%s:%s:%s\n", mode_pt, sprintf(line,"-osirrox %s:%s:%s:%s:%s:%s\n", mode_pt,
xorriso->do_concat_split ? "concat_split_on" : "concat_split_off", xorriso->do_concat_split ? "concat_split_on" : "concat_split_off",
xorriso->do_auto_chmod ? "auto_chmod_on" : "auto_chmod_off", xorriso->do_auto_chmod ? "auto_chmod_on" : "auto_chmod_off",
xorriso->do_restore_sort_lba ? "sort_lba_on" : "sort_lba_off", xorriso->do_restore_sort_lba ? "sort_lba_on" : "sort_lba_off",
xorriso->drives_exclusive ? "o_excl_on" : "o_excl_off" xorriso->drives_exclusive ? "o_excl_on" : "o_excl_off",
(xorriso->do_strict_acl & 1) ? "strict_acl_on" : "strict_acl_off"
); );
if(!(is_default && no_defaults)) if(!(is_default && no_defaults))
Xorriso_status_result(xorriso,filter,fp,flag&2); Xorriso_status_result(xorriso,filter,fp,flag&2);
@ -1985,6 +1986,7 @@ int Xorriso_pacifier_reset(struct XorrisO *xorriso, int flag)
xorriso->start_time= Sfile_microtime(0); xorriso->start_time= Sfile_microtime(0);
xorriso->last_update_time= xorriso->start_time; xorriso->last_update_time= xorriso->start_time;
xorriso->pacifier_count= 0; xorriso->pacifier_count= 0;
xorriso->pacifier_prev_count= 0;
xorriso->pacifier_total= 0; xorriso->pacifier_total= 0;
xorriso->pacifier_byte_count= 0; xorriso->pacifier_byte_count= 0;
return(1); return(1);
@ -2005,17 +2007,22 @@ int Xorriso_pacifier_reset(struct XorrisO *xorriso, int flag)
@param flag bit0= report unconditionally, no time check @param flag bit0= report unconditionally, no time check
bit1= report count <=0 (no thank you for being patient then) bit1= report count <=0 (no thank you for being patient then)
bit2= report xorriso->pacifier_byte_count bit2= report xorriso->pacifier_byte_count
bit3= report speed
bit4= with bit3: count is in blocks, else in bytes
bit5= with bit3: report total speed
bit6= report with carriage return rather than line feed bit6= report with carriage return rather than line feed
*/ */
int Xorriso_pacifier_callback(struct XorrisO *xorriso, char *what_done, int Xorriso_pacifier_callback(struct XorrisO *xorriso, char *what_done,
off_t count, off_t todo, char *current_object, off_t count, off_t todo, char *current_object,
int flag) int flag)
{ {
double current_time, since; double current_time, since, interval_time, speed, speed_factor;
char count_text[80], byte_text[80]; char count_text[80], byte_text[80], profile_name[80], *speed_unit;
int ret, profile_number;
current_time= Sfile_microtime(0); current_time= Sfile_microtime(0);
if(current_time - xorriso->last_update_time < xorriso->pacifier_interval interval_time= current_time - xorriso->last_update_time;
if(interval_time < xorriso->pacifier_interval
&& !(flag&1)) && !(flag&1))
return(1); return(1);
xorriso->last_update_time= Sfile_microtime(0); xorriso->last_update_time= Sfile_microtime(0);
@ -2040,11 +2047,39 @@ int Xorriso_pacifier_callback(struct XorrisO *xorriso, char *what_done,
else else
Sfile_scale((double) count, count_text, 7, 1e5, 1); Sfile_scale((double) count, count_text, 7, 1e5, 1);
sprintf(xorriso->info_text, "%s %s%s in %.f %s", sprintf(xorriso->info_text, "%s %s%s in %.f %s",
count_text, what_done, byte_text, since, (flag&64) ? "s" : "seconds"); count_text, what_done, byte_text, since,
(flag & 64) ? "s" : "seconds");
} else { } else {
sprintf(xorriso->info_text, "%.f of %.f %s%s in %.f seconds", sprintf(xorriso->info_text, "%.f of %.f %s%s in %.f %s",
(double) count, (double) todo, what_done, byte_text, since); (double) count, (double) todo, what_done, byte_text, since,
(flag & (8 | 64)) ? "s" : "seconds");
} }
speed= -1.0;
if((flag & 8)) {
if(flag & 32) {
if(since > 0)
speed= count / since;
} else if(count >= xorriso->pacifier_prev_count) {
speed= (count - xorriso->pacifier_prev_count) / (interval_time);
}
}
if(speed >= 0.0) {
if(flag & 16)
speed*= 2048.0;
ret= Xorriso_get_profile(xorriso, &profile_number, profile_name, 0);
speed_factor= 1385000;
speed_unit= "D";
if(ret == 2) {
speed_factor= 150.0*1024;
speed_unit= "C";
} else if(ret == 3) {
speed_factor= 4495625;
speed_unit= "B";
}
sprintf(xorriso->info_text+strlen(xorriso->info_text), " %s %.1fx%s",
(flag & 32 ? "=" : ","), speed / speed_factor, speed_unit);
}
xorriso->pacifier_prev_count= count;
if(current_object[0]!=0) if(current_object[0]!=0)
sprintf(xorriso->info_text+strlen(xorriso->info_text), sprintf(xorriso->info_text+strlen(xorriso->info_text),
", now at %s", current_object); ", now at %s", current_object);

View File

@ -571,6 +571,7 @@ struct XorrisO { /* the global context of xorriso */
off_t pacifier_count; off_t pacifier_count;
off_t pacifier_total; off_t pacifier_total;
off_t pacifier_byte_count; /* auxiliary counter for data bytes */ off_t pacifier_byte_count; /* auxiliary counter for data bytes */
off_t pacifier_prev_count; /* internal counter for speed measurement */
void *pacifier_fifo; void *pacifier_fifo;

View File

@ -1 +1 @@
#define Xorriso_timestamP "2012.01.18.093532" #define Xorriso_timestamP "2012.01.21.114233"