New -format modes by_size_ and fast_by_size_
This commit is contained in:
@ -1014,7 +1014,7 @@ int Xorriso_auto_format(struct XorrisO *xorriso, int flag)
|
||||
"Unformatted %s media detected. Trying -format fast.",
|
||||
profile_name);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
|
||||
ret= Xorriso_format_media(xorriso, 1 | 4);
|
||||
ret= Xorriso_format_media(xorriso, (off_t) 0, 1 | 4);
|
||||
if(ret<=0) {
|
||||
sprintf(xorriso->info_text, "Automatic formatting of %s failed",
|
||||
profile_name);
|
||||
@ -1054,42 +1054,6 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag)
|
||||
int profile_number;
|
||||
char profile_name[80];
|
||||
|
||||
#ifdef NIX
|
||||
|
||||
int profile, status, num_formats;
|
||||
off_t size;
|
||||
unsigned dummy;
|
||||
|
||||
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
|
||||
"on attempt to write", 2);
|
||||
if(ret<=0)
|
||||
return(0);
|
||||
ret= burn_disc_get_profile(drive, &profile, profile_name);
|
||||
if(ret>0 && (!(flag&1)) &&
|
||||
(profile==0x12 || profile==0x43)) { /* DVD-RAM or BD-RE */
|
||||
ret= burn_disc_get_formats(drive, &status, &size, &dummy, &num_formats);
|
||||
if(ret>0 && status==BURN_FORMAT_IS_UNFORMATTED) {
|
||||
sprintf(xorriso->info_text,
|
||||
"Unformatted %s media detected. Trying -format fast.",
|
||||
profile_name);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
|
||||
ret= Xorriso_format_media(xorriso, 1);
|
||||
if(ret<=0) {
|
||||
sprintf(xorriso->info_text, "Automatic formatting of %s failed",
|
||||
profile_name);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
||||
return(ret);
|
||||
}
|
||||
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
|
||||
"on attempt to write", 2);
|
||||
if(ret<=0)
|
||||
return(0);
|
||||
ret= burn_disc_get_profile(drive, &profile, profile_name);
|
||||
}
|
||||
}
|
||||
|
||||
#else /* NIX */
|
||||
|
||||
if(!(flag & 1)) {
|
||||
ret= Xorriso_auto_format(xorriso, 0);
|
||||
if(ret <=0 )
|
||||
@ -1099,9 +1063,6 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag)
|
||||
"on attempt to write", 2);
|
||||
if(ret<=0)
|
||||
return(0);
|
||||
|
||||
#endif /* ! NIX */
|
||||
|
||||
if(xorriso->out_drive_handle == xorriso->in_drive_handle) {
|
||||
source_drive= drive;
|
||||
} else {
|
||||
@ -4490,13 +4451,14 @@ int Xorriso_blank_media(struct XorrisO *xorriso, int flag)
|
||||
|
||||
|
||||
/* @param flag bit0= try to achieve faster formatting
|
||||
bit1= use parameter size (else use default size)
|
||||
bit2= do not re-aquire drive
|
||||
bit7= by_index mode:
|
||||
bit8 to bit15 contain the index of the format to use.
|
||||
@return 0=failure, did not touch media , -1=failure, altered media
|
||||
1=success, altered media , 2=success, did not touch media
|
||||
*/
|
||||
int Xorriso_format_media(struct XorrisO *xorriso, int flag)
|
||||
int Xorriso_format_media(struct XorrisO *xorriso, off_t in_size, int flag)
|
||||
{
|
||||
int ret, mode_flag= 0, index, status, num_formats;
|
||||
unsigned dummy;
|
||||
@ -4515,7 +4477,11 @@ int Xorriso_format_media(struct XorrisO *xorriso, int flag)
|
||||
if(ret<=0)
|
||||
return(0);
|
||||
|
||||
mode_flag= 4; /* format to full size */
|
||||
if(flag & 2) {
|
||||
mode_flag= 0; /* format to given size */
|
||||
} else {
|
||||
mode_flag= 4; /* format to full size */
|
||||
}
|
||||
burn_disc_get_profile(drive, ¤t_profile, current_profile_name);
|
||||
|
||||
if(flag&128) { /* by_index */
|
||||
@ -4534,12 +4500,13 @@ int Xorriso_format_media(struct XorrisO *xorriso, int flag)
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
||||
return(0);
|
||||
}
|
||||
mode_flag= (flag & 0xff80) | 4; /* with size taken from descriptor */
|
||||
mode_flag|= (flag & 0xff80);
|
||||
if(flag&1)
|
||||
mode_flag|= (1<<6);
|
||||
|
||||
} else if(current_profile == 0x12) { /* DVD+RAM */
|
||||
mode_flag= 6; /* format to default payload size */
|
||||
if(!(flag & 2))
|
||||
mode_flag= 6; /* format to default payload size */
|
||||
if(flag&1)
|
||||
mode_flag|= (1<<6);
|
||||
|
||||
@ -4552,7 +4519,7 @@ int Xorriso_format_media(struct XorrisO *xorriso, int flag)
|
||||
}
|
||||
|
||||
} else if(current_profile == 0x14) { /* DVD-RW sequential */
|
||||
if(flag&1) {
|
||||
if((flag & 3) == 1) {
|
||||
size= 128*1024*1024;
|
||||
mode_flag= 1; /* format to size, then write size of zeros */
|
||||
}
|
||||
@ -4566,12 +4533,14 @@ int Xorriso_format_media(struct XorrisO *xorriso, int flag)
|
||||
}
|
||||
|
||||
} else if(current_profile == 0x41) { /* BD-R SRM */
|
||||
mode_flag= 6; /* format to default payload size */
|
||||
if(!(flag & 2))
|
||||
mode_flag= 6; /* format to default payload size */
|
||||
if(flag&1)
|
||||
mode_flag|= (1<<6);
|
||||
|
||||
} else if(current_profile == 0x43) { /* BD-RE */
|
||||
mode_flag= 6; /* format to default payload size */
|
||||
if(!(flag & 2))
|
||||
mode_flag= 6; /* format to default payload size */
|
||||
if(flag&1)
|
||||
mode_flag|= (1<<6);
|
||||
|
||||
@ -4594,6 +4563,8 @@ int Xorriso_format_media(struct XorrisO *xorriso, int flag)
|
||||
}
|
||||
sprintf(xorriso->info_text, "Beginning to format media.\n");
|
||||
Xorriso_info(xorriso, 0);
|
||||
if(flag & 2)
|
||||
size= in_size;
|
||||
burn_disc_format(drive, size, mode_flag);
|
||||
|
||||
start_time= time(0);
|
||||
@ -4675,19 +4646,19 @@ int Xorriso_blank_as_needed(struct XorrisO *xorriso, int flag)
|
||||
return(0);
|
||||
}
|
||||
if(!is_formatted) {
|
||||
ret= Xorriso_format_media(xorriso, (current_profile == 0x43));
|
||||
ret= Xorriso_format_media(xorriso, (off_t) 0, (current_profile == 0x43));
|
||||
if(ret <= 0)
|
||||
return(ret);
|
||||
did_work= (ret == 1);
|
||||
}
|
||||
} else if(current_profile == 0x14 && (flag&4)) { /* DVD-RW sequential */
|
||||
ret= Xorriso_format_media(xorriso, 0);
|
||||
ret= Xorriso_format_media(xorriso, (off_t) 0, 0);
|
||||
if(ret <= 0)
|
||||
return(ret);
|
||||
did_work= (ret == 1);
|
||||
} else if(current_profile == 0x41) { /* BD-R SRM */
|
||||
if(!is_formatted) {
|
||||
ret= Xorriso_format_media(xorriso, 1);
|
||||
ret= Xorriso_format_media(xorriso, (off_t) 0, 1);
|
||||
if(ret <= 0)
|
||||
return(ret);
|
||||
did_work= (ret == 1);
|
||||
|
Reference in New Issue
Block a user