[Libburn] Cancelling an ongoing burn. Is this dangerous ?

Thomas Schmitt scdbackup at gmx.net
Wed Feb 8 11:30:10 PST 2006


Hi,

impatient as i am, i inserted into libburn/write.c:burn_write_track()
a few
  if(d->cancel)
    return;

This seems to work fine.
The drive becomes BURN_DRIVE_IDLE within a few seconds (15 max).
One can eject it by its own eject-button.
One can successfully write a CD-RW afterwards.


Derek, could you please have a short look at the attached function
from libburn-0.2 (with four inserted if-return statements) wether
there is any danger involved ?
If you see a potential problem, please let me know and i will
switch back to the old state.

(This is not meant as a patch because it was done quite mindless
under the assumption that one simply has to stop processing sectors.)


Have a nice day :)

Thomas

-- 
10 GB Mailbox, 100 FreeSMS/Monat http://www.gmx.net/de/go/topmail
+++ GMX - die erste Adresse für Mail, Message, More +++
-------------- next part --------------
void burn_write_track(struct burn_write_opts *o, struct burn_session *s,
		      int tnum)
{
	struct burn_track *t = s->track[tnum];
	struct burn_drive *d = o->drive;
	int i, tmp = 0;
	int sectors;

	if(d->cancel)
		return;

	d->rlba = -150;

/* XXX for tao, we don't want the pregaps  but still want post? */
	if (o->write_type != BURN_WRITE_TAO) {
		if (t->pregap1)
			d->rlba += 75;
		if (t->pregap2)
			d->rlba += 150;

		if (t->pregap1) {
			struct burn_track *pt = s->track[tnum - 1];

			if (tnum == 0) {
				printf("first track should not have a pregap1\n");
				pt = t;
			}
			for (i = 0; i < 75; i++)
				sector_pregap(o, t->entry->point,
					      pt->entry->control, pt->mode);
		}
		if (t->pregap2)
			for (i = 0; i < 150; i++)
				sector_pregap(o, t->entry->point,
					      t->entry->control, t->mode);
	} else {
		o->control = t->entry->control;
		d->send_write_parameters(d, o);
	}

/* user data */
	sectors = burn_track_get_sectors(t);

	/* Update progress */
	d->progress.start_sector = d->nwa;
	d->progress.sectors = sectors;
	d->progress.current_sector = 0;

	burn_print(12, "track is %d sectors long\n", sectors);

	if (tnum == s->tracks)
		tmp = sectors > 150 ? 150 : sectors;

	for (i = 0; i < sectors - tmp; i++) {

		if(d->cancel)
			return;

		sector_data(o, t, 0);

		/* update current progress */
		d->progress.current_sector++;
	}
	for (; i < sectors; i++) {

		if(d->cancel)
			return;

		burn_print(1, "last track, leadout prep\n");
		sector_data(o, t, 1);

		/* update progress */
		d->progress.current_sector++;
	}

	if (t->postgap)
		for (i = 0; i < 150; i++)
			sector_postgap(o, t->entry->point, t->entry->control,
				       t->mode);

	if(d->cancel)
		return;

	i = t->offset;
	if (o->write_type == BURN_WRITE_SAO) {
		if (d->buffer->bytes) {
			d->write(d, d->nwa, d->buffer);
			d->nwa += d->buffer->sectors;
			d->buffer->bytes = 0;
			d->buffer->sectors = 0;
		}
	}
	if (o->write_type == BURN_WRITE_TAO)
		burn_write_flush(o);
}


More information about the libburn mailing list