From 3b0abc14c006cc150fdec7b0de807ff4133a0b67 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Sat, 13 Jul 2019 17:30:47 +0200 Subject: [PATCH] Improved -toc summary of sessions with multiple tracks or non-data sessions --- xorriso/drive_mgt.c | 54 ++++++++++++++++++++----------------- xorriso/xorriso_timestamp.h | 2 +- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/xorriso/drive_mgt.c b/xorriso/drive_mgt.c index 48726728..94a426b6 100644 --- a/xorriso/drive_mgt.c +++ b/xorriso/drive_mgt.c @@ -979,7 +979,9 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag) { int num_sessions= 0, num_tracks= 0, lba= 0, nwa= -1, ret; int track_count= 0, session_no, track_no, profile_no= -1, track_size; - int last_track_start= 0, last_track_size= -1, num_data= 0, is_data= 0; + int session_size, first_track_start= 0; + int num_session_data, num_session_other; + int num_data= 0, other_data= 0, is_data= 0; int is_inout_drive= 0, drive_role, status, num_formats, emul_lba; int not_recognizable= 0, start_lba, end_lba; int sessions_seen, open_sessions= 0, have_real_open_session= 0; @@ -1267,19 +1269,16 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag) } if(!(flag&1)) Xorriso_toc_line(xorriso, flag & 8); - last_track_start= lba; -/* - num_payload= num_data= last_track_size= nwa; -*/ num_sessions= 1; } else { - num_data= 0; + num_data= other_data= 0; sessions= isoburn_toc_disc_get_sessions(disc, &num_sessions); open_sessions= isoburn_toc_disc_get_incmpl_sess(disc); for (session_no= 0; session_no < num_sessions + open_sessions && !(xorriso->request_to_abort); session_no++) { + num_session_data= num_session_other= 0; tracks= isoburn_toc_session_get_tracks(sessions[session_no], &num_tracks); if (tracks == NULL || num_tracks <= 0) continue; @@ -1290,6 +1289,8 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag) track_count++; is_data= 0; isoburn_toc_track_get_entry(tracks[track_no], &toc_entry); + if((toc_entry.control & 7) >= 4) /* data track */ + is_data= 1; if (toc_entry.extensions_valid & 1) { /* DVD extension valid */ lba= toc_entry.start_lba; @@ -1306,9 +1307,9 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag) track_size= burn_msf_to_lba(next_toc_entry.pmin, next_toc_entry.psec, next_toc_entry.pframe) - lba; } - if(flag&(1|4)) + if((flag & (1 | 4)) || !is_data) { ret= 0; - else { + } else { ret= isoburn_toc_track_get_emul(tracks[track_no], &emul_lba, &image_blocks, volume_id, 0); if(ret <= 0) @@ -1348,13 +1349,12 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag) } if(!(flag&1)) Xorriso_toc_line(xorriso, flag & 8); -/* - if(track_no>0) - num_payload+= lba - last_track_start; -*/ - last_track_start= lba; - if((toc_entry.control&7)>=4) /* data track */ - is_data= 1; + if(is_data) + num_session_data+= track_size; + else + num_session_other+= track_size; + if(track_no == 0) + first_track_start= lba; } isoburn_toc_session_get_leadout_entry(sessions[session_no], &toc_entry); if (toc_entry.extensions_valid & 1) { @@ -1362,20 +1362,19 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag) } else { lba= burn_msf_to_lba(toc_entry.pmin, toc_entry.psec, toc_entry.pframe); } - last_track_size= lba - last_track_start; -/* - num_payload+= last_track_size; -*/ - if(is_data) - num_data+= last_track_size; + session_size= lba - first_track_start; + if(num_session_data > 0 && num_session_other > 0) { + num_data+= num_session_data; + other_data+= num_session_other; + } else if(is_data) { + num_data+= session_size; + } else { + other_data+= session_size; + } } } if(xorriso->request_to_abort) {ret= 1; goto ex;} -/* - num_wasted= lba - num_payload; - num_nondata= lba - num_data; -*/ Sfile_scale(((double) num_data) * 2048.0, mem_text,5,1e4,1); sessions_seen= num_sessions + open_sessions; @@ -1393,6 +1392,11 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag) sprintf(respt+strlen(respt), "\n"); Xorriso_toc_line(xorriso, flag & 8); + if(other_data > 0) { + sprintf(respt, "Non-data blks: %d\n", other_data); + Xorriso_toc_line(xorriso, flag & 8); + } + if (s==BURN_DISC_APPENDABLE && nwa!=0) { ret= isoburn_disc_track_lba_nwa(drive, NULL, 0, &lba, &nwa); if(ret>0) { diff --git a/xorriso/xorriso_timestamp.h b/xorriso/xorriso_timestamp.h index b6d74c51..4b676d1e 100644 --- a/xorriso/xorriso_timestamp.h +++ b/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2019.07.06.130540" +#define Xorriso_timestamP "2019.07.13.153027"