New API calls isoburn_igopt_set_write_type() , isoburn_igopt_get_write_type()

This commit is contained in:
Thomas Schmitt 2012-07-10 08:28:20 +00:00
parent 4000d33656
commit cd6f758d2f
6 changed files with 90 additions and 41 deletions

View File

@ -864,14 +864,8 @@ void isoburn_disc_write(struct burn_write_opts *opts, struct burn_disc *disc)
struct burn_drive *drive;
char *reasons= NULL, *msg= NULL, *adr= NULL;
struct stat stbuf;
#ifdef Libisoburn_write_type_autO
/* <<< on its way out */
enum burn_write_types write_type;
#endif /* Libisoburn_write_type_autO */
drive= burn_write_opts_get_drive(opts);
reasons= calloc(1, BURN_REASONS_LEN);
@ -923,44 +917,42 @@ void isoburn_disc_write(struct burn_write_opts *opts, struct burn_disc *disc)
}
}
#ifdef Libisoburn_write_type_autO
if(o->do_tao) {
if (o->do_tao > 0)
burn_write_opts_set_write_type(opts, BURN_WRITE_TAO, BURN_BLOCK_MODE1);
else
burn_write_opts_set_write_type(opts, BURN_WRITE_SAO, BURN_BLOCK_SAO);
/* <<< on its way out */
ret = burn_precheck_write(opts, disc, reasons, 0);
if(ret <= 0) {
sprintf(msg, "Cannot set write type %s for this medium.",
o->do_tao > 0 ? "TAO" : "SAO");
sprintf(msg + strlen(msg), "Reasons given:\n %s", reasons);
goto no_write_type;
}
sprintf(msg, "Explicitly chosen write type: %s",
o->do_tao > 0 ? "TAO" : "SAO");
isoburn_msgs_submit(o, 0x00060000, msg, 0, "NOTE", 0);
} else {
write_type= burn_write_opts_auto_write_type(opts, disc, reasons, 0);
if (write_type == BURN_WRITE_NONE) {
sprintf(msg, "Failed to find a suitable write type:\n%s", reasons);
no_write_type:;
isoburn_msgs_submit(o, 0x00060000, msg, 0, "FAILURE", 0);
if(o!=NULL)
o->wrote_well= 0;
/* To cause a negative reply with burn_drive_wrote_well() */
burn_drive_cancel(drive);
goto ex;
}
write_type= burn_write_opts_auto_write_type(opts, disc, reasons, 0);
if (write_type == BURN_WRITE_NONE) {
sprintf(msg, "Failed to find a suitable write mode:\n%s", reasons);
isoburn_msgs_submit(o, 0x00060000, msg, 0, "FAILURE", 0);
if(o!=NULL)
o->wrote_well= 0;
/* To cause a negative reply with burn_drive_wrote_well() */
burn_drive_cancel(drive);
goto ex;
sprintf(reasons, "%d", (int) write_type);
sprintf(msg, "Write_type = %s\n",
(write_type == BURN_WRITE_SAO ? "SAO" :
(write_type == BURN_WRITE_TAO ? "TAO" : reasons)));
isoburn_msgs_submit(o, 0x00060000, msg, 0, "DEBUG", 0);
}
sprintf(reasons, "%d", (int) write_type);
sprintf(msg, "Write_type = %s\n",
(write_type == BURN_WRITE_SAO ? "SAO" :
(write_type == BURN_WRITE_TAO ? "TAO" : reasons)));
isoburn_msgs_submit(o, 0x00060000, msg, 0, "DEBUG", 0);
#else /* Libisoburn_write_type_autO */
/* The caller is in charge to select the write type */
ret = burn_precheck_write(opts, disc, reasons, 0);
if(ret <= 0) {
sprintf(msg, "Write parameters not properly set for this medium:\n %s",
reasons);
isoburn_msgs_submit(o, 0x00060000, msg, 0, "FAILURE", 0);
if(o!=NULL)
o->wrote_well= 0;
/* To cause a negative reply with burn_drive_wrote_well() */
burn_drive_cancel(drive);
goto ex;
}
#endif /* ! Libisoburn_write_type_autO */
#ifdef Hardcoded_cd_rW
/* <<< A70929 : hardcoded CD-RW with fabricated -msinfo */
fprintf(stderr, "Setting write address to LBA %d\n", Hardcoded_cd_rw_nwA);

View File

@ -149,6 +149,7 @@ int isoburn_new(struct isoburn **objpt, int flag)
o->msgs_submit= NULL;
o->msgs_submit_handle= NULL;
o->msgs_submit_flag= 0;
o->do_tao= 0;
o->prev= NULL;
o->next= NULL;
o->target_iso_head= calloc(1, o->target_iso_head_size);
@ -435,6 +436,8 @@ int isoburn_prepare_disc_aux(struct burn_drive *in_d, struct burn_drive *out_d,
{ret= -4; goto ex;}
}
out_o->do_tao = opts->do_tao;
state = isoburn_disc_get_status(in_d);
if (state != BURN_DISC_BLANK && state != BURN_DISC_APPENDABLE &&
state != BURN_DISC_FULL) {
@ -1099,6 +1102,7 @@ int isoburn_igopt_new(struct isoburn_imgen_opts **new_o, int flag)
memset(o->hfsp_serial_number, 0, 8);
o->hfsp_block_size= 0;
o->apm_block_size= 0;
o->do_tao= 0;
return(1);
}
@ -1703,3 +1707,19 @@ int isoburn_igopt_get_hfsp_block_size(struct isoburn_imgen_opts *opts,
}
int isoburn_igopt_set_write_type(struct isoburn_imgen_opts *opts, int do_tao)
{
if(do_tao < -1 || do_tao > 1)
return(0);
opts->do_tao= do_tao;
return(1);
}
int isoburn_igopt_get_write_type(struct isoburn_imgen_opts *opts, int *do_tao)
{
*do_tao= opts->do_tao;
return(1);
}

View File

@ -165,6 +165,9 @@ struct isoburn {
void *msgs_submit_handle; /* specific to application method */
int msgs_submit_flag; /* specific to application method */
/* Forwarding an image generation option to the burn wrapper */
int do_tao;
};
@ -691,6 +694,13 @@ struct isoburn_imgen_opts {
*/
int apm_block_size;
/* Write mode for optical media:
* 0 = auto
* 1 = TAO, Incremental, no RESERVE TRACK
* -1 = SAO, DAO, RESERVE TRACK
*/
int do_tao;
};

View File

@ -1834,6 +1834,31 @@ int isoburn_igopt_get_hfsp_block_size(struct isoburn_imgen_opts *opts,
int *hfsp_block_size, int *apm_block_size);
/** Set or inquire the write type for the next write run on optical media.
@since 1.2.4
@param opts
The option set to be manipulated or inquired.
@param do_tao
The value to be set or the variable where to return the current
setting:
0 = Let libburn choose according to other write parameters.
This is advisable unless there are particular reasons not to
use one of the two write types. Be aware that 1 and -1 can
lead to failure if the write type is not appropriate for
the given media situation.
1 = Use BURN_WRITE_TAO which does
TAO on CD, Incremental on DVD-R,
no track reservation on DVD+R and BD-R
-1 = Use BURN_WRITE_SAO which does
SAO on CD, DAO on DVD-R,
track reservation on DVD+R and BD-R
@return
<=0 = error, 1 = success
*/
int isoburn_igopt_set_write_type(struct isoburn_imgen_opts *opts, int do_tao);
int isoburn_igopt_get_write_type(struct isoburn_imgen_opts *opts, int *do_tao);
/* ----------------------------------------------------------------------- */
/* End of Options for image generation */
/* ----------------------------------------------------------------------- */

View File

@ -48,6 +48,7 @@ isoburn_igopt_get_sort_files;
isoburn_igopt_get_system_area;
isoburn_igopt_get_tail_blocks;
isoburn_igopt_get_untranslated_name_len;
isoburn_igopt_get_write_type;
isoburn_igopt_new;
isoburn_igopt_set_disc_label;
isoburn_igopt_set_efi_bootp;
@ -69,6 +70,7 @@ isoburn_igopt_set_sort_files;
isoburn_igopt_set_system_area;
isoburn_igopt_set_tail_blocks;
isoburn_igopt_set_untranslated_name_len;
isoburn_igopt_set_write_type;
isoburn_initialize;
isoburn_is_compatible;
isoburn_libburn_req;

View File

@ -1 +1 @@
#define Xorriso_timestamP "2012.07.08.200735"
#define Xorriso_timestamP "2012.07.10.082919"