Let random access writing obey simulation mode of previous sequential run. New API call burn_drive_reset_simulate().

This commit is contained in:
Thomas Schmitt 2016-11-18 14:21:33 +01:00
parent d7b5090ff9
commit 80175e0054
6 changed files with 59 additions and 4 deletions

View File

@ -1587,6 +1587,20 @@ int burn_drive_set_buffer_waiting(struct burn_drive *d, int enable,
}
int burn_drive_reset_simulate(struct burn_drive *d, int simulate)
{
if (d->busy != BURN_DRIVE_IDLE) {
libdax_msgs_submit(libdax_messenger,
d->global_index, 0x00020140,
LIBDAX_MSGS_SEV_FATAL, LIBDAX_MSGS_PRIO_HIGH,
"Drive is busy on attempt to write random access",0,0);
return 0;
}
d->do_simulate = !!simulate;
return 1;
}
int burn_msf_to_sectors(int m, int s, int f)
{
return (m * 60 + s) * 75 + f;

View File

@ -3033,6 +3033,24 @@ int burn_drive_set_buffer_waiting(struct burn_drive *d, int enable,
int min_usec, int max_usec, int timeout_sec,
int min_percent, int max_percent);
/* ts B61116 */
/** Control the write simulation mode before or after burn_write_opts get
into effect.
Beginning with version 1.4.8 a burn run by burn_disc_write() brings the
burn_drive object in the simulation state as set to the burn_write_opts
by burn_write_opts_set_simulate(). This state is respected by call
burn_random_access_write() until a new call of burn_disc_write() happens
or until burn_drive_reset_simulate() is called.
This call may only be made when burn_drive_get_status() returns
BURN_DRIVE_IDLE.
@param d The drive to control
@param simulate 1 enables simulation, 0 enables real writing
@return 1=success , 0=failure
@since 1.4.8
*/
int burn_drive_reset_simulate(struct burn_drive *d, int simulate);
/* these are for my [Derek Foreman's ?] debugging, they will disappear */
/* ts B11012 :
@ -3100,8 +3118,13 @@ void burn_write_opts_set_format(struct burn_write_opts *opts, int format);
media content and burn_disc_get_status() stay unchanged.
Note: With stdio-drives, the target file gets eventually created, opened,
lseeked, and closed, but not written. So there are effects on it.
Warning: Call burn_random_access_write() will never do simulation because
it does not get any burn_write_opts.
Note: Up to version 1.4.6 the call burn_random_access_write() after
burn_disc_write() did not simulate because it does not get any
burn_write_opts and the drive did not memorize the simulation state.
This has changed now. burn_random_access_write() will not write after
a simulated burn run.
Use burn_drive_reset_simulate(drive, 0) if you really want to end
simulation before you call burn_disc_write() with new write options.
@param opts The write opts to change
@param sim Non-zero enables simulation, 0 enables real writing
@return Returns 1 on success and 0 on failure.
@ -3944,6 +3967,11 @@ int burn_is_aborting(int flag);
only after the write transaction has ended (successfully or not). So it is
wise not to transfer giant amounts of data in a single call.
Important: Data have to fit into the already formatted area of the media.
If the burn_drive object is in simulation mode, then no actual write
operation or synchronization of the drive buffer will happen.
See burn_drive_reset_simulate().
@param d The drive to which to write
@param byte_address The start address of the write in byte
(1 LBA unit = 2048 bytes) (do respect media alignment)

View File

@ -71,6 +71,7 @@ burn_drive_obtain_scsi_adr;
burn_drive_probe_cd_write_modes;
burn_drive_re_assess;
burn_drive_release;
burn_drive_reset_simulate;
burn_drive_scan;
burn_drive_scan_and_grab;
burn_drive_set_buffer_waiting;

View File

@ -5383,6 +5383,8 @@ int mmc_setup_drive(struct burn_drive *d)
d->start_lba = -2000000000;
d->end_lba = -2000000000;
d->do_simulate= 0;
/* ts A61201 - A90815*/
d->erasable = 0;
d->current_profile = -1;

View File

@ -336,6 +336,8 @@ struct burn_drive
int start_lba;
int end_lba;
/* ts B61116 */
int do_simulate;
/* ts A70131 : from 51h READ DISC INFORMATION Number of Sessions (-1)*/
int complete_sessions;

View File

@ -2589,6 +2589,8 @@ int burn_stdio_write(int fd, char *buf, int count, struct burn_drive *d,
if (d->cancel || count <= 0)
return 0;
if(d->do_simulate)
return 1;
todo = count;
done = 0;
@ -2619,6 +2621,7 @@ fprintf(stderr, "libburn_DEBUG: write(%d, %lX, %d)\n",
d->cancel = 1;
ret = 0; goto ex;
}
ret = 1;
ex:;
BURN_FREE_MEM(msg);
return ret;
@ -2794,6 +2797,7 @@ int burn_stdio_write_track(struct burn_write_opts *o, struct burn_session *s,
d->write = burn_stdio_mmc_dummy_write;
else
d->write = burn_stdio_mmc_write;
d->do_simulate = o->simulate;
d->sync_cache = burn_stdio_mmc_sync_cache;
burn_stdio_slowdown(d, &prev_time, 0, 1); /* initialize */
@ -3289,7 +3293,9 @@ int burn_random_access_write(struct burn_drive *d, off_t byte_address,
rpt += d->buffer->bytes;
d->buffer->sectors = chunksize;
d->nwa = start;
if(d->drive_role == 1) {
if(d->do_simulate) {
err = 0;
} else if(d->drive_role == 1) {
err = d->write(d, d->nwa, d->buffer);
} else {
ret = burn_stdio_write(fd, (char *) d->buffer->data,
@ -3309,7 +3315,9 @@ int burn_random_access_write(struct burn_drive *d, off_t byte_address,
if(d->drive_role == 1)
d->needs_sync_cache = 1;
if(flag & 1) {
if(d->drive_role == 1)
if(d->do_simulate) {
;
} else if(d->drive_role == 1)
d->sync_cache(d);
else
burn_stdio_sync_cache(fd, d, 2);