[Libburn] Forgoten attachement

Tiago Cogumbreiro cogumbreiro@linus.uac.pt
Mon, 08 Dec 2003 19:04:05 -0100


--=-Lhw2F0yKYu7fu0t8haPn
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Bah, i forgot about the attachment...
Here it goes.

--=-Lhw2F0yKYu7fu0t8haPn
Content-Disposition: attachment; filename=writing_progress.diff
Content-Type: text/x-patch; name=writing_progress.diff; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

? libburn/.drive.c.swp
? libburn/.libburn.h.swp
? libburn/.sector.c.swp
? libburn/.structure.c.swp
? libburn/.structure.h.swp
? libburn/.write.c.swp
? test/.burniso.c.swp
Index: libburn/drive.c
===================================================================
RCS file: /cvs/burn/burn/libburn/drive.c,v
retrieving revision 1.232
diff -p -u -r1.232 drive.c
--- libburn/drive.c	7 Dec 2003 03:40:04 -0000	1.232
+++ libburn/drive.c	8 Dec 2003 13:19:04 -0000
@@ -162,7 +162,7 @@ void libburn_erase_disc_sync(struct driv
 	d->progress.index = 0;
 	d->progress.indices = 1;
 	d->progress.start_sector = 0;
-	d->progress.end_sector = 0x10000;
+	d->progress.sectors = 0x10000;
 	d->progress.current_sector = 0;
 	/* read the initial 0 stage */
 	while(d->get_erase_progress(d) == 0)
Index: libburn/libburn.h
===================================================================
RCS file: /cvs/burn/burn/libburn/libburn.h,v
retrieving revision 1.157
diff -p -u -r1.157 libburn.h
--- libburn/libburn.h	7 Dec 2003 03:45:21 -0000	1.157
+++ libburn/libburn.h	8 Dec 2003 13:19:07 -0000
@@ -437,8 +437,8 @@ struct libburn_progress {
 	int index;
 	/** The starting logical block address */
 	int start_sector;
-	/** The finishing logical block address */
-	int end_sector;
+	/** The number of sector */
+	int sectors;
 	/** The current sector being processed */
 	int current_sector;
 };
Index: libburn/write.c
===================================================================
RCS file: /cvs/burn/burn/libburn/write.c,v
retrieving revision 1.26
diff -p -u -r1.26 write.c
--- libburn/write.c	7 Dec 2003 03:40:04 -0000	1.26
+++ libburn/write.c	8 Dec 2003 13:19:07 -0000
@@ -228,6 +228,7 @@ void libburn_write_session(struct drive 
 		if (i + 1 < s->tracks)
 			next = s->track[i+1];
 		else next = NULL;
+				
 		libburn_write_track(d, o, s->track[i],
                                     prev, next);
 	}
@@ -241,7 +242,6 @@ void libburn_write_track(struct drive *d
 	int i, tmp = 0;
 	int sectors;
 	d->rlba = 0;
-
 	printf("        pre-gap\n");
 
 /* pregap interval 1 */
@@ -263,16 +263,29 @@ void libburn_write_track(struct drive *d
                                        t->mode);
 /* user data */
 	sectors = libburn_track_get_sectors(t);
+	
+	/* Update progress */
+	d->progress.start_sector = d->nwa;
+	d->progress.sectors = sectors;
+	d->progress.current_sector = 0;
+	
 printf("track is %d sectors long\n", sectors);
 
 	if (!nt)
 		tmp = sectors > 150 ? 150 : sectors;
 printf("cutting short by %d sectors\n", tmp);
-	for (i = 0; i < sectors - tmp; i++)
+	for (i = 0; i < sectors - tmp; i++) {
 		sector_data(d, t, 0);
+		
+		/* update current progress */
+		d->progress.current_sector++;
+	}
 	for (; i < sectors; i++) {
 		printf("last track, leadout prep\n");
 		sector_data(d, t, 1);
+
+		/* update progress */
+		d->progress.current_sector++;
 	}
 /* post gap */
 	if (nt && !(t->mode & LIBBURN_AUDIO) &&
@@ -299,8 +312,7 @@ void libburn_write_disc_sync(struct driv
 	printf("sync write of %d sessions\n", disc->sessions);
 	d->buffer = &buf;
 	memset(d->buffer, 0, sizeof(struct buffer));
-
-	d->busy = LIBBURN_BUSY_WRITING;
+	
 	d->rlba = -150;
 
 	d->alba = d->start_lba;
@@ -310,10 +322,30 @@ void libburn_write_disc_sync(struct driv
 
 	d->write_type = o->write_type;
 	d->block_type = o->block_type;
+	
+	/* init progress before showing the state */
+	d->progress.session = 0;
+	d->progress.sessions = disc->sessions;
+	d->progress.track = 0;
+	d->progress.tracks = disc->session[0]->tracks;
+	/* TODO: handle indices */
+	d->progress.index = 0;
+	d->progress.indices = disc->session[0]->track[0]->indices;
+	/* TODO: handle multissession discs */
+	/* XXX: sectors are only set during write track */
+	d->progress.start_sector = 0;
+	d->progress.sectors = 0;
+	d->progress.current_sector = 0;
+
 /*libburn_create_cue_sheet(d, disc->session[0]);*/
+	d->busy = LIBBURN_BUSY_WRITING;
 
 	d->send_write_parameters(d, o);
 	for (i = 0; i < disc->sessions; i++) {
+		/* update progress */
+		d->progress.session = i;
+		d->progress.tracks = disc->session[i]->tracks;
+		
 		libburn_write_leadin(d, disc->session[i], o, first);
 		libburn_write_session(d, o, disc->session[i]);
 		lt = disc->session[i]->track[disc->session[i]->tracks-1];
@@ -321,6 +353,11 @@ void libburn_write_disc_sync(struct driv
                                       lt->mode);
 		if (first)
 			first = 0;
+		
+		/* XXX: currently signs an end of session */
+		d->progress.current_sector = 0;
+		d->progress.start_sector = 0;
+		d->progress.sectors = 0;
 	}
 	libburn_write_flush(d);
 	sleep(1);
Index: test/burniso.c
===================================================================
RCS file: /cvs/burn/burn/test/burniso.c,v
retrieving revision 1.37
diff -p -u -r1.37 burniso.c
--- test/burniso.c	4 Dec 2003 23:47:53 -0000	1.37
+++ test/burniso.c	8 Dec 2003 13:19:08 -0000
@@ -22,6 +22,7 @@ void burn_iso(struct drive *drive, const
 	struct libburn_write_opts *o;
 	enum libburn_drive_status s;
 	struct track *tr;
+	struct libburn_progress p;
 
 	disc = libburn_disc_create();
 	session = libburn_session_create();
@@ -64,8 +65,11 @@ void burn_iso(struct drive *drive, const
 	libburn_write_disc(drive, disc, o);
 	libburn_write_opts_free(o);
 
-	while (libburn_drive_get_progress(drive, NULL)) {
-		sleep(1);
+	while (libburn_drive_get_progress(drive, &p)) {
+		printf("S: %d/%d ", p.session, p.sessions);
+		printf("T: %d/%d ", p.track, p.tracks);
+		printf("L: %d: %d/%d\n", p.start_sector, p.current_sector, p.sectors);
+		usleep(500);
 	}
 	printf("\n");
 	libburn_drive_release(drive, 0);

--=-Lhw2F0yKYu7fu0t8haPn--