[brasero] Fix #582261 – brasero shows 0% done, while continues burning disc



commit 7ecbd235841e7176853f209af79baf93f4704bfb
Author: Philippe Rouquier <bonfire-app wanadoo fr>
Date:   Mon Jun 22 22:03:22 2009 +0200

    Fix #582261 â?? brasero shows 0% done, while continues burning disc
    Fixed an overflow in variable that stopped wodim/cdrecord to work properly for a size over 2GiB

 libbrasero-burn/burn-job.c       |   10 ++++----
 libbrasero-burn/burn-job.h       |    8 +++---
 libbrasero-burn/burn-task-ctx.c  |    8 +++---
 plugins/cdrkit/burn-wodim.c      |   49 +++++++++++++++++++++++--------------
 plugins/cdrtools/burn-cdrecord.c |   49 +++++++++++++++++++++++--------------
 5 files changed, 73 insertions(+), 51 deletions(-)
---
diff --git a/libbrasero-burn/burn-job.c b/libbrasero-burn/burn-job.c
index 08c98c4..a38e9da 100644
--- a/libbrasero-burn/burn-job.c
+++ b/libbrasero-burn/burn-job.c
@@ -1891,8 +1891,8 @@ brasero_job_set_rate (BraseroJob *self,
 
 BraseroBurnResult
 brasero_job_set_output_size_for_current_track (BraseroJob *self,
-					       gint64 sectors,
-					       gint64 size)
+					       goffset sectors,
+					       goffset bytes)
 {
 	BraseroJobPrivate *priv;
 
@@ -1912,12 +1912,12 @@ brasero_job_set_output_size_for_current_track (BraseroJob *self,
 
 	return brasero_task_ctx_set_output_size_for_current_track (priv->ctx,
 								   sectors,
-								   size);
+								   bytes);
 }
 
 BraseroBurnResult
 brasero_job_set_written_track (BraseroJob *self,
-			       gint64 written)
+			       goffset written)
 {
 	BraseroJobPrivate *priv;
 
@@ -1933,7 +1933,7 @@ brasero_job_set_written_track (BraseroJob *self,
 
 BraseroBurnResult
 brasero_job_set_written_session (BraseroJob *self,
-				 gint64 written)
+				 goffset written)
 {
 	BraseroJobPrivate *priv;
 
diff --git a/libbrasero-burn/burn-job.h b/libbrasero-burn/burn-job.h
index b0a540e..b3c5bdd 100644
--- a/libbrasero-burn/burn-job.h
+++ b/libbrasero-burn/burn-job.h
@@ -264,10 +264,10 @@ brasero_job_set_rate (BraseroJob *job,
 		      gint64 rate);
 BraseroBurnResult
 brasero_job_set_written_track (BraseroJob *job,
-			       gint64 written);
+			       goffset written);
 BraseroBurnResult
 brasero_job_set_written_session (BraseroJob *job,
-				 gint64 written);
+				 goffset written);
 BraseroBurnResult
 brasero_job_set_progress (BraseroJob *job,
 			  gdouble progress);
