brasero r637 - in trunk: . src



Author: philippr
Date: Wed Feb 13 12:43:46 2008
New Revision: 637
URL: http://svn.gnome.org/viewvc/brasero?rev=637&view=rev

Log:
2008-02-13  Philippe Rouquier  <philippr svn gnome org>

	Ported some fixes from stable branch
	- Fixed invalid character in .desktop file. Closes bgo #513097 (Luis Medinas)
	- better fix for #513742 (Philippe Rouquier)
	fix for a small problem where key sense data wasn\'t correct in some cases
	fix for #502703 â Data Integrity Check Always Fails AND Burning Speed Slow (except dvd which ignored setting).
	instead of reading volume declared size we correct the size when we detect a track written in SAO mode (and a multisession disc)
	this means READ CD scsi function was implemented

	* src/Makefile.am:
	* src/burn-medium.c: (brasero_medium_track_written_SAO),
	(brasero_medium_track_get_info), (brasero_medium_set_track_type),
	(brasero_medium_get_CD_sessions_info),
	(brasero_medium_get_sessions_info), (brasero_medium_get_contents):
	* src/scsi-command.h:
	* src/scsi-error.c:
	* src/scsi-error.h:
	* src/scsi-mmc1.h:
	* src/scsi-opcodes.h:
	* src/scsi-read-toc-pma-atip.h:
	* src/scsi-sense-data.c: (brasero_sense_data_illegal_request):
	* src/scsi-sg.c:
	* src/scsi-utils.h:

Added:
   trunk/src/scsi-read-cd.c
   trunk/src/scsi-read-cd.h
Modified:
   trunk/ChangeLog
   trunk/src/Makefile.am
   trunk/src/burn-medium.c
   trunk/src/scsi-command.h
   trunk/src/scsi-error.c
   trunk/src/scsi-error.h
   trunk/src/scsi-mmc1.h
   trunk/src/scsi-opcodes.h
   trunk/src/scsi-read-toc-pma-atip.h
   trunk/src/scsi-sense-data.c
   trunk/src/scsi-sg.c
   trunk/src/scsi-utils.h

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Wed Feb 13 12:43:46 2008
@@ -168,6 +168,8 @@
 	scsi-dvd-structures.h         \
 	scsi-read-format-capacities.c         \
 	scsi-read-format-capacities.h         \
+	scsi-read-cd.h	\
+	scsi-read-cd.c	\
 	burn-debug.c         \
 	burn-debug.h         \
 	burn-track.h         \

Modified: trunk/src/burn-medium.c
==============================================================================
--- trunk/src/burn-medium.c	(original)
+++ trunk/src/burn-medium.c	Wed Feb 13 12:43:46 2008
@@ -1111,37 +1111,6 @@
  * Functions to get information about disc contents
  */
 
-static void
-brasero_medium_set_track_type (BraseroMedium *self,
-			       BraseroMediumTrack *track,
-			       guchar control)
-{
-	BraseroMediumPrivate *priv;
-
-	priv = BRASERO_MEDIUM_PRIVATE (self);
-
-	if (control & BRASERO_SCSI_TRACK_COPY)
-		track->type |= BRASERO_MEDIUM_TRACK_COPY;
-
-	if (!(control & BRASERO_SCSI_TRACK_DATA)) {
-		track->type |= BRASERO_MEDIUM_TRACK_AUDIO;
-		priv->info |= BRASERO_MEDIUM_HAS_AUDIO;
-
-		if (control & BRASERO_SCSI_TRACK_PREEMP)
-			track->type |= BRASERO_MEDIUM_TRACK_PREEMP;
-
-		if (control & BRASERO_SCSI_TRACK_4_CHANNELS)
-			track->type |= BRASERO_MEDIUM_TRACK_4_CHANNELS;
-	}
-	else {
-		track->type |= BRASERO_MEDIUM_TRACK_DATA;
-		priv->info |= BRASERO_MEDIUM_HAS_DATA;
-
-		if (control & BRASERO_SCSI_TRACK_DATA_INCREMENTAL)
-			track->type |= BRASERO_MEDIUM_TRACK_INCREMENTAL;
-	}
-}
-
 static BraseroBurnResult
 brasero_medium_track_volume_size (BraseroMedium *self,
 				  BraseroMediumTrack *track,
@@ -1184,8 +1153,64 @@
 	return BRASERO_BURN_OK;
 }
 
