New API call isoburn_toc_disc_get_incmpl_sess()

This commit is contained in:
Thomas Schmitt 2013-01-13 20:08:31 +00:00
parent 1354d4e5f1
commit 32fca75ccc
5 changed files with 57 additions and 11 deletions

View File

@ -1586,6 +1586,7 @@ int isoburn_toc_destroy_arrays(struct isoburn_toc_disc *o, int flag)
struct isoburn_toc_disc *isoburn_toc_drive_get_disc(struct burn_drive *d) struct isoburn_toc_disc *isoburn_toc_drive_get_disc(struct burn_drive *d)
{ {
int ret, session_count= 0, track_count= 0, num_tracks= 0, i, j; int ret, session_count= 0, track_count= 0, num_tracks= 0, i, j;
int open_sessions= 0;
struct isoburn *o; struct isoburn *o;
struct isoburn_toc_entry *t; struct isoburn_toc_entry *t;
struct isoburn_toc_disc *toc_disc= NULL; struct isoburn_toc_disc *toc_disc= NULL;
@ -1601,6 +1602,7 @@ struct isoburn_toc_disc *isoburn_toc_drive_get_disc(struct burn_drive *d)
toc_disc->tracks= NULL; toc_disc->tracks= NULL;
toc_disc->track_pointers= NULL; toc_disc->track_pointers= NULL;
toc_disc->session_count= 0; toc_disc->session_count= 0;
toc_disc->incomplete_session_count= 0;
toc_disc->track_count= 0; toc_disc->track_count= 0;
toc_disc->toc= NULL; toc_disc->toc= NULL;
@ -1641,18 +1643,26 @@ failure:;
return(NULL); return(NULL);
} }
s= burn_disc_get_sessions(toc_disc->disc, &session_count); s= burn_disc_get_sessions(toc_disc->disc, &session_count);
for(i= 0; i<session_count; i++) { open_sessions= burn_disc_get_incomplete_sessions(toc_disc->disc);
for(i= 0; i < session_count + open_sessions; i++) {
tracks = burn_session_get_tracks(s[i], &num_tracks); tracks = burn_session_get_tracks(s[i], &num_tracks);
if(i == session_count + open_sessions - 1 && open_sessions > 0) {
/* Do not count the invisible track of the last incomplete session */
num_tracks--;
}
track_count+= num_tracks; track_count+= num_tracks;
} }
if(session_count<=0 || track_count<=0) if(session_count + open_sessions <= 0 || track_count <= 0)
goto failure; goto failure;
ret= isoburn_toc_new_arrays(toc_disc, session_count, track_count, 0); ret= isoburn_toc_new_arrays(toc_disc, session_count + open_sessions,
track_count, 0);
if(ret<=0) if(ret<=0)
goto failure; goto failure;
track_count= 0; track_count= 0;
for(i= 0; i<session_count; i++) { for(i= 0; i < session_count + open_sessions; i++) {
tracks = burn_session_get_tracks(s[i], &num_tracks); tracks = burn_session_get_tracks(s[i], &num_tracks);
if(i == session_count + open_sessions - 1 && open_sessions > 0)
num_tracks--;
toc_disc->sessions[i].session= s[i]; toc_disc->sessions[i].session= s[i];
toc_disc->sessions[i].track_pointers= toc_disc->track_pointers+track_count; toc_disc->sessions[i].track_pointers= toc_disc->track_pointers+track_count;
toc_disc->sessions[i].track_count= num_tracks; toc_disc->sessions[i].track_count= num_tracks;
@ -1664,6 +1674,7 @@ failure:;
track_count+= num_tracks; track_count+= num_tracks;
} }
toc_disc->session_count= session_count; toc_disc->session_count= session_count;
toc_disc->incomplete_session_count= open_sessions;
toc_disc->track_count= track_count; toc_disc->track_count= track_count;
return(toc_disc); return(toc_disc);
} }
@ -1672,7 +1683,7 @@ failure:;
int isoburn_toc_disc_get_sectors(struct isoburn_toc_disc *disc) int isoburn_toc_disc_get_sectors(struct isoburn_toc_disc *disc)
{ {
struct isoburn_toc_entry *t; struct isoburn_toc_entry *t;
int ret= 0, num_sessions, num_tracks; int ret= 0, num_sessions, num_tracks, open_sessions= 0, session_idx= -1;
struct burn_session **sessions; struct burn_session **sessions;
struct burn_track **tracks; struct burn_track **tracks;
struct burn_toc_entry entry; struct burn_toc_entry entry;
@ -1684,9 +1695,23 @@ int isoburn_toc_disc_get_sectors(struct isoburn_toc_disc *disc)
ret= t->start_lba + t->track_blocks; ret= t->start_lba + t->track_blocks;
} else if(disc->disc!=NULL) { } else if(disc->disc!=NULL) {
sessions= burn_disc_get_sessions(disc->disc, &num_sessions); sessions= burn_disc_get_sessions(disc->disc, &num_sessions);
if(num_sessions > 0) { open_sessions= burn_disc_get_incomplete_sessions(disc->disc);
tracks = burn_session_get_tracks(sessions[num_sessions - 1], if(num_sessions + open_sessions > 0) {
&num_tracks); session_idx= num_sessions + open_sessions - 1;
tracks = burn_session_get_tracks(sessions[session_idx], &num_tracks);
if(open_sessions > 0) {
/* Do not count the invisible track of the last incomplete session */
num_tracks--;
}
if(num_tracks <= 0)
session_idx--;
}
if(session_idx >= 0) {
tracks = burn_session_get_tracks(sessions[session_idx], &num_tracks);
if(session_idx == num_sessions + open_sessions - 1 && open_sessions > 0) {
/* Do not count the invisible track of the last incomplete session */
num_tracks--;
}
if(num_tracks > 0) { if(num_tracks > 0) {
burn_track_get_entry(tracks[num_tracks - 1], &entry); burn_track_get_entry(tracks[num_tracks - 1], &entry);
if(entry.extensions_valid & 1) if(entry.extensions_valid & 1)
@ -1709,6 +1734,12 @@ struct isoburn_toc_session **isoburn_toc_disc_get_sessions(
} }
int isoburn_toc_disc_get_incmpl_sess(struct isoburn_toc_disc *disc)
{
return(disc->incomplete_session_count);
}
int isoburn_toc_session_get_sectors(struct isoburn_toc_session *s) int isoburn_toc_session_get_sectors(struct isoburn_toc_session *s)
{ {
struct isoburn_toc_entry *t; struct isoburn_toc_entry *t;

View File

@ -28,7 +28,6 @@ struct isoburn_toc_entry {
int track_no; /* point */ int track_no; /* point */
int start_lba; int start_lba;
int track_blocks; int track_blocks;
char *volid; /* For caching a volume id from emulated toc on overwriteables */ char *volid; /* For caching a volume id from emulated toc on overwriteables */
struct isoburn_toc_entry *next; struct isoburn_toc_entry *next;
@ -768,6 +767,7 @@ struct isoburn_toc_disc {
struct isoburn_toc_track *tracks; /* storage array */ struct isoburn_toc_track *tracks; /* storage array */
struct isoburn_toc_track **track_pointers; /* storage array */ struct isoburn_toc_track **track_pointers; /* storage array */
int session_count; int session_count;
int incomplete_session_count;
int track_count; int track_count;
struct isoburn_toc_entry *toc; struct isoburn_toc_entry *toc;
}; };

View File

@ -596,7 +596,11 @@ struct isoburn_toc_disc *isoburn_toc_drive_get_disc(struct burn_drive *d);
int isoburn_toc_disc_get_sectors(struct isoburn_toc_disc *disc); int isoburn_toc_disc_get_sectors(struct isoburn_toc_disc *disc);
/** Get the array of session handles from the table of content. /** Get the array of session handles and the number of complete sessions
from the table of content.
The result array contains *num + isoburn_toc_disc_get_incmpl_sess()
elements. All above *num are incomplete sessions.
Typically there is at most one incomplete session with no track.
Wrapper for: burn_disc_get_sessions() Wrapper for: burn_disc_get_sessions()
@since 0.1.6 @since 0.1.6
@param disc The master handle of the medium @param disc The master handle of the medium
@ -607,6 +611,16 @@ struct isoburn_toc_session **isoburn_toc_disc_get_sessions(
struct isoburn_toc_disc *disc, int *num); struct isoburn_toc_disc *disc, int *num);
/** Obtain the number of incomplete sessions which are recorded in the
result array of isoburn_toc_disc_get_sessions() after the complete
sessions. See above.
@since 1.2.8
@param disc The master handle of the medium
@return the number of incomplete sessions
*/
int isoburn_toc_disc_get_incmpl_sess(struct isoburn_toc_disc *disc);
/** Tell the number of 2048 byte blocks covered by a particular session. /** Tell the number of 2048 byte blocks covered by a particular session.
Wrapper for: burn_session_get_sectors() Wrapper for: burn_session_get_sectors()
@since 0.1.6 @since 0.1.6

View File

@ -105,6 +105,7 @@ isoburn_set_read_pacifier;
isoburn_set_truncate; isoburn_set_truncate;
isoburn_sync_after_write; isoburn_sync_after_write;
isoburn_toc_disc_free; isoburn_toc_disc_free;
isoburn_toc_disc_get_incmpl_sess;
isoburn_toc_disc_get_sectors; isoburn_toc_disc_get_sectors;
isoburn_toc_disc_get_sessions; isoburn_toc_disc_get_sessions;
isoburn_toc_drive_get_disc; isoburn_toc_drive_get_disc;

View File

@ -1 +1 @@
#define Xorriso_timestamP "2013.01.13.102527" #define Xorriso_timestamP "2013.01.13.200742"