@@ -281,8 +281,8 @@ brasero_job_get_current_action (BraseroJob *job,
 				BraseroBurnAction *action);
 BraseroBurnResult
 brasero_job_set_output_size_for_current_track (BraseroJob *job,
-					       gint64 sectors,
-					       gint64 size);
+					       goffset sectors,
+					       goffset bytes);
 
 /**
  * Used to tell it's (or not) dangerous to interrupt this job
diff --git a/libbrasero-burn/burn-task-ctx.c b/libbrasero-burn/burn-task-ctx.c
index 5fa349e..b3ff261 100644
--- a/libbrasero-burn/burn-task-ctx.c
+++ b/libbrasero-burn/burn-task-ctx.c
@@ -534,8 +534,8 @@ brasero_task_ctx_set_rate (BraseroTaskCtx *self,
 
 BraseroBurnResult
 brasero_task_ctx_set_output_size_for_current_track (BraseroTaskCtx *self,
-						    gint64 sectors,
-						    gint64 size)
+						    goffset sectors,
+						    goffset bytes)
 {
 	BraseroTaskCtxPrivate *priv;
 
@@ -553,8 +553,8 @@ brasero_task_ctx_set_output_size_for_current_track (BraseroTaskCtx *self,
 	if (sectors >= 0)
 		priv->blocks += sectors;
 
-	if (size >= 0)
-		priv->size += size;
+	if (bytes >= 0)
+		priv->size += bytes;
 
 	BRASERO_BURN_LOG ("Task output modified %lli blocks %lli bytes",
 			  priv->blocks,
diff --git a/plugins/cdrkit/burn-wodim.c b/plugins/cdrkit/burn-wodim.c
index 3033310..d9d3c29 100644
--- a/plugins/cdrkit/burn-wodim.c
+++ b/plugins/cdrkit/burn-wodim.c
@@ -60,8 +60,8 @@
 BRASERO_PLUGIN_BOILERPLATE (BraseroWodim, brasero_wodim, BRASERO_TYPE_PROCESS, BraseroProcess);
 
 struct _BraseroWodimPrivate {
-	gint64 current_track_end_pos;
-	gint64 current_track_written;
+	goffset current_track_end_pos;
+	goffset current_track_written;
 
 	gint current_track_num;
 	gint track_count;
@@ -207,38 +207,44 @@ brasero_wodim_stderr_read (BraseroProcess *process, const gchar *line)
 
 static void
 brasero_wodim_compute (BraseroWodim *wodim,
-		       gint mb_written,
-		       gint mb_total,
-		       gint track_num)
+		       goffset mb_written,
+		       goffset mb_total,
+		       goffset track_num)
 {
 	gboolean track_num_changed = FALSE;
 	BraseroWodimPrivate *priv;
 	BraseroJobAction action;
-	gint64 this_remain;
-	gint64 bytes;
-	gint64 total;
+	goffset this_remain;
+	goffset bytes;
+	goffset total;
 
 	priv = BRASERO_WODIM_PRIVATE (wodim);
 	if (mb_total <= 0)
 		return;
 
-	total = mb_total * 1048576;
+	total = mb_total * (goffset) 1048576LL;
 
 	if (track_num > priv->current_track_num) {
 		track_num_changed = TRUE;
 		priv->current_track_num = track_num;
-		priv->current_track_end_pos += mb_total * 1048576;
+		priv->current_track_end_pos += mb_total * (goffset) 1048576LL;
 	}
 
-	this_remain = (mb_total - mb_written) * 1048576;
+	this_remain = (mb_total - mb_written) * (goffset) 1048576LL;
 	bytes = (total - priv->current_track_end_pos) + this_remain;
 	brasero_job_set_written_session (BRASERO_JOB (wodim), total - bytes);
 
 	brasero_job_get_action (BRASERO_JOB (wodim), &action);
 	if (action == BRASERO_JOB_ACTION_RECORD) {
 		gchar *action_string;
+		gchar *track_num_str;
+
+		track_num_str = g_strdup_printf ("%02" G_GOFFSET_FORMAT, track_num);
+
+		/* Translators: %s is the number of the track */
+		action_string = g_strdup_printf (_("Writing track %s"), track_num_str);
+		g_free (track_num_str);
 