+static gboolean
+brasero_medium_track_written_SAO (BraseroDeviceHandle *handle,
+				  int track_num,
+				  int track_start)
+{
+	unsigned char buffer [2048];
+	BraseroScsiResult result;
+
+	BRASERO_BURN_LOG ("Checking for TDBs in track pregap.");
+
+	/* The two following sectors are 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,
+					  buffer,
+					  sizeof (buffer),
+					  NULL);
+
+	if (result == BRASERO_SCSI_OK) {
+		int i;
+
+		if (buffer [0] != 'T' || buffer [1] != 'D' || buffer [2] != 'I') {
+			BRASERO_BURN_LOG ("Track was probably recorded in SAO mode - no TDB.");
+			return TRUE;
+		}
+
+		/* Find the TDU (16 bytes) for the track (there can be for other tracks).
+		 * i must be < 128 = ((2048 - 8 (size TDB)) / 16 (size TDU). */
+		for (i = 0; i < 128; i ++) {
+			if (BRASERO_GET_BCD (buffer [8 + i * 16]) != track_num)
+				break;
+		}
+
+		if (i >= 128) {
+			BRASERO_BURN_LOG ("No appropriate TDU for track");
+			return TRUE;
+		}
+
+		if (buffer [8 + i * 16] == 0x80 || buffer [8 + i * 16] == 0x00) {
+			BRASERO_BURN_LOG ("Track was recorded in TAO mode.");
+			return FALSE;
+		}
+
+		BRASERO_BURN_LOG ("Track was recorded in Packet mode.");
+		return FALSE;
+	}
+
+	BRASERO_BURN_LOG ("No pregap. That track must have been recorded in SAO mode.");
+	return TRUE;
+}
+
 static BraseroBurnResult
 brasero_medium_track_get_info (BraseroMedium *self,
+			       gboolean multisession,
 			       BraseroMediumTrack *track,
 			       int track_num,
 			       BraseroDeviceHandle *handle,
@@ -1224,18 +1249,81 @@
 	track->blocks_num = BRASERO_GET_32 (track_info.track_size);
 	track->session = BRASERO_SCSI_SESSION_NUM (track_info);
 
-	/* Now here is a potential bug: we can write tracks (data or not)
-	 * shorter than 300 Kio /2 sec but they will be padded to reach this
-	 * floor value. That means that is blocks_num is 300 blocks that may
-	 * mean that the data length on the track is actually shorter.
-	 * So we read the volume descriptor. If it works, good otherwise
-	 * use the old value.
-	 * That's important for checksuming to have a perfect account of the 
-	 * data size. */
 	if (track->blocks_num <= 300) {
+		/* Now here is a potential bug: we can write tracks (data or
+		 * not) shorter than 300 Kio /2 sec but they will be padded to
+		 * reach this floor value. It means that blocks_num is always
+		 * 300 blocks even if the data length on the track is actually
+		 * shorter.
+		 * So we read the volume descriptor. If it works, good otherwise
+		 * use the old value.
+		 * That's important for checksuming to have a perfect account of
+		 * the data size. */
 		BRASERO_BURN_LOG ("300 sectors size. Checking for real size");
 		brasero_medium_track_volume_size (self, track, handle);
 	}
+	/* NOTE: for multisession CDs only
+	 * if the session was incremental (TAO/packet/...) by opposition to DAO
+	 * and SAO, then 2 blocks (run-out) have been added at the end of user
+	 * track for linking. That's why we have 2 additional sectors when the
+	 * track has been recorded in TAO mode
+	 * See MMC5
+	 * 6.44.3.2 CD-R Fixed Packet, Variable Packet, Track-At-Once
+	 * Now, strangely track_get_info always removes two blocks, whereas read
+	 * raw toc adds them (always) and this, whatever the mode, the position.
+	 * It means that when we detect a SAO session we have to add 2 blocks to
+	 * all tracks in it. 
+	 * See # for any information:
+	 * if first track is recorded in SAO/DAO then the length will be two sec
+	 * shorter. If not, if it was recorded in TAO, that's fine.
+	 * The other way would be to use read raw toc but then that's the
+	 * opposite that happens and that latter will return two more bytes for
+	 * TAO recorded session.
+	 * So there are 2 workarounds:
+	 * - read the volume size (can be unreliable)
+	 * - read the 2 last blocks and see if they are run-outs
+	 * here we do solution 2 but only for CDRW, not blank, and for first
+	 * session only since that's the only one that can be recorded in DAO. */
+	else if (track->session == 1
+	     && (track->type & BRASERO_MEDIUM_TRACK_DATA)
+	     &&  multisession
+	     &&  (priv->info & BRASERO_MEDIUM_CD)
+	     && !(priv->info & BRASERO_MEDIUM_ROM)) {
+		BRASERO_BURN_LOG ("Data track belongs to first session of multisession CD. "
+				  "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
+		 * as Packet.
+		 * NOTE: in this case we need to skip 7 sectors before since if
+		 * it was recorded incrementally then there is also 4 runins,
+		 * 1 link sector and 2 runouts (at end of pregap). 
+		 * we also make sure that the two blocks we're adding are
+		 * actually readable. */
+		/* Test the last block, the before last and the one before before last */
+		result = brasero_mmc1_read_block (handle,
+						  FALSE,
+						  BRASERO_SCSI_BLOCK_TYPE_ANY,
+						  BRASERO_SCSI_BLOCK_HEADER_NONE,
+						  BRASERO_SCSI_BLOCK_NO_SUBCHANNEL,
+						  track->blocks_num + track->start,
+						  2,
+						  NULL,
+						  0,
+						  NULL);
+
+		if (result == BRASERO_SCSI_OK) {
+			BRASERO_BURN_LOG ("Following two sectors are readable.");
+
+			if (brasero_medium_track_written_SAO (handle, track_num, track->start)) {
+				track->blocks_num += 2;
+				BRASERO_BURN_LOG ("Correcting track size (now %i)", track->blocks_num);
+			}
+		}
+		else
+			BRASERO_BURN_LOG ("Detected runouts");
+	}
 
 	if (track_info.next_wrt_address_valid)
 		priv->next_wr_add = BRASERO_GET_32 (track_info.next_wrt_address);
@@ -1250,6 +1338,39 @@
 	return BRASERO_BURN_OK;
 }
 
+#if 0
+
+static void
+brasero_medium_set_track_type (BraseroMedium *self,
+			       BraseroMediumTrack *track,
+			       guchar control)
+{
+	BraseroMediumPrivate *priv;
+
+	priv = BRASERO_MEDIUM_PRIVATE (self);
+
+	if (control & BRASERO_SCSI_TRACK_COPY)
+		track->type |= BRASERO_MEDIUM_TRACK_COPY;
+
+	if (!(control & BRASERO_SCSI_TRACK_DATA)) {
+		track->type |= BRASERO_MEDIUM_TRACK_AUDIO;
+		priv->info |= BRASERO_MEDIUM_HAS_AUDIO;
+
+		if (control & BRASERO_SCSI_TRACK_PREEMP)
+			track->type |= BRASERO_MEDIUM_TRACK_PREEMP;
+
+		if (control & BRASERO_SCSI_TRACK_4_CHANNELS)
+			track->type |= BRASERO_MEDIUM_TRACK_4_CHANNELS;
+	}
+	else {
+		track->type |= BRASERO_MEDIUM_TRACK_DATA;
+		priv->info |= BRASERO_MEDIUM_HAS_DATA;
+
+		if (control & BRASERO_SCSI_TRACK_DATA_INCREMENTAL)
+			track->type |= BRASERO_MEDIUM_TRACK_INCREMENTAL;
+	}
+}
+
 /**
  * return :
  *  0 when it's not possible to determine (fallback to formatted toc)
@@ -1548,7 +1669,12 @@
 		track->start = leadout_start;
 		track->type = BRASERO_MEDIUM_TRACK_LEADOUT;
 
-		brasero_medium_track_get_info (self, track, g_slist_length (priv->tracks), handle, code); 
+		brasero_medium_track_get_info (self,
+					       FALSE,
+					       track,
+					       g_slist_length (priv->tracks),
+					       handle,
+					       code); 
 	}
 
 	priv->tracks = g_slist_reverse (priv->tracks);
@@ -1575,6 +1701,8 @@
 	return BRASERO_BURN_OK;
 }
 
+#endif
+
 /**
  * NOTE: for DVD-R multisession we lose 28688 blocks for each session
  * so the capacity is the addition of all session sizes + 28688 for each
@@ -1622,6 +1750,7 @@
 				  BraseroScsiErrCode *code)
 {
 	int num, i, size;
+	gboolean multisession;
 	BraseroScsiResult result;
 	BraseroScsiTocDesc *desc;
 	BraseroMediumPrivate *priv;
@@ -1645,6 +1774,9 @@
 	num = (size - sizeof (BraseroScsiFormattedTocData)) /
 	       sizeof (BraseroScsiTocDesc);
 
+	/* remove 1 for leadout */
+	multisession = (priv->info & BRASERO_MEDIUM_APPENDABLE) || (num -1) != 1;
+
 	BRASERO_BURN_LOG ("%i track(s) found", num);
 
 	desc = toc->desc;
@@ -1659,12 +1791,6 @@
 		track->start = BRASERO_GET_32 (desc->track_start);
 
 		/* we shouldn't request info on a track if the disc is closed */
-		brasero_medium_track_get_info (self,
-					       track,
-					       g_slist_length (priv->tracks),
-					       handle,
-					       code);
-
 		if (desc->control & BRASERO_SCSI_TRACK_COPY)
 			track->type |= BRASERO_MEDIUM_TRACK_COPY;
 
@@ -1678,8 +1804,26 @@
 			if (desc->control & BRASERO_SCSI_TRACK_4_CHANNELS)
 				track->type |= BRASERO_MEDIUM_TRACK_4_CHANNELS;
 		}
