Ticket 91: update media state model after content change

This commit is contained in:
Thomas Schmitt 2006-11-25 15:26:35 +00:00
parent 13214d9ac5
commit 56ab215db0
4 changed files with 74 additions and 69 deletions

View File

@ -135,33 +135,15 @@ unsigned int burn_drive_count(void)
return drivetop + 1; return drivetop + 1;
} }
int burn_drive_grab(struct burn_drive *d, int le)
{
int errcode;
int was_equal = 0, must_equal = 3, max_loop = 20;
/* ts A61125 : media status aspects of burn_drive_grab() */
int burn_drive_inquire_media(struct burn_drive *d)
{
/* ts A60907 */ /* ts A60907 */
int was_equal = 0, must_equal = 3, max_loop = 20;
int loop_count, old_speed = -1234567890, new_speed = -987654321; int loop_count, old_speed = -1234567890, new_speed = -987654321;
int old_erasable = -1234567890, new_erasable = -987654321; int old_erasable = -1234567890, new_erasable = -987654321;
if (!d->released) {
burn_print(1, "can't grab - already grabbed\n");
return 0;
}
errcode = d->grab(d);
if (errcode == 0) {
burn_print(1, "low level drive grab failed\n");
return 0;
}
d->busy = BURN_DRIVE_GRABBING;
if (le)
d->load(d);
d->lock(d);
d->start_unit(d);
/* ts A61020 : this was BURN_DISC_BLANK as pure guess */ /* ts A61020 : this was BURN_DISC_BLANK as pure guess */
d->status = BURN_DISC_UNREADY; d->status = BURN_DISC_UNREADY;
@ -169,6 +151,7 @@ int burn_drive_grab(struct burn_drive *d, int le)
d->mdata->dvdr_write || d->mdata->dvdram_write) { d->mdata->dvdr_write || d->mdata->dvdram_write) {
#ifdef Libburn_grab_release_and_grab_agaiN #ifdef Libburn_grab_release_and_grab_agaiN
/* This code demanded the app to release and re-grab. */
d->read_disc_info(d); d->read_disc_info(d);
@ -178,8 +161,7 @@ int burn_drive_grab(struct burn_drive *d, int le)
without closing and re-opening the drive */ without closing and re-opening the drive */
/* This seems to work for burn_disc_erasable() . /* This seems to work for burn_disc_erasable() .
Speed values on RIP-14 and LITE-ON 48125S are stable Speed values on RIP-14 and LITE-ON 48125S are stable
and false, nevertheless. So cdrskin -atip is still and false, nevertheless. */
forced to finish-initialize. */
/* /*
fprintf(stderr,"libburn: experimental: read_disc_info()\n"); fprintf(stderr,"libburn: experimental: read_disc_info()\n");
*/ */
@ -216,6 +198,38 @@ int burn_drive_grab(struct burn_drive *d, int le)
return 1; return 1;
} }
int burn_drive_grab(struct burn_drive *d, int le)
{
int errcode;
/* ts A61125 */
int ret;
if (!d->released) {
burn_print(1, "can't grab - already grabbed\n");
return 0;
}
errcode = d->grab(d);
if (errcode == 0) {
burn_print(1, "low level drive grab failed\n");
return 0;
}
d->busy = BURN_DRIVE_GRABBING;
if (le)
d->load(d);
d->lock(d);
/* ts A61118 */
d->start_unit(d);
/* ts A61125 : outsourced media state inquiry aspects */
ret = burn_drive_inquire_media(d);
return ret;
}
struct burn_drive *burn_drive_register(struct burn_drive *d) struct burn_drive *burn_drive_register(struct burn_drive *d)
{ {
#ifdef Libburn_ticket_62_re_register_is_possiblE #ifdef Libburn_ticket_62_re_register_is_possiblE
@ -311,6 +325,26 @@ struct burn_drive *burn_drive_finish_enum(struct burn_drive *d)
} }
/* ts A61125 : model aspects of burn_drive_release */
int burn_drive_mark_unready(struct burn_drive *d)
{
/* ts A61020 : mark media info as invalid */
d->start_lba= -2000000000;
d->end_lba= -2000000000;
d->status = BURN_DISC_UNREADY;
if (d->toc_entry != NULL)
free(d->toc_entry);
d->toc_entry = NULL;
d->toc_entries = 0;
if (d->disc != NULL) {
burn_disc_free(d->disc);
d->disc = NULL;
}
return 1;
}
void burn_drive_release(struct burn_drive *d, int le) void burn_drive_release(struct burn_drive *d, int le)
{ {
if (d->released) { if (d->released) {
@ -334,26 +368,14 @@ void burn_drive_release(struct burn_drive *d, int le)
return; return;
} }
/* ts A61020 : mark media info as invalid */
d->start_lba= -2000000000;
d->end_lba= -2000000000;
d->unlock(d); d->unlock(d);
if (le) if (le)
d->eject(d); d->eject(d);
d->release(d); d->release(d);
d->status = BURN_DISC_UNREADY;
d->released = 1; d->released = 1;
if (d->toc_entry != NULL)
free(d->toc_entry); /* ts A61125 : outsourced model aspects */
d->toc_entry = NULL; burn_drive_mark_unready(d);
d->toc_entries = 0;
if (d->disc != NULL) {
burn_disc_free(d->disc);
d->disc = NULL;
}
} }
@ -435,6 +457,10 @@ void burn_disc_erase_sync(struct burn_drive *d, int fast)
sleep(1); sleep(1);
d->progress.sector = 0x10000; d->progress.sector = 0x10000;
d->busy = BURN_DRIVE_IDLE; d->busy = BURN_DRIVE_IDLE;
/* ts A61125 : update media state records */
burn_drive_mark_unready(d);
burn_drive_inquire_media(d);
} }
enum burn_disc_status burn_disc_get_status(struct burn_drive *d) enum burn_disc_status burn_disc_get_status(struct burn_drive *d)

