From 66eba145d38a0448986fa494ebe09e962c8431d8 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Wed, 11 Jan 2012 12:25:06 +0000 Subject: [PATCH] Obtaining more accurate track sizes for CD with pre-gap --- cdrskin/cdrskin_timestamp.h | 2 +- libburn/mmc.c | 2 +- libburn/mmc.h | 6 ++++++ libburn/structure.c | 32 ++++++++++++++++++++++++++++++-- libburn/structure.h | 2 +- 5 files changed, 39 insertions(+), 5 deletions(-) diff --git a/cdrskin/cdrskin_timestamp.h b/cdrskin/cdrskin_timestamp.h index 9760d87..d5c2c8e 100644 --- a/cdrskin/cdrskin_timestamp.h +++ b/cdrskin/cdrskin_timestamp.h @@ -1 +1 @@ -#define Cdrskin_timestamP "2012.01.11.122158" +#define Cdrskin_timestamP "2012.01.11.122442" diff --git a/libburn/mmc.c b/libburn/mmc.c index e8ab8ac..2cd7bb5 100644 --- a/libburn/mmc.c +++ b/libburn/mmc.c @@ -1587,7 +1587,7 @@ static int mmc_read_toc_al(struct burn_drive *d, int *alloc_len) } /* A80808 */ - burn_disc_cd_toc_extensions(d->disc, 0); + burn_disc_cd_toc_extensions(d, 0); ret = 1; ex:; diff --git a/libburn/mmc.h b/libburn/mmc.h index b01cd3e..b0f2240 100644 --- a/libburn/mmc.h +++ b/libburn/mmc.h @@ -79,6 +79,12 @@ int mmc_compose_mode_page_5(struct burn_drive *d, /* ts A70201 */ int mmc_four_char_to_int(unsigned char *data); +/* ts A70201 : + Common track info fetcher for mmc_get_nwa() and mmc_fake_toc() +*/ +int mmc_read_track_info(struct burn_drive *d, int trackno, struct buffer *buf, + int alloc_len); + /* ts A70812 : return 0 = ok , return BE_CANCELLED = error occured */ int mmc_read_10(struct burn_drive *d, int start, int amount, struct buffer *buf); diff --git a/libburn/structure.c b/libburn/structure.c index cf7052f..e5db5d3 100644 --- a/libburn/structure.c +++ b/libburn/structure.c @@ -27,6 +27,8 @@ #include "debug.h" #include "init.h" #include "util.h" +#include "transport.h" +#include "mmc.h" #include "libdax_msgs.h" extern struct libdax_msgs *libdax_messenger; @@ -690,14 +692,18 @@ int burn_session_get_hidefirst(struct burn_session *session) /* ts A80808 : Enhance CD toc to DVD toc */ -int burn_disc_cd_toc_extensions(struct burn_disc *d, int flag) +int burn_disc_cd_toc_extensions(struct burn_drive *drive, int flag) { - int sidx= 0, tidx= 0, ret; + int sidx= 0, tidx= 0, ret, track_offset, alloc_len = 34; struct burn_toc_entry *entry, *prev_entry= NULL; + struct burn_disc *d; /* ts A81126 : ticket 146 : There was a SIGSEGV in here */ char *msg_data = NULL, *msg; + struct buffer *buf = NULL; + d = drive->disc; BURN_ALLOC_MEM(msg_data, char, 321); + BURN_ALLOC_MEM(buf, struct buffer, 1); strcpy(msg_data, "Damaged CD table-of-content detected and truncated."); strcat(msg_data, " In burn_disc_cd_toc_extensions: "); @@ -706,6 +712,14 @@ int burn_disc_cd_toc_extensions(struct burn_disc *d, int flag) strcpy(msg, "d->session == NULL"); goto failure; } + if (d->sessions <= 0) { + ret = 1; + goto ex; + } + track_offset = burn_session_get_start_tno(d->session[0], 0); + if (track_offset <= 0) + track_offset = 1; + for (sidx = 0; sidx < d->sessions; sidx++) { if (d->session[sidx] == NULL) { sprintf(msg, "d->session[%d of %d] == NULL", @@ -749,6 +763,19 @@ int burn_disc_cd_toc_extensions(struct burn_disc *d, int flag) prev_entry->track_blocks = entry->start_lba - prev_entry->start_lba; + + /* The drive might know size restrictions + like pre-gaps + */ + ret = mmc_read_track_info(drive, + tidx - 1 + track_offset, buf, + alloc_len); + if (ret > 0) { + ret = mmc_four_char_to_int( + buf->data + 24); + if (ret < prev_entry->track_blocks) + prev_entry->track_blocks = ret; + } prev_entry->extensions_valid |= 1; } if (tidx == d->session[sidx]->tracks) { @@ -767,6 +794,7 @@ failure: d->sessions= sidx; ret = 0; ex:; + BURN_FREE_MEM(buf); BURN_FREE_MEM(msg_data); return ret; } diff --git a/libburn/structure.h b/libburn/structure.h index 3da99b0..13d7591 100644 --- a/libburn/structure.h +++ b/libburn/structure.h @@ -164,7 +164,7 @@ off_t burn_track_get_default_size(struct burn_track *t); /* ts A80808 : Enhance CD toc to DVD toc */ -int burn_disc_cd_toc_extensions(struct burn_disc *d, int flag); +int burn_disc_cd_toc_extensions(struct burn_drive *drive, int flag); /* ts B11206 */