-		else if (BRASERO_MEDIUM_IS (priv->info, BRASERO_MEDIUM_DVDRW_PLUS)
-		     ||  BRASERO_MEDIUM_IS (priv->info, BRASERO_MEDIUM_DVDRW_RESTRICTED)) {
+		else {
+			track->type |= BRASERO_MEDIUM_TRACK_DATA;
+			priv->info |= BRASERO_MEDIUM_HAS_DATA;
+
+			if (desc->control & BRASERO_SCSI_TRACK_DATA_INCREMENTAL)
+				track->type |= BRASERO_MEDIUM_TRACK_INCREMENTAL;
+		}
+
+		brasero_medium_track_get_info (self,
+					       multisession,
+					       track,
+					       g_slist_length (priv->tracks),
+					       handle,
+					       code);
+
+		if (desc->control & BRASERO_SCSI_TRACK_COPY)
+			track->type |= BRASERO_MEDIUM_TRACK_COPY;
+
+		if (BRASERO_MEDIUM_IS (priv->info, BRASERO_MEDIUM_DVDRW_PLUS)
+		||  BRASERO_MEDIUM_IS (priv->info, BRASERO_MEDIUM_DVDRW_RESTRICTED)) {
 			BraseroBurnResult result;
 
 			/* a special case for these two kinds of media (DVD+RW)
@@ -1687,29 +1831,15 @@
 			result = brasero_medium_track_volume_size (self, 
 								   track,
 								   handle);
-			if (result == BRASERO_BURN_OK) {
-				track->type |= BRASERO_MEDIUM_TRACK_DATA;
-				priv->info |= BRASERO_MEDIUM_HAS_DATA;
-
-				priv->next_wr_add = 0;
-
-				if (desc->control & BRASERO_SCSI_TRACK_DATA_INCREMENTAL)
-					track->type |= BRASERO_MEDIUM_TRACK_INCREMENTAL;
-			}
-			else {
+			if (result != BRASERO_BURN_OK) {
 				priv->tracks = g_slist_remove (priv->tracks, track);
 				g_free (track);
 
 				priv->info |= BRASERO_MEDIUM_BLANK;
 				priv->info &= ~BRASERO_MEDIUM_CLOSED;
 			}
-		}
-		else {
-			track->type |= BRASERO_MEDIUM_TRACK_DATA;
-			priv->info |= BRASERO_MEDIUM_HAS_DATA;
-
-			if (desc->control & BRASERO_SCSI_TRACK_DATA_INCREMENTAL)
-				track->type |= BRASERO_MEDIUM_TRACK_INCREMENTAL;
+			else
+				priv->next_wr_add = 0;
 		}
 	}
 
@@ -1730,6 +1860,7 @@
 		track->type = BRASERO_MEDIUM_TRACK_LEADOUT;
 
 		brasero_medium_track_get_info (self,
+					       FALSE,
 					       track,
 					       g_slist_length (priv->tracks),
 					       handle,
@@ -1787,6 +1918,7 @@
 			priv->tracks = g_slist_prepend (priv->tracks, track);
 			
 			brasero_medium_track_get_info (self,
+						       FALSE,
 						       track,
 						       1,
 						       handle,
@@ -1804,21 +1936,12 @@
 		BRASERO_BURN_LOG ("Closed media");
 	}
 
-	if (priv->info & BRASERO_MEDIUM_CD) {
-		result = brasero_medium_get_CD_sessions_info (self, handle, code);
-		if (result != BRASERO_BURN_OK)
-			result = brasero_medium_get_sessions_info (self, handle, code);
-	}
-	else
-		result = brasero_medium_get_sessions_info (self, handle, code);
-
-	if (result != BRASERO_BURN_OK)
-		goto end;
+	result = brasero_medium_get_sessions_info (self, handle, code);
 
 end:
 
 	g_free (info);
-	return BRASERO_BURN_OK;
+	return result;
 }
 
 static void

Modified: trunk/src/scsi-command.h
==============================================================================
--- trunk/src/scsi-command.h	(original)
+++ trunk/src/scsi-command.h	Wed Feb 13 12:43:46 2008
@@ -51,8 +51,6 @@
 };
 typedef struct _BraseroScsiCmdInfo BraseroScsiCmdInfo;
 
-typedef struct _BraseroScsiCmd BraseroScsiCmd;
-
 #define BRASERO_SCSI_COMMAND_DEFINE(cdb, name, fd_flags, direction)		\
 static const BraseroScsiCmdInfo info =						\
 {	/* SCSI commands always end by 1 byte of ctl */				\

Modified: trunk/src/scsi-error.c
==============================================================================
--- trunk/src/scsi-error.c	(original)
+++ trunk/src/scsi-error.c	Wed Feb 13 12:43:46 2008
@@ -38,6 +38,7 @@
 					N_("invalid field in command"),
 					N_("the device timed out"),
 					N_("key not established"),
+					N_("invalid track mode"),
 					NULL	};	/* errno */
 
 const gchar *

Modified: trunk/src/scsi-error.h
==============================================================================
--- trunk/src/scsi-error.h	(original)
+++ trunk/src/scsi-error.h	Wed Feb 13 12:43:46 2008
@@ -51,6 +51,7 @@
 	BRASERO_SCSI_INVALID_FIELD,
 	BRASERO_SCSI_TIMEOUT,
 	BRASERO_SCSI_KEY_NOT_ESTABLISHED,
+	BRASERO_SCSI_INVALID_TRACK_MODE,
 	BRASERO_SCSI_ERRNO,
 	BRASERO_SCSI_ERROR_LAST
 } BraseroScsiErrCode;

