Improved -as cdrecord
This commit is contained in:
@ -56,7 +56,7 @@
|
||||
#endif /* Xorriso_standalonE */
|
||||
|
||||
|
||||
int Xorriso_pacifier_loop(struct XorrisO *xorriso, struct burn_drive *drive,
|
||||
int Xorriso_pacifier_loop(struct XorrisO *xorriso, struct burn_drive *drive,
|
||||
int flag);
|
||||
|
||||
int Xorriso__read_pacifier(IsoImage *image, IsoFileSource *filesource);
|
||||
@ -1065,36 +1065,82 @@ int Xorriso_check_burn_abort(struct XorrisO *xorriso, int flag)
|
||||
|
||||
/* This loop watches burn runs until they end.
|
||||
It issues pacifying update messages to the user.
|
||||
@param flag bit0-3 = emulation mode
|
||||
0= xorriso
|
||||
1= cdrskin
|
||||
bit4= report speed in CD units
|
||||
*/
|
||||
int Xorriso_pacifier_loop(struct XorrisO *xorriso, struct burn_drive *drive,
|
||||
int flag)
|
||||
{
|
||||
int ret, size, free_bytes, i, aborting= 0;
|
||||
int ret, size, free_bytes, i, aborting= 0, emul, buffer_fill= 50, last_sector;
|
||||
struct burn_progress progress;
|
||||
char *status_text;
|
||||
enum burn_drive_status drive_status;
|
||||
double start_time, current_time;
|
||||
double start_time, current_time, last_time;
|
||||
double measured_speed, speed_factor= 1385000;
|
||||
|
||||
start_time= Sfile_microtime(0);
|
||||
while(burn_drive_get_status(drive, NULL) == BURN_DRIVE_SPAWNING)
|
||||
usleep(100002);
|
||||
|
||||
emul= flag&15;
|
||||
if(flag&16)
|
||||
speed_factor= 150.0*1024;
|
||||
progress.sector= 0;
|
||||
current_time= Sfile_microtime(0);
|
||||
while(1) {
|
||||
last_time= current_time;
|
||||
last_sector= progress.sector;
|
||||
drive_status= burn_drive_get_status(drive, &progress);
|
||||
if(drive_status == BURN_DRIVE_IDLE)
|
||||
break;
|
||||
current_time= Sfile_microtime(0);
|
||||
current_time= Sfile_microtime(0);
|
||||
if(drive_status == BURN_DRIVE_WRITING && progress.sectors > 0) {
|
||||
if(progress.sector<=progress.sectors)
|
||||
sprintf(xorriso->info_text, "Writing: sector %d of %d",
|
||||
progress.sector, progress.sectors);
|
||||
else
|
||||
sprintf(xorriso->info_text, "Writing: sector %d", progress.sector);
|
||||
ret= isoburn_get_fifo_status(drive, &size, &free_bytes, &status_text);
|
||||
if(ret>0 )
|
||||
sprintf(xorriso->info_text+strlen(xorriso->info_text),
|
||||
" [fifo %s, %2d%% fill]", status_text,
|
||||
(int) (100.0-100.0*((double) free_bytes)/(double) size));
|
||||
if(emul==1) {
|
||||
if(progress.sector<=progress.sectors)
|
||||
sprintf(xorriso->info_text, "%4d of %4d MB written",
|
||||
progress.sector / 512, progress.sectors / 512);
|
||||
else
|
||||
sprintf(xorriso->info_text, "%4d MB written",
|
||||
progress.sector / 512);
|
||||
|
||||
if(xorriso->pacifier_fifo!=NULL) {
|
||||
ret= burn_fifo_inquire_status(xorriso->pacifier_fifo,
|
||||
&size, &free_bytes, &status_text);
|
||||
if(ret>0 )
|
||||
sprintf(xorriso->info_text+strlen(xorriso->info_text),
|
||||
" (fifo %2d%%)",
|
||||
(int) (100.0-100.0*((double) free_bytes)/(double) size));
|
||||
}
|
||||
|
||||
buffer_fill= 50;
|
||||
if(progress.buffer_capacity>0)
|
||||
buffer_fill= (double) (progress.buffer_capacity
|
||||
- progress.buffer_available) * 100.0
|
||||
/ (double) progress.buffer_capacity;
|
||||
sprintf(xorriso->info_text+strlen(xorriso->info_text), " [buf %3d%%]",
|
||||
buffer_fill);
|
||||
|
||||
if(current_time-last_time>0.2) {
|
||||
measured_speed= (progress.sector - last_sector) * 2048.0 /
|
||||
(current_time - last_time);
|
||||
sprintf(xorriso->info_text+strlen(xorriso->info_text), " %4.1fx.",
|
||||
measured_speed/speed_factor);
|
||||
}
|
||||
|
||||
} else {
|
||||
if(progress.sector<=progress.sectors)
|
||||
sprintf(xorriso->info_text, "Writing: sector %d of %d",
|
||||
progress.sector, progress.sectors);
|
||||
else
|
||||
sprintf(xorriso->info_text, "Writing: sector %d", progress.sector);
|
||||
ret= isoburn_get_fifo_status(drive, &size, &free_bytes, &status_text);
|
||||
if(ret>0 )
|
||||
sprintf(xorriso->info_text+strlen(xorriso->info_text),
|
||||
" [fifo %s, %2d%% fill]", status_text,
|
||||
(int) (100.0-100.0*((double) free_bytes)/(double) size));
|
||||
}
|
||||
} else if(drive_status == BURN_DRIVE_CLOSING_SESSION ||
|
||||
drive_status == BURN_DRIVE_CLOSING_TRACK)
|
||||
sprintf(xorriso->info_text,
|
||||
@ -3937,7 +3983,7 @@ int Xorriso_atip(struct XorrisO *xorriso, int flag)
|
||||
|
||||
int Xorriso_burn_track(struct XorrisO *xorriso, char *track_source, int flag)
|
||||
{
|
||||
int ret, fd, unpredicted_size;
|
||||
int ret, fd, unpredicted_size, profile_number, is_cd= 0;
|
||||
struct burn_drive_info *dinfo;
|
||||
struct burn_drive *drive;
|
||||
struct burn_write_opts *burn_options;
|
||||
@ -3948,7 +3994,7 @@ int Xorriso_burn_track(struct XorrisO *xorriso, char *track_source, int flag)
|
||||
off_t fixed_size= 0;
|
||||
struct burn_source *data_src, *fifo_src;
|
||||
enum burn_disc_status disc_state;
|
||||
char reasons[BURN_REASONS_LEN], sfe[5*SfileadrL];
|
||||
char reasons[BURN_REASONS_LEN], sfe[5*SfileadrL], profile_name[80];
|
||||
|
||||
|
||||
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
|
||||
@ -3994,6 +4040,7 @@ int Xorriso_burn_track(struct XorrisO *xorriso, char *track_source, int flag)
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
|
||||
ret= 0; goto ex;
|
||||
}
|
||||
xorriso->pacifier_fifo= fifo_src;
|
||||
if(burn_track_set_source(track, fifo_src)!=BURN_SOURCE_OK) {
|
||||
sprintf(xorriso->info_text,
|
||||
"Cannot attach source object to track object");
|
||||
@ -4042,6 +4089,8 @@ int Xorriso_burn_track(struct XorrisO *xorriso, char *track_source, int flag)
|
||||
ret= 0; goto ex;
|
||||
}
|
||||
|
||||
ret= Xorriso_get_profile(xorriso, &profile_number, profile_name, 2);
|
||||
is_cd= (ret==2);
|
||||
if(isoburn_needs_emulation(drive))
|
||||
burn_write_opts_set_start_byte(burn_options, (off_t) 0);
|
||||
ret= Xorriso_sanitize_image_size(xorriso, drive, disc, burn_options, 2);
|
||||
@ -4051,7 +4100,7 @@ int Xorriso_burn_track(struct XorrisO *xorriso, char *track_source, int flag)
|
||||
xorriso->run_state= 1; /* Indicate that burning has started */
|
||||
burn_disc_write(burn_options, disc);
|
||||
|
||||
ret= Xorriso_pacifier_loop(xorriso, drive, 0);
|
||||
ret= Xorriso_pacifier_loop(xorriso, drive, 1|(is_cd<<4));
|
||||
if(ret<=0)
|
||||
goto ex;
|
||||
if(!burn_drive_wrote_well(drive)) {
|
||||
@ -4069,6 +4118,9 @@ ex:;
|
||||
Xorriso_process_msg_queues(xorriso,0);
|
||||
if(disc!=NULL)
|
||||
burn_disc_free(disc);
|
||||
if(xorriso->pacifier_fifo!=NULL)
|
||||
burn_source_free(xorriso->pacifier_fifo);
|
||||
xorriso->pacifier_fifo= NULL;
|
||||
xorriso->run_state= 0; /* Indicate that burning has ended */
|
||||
return(ret);
|
||||
}
|
||||
|
Reference in New Issue
Block a user