diff --git a/cdrskin/cdrskin_timestamp.h b/cdrskin/cdrskin_timestamp.h index d935d00..aa6479d 100644 --- a/cdrskin/cdrskin_timestamp.h +++ b/cdrskin/cdrskin_timestamp.h @@ -1 +1 @@ -#define Cdrskin_timestamP "2012.01.13.101844" +#define Cdrskin_timestamP "2012.01.13.122205" diff --git a/libburn/sector.c b/libburn/sector.c index 0bba551..2f420d6 100644 --- a/libburn/sector.c +++ b/libburn/sector.c @@ -223,6 +223,36 @@ ex:; } } + +/* ts B20113 : outsourced from get_sector() */ +int sector_write_buffer(struct burn_drive *d, + struct burn_track *track, int flag) +{ + int err; + struct buffer *out; + + out = d->buffer; + if (out->sectors <= 0) + return 2; + err = d->write(d, d->nwa, out); + if (err == BE_CANCELLED) + return 0; + + /* ts A61101 */ + if(track != NULL) { + track->writecount += out->bytes; + track->written_sectors += out->sectors; + } + /* ts A61119 */ + d->progress.buffered_bytes += out->bytes; + + d->nwa += out->sectors; + out->bytes = 0; + out->sectors = 0; + return 1; +} + + /* ts A61009 : seems to hand out sector start pointer in opts->drive->buffer and to count hand outs as well as reserved bytes */ /* ts A61101 : added parameter track for counting written bytes */ @@ -231,7 +261,7 @@ static unsigned char *get_sector(struct burn_write_opts *opts, { struct burn_drive *d = opts->drive; struct buffer *out = d->buffer; - int outmode, seclen; + int outmode, seclen, write_ret; unsigned char *ret; outmode = get_outmode(opts); @@ -250,22 +280,9 @@ static unsigned char *get_sector(struct burn_write_opts *opts, /* (there is enough buffer size reserve for track->cdxa_conversion) */ if (out->bytes + seclen > BUFFER_SIZE || (opts->obs > 0 && out->bytes + seclen > opts->obs)) { - int err; - err = d->write(d, d->nwa, out); - if (err == BE_CANCELLED) + write_ret = sector_write_buffer(d, track, 0); + if (write_ret <= 0) return NULL; - - /* ts A61101 */ - if(track != NULL) { - track->writecount += out->bytes; - track->written_sectors += out->sectors; - } - /* ts A61119 */ - d->progress.buffered_bytes += out->bytes; - - d->nwa += out->sectors; - out->bytes = 0; - out->sectors = 0; } ret = out->data + out->bytes; out->bytes += seclen; diff --git a/libburn/sector.h b/libburn/sector.h index 4698f17..422444d 100644 --- a/libburn/sector.h +++ b/libburn/sector.h @@ -24,6 +24,10 @@ int sector_postgap(struct burn_write_opts *, unsigned char tno, int sector_lout(struct burn_write_opts *, unsigned char control, int mode); int sector_data(struct burn_write_opts *, struct burn_track *t, int psub); +/* ts B20113 */ +int sector_write_buffer(struct burn_drive *d, + struct burn_track *track, int flag); + /* ts A61009 */ int sector_headers_is_ok(struct burn_write_opts *o, int mode); diff --git a/libburn/write.c b/libburn/write.c index 902726b..220f0e8 100644 --- a/libburn/write.c +++ b/libburn/write.c @@ -1052,7 +1052,12 @@ int burn_disc_init_track_status(struct burn_write_opts *o, struct burn_drive *d = o->drive; /* Update progress */ + + /* >>> ts B20113 : This is wrong, because nwa does not count buffered + but yet unwritten sectors. + */ d->progress.start_sector = d->nwa; + d->progress.sectors = sectors; d->progress.sector = 0; @@ -1121,6 +1126,13 @@ int burn_write_track(struct burn_write_opts *o, struct burn_session *s, if (!sector_pregap(o, t->entry->point, t->entry->control, t->mode)) { ret = 0; goto ex; } + + /* Flush buffer to avoid influence of previous track or pregap + on track counter */ + ret = sector_write_buffer(d, NULL, 0); + if (ret <= 0) + goto ex; + } else { o->control = t->entry->control; d->send_write_parameters(d, s, tnum, o);