Modified: trunk/src/scsi-mmc1.h
==============================================================================
--- trunk/src/scsi-mmc1.h	(original)
+++ trunk/src/scsi-mmc1.h	Wed Feb 13 12:43:46 2008
@@ -27,6 +27,7 @@
 #include "scsi-base.h"
 #include "scsi-device.h"
 #include "scsi-error.h"
+#include "scsi-read-cd.h"
 #include "scsi-read-disc-info.h"
 #include "scsi-read-toc-pma-atip.h"
 #include "scsi-read-track-information.h"
@@ -68,6 +69,18 @@
 			      int *size,
 			      BraseroScsiErrCode *error);
 
+BraseroScsiResult
+brasero_mmc1_read_block (BraseroDeviceHandle *handle,
+			 gboolean user_data,
+			 BraseroScsiBlockType type,
+			 BraseroScsiBlockHeader header,
+			 BraseroScsiBlockSubChannel channel,
+			 int start,
+			 int size,
+			 unsigned char *buffer,
+			 int buffer_len,
+			 BraseroScsiErrCode *error);
+
 G_END_DECLS
 
 #endif /* _BURN_MMC1_H */

Modified: trunk/src/scsi-opcodes.h
==============================================================================
--- trunk/src/scsi-opcodes.h	(original)
+++ trunk/src/scsi-opcodes.h	Wed Feb 13 12:43:46 2008
@@ -52,6 +52,8 @@
 #define BRASERO_READ_SUB_CHANNEL_OPCODE			0x42
 #define BRASERO_READ_MASTER_CUE_OPCODE			0x59
 
