brasero r804 - in trunk: . src src/plugins/growisofs



Author: philippr
Date: Fri May  9 12:57:43 2008
New Revision: 804
URL: http://svn.gnome.org/viewvc/brasero?rev=804&view=rev

Log:
	Fix progress when blanking (for the backends that return progress)
	Fix progress for dvd+rw-format
	Fix some warnings

	* src/brasero-project-size.c (brasero_project_size_finalize),
	(brasero_project_size_disc_removed_cb):
	* src/burn-job.c (brasero_job_set_progress):
	* src/burn-process.c (brasero_process_read),
	(brasero_process_setup_channel):
	* src/burn-task-ctx.c (brasero_task_ctx_get_progress):
	* src/burn.c (brasero_burn_wait_for_dest_insertion),
	(brasero_burn_mount_media), (brasero_burn_run_tasks):
	* src/plugins/growisofs/burn-dvd-rw-format.c
	(brasero_dvd_rw_format_read_stderr):

Modified:
   trunk/ChangeLog
   trunk/src/brasero-project-size.c
   trunk/src/burn-job.c
   trunk/src/burn-process.c
   trunk/src/burn-task-ctx.c
   trunk/src/burn.c
   trunk/src/plugins/growisofs/burn-dvd-rw-format.c

Modified: trunk/src/brasero-project-size.c
==============================================================================
--- trunk/src/brasero-project-size.c	(original)
+++ trunk/src/brasero-project-size.c	Fri May  9 12:57:43 2008
@@ -303,9 +303,6 @@
 		BraseroDriveSize *drive;
 
 		drive = iter->data;
-		if (drive->medium)
-			g_object_unref (drive->medium);
-
 		g_free (drive);
 	}
 	g_list_free (cobj->priv->drives);
