Moved tao_to_sao_tsize into libburn, let cdrskin use auto_write_type and precheck

This commit is contained in:
2007-02-21 20:53:28 +00:00
parent 9f2aa02c0d
commit d1ae732338
9 changed files with 288 additions and 141 deletions

View File

@ -369,8 +369,8 @@ void burn_disc_write(struct burn_write_opts *opts, struct burn_disc *disc)
/* ts A70219 : intended to replace all further tests here and many
tests in burn_*_write_sync()
*/
strcpy(reasons, "Write job parameters seem unsuitable:\n");
if (burn_precheck_write(opts, disc, reasons + strlen(reasons), 0)
strcpy(reasons, "Write job parameters are unsuitable:\n");
if (burn_precheck_write(opts, disc, reasons + strlen(reasons), 1)
== BURN_WRITE_NONE) {
#ifndef Libburn_precheck_write_ruleS

View File

@ -1677,6 +1677,7 @@ int burn_disc_get_multi_caps(struct burn_drive *d, enum burn_write_types wt,
d->best_format_size - 2048;
}
}
o->might_do_sao = 3;
o->might_do_tao = 2;
o->advised_write_mode = BURN_WRITE_TAO;
} else /* unknown media */

View File

@ -1005,12 +1005,13 @@ void burn_disc_read(struct burn_drive *drive, const struct burn_read_opts *o);
@param o The options for the writing operation.
@param disc The descrition of the disc to be created
@param reasons Eventually returns a list of rejection reason statements
@param silent 1= do not issue error messages , 0= report severe problems
@param silent 1= do not issue error messages , 0= report problems
@return 1 ok, -1= no recordable media detected, 0= other failure
*/
int burn_precheck_write( struct burn_write_opts *o, struct burn_disc *disc,
int burn_precheck_write(struct burn_write_opts *o, struct burn_disc *disc,
char reasons[1024], int silent);
/* <<< enabling switch for internal usage and trust in this functiion */
/* <<< enabling switch for internal usage and trust in this function */
#define Libburn_precheck_write_ruleS 1
@ -1276,6 +1277,7 @@ int burn_write_opts_set_write_type(struct burn_write_opts *opts,
@param flag Bitfield for control purposes:
bit0= do not choose type but check the one that is already set
bit1= do not issue error messages via burn_msgs queue
(is automatically set with bit0)
@return Chosen write type. BURN_WRITE_NONE on failure.
*/
enum burn_write_types burn_write_opts_auto_write_type(
@ -1516,6 +1518,7 @@ struct burn_multi_caps {
off_t start_range_high;
/** Potential availability of write modes
3= allowed but not to be chosen automatically
2= available, no size prediction necessary
1= available, needs exact size prediction
0= not available
@ -1526,7 +1529,9 @@ struct burn_multi_caps {
int might_do_sao;
int might_do_raw;
/** Advised write mode.
/** Generally advised write mode.
Not necessarily the one chosen by burn_write_opts_auto_write_type()
because the burn_disc structure might impose particular demands.
*/
enum burn_write_types advised_write_mode;

View File

@ -363,9 +363,8 @@ Range "scdbackup" : 0x00020000 to 0x0002ffff
0x00020136 (SORRY,HIGH) = DAO burning restricted to single fixed size track
0x00020137 (HINT,HIGH) = TAO would be possible
0x00020138 (FATAL,HIGH) = Cannot reserve track
0x00020139 (WARN,HIGH) = Unsuitable write type and/or block types detected
to become ^ SORRY ^ soon
0x00020139 (SORRY,HIGH) = Write job parameters are unsuitable
0x0002013a (FATAL,HIGH) = No suitable media detected
libdax_audioxtr:
0x00020200 (SORRY,HIGH) = Cannot open audio source file

View File

@ -173,6 +173,10 @@ void burn_write_opts_set_start_byte(struct burn_write_opts *opts, off_t value)
/* ts A70207 API */
/** @param flag Bitfield for control purposes:
bit0= do not choose type but check the one that is already set
bit1= do not issue error messages via burn_msgs queue
*/
enum burn_write_types burn_write_opts_auto_write_type(
struct burn_write_opts *opts, struct burn_disc *disc,
char reasons[1024], int flag)
@ -186,6 +190,19 @@ enum burn_write_types burn_write_opts_auto_write_type(
reasons[0] = 0;
if (d->status != BURN_DISC_BLANK &&
d->status != BURN_DISC_APPENDABLE){
if (d->status == BURN_DISC_FULL)
strcat(reasons, "MEDIA: closed or not recordable, ");
else
strcat(reasons,"MEDIA: no writeable media detected, ");
if (!(flag & 3))
libdax_msgs_submit(libdax_messenger, d->global_index,
0x0002013a,
LIBDAX_MSGS_SEV_FATAL, LIBDAX_MSGS_PRIO_HIGH,
"No suitable media detected", 0, 0);
return BURN_WRITE_NONE;
}
ret = burn_disc_get_write_mode_demands(disc, opts, &demands,
!!opts->fill_up_media);
if (ret <= 0) {
@ -193,12 +210,6 @@ enum burn_write_types burn_write_opts_auto_write_type(
{wt = BURN_WRITE_NONE; goto ex;}
}
if (demands.exotic_track && !d->current_is_cd_profile) {
if (!(flag & 2))
libdax_msgs_submit(libdax_messenger, d->global_index,
0x00020123,
LIBDAX_MSGS_SEV_SORRY, LIBDAX_MSGS_PRIO_HIGH,
"DVD Media are unsuitable for desired track type",
0, 0);
if (demands.audio)
strcat(reasons, "audio track prohibited by non-CD, ");
else
@ -207,24 +218,22 @@ enum burn_write_types burn_write_opts_auto_write_type(
}
if ((flag & 1) && opts->write_type != BURN_WRITE_SAO)
goto try_tao;
reason_pt = reasons + strlen(reasons);
strcat(reasons, "SAO: ");
if (d->status != BURN_DISC_BLANK) {
strcat(reasons, "write type SAO works only on blank media, ");
goto try_tao;
}
burn_disc_free_multi_caps(&caps);
ret = burn_disc_get_multi_caps(d, BURN_WRITE_SAO, &caps, 0);
if (ret < 0) {
no_caps:;
if (!(flag & 2))
libdax_msgs_submit(libdax_messenger, d->global_index,
0x0002012a,
LIBDAX_MSGS_SEV_FATAL, LIBDAX_MSGS_PRIO_HIGH,
"Cannot inquire write mode capabilities",
0, 0);
strcat(reasons, "cannot inquire write mode capabilities, ");
{wt = BURN_WRITE_NONE; goto ex;}
} else if (ret == 0) {
strcat(reasons, "SAO: no SAO offered by drive and media, ");
strcat(reasons, "no SAO offered by drive and media, ");
goto no_sao;
}
reason_pt = reasons + strlen(reasons);
strcat(reasons, "SAO: ");
if ((opts->multi || demands.multi_session) &&
!caps->multi_session)
strcat(reasons, "multi session capability lacking, ");
@ -250,14 +259,14 @@ no_caps:;
if (demands.unknown_track_size == 2 && !(flag & 1)) {
strcat(reasons, "would have to use default track sizes, ");
goto no_sao;
}
} else if (caps->might_do_sao == 3 && !(flag & 1))
goto try_tao;
do_sao:;
if (!(flag & 1))
burn_write_opts_set_write_type(
opts, BURN_WRITE_SAO, BURN_BLOCK_SAO);
{wt = BURN_WRITE_SAO; goto ex;}
no_sao:;
strcat(reasons, "\n");
try_tao:;
if ((flag & 1) && opts->write_type != BURN_WRITE_TAO)
goto try_raw;
@ -289,11 +298,10 @@ try_tao:;
opts, BURN_WRITE_TAO, BURN_BLOCK_MODE1);
{wt = BURN_WRITE_TAO; goto ex;}
no_tao:;
if (would_do_sao && !(flag &1))
if (would_do_sao && !(flag & 1))
goto do_sao;
if (!d->current_is_cd_profile)
goto no_write_mode;
strcat(reasons, "\n");
try_raw:;
if ((flag & 1) && opts->write_type != BURN_WRITE_RAW)
goto no_write_mode;
@ -304,9 +312,11 @@ try_raw:;
reason_pt = reasons + strlen(reasons);
strcat(reasons, "RAW: ");
if (!d->current_is_cd_profile)
strcat(reasons, "prohibited by non-CD, ");
if ((d->block_types[BURN_WRITE_TAO] & demands.block_types) !=
demands.block_types)
strcat(reasons, "write type RAW prohibited by non-CD, ");
else if (d->status != BURN_DISC_BLANK)
strcat(reasons, "write type RAW works only on blank media, ");
else if ((d->block_types[BURN_WRITE_TAO] & demands.block_types) !=
demands.block_types)
strcat(reasons, "drive dislikes block type, ");
if (strcmp(reason_pt, "RAW: ") != 0)
goto no_write_mode;
@ -316,15 +326,16 @@ try_raw:;
{wt = BURN_WRITE_RAW; goto ex;}
no_write_mode:;
if (!(flag & (1 | 2)))
wt = BURN_WRITE_NONE;
ex:;
burn_disc_free_multi_caps(&caps);
if (wt == BURN_WRITE_NONE && !(flag & 3)) {
libdax_msgs_submit(libdax_messenger, d->global_index,
0x0002012b,
LIBDAX_MSGS_SEV_SORRY, LIBDAX_MSGS_PRIO_HIGH,
"Drive offers no suitable write mode with this job",
0, 0);
wt = BURN_WRITE_NONE;
ex:;
burn_disc_free_multi_caps(&caps);
}
return wt;
}

View File

@ -356,6 +356,7 @@ int burn_track_set_sectors(struct burn_track *t, int sectors)
/* ts A70218 */
int burn_track_set_size(struct burn_track *t, off_t size)
{
t->open_ended = (size <= 0);
return t->source->set_size(t->source, size);
}

View File

@ -1256,18 +1256,24 @@ int burn_precheck_write(struct burn_write_opts *o, struct burn_disc *disc,
{
enum burn_write_types wt;
struct burn_drive *d = o->drive;
char msg[160];
char msg[160], *reason_pt;
int no_media = 0;
reason_pt= reasons;
reasons[0] = 0;
/* check write mode against write job */
reasons[0] = 0;
wt = burn_write_opts_auto_write_type(o, disc, reasons,
1 | ((!!silent) << 1));
if (wt == BURN_WRITE_NONE)
return 0;
wt = burn_write_opts_auto_write_type(o, disc, reasons, 1);
if (wt == BURN_WRITE_NONE) {
if (strncmp(reasons, "MEDIA: ", 7)==0)
no_media = 1;
goto ex;
}
sprintf(reasons, "%s: ", d->current_profile_text);
reason_pt= reasons + strlen(reasons);
if (d->current_profile == 0x09 || d->current_profile == 0x0a) {
if (! burn_disc_write_is_ok(o, disc, (!!silent) << 1))
if (!burn_disc_write_is_ok(o, disc, (!!silent) << 1))
strcat(reasons, "unsuitable track mode found, ");
if (o->start_byte >= 0)
strcat(reasons, "write start address not supported, ");
@ -1293,9 +1299,25 @@ int burn_precheck_write(struct burn_write_opts *o, struct burn_disc *disc,
LIBDAX_MSGS_SEV_SORRY, LIBDAX_MSGS_PRIO_HIGH,
msg, 0, 0);
strcat(reasons, "no suitable media profile detected, ");
}
if (strlen(reasons) > strlen(d->current_profile_text) + 2)
return 0;
}
ex:;
if (reason_pt[0]) {
if (no_media) {
if (!silent)
libdax_msgs_submit(libdax_messenger,
d->global_index, 0x0002013a,
LIBDAX_MSGS_SEV_FATAL, LIBDAX_MSGS_PRIO_HIGH,
"No suitable media detected", 0, 0);
return -1;
}
if (!silent)
libdax_msgs_submit(libdax_messenger,
d->global_index, 0x00020139,
LIBDAX_MSGS_SEV_SORRY, LIBDAX_MSGS_PRIO_HIGH,
"Write job parameters are unsuitable", 0, 0);
return 0;
}
return 1;
}