+#define BRASERO_READ_CD_OPCODE				0xBE
+
 /**
  *	MMC2
  */

Added: trunk/src/scsi-read-cd.c
==============================================================================
--- (empty file)
+++ trunk/src/scsi-read-cd.c	Wed Feb 13 12:43:46 2008
@@ -0,0 +1,146 @@
+/***************************************************************************
+ *            scsi-read-cd.c
+ *
+ *  Sun Jan 27 20:39:40 2008
+ *  Copyright  2008  Philippe Rouquier
+ *  <bonfire-app wanadoo fr>
+ ****************************************************************************/
+
+/*
+ * This program 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.
+ * 
+ * This program 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 Library General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
+ */
+
+#include <fcntl.h>
+
+#include <glib.h>
+
+#include "scsi-error.h"
+#include "scsi-utils.h"
+#include "scsi-base.h"
+#include "scsi-command.h"
+#include "scsi-opcodes.h"
+#include "scsi-read-cd.h"
+
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+
+struct _BraseroReadCDCDB {
+	uchar opcode;
+
+	uchar rel_add		:1;
+	uchar reserved1		:1;
+	uchar sec_type		:3;
+	uchar reserved0		:3;
+
+	uchar start_lba		[4];
+	uchar len		[3];
+
+	uchar reserved2		:1;
+	uchar error		:2;
+	uchar edc		:1;
+	uchar user_data		:1;
+	uchar header		:2;
+	uchar sync		:1;
+
+	uchar subchannel	:3;
+	uchar reserved3		:5;
+
+	uchar ctl;
+};
+
+#else
+
+struct _BraseroReadCDCDB {
+	uchar opcode;
+
+	uchar reserved0		:3;
+	uchar sec_type		:3;
+	uchar reserved1		:1;
+	uchar rel_add		:1;
+
+	uchar start_lba		[4];
+	uchar len		[3];
+
+	uchar sync		:1;
+	uchar header		:2;
+	uchar user_data		:1;
+	uchar edc		:1;
+	uchar error		:2;
+	uchar reserved2		:1;
+
+	uchar reserved3		:5;
+	uchar subchannel	:3;
+
+	uchar ctl;
+};
+
+#endif
+
+typedef struct _BraseroReadCDCDB BraseroReadCDCDB;
+
+BRASERO_SCSI_COMMAND_DEFINE (BraseroReadCDCDB,
+			     READ_CD,
+			     O_RDONLY,
+			     BRASERO_SCSI_READ);
+
+BraseroScsiResult
+brasero_mmc1_read_block (BraseroDeviceHandle *handle,
+			 gboolean user_data,
+			 BraseroScsiBlockType type,
+			 BraseroScsiBlockHeader header,
+			 BraseroScsiBlockSubChannel channel,
+			 int start,
+			 int size,
+			 unsigned char *buffer,
+			 int buffer_len,
+			 BraseroScsiErrCode *error)
+{
+	BraseroReadCDCDB *cdb;
+	BraseroScsiResult res;
+
+	cdb = brasero_scsi_command_new (&info, handle);
+	BRASERO_SET_32 (cdb->start_lba, start);
+
+	/* NOTE: if we just want to test if block is readable len can be 0 */
+	BRASERO_SET_24 (cdb->len, size);
+
+	/* reladr should be O */
+	/* no sync field included */
+	cdb->sync = 0;
+
+	/* no filtering */
+	cdb->sec_type = type;
+
+	/* header ?*/
+	cdb->header = header;
+
+	/* returns user data ?*/
+	cdb->user_data = user_data;
+
+	/* no EDC */
+	/* no error/C2 error */
+
+	/* subchannel */
+	cdb->subchannel = channel;
+
+	if (buffer)
+		memset (buffer, 0, buffer_len);
+
+	res = brasero_scsi_command_issue_sync (cdb,
+					       buffer,
+					       buffer_len,
+					       error);
+
+	return res;
+}

