From 0bc022b5101652ddf341576578ddb8f6c6ce8414 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Wed, 14 Feb 2007 20:32:56 +0000 Subject: [PATCH] Optional padding up to full media size when closing (incomplete yet) --- libburn/trunk/cdrskin/cdrskin_timestamp.h | 2 +- libburn/trunk/libburn/drive.c | 2 + libburn/trunk/libburn/libburn.h | 14 +++++++ libburn/trunk/libburn/options.c | 9 +++++ libburn/trunk/libburn/options.h | 3 ++ libburn/trunk/libburn/structure.c | 34 ++++++++++++++++ libburn/trunk/libburn/structure.h | 9 +++++ libburn/trunk/libburn/write.c | 49 +++++++++++++++++++++-- 8 files changed, 118 insertions(+), 4 deletions(-) diff --git a/libburn/trunk/cdrskin/cdrskin_timestamp.h b/libburn/trunk/cdrskin/cdrskin_timestamp.h index ef083569..645fa12d 100644 --- a/libburn/trunk/cdrskin/cdrskin_timestamp.h +++ b/libburn/trunk/cdrskin/cdrskin_timestamp.h @@ -1 +1 @@ -#define Cdrskin_timestamP "2007.02.14.122218" +#define Cdrskin_timestamP "2007.02.14.202944" diff --git a/libburn/trunk/libburn/drive.c b/libburn/trunk/libburn/drive.c index d3f1761a..704185e7 100644 --- a/libburn/trunk/libburn/drive.c +++ b/libburn/trunk/libburn/drive.c @@ -1712,6 +1712,8 @@ int burn_disc_get_write_mode_demands(struct burn_disc *disc, int i, j, mode; memset((char *) result, 0, sizeof(struct burn_disc_mode_demands)); + if (disc == NULL) + return 2; if (disc->sessions > 1) result->multi_session = 1; for (i = 0; i < disc->sessions; i++) { diff --git a/libburn/trunk/libburn/libburn.h b/libburn/trunk/libburn/libburn.h index 5a181b6f..65030f21 100644 --- a/libburn/trunk/libburn/libburn.h +++ b/libburn/trunk/libburn/libburn.h @@ -1311,6 +1311,20 @@ void burn_write_opts_set_multi(struct burn_write_opts *opts, int multi); void burn_write_opts_set_start_byte(struct burn_write_opts *opts, off_t value); +/* ts A70213 */ +/** Caution: still immature and likely to change. Problems arose with + sequential DVD-RW. + + Controls wether the whole available space of the media shall be filled up + by the last track of the last session. + @param opts The write opts to change + @param fill_up_media If 1 : fill up by last track, if 0 = do not fill up +*/ +void burn_write_opts_set_fillup(struct burn_write_opts *opts, + int fill_up_media); + + + /** Sets whether to read in raw mode or not @param opts The read opts to change @param raw_mode If non-zero, reading will be done in raw mode, so that everything in the data tracks on the diff --git a/libburn/trunk/libburn/options.c b/libburn/trunk/libburn/options.c index 42e3a09d..1521e14e 100644 --- a/libburn/trunk/libburn/options.c +++ b/libburn/trunk/libburn/options.c @@ -36,6 +36,7 @@ struct burn_write_opts *burn_write_opts_new(struct burn_drive *drive) opts->obs = -1; opts->obs_pad = 0; opts->start_byte = -1; + opts->fill_up_media = 0; opts->has_mediacatalog = 0; opts->format = BURN_CDROM; opts->multi = 0; @@ -261,6 +262,14 @@ no_write_mode:; } +/* ts A70213 : new API function */ +void burn_write_opts_set_fillup(struct burn_write_opts *opts,int fill_up_media) +{ + opts->fill_up_media = !!fill_up_media; + return; +} + + void burn_read_opts_set_raw(struct burn_read_opts *opts, int raw) { opts->raw = raw; diff --git a/libburn/trunk/libburn/options.h b/libburn/trunk/libburn/options.h index 2a0d1a3e..1005d67a 100644 --- a/libburn/trunk/libburn/options.h +++ b/libburn/trunk/libburn/options.h @@ -41,6 +41,9 @@ struct burn_write_opts /* ts A61222 : Start address for media which allow a choice */ off_t start_byte; + /* ts A70213 : Wether to fill up the while available space on media */ + int fill_up_media; + /** A disc can have a media catalog number */ int has_mediacatalog; unsigned char mediacatalog[13]; diff --git a/libburn/trunk/libburn/structure.c b/libburn/trunk/libburn/structure.c index 7f4c1973..31b1154e 100644 --- a/libburn/trunk/libburn/structure.c +++ b/libburn/trunk/libburn/structure.c @@ -113,6 +113,10 @@ struct burn_track *burn_track_create(void) t->mode = BURN_MODE1; t->isrc.has_isrc = 0; t->pad = 1; + + /* ts A70213 */ + t->fill_up_media = 0; + t->entry = NULL; t->source = NULL; t->eos = 0; @@ -346,6 +350,36 @@ int burn_track_set_sectors(struct burn_track *t, int sectors) } +/* ts A70213 */ +int burn_track_set_fillup(struct burn_track *t, int fill_up_media) +{ + t->fill_up_media = fill_up_media; + return 1; +} + + +/* ts A70213 */ +/** + @param flag bit0= force new size even if existing track size is larger +*/ +int burn_track_apply_fillup(struct burn_track *t, off_t max_size, int flag) +{ + int max_sectors, ret; + + if (t->fill_up_media <= 0) + return 2; + max_sectors = max_size / 2048; + if (burn_track_get_sectors(t) < max_sectors || (flag & 1)) { + ret = burn_track_set_sectors(t, max_sectors); + + /* <<< */ + fprintf(stderr, "LIBBURN_DEBUG: Setting total track size to %ds (payload %ds)\n", max_sectors, (int) (t->source->get_size(t->source)/2048)); + + } + return ret; +} + + /* ts A61031 */ int burn_track_is_open_ended(struct burn_track *t) { diff --git a/libburn/trunk/libburn/structure.h b/libburn/trunk/libburn/structure.h index f1b2e0a0..15739b3b 100644 --- a/libburn/trunk/libburn/structure.h +++ b/libburn/trunk/libburn/structure.h @@ -27,6 +27,10 @@ struct burn_track int tailcount; /** 1 means Pad with zeros, 0 means start reading the next track */ int pad; + + /* ts A70213 : wether to expand this track to full available media */ + int fill_up_media; + /** Data source */ struct burn_source *source; /** End of Source flag */ @@ -91,5 +95,10 @@ int burn_track_is_data_done(struct burn_track *t); /* ts A70125 */ int burn_track_set_sectors(struct burn_track *t, int sectors); +/* ts A70213 */ +int burn_track_set_fillup(struct burn_track *t, int fill_up_media); +int burn_track_apply_fillup(struct burn_track *t, off_t max_size, int flag); + + #endif /* BURN__STRUCTURE_H */ diff --git a/libburn/trunk/libburn/write.c b/libburn/trunk/libburn/write.c index d040c1e3..ce921508 100644 --- a/libburn/trunk/libburn/write.c +++ b/libburn/trunk/libburn/write.c @@ -37,6 +37,7 @@ #include "sg.h" #include "write.h" #include "options.h" +#include "structure.h" #include "libdax_msgs.h" extern struct libdax_msgs *libdax_messenger; @@ -706,14 +707,21 @@ int burn_write_track(struct burn_write_opts *o, struct burn_session *s, /* ts A61103 */ ret = d->get_nwa(d, -1, &lba, &nwa); + + /* ts A70213: CD-TAO: eventually expand size of track to max */ + burn_track_apply_fillup(t, d->media_capacity_remaining, 0); + + /* <<< */ sprintf(msg, - "pre-track %2.2d : get_nwa(%d), ret= %d , d->nwa= %d\n", - tnum+1, nwa, ret, d->nwa); + "TAO pre-track %2.2d : get_nwa(%d)=%d, d=%d , demand=%.f , cap=%.f\n", + tnum+1, nwa, ret, d->nwa, (double) burn_track_get_sectors(t) * 2048.0, + (double) d->media_capacity_remaining); libdax_msgs_submit(libdax_messenger, d->global_index, 0x000002, LIBDAX_MSGS_SEV_DEBUG, LIBDAX_MSGS_PRIO_ZERO, msg,0,0); if (nwa > d->nwa) d->nwa = nwa; + } /* user data */ @@ -838,6 +846,8 @@ int burn_disc_init_write_status(struct burn_write_opts *o, struct burn_disc *disc) { struct burn_drive *d = o->drive; + struct burn_track *t = NULL; + int sx, tx; d->cancel = 0; @@ -862,6 +872,15 @@ int burn_disc_init_write_status(struct burn_write_opts *o, d->progress.buffered_bytes = 0; d->progress.buffer_min_fill = 0xffffffff; + /* Set eventual media fill up for last track only */ + for (sx = 0; sx < disc->sessions; sx++) + for (tx = 0 ; tx < disc->session[sx]->tracks; tx++) { + t = disc->session[sx]->track[tx]; + burn_track_set_fillup(t, 0); + } + if (o->fill_up_media && t != NULL) + burn_track_set_fillup(t, 1); + d->busy = BURN_DRIVE_WRITING; return 1; @@ -886,6 +905,8 @@ int burn_disc_open_track_dvd_minus_r(struct burn_write_opts *o, LIBDAX_MSGS_SEV_DEBUG, LIBDAX_MSGS_PRIO_ZERO, msg,0,0); if (nwa > d->nwa) d->nwa = nwa; + /* ts A70214 : eventually adjust already expanded size of track */ + burn_track_apply_fillup(s->track[tnum], d->media_capacity_remaining,1); if (o->write_type == BURN_WRITE_SAO) { /* DAO */ /* Round track size up to 32 KiB and reserve track */ @@ -942,9 +963,26 @@ int burn_dvd_write_track(struct burn_write_opts *o, int sectors; int i, open_ended = 0, ret= 0, is_flushed = 0; + /* ts A70213 : eventually expand size of track to max */ + burn_track_apply_fillup(t, d->media_capacity_remaining, 0); + sectors = burn_track_get_sectors(t); open_ended = burn_track_is_open_ended(t); + /* <<< */ + { + char msg[160]; + + sprintf(msg, + "DVD pre-track %2.2d : demand=%.f%s, cap=%.f\n", + tnum+1, (double) sectors * 2048.0, + (open_ended ? " (open ended)" : ""), + (double) d->media_capacity_remaining); + libdax_msgs_submit(libdax_messenger, d->global_index, 0x000002, + LIBDAX_MSGS_SEV_DEBUG, LIBDAX_MSGS_PRIO_ZERO, + msg,0,0); + } + if (d->current_profile == 0x11 || d->current_profile == 0x14) { /* DVD-R, DVD-RW Sequential */ ret = burn_disc_open_track_dvd_minus_r(o, s, tnum); @@ -1464,11 +1502,16 @@ return crap. so we send the command, then ignore the result. d->send_write_parameters(d, o); ret = d->get_nwa(d, -1, &lba, &nwa); - sprintf(msg, "Inquired nwa: %d (ret=%d)", nwa, ret); + sprintf(msg, + "SAO|RAW: Inquired nwa: %d , ret= %d , cap=%.f\n", + nwa, ret, (double) d->media_capacity_remaining); libdax_msgs_submit(libdax_messenger, d->global_index, 0x00000002, LIBDAX_MSGS_SEV_DEBUG, LIBDAX_MSGS_PRIO_ZERO, msg,0,0); + + /* >>> ts A70212 : CD-DAO/SAO : eventually expand size of last track to maximum */; + } for (i = 0; i < disc->sessions; i++) {