From ef7999342b9b5c4bf6b4b3512375ac97be2c6119 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Thu, 12 Jan 2012 08:44:34 +0000 Subject: [PATCH] New API call burn_track_set_postgap_size() --- cdrskin/cdrskin_timestamp.h | 2 +- libburn/libburn.h | 31 +++++++++++++--- libburn/libburn.ver | 1 + libburn/libdax_msgs.h | 1 + libburn/structure.c | 14 ++++++-- libburn/structure.h | 5 +++ libburn/write.c | 72 ++++++++++++++++++++++++++----------- 7 files changed, 97 insertions(+), 29 deletions(-) diff --git a/cdrskin/cdrskin_timestamp.h b/cdrskin/cdrskin_timestamp.h index 9cde37f..6dcab80 100644 --- a/cdrskin/cdrskin_timestamp.h +++ b/cdrskin/cdrskin_timestamp.h @@ -1 +1 @@ -#define Cdrskin_timestamP "2012.01.11.132946" +#define Cdrskin_timestamP "2012.01.12.084429" diff --git a/libburn/libburn.h b/libburn/libburn.h index b855e36..1a7b7e7 100644 --- a/libburn/libburn.h +++ b/libburn/libburn.h @@ -2428,22 +2428,43 @@ int burn_track_clear_indice(struct burn_track *t, int flag); /* ts B20110 */ /** Define whether a pre-gap shall be written before the track and how many - sectors this pregap shall have. A pre-gap is written in the range of track + sectors this pre-gap shall have. A pre-gap is written in the range of track index 0 and contains zeros resp. silence. No bytes from the track source will be read for writing the pre-gap. This setting affects only CD SAO write runs. - Track 1 always has a pre-gap of at least 150 sectors. Further pre-gaps - are not mandatory for MMC compliance as long as track modes are not mixed. - Mode mixing is currently not supported by libburn. + The first track automatically gets a pre-gap of at least 150 sectors. Its + size may be enlarged by this call. Further pre-gaps are demanded by MMC + for tracks which follow tracks of a different mode. (But Mode mixing in + CD SAO sessions is currently not supported by libburn.) @param t The track to change @param size Number of sectors in the pre-gap. - 0 disables pre-gap, except for the first track. + -1 disables pre-gap, except for the first track. + libburn allows 0, but MMC does not propose this. @param flag Bitfield for control purposes. Unused yet. Submit 0. @return > 0 indicates success, <= 0 means failure @since 1.2.0 */ int burn_track_set_pregap_size(struct burn_track *t, int size, int flag); +/* ts B20111 */ +/** Define whether a post-gap shall be written at the end of the track and + how many sectors this gap shall have. A post-gap occupies the range of + an additional index of the track. It contains zeros. No bytes from the + track source will be read for writing the post-gap. + This setting affects only CD SAO write runs. + MMC prescribes to add a post-gap to a data track which is followed by + a non-data track. (But libburn does not yet support mixed mode CD SAO + sessions.) + @param t The track to change + @param size Number of sectors in the post-gap. + -1 disables post-gap. + libburn allows 0, but MMC does not propose this. + @param flag Bitfield for control purposes. Unused yet. Submit 0. + @return > 0 indicates success, <= 0 means failure + @since 1.2.0 +*/ +int burn_track_set_postgap_size(struct burn_track *t, int size, int flag); + /* ts A61024 */ /** Define whether a track shall swap bytes of its input stream. diff --git a/libburn/libburn.ver b/libburn/libburn.ver index 9ea9601..6ce8d23 100644 --- a/libburn/libburn.ver +++ b/libburn/libburn.ver @@ -159,6 +159,7 @@ burn_track_set_default_size; burn_track_set_index; burn_track_set_isrc; burn_track_set_isrc_string; +burn_track_set_postgap_size; burn_track_set_pregap_size; burn_track_set_size; burn_track_set_source; diff --git a/libburn/libdax_msgs.h b/libburn/libdax_msgs.h index 2762dbd..5afa9bd 100644 --- a/libburn/libdax_msgs.h +++ b/libburn/libdax_msgs.h @@ -594,6 +594,7 @@ Range "scdbackup" : 0x00020000 to 0x0002ffff 0x00020199 (SORRY,HIGH) = Text input file reading aborted 0x0002019a (SORRY,HIGH) = Bad track index number 0x0002019b (SORRY,HIGH) = CD track number exceeds range of 1 to 99 + 0x0002019c (FAILURE,HIGH) = Session has no defined tracks libdax_audioxtr: diff --git a/libburn/structure.c b/libburn/structure.c index e5db5d3..9c13560 100644 --- a/libburn/structure.c +++ b/libburn/structure.c @@ -202,11 +202,13 @@ struct burn_track *burn_track_create(void) /* ts B10103 */ t->end_on_premature_eoi = 0; - t->postgap = 0; t->pregap1 = 0; t->pregap2 = 0; t->pregap2_size = 150; + t->postgap = 0; + t->postgap_size = 150; + /* ts A61024 */ t->swap_source_bytes = 0; @@ -481,11 +483,19 @@ int burn_track_clear_indice(struct burn_track *t, int flag) /* ts B20110 API */ int burn_track_set_pregap_size(struct burn_track *t, int size, int flag) { - t->pregap2 = (size > 0); + t->pregap2 = (size >= 0); t->pregap2_size = size; return 1; } +/* ts B20111 API */ +int burn_track_set_postgap_size(struct burn_track *t, int size, int flag) +{ + t->postgap = (size >= 0); + t->postgap_size = size; + return 1; +} + int burn_track_get_sectors(struct burn_track *t) { /* ts A70125 : was int */ diff --git a/libburn/structure.h b/libburn/structure.h index 13d7591..f4b4330 100644 --- a/libburn/structure.h +++ b/libburn/structure.h @@ -97,6 +97,11 @@ struct burn_track /** The track contains a postgap */ int postgap; + + /* ts B20111 */ + /** The number of sectors in post-gap, if .postgap is set */ + int postgap_size; + struct isrc isrc; /* ts A61024 */ diff --git a/libburn/write.c b/libburn/write.c index 1a23bf4..902726b 100644 --- a/libburn/write.c +++ b/libburn/write.c @@ -456,7 +456,7 @@ struct cue_sheet *burn_create_toc_entries(struct burn_write_opts *o, int nwa) { int i, m, s, f, form, pform, runtime = -150, ret, track_length; - int leadin_form, leadin_start, pregap = 150; + int leadin_form, leadin_start, pregap = 150, postgap; unsigned char ctladr, scms; struct burn_drive *d; struct burn_toc_entry *e; @@ -471,7 +471,12 @@ struct cue_sheet *burn_create_toc_entries(struct burn_write_opts *o, int j; #endif - + if (ntr < 1) { + libdax_msgs_submit(libdax_messenger, -1, 0x0002019c, + LIBDAX_MSGS_SEV_SORRY, LIBDAX_MSGS_PRIO_HIGH, + "Session has no defined tracks", 0, 0); + return NULL; + } d = o->drive; @@ -597,6 +602,20 @@ struct cue_sheet *burn_create_toc_entries(struct burn_write_opts *o, pform = form; for (i = 0; i < ntr; i++) { + + /* ts A70125 : + Still not understanding the sense behind linking tracks, + i decided to at least enforce the MMC specs' minimum + track length. + */ + track_length = burn_track_get_sectors(tar[i]); + if (track_length < 300 && !burn_track_is_open_ended(tar[i])) { + track_length = 300; + if (!tar[i]->pad) + tar[i]->pad = 1; + burn_track_set_sectors(tar[i], track_length); + } + type_to_form(tar[i]->mode, &ctladr, &form); if (tar[i]->mode & BURN_SCMS) scms = 0x80; @@ -609,16 +628,33 @@ struct cue_sheet *burn_create_toc_entries(struct burn_write_opts *o, if (ret <= 0) goto failed; } + pregap = 0; if (tar[i]->pregap2) pregap = tar[i]->pregap2_size; + postgap = 0; + if (tar[i]->postgap) { + if (tar[i]->indices >= 99) { + libdax_msgs_submit(libdax_messenger, -1, + 0x0002019a, LIBDAX_MSGS_SEV_SORRY, + LIBDAX_MSGS_PRIO_HIGH, + "Post-gap index number exceeds 99", + 0, 0); + goto failed; + } + if (tar[i]->indices < 2) + tar[i]->indices = 2; + tar[i]->index[tar[i]->indices] = track_length; + postgap = tar[i]->postgap_size; + } #ifdef Libburn_track_multi_indeX - for(j = 0; j < tar[i]->indices || j < 2; j++) { + for(j = 0; j < (tar[i]->indices + !!tar[i]->postgap) || j < 2; + j++) { if(tar[i]->index[j] == 0x7fffffff) { if (j > 1) break; - if (pregap <= 0) + if (j == 0 && pregap <= 0) continue; /* force existence of mandatory index */ tar[i]->index[j] = 0; @@ -654,6 +690,8 @@ struct cue_sheet *burn_create_toc_entries(struct burn_write_opts *o, pregap = 0; } + runtime += track_length + postgap; + #else /* Libburn_track_multi_indeX */ if (i == 0) { @@ -691,6 +729,10 @@ struct cue_sheet *burn_create_toc_entries(struct burn_write_opts *o, Next one has to care for Post-gap: table 555 in mmc5r03c.pdf does not show any although 6.33.3.19 would prescribe some. + ts B20111: Table 1 of MMC-1 shows two post-gaps. The first matches the + precriptions with SEND CUE SHEET. The second one is riddling. + Both are part of a track and occupy the range of the last index + of the track. Length is 2 seconds for each. Nobody seems to have ever tested this situation, up to now. It is banned for now in burn_disc_write(). @@ -715,23 +757,11 @@ struct cue_sheet *burn_create_toc_entries(struct burn_write_opts *o, if (ret <= 0) goto failed; + runtime += track_length; + #endif /* ! Libburn_track_multi_indeX */ - /* ts A70125 : - Still not understanding the sense behind linking tracks, - i decided to at least enforce the MMC specs' minimum - track length. - */ - track_length = burn_track_get_sectors(tar[i]); - if (track_length < 300 && !burn_track_is_open_ended(tar[i])) { - track_length = 300; - if (!tar[i]->pad) - tar[i]->pad = 1; - burn_track_set_sectors(tar[i], track_length); - } - runtime += track_length; - /* if we're padding, we'll clear any current shortage. if we're not, we'll slip toc entries by a sector every time our shortage is more than a sector @@ -1174,9 +1204,9 @@ int burn_write_track(struct burn_write_opts *o, struct burn_session *s, } if (t->postgap) - for (i = 0; i < 150; i++) - if (!sector_postgap(o, t->entry->point, t->entry->control, - t->mode)) + for (i = 0; i < t->postgap_size; i++) + if (!sector_postgap(o, t->entry->point, + t->entry->control, t->mode)) { ret = 0; goto ex; } i = t->offset; if (o->write_type == BURN_WRITE_SAO) {