Added: trunk/src/scsi-read-cd.h
==============================================================================
--- (empty file)
+++ trunk/src/scsi-read-cd.h	Wed Feb 13 12:43:46 2008
@@ -0,0 +1,58 @@
+/***************************************************************************
+ *            scsi-read-cd.h
+ *
+ *  Sun Jan 27 20:39:17 2008
+ *  Copyright  2008  Philippe Rouquier
+ *  <bonfire-app wanadoo fr>
+ ****************************************************************************/
+
+/*
+ * This program 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.
+ * 
+ * This program 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 Library General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
+ */
+ 
+#ifndef _SCSI_READ_CD_H
+#define _SCSI_READ_CD_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+
+typedef enum {
+	BRASERO_SCSI_BLOCK_HEADER_NONE		= 0,
+	BRASERO_SCSI_BLOCK_HEADER_MAIN		= 1,
+	BRASERO_SCSI_BLOCK_HEADER_SUB		= 1 << 1
+} BraseroScsiBlockHeader;
+
+typedef enum {
+	BRASERO_SCSI_BLOCK_TYPE_ANY		= 0,
+	BRASERO_SCSI_BLOCK_TYPE_CDDA		= 1,
+	BRASERO_SCSI_BLOCK_TYPE_MODE1		= 2,
+	BRASERO_SCSI_BLOCK_TYPE_MODE2_FORMLESS	= 3,
+	BRASERO_SCSI_BLOCK_TYPE_MODE2_FORM1	= 4,
+	BRASERO_SCSI_BLOCK_TYPE_MODE2_FORM2	= 5
+} BraseroScsiBlockType;
+
+typedef enum {
+	BRASERO_SCSI_BLOCK_NO_SUBCHANNEL	= 0,
+	BRASERO_SCSI_BLOCK_SUB_Q		= 2,
+	BRASERO_SCSI_BLOCK_SUB_R_W		= 4
+} BraseroScsiBlockSubChannel;
+
+
+G_END_DECLS
+
+#endif /* _SCSI_READ_CD_H */
+