-		action_string = g_strdup_printf ("Writing track %02i", track_num);
 		brasero_job_set_current_action (BRASERO_JOB (wodim),
 						BRASERO_BURN_ACTION_RECORDING,
 						action_string,
@@ -275,7 +281,7 @@ brasero_wodim_stdout_read (BraseroProcess *process, const gchar *line)
 			       (gdouble) CD_RATE;
 		brasero_job_set_rate (BRASERO_JOB (wodim), current_rate);
 
-		priv->current_track_written = mb_written * 1048576;
+		priv->current_track_written = (goffset) mb_written * (goffset) 1048576LL;
 		brasero_wodim_compute (wodim,
 				       mb_written,
 				       mb_total,
@@ -293,7 +299,7 @@ brasero_wodim_stdout_read (BraseroProcess *process, const gchar *line)
 			       (gdouble) CD_RATE;
 		brasero_job_set_rate (BRASERO_JOB (wodim), current_rate);
 
-		priv->current_track_written = mb_written * 1048576;
+		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;
 
@@ -301,7 +307,7 @@ brasero_wodim_stdout_read (BraseroProcess *process, const gchar *line)
 			brasero_job_get_session_output_size (BRASERO_JOB (wodim),
 							     NULL,
 							     &bytes);
-			mb_total = bytes / 1048576;
+			mb_total = bytes / (goffset) 1048576LL;
 			brasero_wodim_compute (wodim,
 					       mb_written,
 					       mb_total,
@@ -359,10 +365,15 @@ brasero_wodim_stdout_read (BraseroProcess *process, const gchar *line)
 	}
 	else if (g_str_has_prefix (line, "Fixating...")
 	     ||  g_str_has_prefix (line, "Writing Leadout...")) {
-		brasero_job_set_current_action (BRASERO_JOB (process),
-						BRASERO_BURN_ACTION_FIXATING,
-						NULL,
-						FALSE);
+		BraseroJobAction action;
+
+		/* Do this to avoid strange things to appear when erasing */
+		brasero_job_get_action (BRASERO_JOB (wodim), &action);
+		if (action == BRASERO_JOB_ACTION_RECORD)
+			brasero_job_set_current_action (BRASERO_JOB (process),
+							BRASERO_BURN_ACTION_FIXATING,
+							NULL,
+							FALSE);
 	}
 	else if (g_str_has_prefix (line, "Last chance to quit, ")) {
 		brasero_job_set_dangerous (BRASERO_JOB (process), TRUE);
diff --git a/plugins/cdrtools/burn-cdrecord.c b/plugins/cdrtools/burn-cdrecord.c
index ff9133f..837ab49 100644
--- a/plugins/cdrtools/burn-cdrecord.c
+++ b/plugins/cdrtools/burn-cdrecord.c
@@ -60,8 +60,8 @@
 BRASERO_PLUGIN_BOILERPLATE (BraseroCDRecord, brasero_cdrecord, BRASERO_TYPE_PROCESS, BraseroProcess);
 
 struct _BraseroCDRecordPrivate {
-	gint64 current_track_end_pos;
-	gint64 current_track_written;
+	goffset current_track_end_pos;
+	goffset current_track_written;
 
 	gint current_track_num;
 	gint track_count;
@@ -208,34 +208,40 @@ brasero_cdrecord_stderr_read (BraseroProcess *process, const gchar *line)
 
 static void
 brasero_cdrecord_compute (BraseroCDRecord *cdrecord,
-			  gint mb_written,
-			  gint mb_total,
-			  gint track_num)
+			  goffset mb_written,
+			  goffset mb_total,
+			  goffset track_num)
 {
 	gboolean track_num_changed = FALSE;
 	BraseroCDRecordPrivate *priv;
 	gchar *action_string;
-	gint64 this_remain;
-	gint64 bytes;
-	gint64 total;
+	gchar *track_num_str;
+	goffset this_remain;
+	goffset bytes;
+	goffset total;
 
 	priv = BRASERO_CD_RECORD_PRIVATE (cdrecord);
 	if (mb_total <= 0)
 		return;
 
-	total = mb_total * 1048576;
+	total = mb_total * (goffset) 1048576LL;
 
 	if (track_num > priv->current_track_num) {
 		track_num_changed = TRUE;
 		priv->current_track_num = track_num;
-		priv->current_track_end_pos += mb_total * 1048576;
+		priv->current_track_end_pos += mb_total * (goffset) 1048576LL;
 	}
 
-	this_remain = (mb_total - mb_written) * 1048576;
+	this_remain = (mb_total - mb_written) * (goffset) 1048576LL;
 	bytes = (total - priv->current_track_end_pos) + this_remain;
 	brasero_job_set_written_session (BRASERO_JOB (cdrecord), total - bytes);
 
-	action_string = g_strdup_printf ("Writing track %02i", track_num);
+	track_num_str = g_strdup_printf ("%02" G_GOFFSET_FORMAT, track_num);
+
+	/* Translators: %s is the number of the track */
+	action_string = g_strdup_printf (_("Writing track %s"), track_num_str);
+	g_free (track_num_str);
+
 	brasero_job_set_current_action (BRASERO_JOB (cdrecord),
 					BRASERO_BURN_ACTION_RECORDING,
 					action_string,
@@ -264,7 +270,7 @@ brasero_cdrecord_stdout_read (BraseroProcess *process, const gchar *line)
 			       (gdouble) CD_RATE;
 		brasero_job_set_rate (BRASERO_JOB (cdrecord), current_rate);
 
-		priv->current_track_written = mb_written * 1048576;
+		priv->current_track_written = (goffset) mb_written * (goffset) 1048576LL;
 		brasero_cdrecord_compute (cdrecord,
 					  mb_written,
 					  mb_total,
@@ -282,7 +288,7 @@ brasero_cdrecord_stdout_read (BraseroProcess *process, const gchar *line)
 			       (gdouble) CD_RATE;
 		brasero_job_set_rate (BRASERO_JOB (cdrecord), current_rate);
 
-		priv->current_track_written = mb_written * 1048576;
+		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;
 
@@ -290,7 +296,7 @@ brasero_cdrecord_stdout_read (BraseroProcess *process, const gchar *line)
 			brasero_job_get_session_output_size (BRASERO_JOB (cdrecord),
 							     NULL,
 							     &bytes);
-			mb_total = bytes / 1048576;
+			mb_total = bytes / (goffset) 1048576LL;
 			brasero_cdrecord_compute (cdrecord,
 						  mb_written,
 						  mb_total,
@@ -344,10 +350,15 @@ brasero_cdrecord_stdout_read (BraseroProcess *process, const gchar *line)
 	}
 	else if (g_str_has_prefix (line, "Fixating...")
 	     ||  g_str_has_prefix (line, "Writing Leadout...")) {
-		brasero_job_set_current_action (BRASERO_JOB (process),
-						BRASERO_BURN_ACTION_FIXATING,
-						NULL,
-						FALSE);
+		BraseroJobAction action;
+
+		/* Do this to avoid strange things to appear when erasing */
+		brasero_job_get_action (BRASERO_JOB (process), &action);
+		if (action == BRASERO_JOB_ACTION_RECORD)
+			brasero_job_set_current_action (BRASERO_JOB (process),
+							BRASERO_BURN_ACTION_FIXATING,
+							NULL,
+							FALSE);
 	}
 	else if (g_str_has_prefix (line, "Last chance to quit, ")) {
 		brasero_job_set_dangerous (BRASERO_JOB (process), TRUE);



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