[brasero/gnome-2-30] Improved handling of very short SVCDs Retry getting TOC several time when there are no errors but a



commit cf199a67b529564acb85bec94f917590d84d28fc
Author: Philippe Rouquier <bonfire-app wanadoo fr>
Date:   Mon Jun 7 15:23:52 2010 +0200

    Improved handling of very short SVCDs
    Retry getting TOC several time when there are no errors but a 0 size
    Test READCD before actually using it to read TDBs not to lock for 3 seconds
    Some cosmetic code change

 libbrasero-burn/brasero-src-selection.c |   11 +++-----
 libbrasero-media/brasero-medium.c       |   42 ++++++++++++++++++++++++++----
 libbrasero-media/scsi-error.h           |    3 +-
 3 files changed, 42 insertions(+), 14 deletions(-)
---
diff --git a/libbrasero-burn/brasero-src-selection.c b/libbrasero-burn/brasero-src-selection.c
index a0a73ee..a2cf3ce 100644
--- a/libbrasero-burn/brasero-src-selection.c
+++ b/libbrasero-burn/brasero-src-selection.c
@@ -71,13 +71,10 @@ brasero_src_selection_medium_changed (BraseroMediumSelection *selection,
 
 	priv = BRASERO_SRC_SELECTION_PRIVATE (selection);
 
-	if (!priv->session || !priv->track)
-		goto chain;
-
-	drive = brasero_medium_get_drive (medium);
-	brasero_track_disc_set_drive (priv->track, drive);
-
-chain:
+	if (priv->session && priv->track) {
+		drive = brasero_medium_get_drive (medium);
+		brasero_track_disc_set_drive (priv->track, drive);
+	}
 
 	gtk_widget_set_sensitive (GTK_WIDGET (selection), drive != NULL);
 
diff --git a/libbrasero-media/brasero-medium.c b/libbrasero-media/brasero-medium.c
index 042a0f9..1b569c0 100644
--- a/libbrasero-media/brasero-medium.c
+++ b/libbrasero-media/brasero-medium.c
@@ -1567,12 +1567,26 @@ brasero_medium_track_written_SAO (BraseroDeviceHandle *handle,
 				  int track_num,
 				  int track_start)
 {
+	BraseroScsiErrCode error = BRASERO_SCSI_ERROR_NONE;
 	unsigned char buffer [2048];
 	BraseroScsiResult result;
 
 	BRASERO_MEDIA_LOG ("Checking for TDBs in track pregap.");
 
-	/* The two following sectors are readable */
+	/* To avoid blocking try to check whether it is readable */
+	result = brasero_mmc1_read_block (handle,
+					  TRUE,
+					  BRASERO_SCSI_BLOCK_TYPE_ANY,
+					  BRASERO_SCSI_BLOCK_HEADER_NONE,
+					  BRASERO_SCSI_BLOCK_NO_SUBCHANNEL,
+					  track_start - 1,
+					  1,
+					  NULL,
+					  0,
+					  &error);
+	if (result != BRASERO_SCSI_OK || error != BRASERO_SCSI_ERROR_NONE)
+		return TRUE;
+
 	result = brasero_mmc1_read_block (handle,
 					  TRUE,
 					  BRASERO_SCSI_BLOCK_TYPE_ANY,
@@ -1582,9 +1596,8 @@ brasero_medium_track_written_SAO (BraseroDeviceHandle *handle,
 					  1,
 					  buffer,
 					  sizeof (buffer),
-					  NULL);
-
-	if (result == BRASERO_SCSI_OK) {
+					  &error);
+	if (result == BRASERO_SCSI_OK && error == BRASERO_SCSI_ERROR_NONE) {
 		int i;
 
 		if (buffer [0] != 'T' || buffer [1] != 'D' || buffer [2] != 'I') {
@@ -1699,8 +1712,8 @@ brasero_medium_track_get_info (BraseroMedium *self,
 	     &&  (priv->info & BRASERO_MEDIUM_CD)
 	     && !(priv->info & BRASERO_MEDIUM_ROM)) {
 		BRASERO_MEDIA_LOG ("Data track belongs to first session of multisession CD. "
-				  "Checking for real size (%i sectors currently).",
-				  track->blocks_num);
+				   "Checking for real size (%i sectors currently).",
+				   track->blocks_num);
 
 		/* we test the pregaps blocks for TDB: these are special blocks
 		 * filling the pregap of a track when it was recorded as TAO or
@@ -2010,6 +2023,9 @@ brasero_medium_get_sessions_info (BraseroMedium *self,
 	BRASERO_MEDIA_LOG ("Reading Toc");
 
 	priv = BRASERO_MEDIUM_PRIVATE (self);
+
+tryagain:
+
 	result = brasero_mmc1_read_toc_formatted (handle,
 						  0,
 						  &toc,
@@ -2020,6 +2036,20 @@ brasero_medium_get_sessions_info (BraseroMedium *self,
 		return FALSE;
 	}
 
+	if (priv->probe_cancelled) {
+		g_free (toc);
+		return FALSE;
+	}
+
+	/* My drive with some Video CDs gets a size of 2 (basically the size
+	 * member of the structure) without any error. Consider the drive is not
+	 * ready and needs retrying */
+	if (size < sizeof (BraseroScsiFormattedTocData)) {
+		g_free (toc);
+		toc = NULL;
+		goto tryagain;
+	}
+
 	num = (size - sizeof (BraseroScsiFormattedTocData)) /
 	       sizeof (BraseroScsiTocDesc);
 
diff --git a/libbrasero-media/scsi-error.h b/libbrasero-media/scsi-error.h
index 73b768b..321e16b 100644
--- a/libbrasero-media/scsi-error.h
+++ b/libbrasero-media/scsi-error.h
@@ -45,7 +45,8 @@
 G_BEGIN_DECLS
 
 typedef enum {
-	BRASERO_SCSI_ERR_UNKNOWN = 0,
+	BRASERO_SCSI_ERROR_NONE	   = 0,
+	BRASERO_SCSI_ERR_UNKNOWN,
 	BRASERO_SCSI_SIZE_MISMATCH,
 	BRASERO_SCSI_TYPE_MISMATCH,
 	BRASERO_SCSI_BAD_ARGUMENT,



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