From c95665c1e05290940677d69a25252bb8795c1602 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Fri, 13 Jan 2012 12:22:07 +0000 Subject: [PATCH] Flushing buffer to MMC before a new track begins --- libburn/trunk/cdrskin/cdrskin_timestamp.h | 2 +- libburn/trunk/libburn/sector.c | 49 +++++++++++++++-------- libburn/trunk/libburn/sector.h | 4 ++ libburn/trunk/libburn/write.c | 12 ++++++ 4 files changed, 50 insertions(+), 17 deletions(-) diff --git a/libburn/trunk/cdrskin/cdrskin_timestamp.h b/libburn/trunk/cdrskin/cdrskin_timestamp.h index d935d003..aa6479d1 100644 --- a/libburn/trunk/cdrskin/cdrskin_timestamp.h +++ b/libburn/trunk/cdrskin/cdrskin_timestamp.h @@ -1 +1 @@ -#define Cdrskin_timestamP "2012.01.13.101844" +#define Cdrskin_timestamP "2012.01.13.122205" diff --git a/libburn/trunk/libburn/sector.c b/libburn/trunk/libburn/sector.c index 0bba5512..2f420d65 100644 --- a/libburn/trunk/libburn/sector.c +++ b/libburn/trunk/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/trunk/libburn/sector.h b/libburn/trunk/libburn/sector.h index 4698f17a..422444d8 100644 --- a/libburn/trunk/libburn/sector.h +++ b/libburn/trunk/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/trunk/libburn/write.c b/libburn/trunk/libburn/write.c index 902726be..220f0e8d 100644 --- a/libburn/trunk/libburn/write.c +++ b/libburn/trunk/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);