Modified: trunk/src/scsi-read-toc-pma-atip.h
==============================================================================
--- trunk/src/scsi-read-toc-pma-atip.h	(original)
+++ trunk/src/scsi-read-toc-pma-atip.h	Wed Feb 13 12:43:46 2008
@@ -29,10 +29,7 @@
 #ifndef _SCSI_READ_TOC_PMA_ATIP_H
 #define _SCSI_READ_TOC_PMA_ATIP_H
 
-#ifdef __cplusplus
-extern "C"
-{
-#endif
+G_BEGIN_DECLS
 
 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
 
@@ -328,8 +325,6 @@
 
 #define BRASERO_SCSI_TRACK_LEADOUT_START	0xAA
 
-#ifdef __cplusplus
-}
-#endif
+G_END_DECLS
 
 #endif /* _SCSI_READ_TOC_PMA_ATIP_H */

Modified: trunk/src/scsi-sense-data.c
==============================================================================
--- trunk/src/scsi-sense-data.c	(original)
+++ trunk/src/scsi-sense-data.c	Wed Feb 13 12:43:46 2008
@@ -39,7 +39,7 @@
  * (defined in SCSI Primary command 3 / SPC specs)
  **/
 
-#define SENSE_DATA_KEY(sense)			((sense) ? (sense) [2] & 0xFF : 0x00)			/* Sense code itself */
+#define SENSE_DATA_KEY(sense)			((sense) ? (sense) [2] & 0x0F : 0x00)			/* Sense code itself */
 #define SENSE_DATA_ASC(sense)			((sense) ? (sense) [12] : 0x00)				/* Additional Sense Code */
 #define SENSE_DATA_ASCQ(sense)			((sense) ? (sense) [13] : 0x00)				/* Additional Sense Code Qualifier */
 #define SENSE_DATA_ASC_ASCQ(sense)		((sense) ? (sense) [12] << 8 | (sense) [13] : 0x00)	/* ASC and ASCQ combined */