@@ -1585,22 +1582,22 @@
 				      BraseroProjectSize *self)
 {
 	GList *iter;
+	GList *next;
 
-	for (iter = self->priv->drives; iter; iter = iter->next) {
+	for (iter = self->priv->drives; iter; iter = next) {
 		BraseroDriveSize *drive;
 
 		drive = iter->data;
-		if (drive->medium
-		&&  medium == drive->medium) {
-			drive->media = BRASERO_MEDIUM_NONE;
-			drive->sectors = 0;
-			drive->free_space = 0;
-
-			brasero_project_size_find_proper_drive (self);
-			brasero_project_size_disc_changed (self);
+		next = iter->next;
+		if (medium == drive->medium) {
+			self->priv->drives = g_list_remove (self->priv->drives, drive);
+			g_free (drive);
 		}
 	}
 
+	brasero_project_size_find_proper_drive (self);
+	brasero_project_size_disc_changed (self);
+
 	/* we need to rebuild the menu is any */
 	if (self->priv->menu)
 		brasero_project_size_show_menu_real (self, NULL);

Modified: trunk/src/burn-job.c
==============================================================================
--- trunk/src/burn-job.c	(original)
+++ trunk/src/burn-job.c	Fri May  9 12:57:43 2008
@@ -1613,7 +1613,7 @@
 	if (priv->next)
 		return BRASERO_BURN_ERR;
 
-	if (progress < 0.0)
+	if (progress < 0.0 || progress > 1.0)
 		return BRASERO_BURN_ERR;
 
 	return brasero_task_ctx_set_progress (priv->ctx, progress);

Modified: trunk/src/burn-process.c
==============================================================================
--- trunk/src/burn-process.c	(original)
+++ trunk/src/burn-process.c	Fri May  9 12:57:43 2008
@@ -349,9 +349,9 @@
 
 		if (status == G_IO_STATUS_AGAIN) {
 			gchar character;
-			/* line is NULL since there wasn't any character ending the line and so it wasn't
-			 * read at all.
-			 * some processes (like cdrecord/cdrdao) produce an extra character sometimes */
+			/* there wasn't any character ending the line.
+			 * some processes (like cdrecord/cdrdao) produce an
+			 * extra character sometimes */
 			status = g_io_channel_read_chars (channel,
 							  &character,
 							  1,
@@ -362,15 +362,16 @@
 				g_string_append_c (buffer, character);
 
 				switch (character) {
+				case '\b':
 				case '\n':
 				case '\r':
-				case '\xe2':
+				case '\xe2': /* Unicode paragraph separator */
 				case '\0':
 					BRASERO_JOB_LOG (process,
 							 debug_prefixes [channel_type],
 							 buffer->str);
 
-					if (readfunc)
+					if (readfunc && buffer->str [0] != '\0')
 						result = readfunc (process, buffer->str);
 
 					/* a subclass could have stopped or errored out.
@@ -405,7 +406,7 @@
 					 debug_prefixes [channel_type],
 					 buffer->str);
 
-			if (readfunc)
+			if (readfunc && buffer->str [0] != '\0')
 				result = readfunc (process, buffer->str);
 
 			/* a subclass could have stopped or errored out.
@@ -541,29 +542,13 @@
 			       GIOFunc function)
 {
 	GIOChannel *channel;
-	const gchar *term;
-	gint len = 0;
 
 	fcntl (pipe, F_SETFL, O_NONBLOCK);
 	channel = g_io_channel_unix_new (pipe);
 
-	term = g_io_channel_get_line_term (channel, &len);
-	if (term) {
-		gchar *tmp;
-
-		tmp = g_strdup_printf ("\b%s", term);
-g_print ("In here\n");
-		len ++;
-		g_io_channel_set_line_term (channel, tmp, len);
-		g_free (tmp);
-	}
-	else {
-		gchar *tmp;
-g_print ("KKKLKD\n");
-		tmp = g_strdup ("\n\r\b\0");
-		g_io_channel_set_line_term (channel, tmp, 4);
-		g_free (tmp);
-	}
+	/* It'd be good if we were allowed to add some to the default line
+	 * separator */
+//	g_io_channel_set_line_term (channel, "\b", -1);
 
 	g_io_channel_set_flags (channel,
 				g_io_channel_get_flags (channel) | G_IO_FLAG_NONBLOCK,

Modified: trunk/src/burn-task-ctx.c
==============================================================================
--- trunk/src/burn-task-ctx.c	(original)
+++ trunk/src/burn-task-ctx.c	Fri May  9 12:57:43 2008
@@ -803,13 +803,21 @@
 	gdouble track_num = 0;
 	gdouble track_nb = 0;
 	gint64 total = -1;
-	GSList *tracks;
 
 	priv = BRASERO_TASK_CTX_PRIVATE (self);
 
-	tracks = brasero_burn_session_get_tracks (priv->session);
-	track_num = g_slist_length (tracks);
-	track_nb = g_slist_index (tracks, priv->current_track);
+	/* The following can happen when we're blanking since there's no track */
+	if (priv->action == BRASERO_TASK_ACTION_ERASE) {
+		track_num = 1.0;
+		track_nb = 0.0;
+	}
+	else {
+		GSList *tracks;
+
+		tracks = brasero_burn_session_get_tracks (priv->session);
+		track_num = g_slist_length (tracks);
+		track_nb = g_slist_index (tracks, priv->current_track);
+	}
 
 	if (priv->progress >= 0.0) {
 		if (progress)

Modified: trunk/src/burn.c
==============================================================================
--- trunk/src/burn.c	(original)
+++ trunk/src/burn.c	Fri May  9 12:57:43 2008
@@ -128,9 +128,12 @@
 #define BRASERO_BURN_PRIVATE(o)  (G_TYPE_INSTANCE_GET_PRIVATE ((o), BRASERO_TYPE_BURN, BraseroBurnPrivate))
 
 #define MAX_EJECT_WAIT_TIME	20000
-#define MAX_MOUNT_ATTEMPS	10
+#define MAX_MOUNT_ATTEMPTS	10
 #define MOUNT_TIMEOUT		500
 
+#define MAX_LOAD_ATTEMPTS	20
+#define LOAD_TIMEOUT		500
+
 static GObjectClass *parent_class = NULL;
 
 #ifdef BUILD_DBUS
@@ -232,6 +235,67 @@
 }
 
 static BraseroBurnResult
+brasero_burn_wait_for_dest_insertion (BraseroBurn *burn,
+				      GError **error)
+{
+	BraseroBurnPrivate *priv = BRASERO_BURN_PRIVATE (burn);
+	BraseroMedium *medium;
+	guint attempt = 0;
+	gchar *failure;
+
+	BRASERO_BURN_LOG ("Waiting for destination disc");
+	if (!priv->dest)
+		return BRASERO_BURN_OK;
+
+	/* we need to release our lock */
+	if (priv->dest_locked) {
+		priv->dest_locked = 0;
+		if (!brasero_drive_unlock (priv->dest)) {
+			gchar *name;
+
+			name = brasero_drive_get_display_name (priv->dest);
+			g_set_error (error,
+				     BRASERO_BURN_ERROR,
+				     BRASERO_BURN_ERROR_GENERAL,
+				     _("\"%s\" can't be unlocked"),
+				     name);
+			g_free (name);
+			return BRASERO_BURN_ERR;
+		}
+	}
+
+	medium = brasero_drive_get_medium (priv->dest);
+	while (brasero_medium_get_status (medium) == BRASERO_MEDIUM_NONE) {
+		brasero_burn_sleep (burn, LOAD_TIMEOUT);
+		
+		attempt ++;
+		if (attempt > MAX_LOAD_ATTEMPTS) {
+			g_set_error (error,
+				     BRASERO_BURN_ERROR,
+				     BRASERO_BURN_ERROR_GENERAL,
+				     _("the disc could not be reloaded (max attemps reached)"));
+			return BRASERO_BURN_ERR;
+		}
+
+		medium = brasero_drive_get_medium (priv->dest);
+	}
+
+	/* Re-add the lock */
+	if (!priv->dest_locked
+	&&  !brasero_drive_lock (priv->dest, _("ongoing burning process"), &failure)) {
+		g_set_error (error,
+			     BRASERO_BURN_ERROR,
+			     BRASERO_BURN_ERROR_GENERAL,
+			     _("the drive can't be locked (%s)"),
+			     failure);
+		return BRASERO_BURN_ERR;
+	}
+	priv->dest_locked = 1;
+
+	return BRASERO_BURN_OK;
+}
+
+static BraseroBurnResult
 brasero_burn_eject_dest_media (BraseroBurn *self,
 			       GError **error)
 {
@@ -923,7 +987,7 @@
 
 	medium = brasero_drive_get_medium (priv->dest);
 	while (!brasero_volume_is_mounted (BRASERO_VOLUME (medium))) {
-		if (retries++ > MAX_MOUNT_ATTEMPS) {
+		if (retries++ > MAX_MOUNT_ATTEMPTS) {
 			g_set_error (error,
 				     BRASERO_BURN_ERROR,
 				     BRASERO_BURN_ERROR_GENERAL,
@@ -1580,6 +1644,14 @@
 			g_object_unref (priv->task);
 			priv->task = NULL;
 			priv->tasks_done ++;
+
+			/* Now it can happen (like with dvd+rw-format) that for
+			 * the whole OS, the disc doesn't exist during the 
+			 * formatting. Wait for the disc to reappear */
+			result = brasero_burn_wait_for_dest_insertion (burn, error);
+			if (result != BRASERO_BURN_OK)
+				break;
+
 			continue;
 		}
 

Modified: trunk/src/plugins/growisofs/burn-dvd-rw-format.c
==============================================================================
--- trunk/src/plugins/growisofs/burn-dvd-rw-format.c	(original)
+++ trunk/src/plugins/growisofs/burn-dvd-rw-format.c	Fri May  9 12:57:43 2008
@@ -50,6 +50,7 @@
 static BraseroBurnResult
 brasero_dvd_rw_format_read_stderr (BraseroProcess *process, const gchar *line)
 {
+	int perc_1 = 0, perc_2 = 0;
 	float percent;
 
 	if (strstr (line, "unable to proceed with format")
@@ -65,14 +66,17 @@
 		return BRASERO_BURN_OK;
 	}
 
-	if ((sscanf (line, "* blanking %f%%,", &percent) == 1)
-	||  (sscanf (line, "* formatting %f%%,", &percent) == 1)
-	||  (sscanf (line, "* relocating lead-out %f%%,", &percent) == 1))
+	if ((sscanf (line, "* blanking %d.%1d%%,", &perc_1, &perc_2) == 2)
+	||  (sscanf (line, "* formatting %d.%1d%%,", &perc_1, &perc_2) == 2)
+	||  (sscanf (line, "* relocating lead-out %d.%1d%%,", &perc_1, &perc_2) == 2))
 		brasero_job_set_dangerous (BRASERO_JOB (process), TRUE);
+	else 
+		sscanf (line, "%d.%1d%%", &perc_1, &perc_2);
 
-	if (percent >= 1.0) {
-		brasero_job_set_written_session (BRASERO_JOB (process), percent);
-		brasero_job_set_progress (BRASERO_JOB (process), 1.0);
+	percent = (float) perc_1 / 100.0 + (float) perc_2 / 1000.0;
+	if (percent) {
+		brasero_job_start_progress (BRASERO_JOB (process), FALSE);
+		brasero_job_set_progress (BRASERO_JOB (process), percent);
 	}
 
 	return BRASERO_BURN_OK;



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