brasero r1256 - in trunk: . src/plugins/libburnia



Author: philippr
Date: Mon Sep  8 18:11:26 2008
New Revision: 1256
URL: http://svn.gnome.org/viewvc/brasero?rev=1256&view=rev

Log:
	Improved libburn cancellation

	* src/plugins/libburnia/burn-libburn-common.c
	(brasero_libburn_common_ctx_free_real),
	(brasero_libburn_common_ctx_wait_for_idle_drive),
	(brasero_libburn_common_ctx_free):
	* src/plugins/libburnia/burn-libburn.c (brasero_libburn_finalize),
	(brasero_libburn_export_caps):


Modified:
   trunk/ChangeLog
   trunk/src/plugins/libburnia/burn-libburn-common.c
   trunk/src/plugins/libburnia/burn-libburn.c

Modified: trunk/src/plugins/libburnia/burn-libburn-common.c
==============================================================================
--- trunk/src/plugins/libburnia/burn-libburn-common.c	(original)
+++ trunk/src/plugins/libburnia/burn-libburn-common.c	Mon Sep  8 18:11:26 2008
@@ -35,34 +35,15 @@
 #include <glib/gi18n-lib.h>
 
 #include "burn-basics.h"
+#include "burn-debug.h"
 #include "burn-job.h"
 #include "burn-libburn-common.h"
 
 #include <libburn/libburn.h>
 
-void
-brasero_libburn_common_ctx_free (BraseroLibburnCtx *ctx)
+static void
+brasero_libburn_common_ctx_free_real (BraseroLibburnCtx *ctx)
 {
-	enum burn_drive_status status;
-
-	/* try to properly cancel the drive */
-	status = burn_drive_get_status (ctx->drive, NULL);
-	if (status == BURN_DRIVE_WRITING || status == BURN_DRIVE_READING) {
-		burn_drive_cancel (ctx->drive);
-
-		/* wait for some time for the drive to be idle.*/
-		/* FIXME: we don't want to be stuck here waiting for a state
-		 * that will come we don't know when ...
-		status = burn_drive_get_status (ctx->drive, NULL);
-		while (status != BURN_DRIVE_IDLE)
-			status = burn_drive_get_status (ctx->drive, NULL);
-		*/
-	}
-	else if (status == BURN_DRIVE_GRABBING) {
-		/* This should probably never happen */
-		burn_drive_info_forget (ctx->drive_info, 1);
-	}
-
 	if (ctx->drive_info) {
 		burn_drive_info_free (ctx->drive_info);
 		ctx->drive_info = NULL;
@@ -80,6 +61,59 @@
 	}
 
 	g_free (ctx);
+
+	/* Since the library is not needed any more call burn_finish ().
+	 * NOTE: it itself calls burn_abort (). */
+	burn_finish ();
+}
+
+static gboolean
+brasero_libburn_common_ctx_wait_for_idle_drive (gpointer data)
+{
+	BraseroLibburnCtx *ctx = data;
+	enum burn_drive_status status;
+
+	/* try to properly cancel the drive */
+	status = burn_drive_get_status (ctx->drive, NULL);
+	if (status == BURN_DRIVE_WRITING || status == BURN_DRIVE_READING)
+		burn_drive_cancel (ctx->drive);
+	if (status == BURN_DRIVE_GRABBING)
+		/* This should probably never happen */
+		burn_drive_info_forget (ctx->drive_info, 1);
+
+	if (status != BURN_DRIVE_IDLE) {
+		BRASERO_BURN_LOG ("Drive not idle yet");
+		return TRUE;
+	}
+
+	brasero_libburn_common_ctx_free_real (ctx);
+	return FALSE;
+}
+
+void
+brasero_libburn_common_ctx_free (BraseroLibburnCtx *ctx)
+{
+	enum burn_drive_status status;
+
+	/* try to properly cancel the drive */
+	status = burn_drive_get_status (ctx->drive, NULL);
+	if (status == BURN_DRIVE_WRITING || status == BURN_DRIVE_READING)
+		burn_drive_cancel (ctx->drive);
+
+	if (status == BURN_DRIVE_GRABBING)
+		/* This should probably never happen */
+		burn_drive_info_forget (ctx->drive_info, 1);
+	
+	if (status != BURN_DRIVE_IDLE) {
+		/* otherwise wait for the drive to calm down */
+		BRASERO_BURN_LOG ("Drive not idle yet");
+		g_timeout_add (200,
+			       brasero_libburn_common_ctx_wait_for_idle_drive,
+			       ctx);
+		return;
+	}
+
+	brasero_libburn_common_ctx_free_real (ctx);
 }
 
 BraseroLibburnCtx *

Modified: trunk/src/plugins/libburnia/burn-libburn.c
==============================================================================
--- trunk/src/plugins/libburnia/burn-libburn.c	(original)
+++ trunk/src/plugins/libburnia/burn-libburn.c	Mon Sep  8 18:11:26 2008
@@ -53,7 +53,7 @@
 
 BRASERO_PLUGIN_BOILERPLATE (BraseroLibburn, brasero_libburn, BRASERO_TYPE_JOB, BraseroJob);
 
-#define BRASERO_PVD_SIZE	32 * 2048
+#define BRASERO_PVD_SIZE	32L * 2048L
 
 struct _BraseroLibburnPrivate {
 	BraseroLibburnCtx *ctx;
@@ -804,10 +804,6 @@
 		priv->ctx = NULL;
 	}
 
-	/* Since the library is not needed any more call burn_finish ().
-	 * NOTE: it itself calls burn_abort (). */
-	burn_finish ();
-
 	G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
@@ -883,14 +879,14 @@
 	BRASERO_PLUGIN_ADD_STANDARD_DVDR_PLUS_FLAGS (plugin);
 	BRASERO_PLUGIN_ADD_STANDARD_DVDR_FLAGS (plugin);
 
-	/* ... and DVDs-RW (sequential) */
+	/* ... and DVD-RW (sequential) */
 	output = brasero_caps_disc_new (media_dvd_rw);
 	brasero_plugin_link_caps (plugin, output, input);
 	g_slist_free (output);
 
 	BRASERO_PLUGIN_ADD_STANDARD_DVDRW_FLAGS (plugin);
 
-	/* for DVD+/- restricted */
+	/* for DVD+/-RW restricted */
 	output = brasero_caps_disc_new (media_dvd_rw_plus);
 	brasero_plugin_link_caps (plugin, output, input);
 	g_slist_free (output);



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