brasero r1417 - in trunk: . src



Author: philippr
Date: Fri Oct 24 16:11:42 2008
New Revision: 1417
URL: http://svn.gnome.org/viewvc/brasero?rev=1417&view=rev

Log:
	Added and use TEST_UNIT_READY function before probing the device, which
	may avoid to get stuck later.

	* src/Makefile.am:
	* src/burn-medium.c (brasero_medium_probe_thread):
	* src/scsi-spc1.h:
	* src/scsi-test-unit-ready.c (brasero_spc1_test_unit_ready):


Added:
   trunk/src/scsi-test-unit-ready.c
Modified:
   trunk/ChangeLog
   trunk/src/Makefile.am
   trunk/src/burn-medium.c
   trunk/src/scsi-spc1.h

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Fri Oct 24 16:11:42 2008
@@ -279,7 +279,8 @@
 	burn-media.c           \
 	burn-media.h           \
 	burn-hal-watch.c           \
-	burn-hal-watch.h
+	burn-hal-watch.h           \
+	scsi-test-unit-ready.c
 
 if BUILD_INOTIFY
 brasero_SOURCES += brasero-file-monitor.c brasero-file-monitor.h

Modified: trunk/src/burn-medium.c
==============================================================================
--- trunk/src/burn-medium.c	(original)
+++ trunk/src/burn-medium.c	Fri Oct 24 16:11:42 2008
@@ -2958,6 +2958,22 @@
 
 	if (handle) {
 		BRASERO_BURN_LOG ("Open () succeeded");
+
+		/* NOTE: if we wanted to know the status we'd need to read the 
+		 * error code variable which is currently NULL */
+		while (brasero_spc1_test_unit_ready (handle, NULL) != BRASERO_SCSI_OK) {
+			sleep (1);
+
+			if (priv->probe_cancelled) {
+				priv->probe = NULL;
+				brasero_device_handle_close (handle);
+				BRASERO_BURN_LOG ("Device probing cancelled");
+				return NULL;
+			}
+		}
+
+		BRASERO_BURN_LOG ("Device ready");
+
 		brasero_medium_init_real (BRASERO_MEDIUM (self), handle);
 		brasero_device_handle_close (handle);
 	}

Modified: trunk/src/scsi-spc1.h
==============================================================================
--- trunk/src/scsi-spc1.h	(original)
+++ trunk/src/scsi-spc1.h	Fri Oct 24 16:11:42 2008
@@ -35,6 +35,10 @@
 G_BEGIN_DECLS
 
 BraseroScsiResult
+brasero_spc1_test_unit_ready (BraseroDeviceHandle *handle,
+			      BraseroScsiErrCode *error);
+
+BraseroScsiResult
 brasero_spc1_mode_sense_get_page (BraseroDeviceHandle *handle,
 				  BraseroSPCPageType num,
 				  BraseroScsiModeData **data,

Added: trunk/src/scsi-test-unit-ready.c
==============================================================================
--- (empty file)
+++ trunk/src/scsi-test-unit-ready.c	Fri Oct 24 16:11:42 2008
@@ -0,0 +1,61 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * brasero
+ * Copyright (C) Philippe Rouquier 2007-2008 <bonfire-app wanadoo fr>
+ * 
+ *  Brasero is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ * 
+ * brasero is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with brasero.  If not, write to:
+ * 	The Free Software Foundation, Inc.,
+ * 	51 Franklin Street, Fifth Floor
+ * 	Boston, MA  02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include "scsi-error.h"
+#include "scsi-utils.h"
+#include "scsi-base.h"
+#include "scsi-command.h"
+#include "scsi-opcodes.h"
+
+struct _BraseroTestUnitReadyCDB {
+	uchar opcode;
+	uchar reserved		[4];
+	uchar ctl;
+};
+
+typedef struct _BraseroTestUnitReadyCDB BraseroTestUnitReadyCDB;
+
+BRASERO_SCSI_COMMAND_DEFINE (BraseroTestUnitReadyCDB,
+			     TEST_UNIT_READY,
+			     BRASERO_SCSI_READ);
+
+BraseroScsiResult
+brasero_spc1_test_unit_ready (BraseroDeviceHandle *handle,
+			      BraseroScsiErrCode *error)
+{
+	BraseroTestUnitReadyCDB *cdb;
+	BraseroScsiResult res;
+
+	cdb = brasero_scsi_command_new (&info, handle);
+	res = brasero_scsi_command_issue_sync (cdb,
+					       NULL,
+					       0,
+					       error);
+	brasero_scsi_command_free (cdb);
+	return res;
+}
+
+ 



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