@@ -60,6 +60,7 @@
 #define ASC_ASCQ_CODE_INSUFFICIENT_TIME_FOR_OPERATION	0x2E00
 #define ASC_ASCQ_CODE_KEY_NOT_ESTABLISHED		0x6F02
 #define ASC_ASCQ_CODE_SCRAMBLED_SECTOR			0x6F03
+#define ASC_ASCQ_CODE_INVALID_TRACK_MODE		0x6400
 
 /**
  * error processing 
@@ -138,6 +139,10 @@
 			BRASERO_SCSI_SET_ERRCODE (err, BRASERO_SCSI_KEY_NOT_ESTABLISHED);
 			break;
 
+		case ASC_ASCQ_CODE_INVALID_TRACK_MODE:
+			BRASERO_SCSI_SET_ERRCODE (err, BRASERO_SCSI_INVALID_TRACK_MODE);
+			break;
+
 		default:
 			res = brasero_sense_data_unknown (sense_data, err);
 			break;

Modified: trunk/src/scsi-sg.c
==============================================================================
--- trunk/src/scsi-sg.c	(original)
+++ trunk/src/scsi-sg.c	Wed Feb 13 12:43:46 2008
@@ -57,6 +57,7 @@
 
 	const BraseroScsiCmdInfo *info;
 };
+typedef struct _BraseroScsiCmd BraseroScsiCmd;
 
 #define BRASERO_SCSI_CMD_OPCODE_OFF			0
 #define BRASERO_SCSI_CMD_SET_OPCODE(command)		(command->cmd [BRASERO_SCSI_CMD_OPCODE_OFF] = command->info->opcode)

Modified: trunk/src/scsi-utils.h
==============================================================================
--- trunk/src/scsi-utils.h	(original)
+++ trunk/src/scsi-utils.h	Wed Feb 13 12:43:46 2008
@@ -40,6 +40,7 @@
 
 #define BRASERO_SET_BCD(data, num)	(uchar)(data)=((((num)/10)<<4)&0xF0)|((num)-(((num)/10)*10))
 #define BRASERO_SET_16(data, num)	(data)[0]=(((num)>>8)&0xFF);(data)[1]=(uchar)((num)&0xFF)
+#define BRASERO_SET_24(data, num)	(data)[0]=(uchar)(((num)>>16)&0xFF);(data)[1]=(uchar)(((num)>>8)&0xFF);(data)[2]=(uchar)((num)&0xFF);
 #define BRASERO_SET_32(data, num)	(data)[0]=(uchar)(((num)>>24)&0xFF);(data)[1]=(uchar)(((num)>>16)&0xFF);(data)[2]=(uchar)(((num)>>8)&0xFF);(data)[3]=(uchar)((num)&0xFF)
 
 #define BRASERO_MSF_TO_LBA(minute, second, frame)	(((minute)*60+(second))*75+frame)



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