Experiment for TOC on overwriteables: Keep a target_head copy of session #1

This commit is contained in:
2008-05-06 14:45:49 +00:00
parent f830c30196
commit 3eae8634cd
5 changed files with 204 additions and 23 deletions

View File

@ -213,7 +213,27 @@ int isoburn_libburn_req(int *major, int *minor, int *micro)
}
/** Examine the media and sets appropriate emulation if needed.
int isoburn_is_intermediate_dvd_rw(struct burn_drive *d, int flag)
{
int profile, ret= 0, format_status, num_formats;
char profile_name[80];
enum burn_disc_status s;
off_t format_size= -1;
unsigned bl_sas;
s= isoburn_disc_get_status(d);
ret= burn_disc_get_profile(d, &profile, profile_name);
if(ret>0 && profile==0x13)
ret= burn_disc_get_formats(d, &format_status, &format_size,
&bl_sas, &num_formats);
if(ret>0 && profile==0x13 && s==BURN_DISC_BLANK &&
format_status==BURN_FORMAT_IS_UNKNOWN)
return(1);
return(0);
}
/** Examines the media and sets appropriate emulation if needed.
@param flag bit0= pretent blank on overwriteable media
*/
static int isoburn_welcome_media(struct isoburn **o, struct burn_drive *d,
@ -238,9 +258,14 @@ static int isoburn_welcome_media(struct isoburn **o, struct burn_drive *d,
if(caps->start_adr) { /* set emulation to overwriteable */
(*o)->emulation_mode= 1;
if(flag&1) {
ret= isoburn_is_intermediate_dvd_rw(d, 0);
if(ret>0) {
(*o)->min_start_byte= 0;
(*o)->nwa= 0;
(*o)->zero_nwa= 0;
}
if(flag&1) {
(*o)->nwa= (*o)->zero_nwa;
(*o)->fabricated_disc_status= BURN_DISC_BLANK;
} else {
ret= isoburn_start_emulation(*o, 0);
@ -386,7 +411,7 @@ enum burn_disc_status isoburn_disc_get_status(struct burn_drive *drive)
/* emulated status */
if(o->emulation_mode==-1)
return(BURN_DISC_UNSUITABLE);
if(o->nwa>0)
if(o->nwa>o->zero_nwa)
return(BURN_DISC_APPENDABLE);
return(BURN_DISC_BLANK);
}
@ -520,6 +545,16 @@ void isoburn_disc_write(struct burn_write_opts *opts, struct burn_disc *disc)
enum burn_write_types write_type;
struct stat stbuf;
#ifdef NIX
/* <<< now in isoburn_is_intermediate_dvd_rw()
*/
int profile, format_status, num_formats;
unsigned bl_sas;
off_t format_size= -1;
char profile_name[80];
enum burn_disc_status s;
#endif
drive= burn_write_opts_get_drive(opts);
ret= isoburn_find_emulator(&o, drive, 0);
if(ret<0)
@ -529,8 +564,52 @@ void isoburn_disc_write(struct burn_write_opts *opts, struct burn_disc *disc)
if(o->emulation_mode!=0) {
burn_write_opts_set_multi(opts, 0);
if(o->emulation_mode>0 && o->nwa >= 0) {
burn_write_opts_set_start_byte(opts, ((off_t) o->nwa) * (off_t) 2048);
nwa= o->nwa;
/* This caters for unwritten formatted DVD-RW. They need to be written
sequentially on the first use. Only written areas are random access.
If the first session is not written to LBA 0, then re-opening of
formatting and padding is needed.
This can be done. But when the track gets closed after padding,
this lasts a long time. There is a high risk that an app will not
poll the message queue while waiting for isoburn_disc_write() to
return. The pacifier loop usually happens only afterwards.
So automatic formatting might cause a nervous clueless user.
*/
#ifdef NIX
/* <<< now in isoburn_is_intermediate_dvd_rw()
*/
s= isoburn_disc_get_status(drive);
ret= burn_disc_get_profile(drive, &profile, profile_name);
if(ret>0 && profile==0x13)
ret= burn_disc_get_formats(drive, &format_status, &format_size,
&bl_sas, &num_formats);
if(ret>0 && profile==0x13 && s==BURN_DISC_BLANK && nwa>0 &&
nwa <= o->zero_nwa && format_status==BURN_FORMAT_IS_UNKNOWN) {
#else
ret= isoburn_is_intermediate_dvd_rw(drive, 0);
if(ret>0 && nwa>0 && nwa <= o->zero_nwa) {
#endif /* ! NIX */
/* actually this should not happen since such media get recognized
by isoburn_welcome_media and o->zero_nwa gets set to 0
*/
sprintf(msg,
"DVD-RW insufficiently formatted. (Intermediate State, size unknown)");
burn_msgs_submit(0x00060000, msg, 0, "FAILURE", NULL);
sprintf(msg,
"It might help to first deformat it and then format it again");
burn_msgs_submit(0x00060000, msg, 0, "HINT", NULL);
burn_drive_cancel(drive); /* mark run as failure */
return;
}
/* end of DVD-RW oriented check */
burn_write_opts_set_start_byte(opts, nwa * (off_t) 2048);
}
}
}
@ -546,12 +625,11 @@ void isoburn_disc_write(struct burn_write_opts *opts, struct burn_disc *disc)
return;
}
/*
sprintf(reasons, "%d", (int) write_type);
fprintf(stderr, "isoburn_EXPERIMENTAL: write_type = %s\n",
(write_type == BURN_WRITE_SAO ? "SAO" :
(write_type == BURN_WRITE_TAO ? "TAO" : reasons)));
*/
sprintf(msg, "Write_type = %s\n",
(write_type == BURN_WRITE_SAO ? "SAO" :
(write_type == BURN_WRITE_TAO ? "TAO" : reasons)));
burn_msgs_submit(0x00060000, msg, 0, "DEBUG", NULL);
#ifdef Hardcoded_cd_rW
/* <<< A70929 : hardcoded CD-RW with fabricated -msinfo */
@ -638,9 +716,10 @@ int isoburn_set_start_byte(struct isoburn *o, off_t value, int flag)
if(value % caps->start_alignment)
value+= caps->start_alignment - (value % caps->start_alignment);
o->nwa= value/2048;
/* If suitable for alignment, round up to full 16 sector addresses */
if((o->nwa%16) && ((16*2048) % caps->start_alignment)==0 )
o->nwa+= 16 - (o->nwa%16);
/* If suitable for media alignment, round up to Libisoburn_nwa_alignemenT */
if((o->nwa % Libisoburn_nwa_alignemenT) &&
((Libisoburn_nwa_alignemenT*2048) % caps->start_alignment)==0 )
o->nwa+= Libisoburn_nwa_alignemenT - (o->nwa % Libisoburn_nwa_alignemenT);
ret= 1;
ex:
if(caps!=NULL)