[brasero/gnome-2-30] Fix wrong report of speed with both cdrecord and wodim



commit 1e1f029ebb46723ede91f12f0f4884ae3e9de26c
Author: Philippe Rouquier <bonfire-app wanadoo fr>
Date:   Sat Jun 5 15:57:15 2010 +0200

    Fix wrong report of speed with both cdrecord and wodim

 plugins/cdrkit/burn-wodim.c      |   43 +++++++++++++++++++++++++------------
 plugins/cdrtools/burn-cdrecord.c |   42 +++++++++++++++++++++++++-----------
 2 files changed, 58 insertions(+), 27 deletions(-)
---
diff --git a/plugins/cdrkit/burn-wodim.c b/plugins/cdrkit/burn-wodim.c
index 9e14b3a..0140247 100644
--- a/plugins/cdrkit/burn-wodim.c
+++ b/plugins/cdrkit/burn-wodim.c
@@ -271,6 +271,33 @@ brasero_wodim_compute (BraseroWodim *wodim,
 	}
 }
 
+static void
+brasero_wodim_set_rate (BraseroProcess *process,
+                        int speed_1,
+                        int speed_2)
+{
+	gdouble current_rate;
+	BraseroMedia media;
+
+	if (brasero_job_get_media (BRASERO_JOB (process), &media) != BRASERO_BURN_OK)
+		return;
+
+	if (BRASERO_MEDIUM_IS (media, BRASERO_MEDIUM_CD))
+		current_rate = (gdouble) ((gdouble) speed_1 +
+			       (gdouble) speed_2 / 10.0) *
+			       (gdouble) CD_RATE;
+	else if (BRASERO_MEDIUM_IS (media, BRASERO_MEDIUM_DVD))
+		current_rate = (gdouble) ((gdouble) speed_1 +
+			       (gdouble) speed_2 / 10.0) *
+			       (gdouble) DVD_RATE;
+	else if (BRASERO_MEDIUM_IS (media, BRASERO_MEDIUM_BD))
+		current_rate = (gdouble) ((gdouble) speed_1 +
+			       (gdouble) speed_2 / 10.0) *
+			       (gdouble) BD_RATE;
+
+	brasero_job_set_rate (BRASERO_JOB (process), current_rate);
+}
+
 static BraseroBurnResult
 brasero_wodim_stdout_read (BraseroProcess *process, const gchar *line)
 {
@@ -288,13 +315,7 @@ brasero_wodim_stdout_read (BraseroProcess *process, const gchar *line)
 	    /* This is for DVD+R */
 	    sscanf (line, "Track %2u:    %d of %d MB written (fifo  %d%%) [buf  %d%%] |%*s  %*s|   %d.%dx.",
 	            &track, &mb_written, &mb_total, &fifo, &buf, &speed_1, &speed_2) == 7) {
-		gdouble current_rate;
-
-		current_rate = (gdouble) ((gdouble) speed_1 +
-			       (gdouble) speed_2 / 10.0) *
-			       (gdouble) CD_RATE;
-		brasero_job_set_rate (BRASERO_JOB (wodim), current_rate);
-
+		brasero_wodim_set_rate (process, speed_1, speed_2);
 		priv->current_track_written = (goffset) mb_written * (goffset) 1048576LL;
 		brasero_wodim_compute (wodim,
 				       mb_written,
@@ -307,14 +328,8 @@ brasero_wodim_stdout_read (BraseroProcess *process, const gchar *line)
 			 &track, &mb_written, &fifo, &buf, &speed_1, &speed_2) == 6 ||
 	         sscanf (line, "Track %2u:    %d MB written (fifo %d%%) [buf  %d%%] |%*s  %*s|   %d.%dx.",
 			 &track, &mb_written, &fifo, &buf, &speed_1, &speed_2) == 6) {
-		gdouble current_rate;
-
 		/* this line is printed when wodim writes on the fly */
-		current_rate = (gdouble) ((gdouble) speed_1 +
-			       (gdouble) speed_2 / 10.0) *
-			       (gdouble) CD_RATE;
-		brasero_job_set_rate (BRASERO_JOB (wodim), current_rate);
-
+		brasero_wodim_set_rate (process, speed_1, speed_2);
 		priv->current_track_written = (goffset) mb_written * (goffset) 1048576LL;
 		if (brasero_job_get_fd_in (BRASERO_JOB (wodim), NULL) == BRASERO_BURN_OK) {
 			goffset bytes = 0;
diff --git a/plugins/cdrtools/burn-cdrecord.c b/plugins/cdrtools/burn-cdrecord.c
index db75675..a32536f 100644
--- a/plugins/cdrtools/burn-cdrecord.c
+++ b/plugins/cdrtools/burn-cdrecord.c
@@ -260,6 +260,33 @@ brasero_cdrecord_compute (BraseroCDRecord *cdrecord,
 	g_free (action_string);
 }
 
+static void
+brasero_cdrecord_set_rate (BraseroProcess *process,
+                           int speed_1,
+                           int speed_2)
+{
+	gdouble current_rate;
+	BraseroMedia media;
+
+	if (brasero_job_get_media (BRASERO_JOB (process), &media) != BRASERO_BURN_OK)
+		return;
+
+	if (BRASERO_MEDIUM_IS (media, BRASERO_MEDIUM_CD))
+		current_rate = (gdouble) ((gdouble) speed_1 +
+			       (gdouble) speed_2 / 10.0) *
+			       (gdouble) CD_RATE;
+	else if (BRASERO_MEDIUM_IS (media, BRASERO_MEDIUM_DVD))
+		current_rate = (gdouble) ((gdouble) speed_1 +
+			       (gdouble) speed_2 / 10.0) *
+			       (gdouble) DVD_RATE;
+	else if (BRASERO_MEDIUM_IS (media, BRASERO_MEDIUM_BD))
+		current_rate = (gdouble) ((gdouble) speed_1 +
+			       (gdouble) speed_2 / 10.0) *
+			       (gdouble) BD_RATE;
+
+	brasero_job_set_rate (BRASERO_JOB (process), current_rate);
+}
+
 static BraseroBurnResult
 brasero_cdrecord_stdout_read (BraseroProcess *process, const gchar *line)
 {
@@ -277,13 +304,8 @@ brasero_cdrecord_stdout_read (BraseroProcess *process, const gchar *line)
 	    /* This is for DVD+R */
 	    sscanf (line, "Track %2u:    %d of %d MB written (fifo  %d%%) [buf  %d%%] |%*s  %*s|   %d.%dx.",
 	            &track, &mb_written, &mb_total, &fifo, &buf, &speed_1, &speed_2) == 7) {
-		gdouble current_rate;
-
-		current_rate = (gdouble) ((gdouble) speed_1 +
-			       (gdouble) speed_2 / 10.0) *
-			       (gdouble) CD_RATE;
-		brasero_job_set_rate (BRASERO_JOB (cdrecord), current_rate);
 
+		brasero_cdrecord_set_rate (process, speed_1, speed_2);
 		priv->current_track_written = (goffset) mb_written * (goffset) 1048576LL;
 		brasero_cdrecord_compute (cdrecord,
 					  mb_written,
@@ -296,14 +318,8 @@ brasero_cdrecord_stdout_read (BraseroProcess *process, const gchar *line)
 			 &track, &mb_written, &fifo, &buf, &speed_1, &speed_2) == 6 ||
 	         sscanf (line, "Track %2u:    %d MB written (fifo %d%%) [buf  %d%%] |%*s  %*s|   %d.%dx.",
 			 &track, &mb_written, &fifo, &buf, &speed_1, &speed_2) == 6) {
-		gdouble current_rate;
-
-		/* this line is printed when cdrecord writes on the fly */
-		current_rate = (gdouble) ((gdouble) speed_1 +
-			       (gdouble) speed_2 / 10.0) *
-			       (gdouble) CD_RATE;
-		brasero_job_set_rate (BRASERO_JOB (cdrecord), current_rate);
 
+				 brasero_cdrecord_set_rate (process, speed_1, speed_2);
 		priv->current_track_written = (goffset) mb_written * (goffset) 1048576LL;
 		if (brasero_job_get_fd_in (BRASERO_JOB (cdrecord), NULL) == BRASERO_BURN_OK) {
 			goffset bytes = 0;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]