View File

@ -69,5 +69,10 @@ int burn_setup_drive(struct burn_drive *d, char *fname);
*/ */
struct burn_drive *burn_drive_finish_enum(struct burn_drive *d); struct burn_drive *burn_drive_finish_enum(struct burn_drive *d);
/* ts A61125 : media status aspects of burn_drive_grab() */
int burn_drive_inquire_media(struct burn_drive *d);
/* ts A61125 : model aspects of burn_drive_release */
int burn_drive_mark_unready(struct burn_drive *d);
#endif /* __DRIVE */ #endif /* __DRIVE */

View File

@ -923,6 +923,10 @@ return crap. so we send the command, then ignore the result.
burn_print(1, "done\n"); burn_print(1, "done\n");
d->busy = BURN_DRIVE_IDLE; d->busy = BURN_DRIVE_IDLE;
/* ts A61125 : update media state records */
burn_drive_mark_unready(d);
burn_drive_inquire_media(d);
/* ts A61012 : This return was traditionally missing. I suspect this /* ts A61012 : This return was traditionally missing. I suspect this
to have caused Cdrskin_eject() failures */ to have caused Cdrskin_eject() failures */
return; return;

View File

@ -25,8 +25,6 @@
libburner_aquire_by_driveno() demonstrates a scan-and-choose approach libburner_aquire_by_driveno() demonstrates a scan-and-choose approach
With that aquired drive you can blank a CD-RW With that aquired drive you can blank a CD-RW
libburner_blank_disc() libburner_blank_disc()
Between blanking and burning one eventually has to reload the drive status
libburner_regrab()
With the aquired drive you can burn to CD-R or blank CD-RW With the aquired drive you can burn to CD-R or blank CD-RW
libburner_payload() libburner_payload()
When everything is done, main() releases the drive and shuts down libburn: When everything is done, main() releases the drive and shuts down libburn:
@ -287,27 +285,6 @@ int libburner_blank_disc(struct burn_drive *drive, int blank_fast)
} }
/** This gesture is necessary to get the drive info after blanking.
It opens a small gap for losing the drive to another libburn instance.
We will work on closing this gap.
*/
int libburner_regrab(struct burn_drive *drive) {
int ret;
printf("Releasing and regrabbing drive ...\n");
if (drive_is_grabbed)
burn_drive_release(drive, 0);
drive_is_grabbed = 0;
ret = burn_drive_grab(drive, 0);
if (ret != 0) {
drive_is_grabbed = 1;
printf("Done\n");
} else
printf("FAILED\n");
return !!ret;
}
/** Brings preformatted track images (ISO 9660, audio, ...) onto media. /** Brings preformatted track images (ISO 9660, audio, ...) onto media.
To make sure a data image is fully readable on any Linux machine, this To make sure a data image is fully readable on any Linux machine, this
function adds 300 kB of padding to the (usualy single) track. function adds 300 kB of padding to the (usualy single) track.
@ -606,13 +583,6 @@ int main(int argc, char **argv)
do_blank == 1); do_blank == 1);
if (ret<=0) if (ret<=0)
{ ret = 36; goto release_drive; } { ret = 36; goto release_drive; }
if (ret != 2 && source_adr_count > 0)
ret = libburner_regrab(drive_list[driveno].drive);
if (ret<=0) {
fprintf(stderr,
"FATAL: Cannot release and grab again drive after blanking\n");
{ ret = 37; goto finish_libburn; }
}
} }
if (source_adr_count > 0) { if (source_adr_count > 0) {
ret = libburner_payload(drive_list[driveno].drive, ret = libburner_payload(drive_list[driveno].drive,