[brasero] Check the endianness of bin file associated to a cue and use swap or swab options in backend if it i



commit 6074525eb83d4caf122ccb9aaf5f2b2496a8a7eb
Author: Philippe Rouquier <bonfire-app wanadoo fr>
Date:   Sun Nov 22 08:36:31 2009 +0100

    Check the endianness of bin file associated to a cue and use swap or swab options in backend if it is a little endian one

 libbrasero-burn/burn-image-format.c |   49 +++++++++++++++++++++++++++++++++++
 libbrasero-burn/burn-image-format.h |    4 +++
 plugins/cdrdao/burn-cdrdao.c        |   13 ++++++++-
 plugins/cdrkit/burn-wodim.c         |    9 ++++++
 plugins/cdrtools/burn-cdrecord.c    |    9 ++++++
 5 files changed, 83 insertions(+), 1 deletions(-)
---
diff --git a/libbrasero-burn/burn-image-format.c b/libbrasero-burn/burn-image-format.c
index 13fd697..63eb4d7 100644
--- a/libbrasero-burn/burn-image-format.c
+++ b/libbrasero-burn/burn-image-format.c
@@ -514,6 +514,55 @@ brasero_image_format_get_cdrdao_size (gchar *uri,
 	return TRUE;
 }
 
+gboolean
+brasero_image_format_cue_bin_byte_swap (gchar *uri,
+					GCancellable *cancel,
+					GError **error)
+{
+	GFile *file;
+	gchar *line;
+	GFileInputStream *input;
+	GDataInputStream *stream;
+	gboolean is_audio = FALSE;
+	gboolean is_binary = FALSE;
+
+	file = g_file_new_for_uri (uri);
+	input = g_file_read (file, cancel, error);
+
+	if (!input) {
+		g_object_unref (file);
+		return FALSE;
+	}
+
+	stream = g_data_input_stream_new (G_INPUT_STREAM (input));
+	g_object_unref (input);
+
+	while ((line = g_data_input_stream_read_line (stream, NULL, cancel, error))) {
+		const gchar *ptr;
+		
+		if ((ptr = strstr (line, "FILE"))) {
+			if (strstr (ptr, "BINARY"))
+				is_binary = TRUE;
+
+			g_free (line);
+			break;
+		}
+		else if ((ptr = strstr (line, "TRACK"))) {
+			if (strstr (ptr, "AUDIO"))
+				is_audio = TRUE;
+
+			g_free (line);
+			break;
+		}
+		g_free (line);
+	}
+
+	g_object_unref (stream);
+	g_object_unref (file);
+
+	return is_binary && is_audio;
+}
+
 /**
  * .cue can use various data files but have to use them ALL. So we don't need
  * to care about a start/size address. We just go through the whole file and
diff --git a/libbrasero-burn/burn-image-format.h b/libbrasero-burn/burn-image-format.h
index a1d7d2f..9073abd 100644
--- a/libbrasero-burn/burn-image-format.h
+++ b/libbrasero-burn/burn-image-format.h
@@ -78,6 +78,10 @@ brasero_image_format_get_clone_size (gchar *uri,
 				     GCancellable *cancel,
 				     GError **error);
 
+gboolean
+brasero_image_format_cue_bin_byte_swap (gchar *uri,
+					GCancellable *cancel,
+					GError **error);
 G_END_DECLS
 
 #endif /* _BURN_IMAGES_FORMAT_H */
diff --git a/plugins/cdrdao/burn-cdrdao.c b/plugins/cdrdao/burn-cdrdao.c
index e883db7..79e62de 100644
--- a/plugins/cdrdao/burn-cdrdao.c
+++ b/plugins/cdrdao/burn-cdrdao.c
@@ -55,6 +55,8 @@
 #include "brasero-drive.h"
 #include "brasero-medium.h"
 
+#include "burn-image-format.h"
+
 
 #define BRASERO_TYPE_CDRDAO         (brasero_cdrdao_get_type ())
 #define BRASERO_CDRDAO(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), BRASERO_TYPE_CDRDAO, BraseroCdrdao))
@@ -365,14 +367,23 @@ brasero_cdrdao_set_argv_record (BraseroCdrdao *cdrdao,
 
 		if (brasero_track_type_get_image_format (type) == BRASERO_IMAGE_FORMAT_CUE) {
 			gchar *parent;
+			gchar *cueuri;
 
 			cuepath = brasero_track_image_get_toc_source (BRASERO_TRACK_IMAGE (track), FALSE);
 			parent = g_path_get_dirname (cuepath);
 			brasero_process_set_working_directory (BRASERO_PROCESS (cdrdao), parent);
 			g_free (parent);
+
+			/* we need to check endianness */
+			cueuri = brasero_track_image_get_toc_source (BRASERO_TRACK_IMAGE (track), TRUE);
+			if (brasero_image_format_cue_bin_byte_swap (cueuri, NULL, NULL))
+				g_ptr_array_add (argv, g_strdup ("-swap"));
+			g_free (cueuri);
 		}
-		else if (brasero_track_type_get_image_format (type) == BRASERO_IMAGE_FORMAT_CDRDAO)
+		else if (brasero_track_type_get_image_format (type) == BRASERO_IMAGE_FORMAT_CDRDAO) {
+			/* CDRDAO files are always BIG ENDIAN */
 			cuepath = brasero_track_image_get_toc_source (BRASERO_TRACK_IMAGE (track), FALSE);
+		}
 		else {
 			brasero_track_type_free (type);
 			BRASERO_JOB_NOT_SUPPORTED (cdrdao);
diff --git a/plugins/cdrkit/burn-wodim.c b/plugins/cdrkit/burn-wodim.c
index 9a22351..b96bea7 100644
--- a/plugins/cdrkit/burn-wodim.c
+++ b/plugins/cdrkit/burn-wodim.c
@@ -60,6 +60,8 @@
 #include "brasero-track-image.h"
 #include "brasero-track-stream.h"
 
+#include "burn-image-format.h"
+
 
 #define BRASERO_TYPE_WODIM         (brasero_wodim_get_type ())
 #define BRASERO_WODIM(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), BRASERO_TYPE_WODIM, BraseroWodim))
@@ -968,6 +970,7 @@ brasero_wodim_set_argv_record (BraseroWodim *wodim,
 		else if (format == BRASERO_IMAGE_FORMAT_CUE) {
 			gchar *cue_str;
 			gchar *cuepath;
+			gchar *cueuri;
 
 			cuepath = brasero_track_image_get_toc_source (BRASERO_TRACK_IMAGE (track), FALSE);
 			if (!cuepath) {
@@ -975,6 +978,12 @@ brasero_wodim_set_argv_record (BraseroWodim *wodim,
 				BRASERO_JOB_NOT_READY (wodim);
 			}
 
+			/* we need to check endianness */
+			cueuri = brasero_track_image_get_toc_source (BRASERO_TRACK_IMAGE (track), TRUE);
+			if (brasero_image_format_cue_bin_byte_swap (cueuri, NULL, NULL))
+				g_ptr_array_add (argv, g_strdup ("-swab"));
+			g_free (cueuri);
+
 			g_ptr_array_add (argv, g_strdup ("fs=16m"));
 
 			/* This is to make sure the CD-TEXT stuff gets written */
diff --git a/plugins/cdrtools/burn-cdrecord.c b/plugins/cdrtools/burn-cdrecord.c
index c28c93c..9dff304 100644
--- a/plugins/cdrtools/burn-cdrecord.c
+++ b/plugins/cdrtools/burn-cdrecord.c
@@ -60,6 +60,8 @@
 #include "brasero-track-image.h"
 #include "brasero-track-stream.h"
 
+#include "burn-image-format.h"
+
 
 #define BRASERO_TYPE_CD_RECORD         (brasero_cdrecord_get_type ())
 #define BRASERO_CD_RECORD(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), BRASERO_TYPE_CD_RECORD, BraseroCDRecord))
@@ -964,6 +966,7 @@ brasero_cdrecord_set_argv_record (BraseroCDRecord *cdrecord,
 		else if (format == BRASERO_IMAGE_FORMAT_CUE) {
 			gchar *cue_str;
 			gchar *cuepath;
+			gchar *cueuri;
 
 			cuepath = brasero_track_image_get_toc_source (BRASERO_TRACK_IMAGE (track), FALSE);
 			if (!cuepath) {
@@ -971,6 +974,12 @@ brasero_cdrecord_set_argv_record (BraseroCDRecord *cdrecord,
 				BRASERO_JOB_NOT_READY (cdrecord);
 			}
 
+			/* we need to check endianness */
+			cueuri = brasero_track_image_get_toc_source (BRASERO_TRACK_IMAGE (track), TRUE);
+			if (brasero_image_format_cue_bin_byte_swap (cueuri, NULL, NULL))
+				g_ptr_array_add (argv, g_strdup ("-swab"));
+			g_free (cueuri);
+
 			g_ptr_array_add (argv, g_strdup ("fs=16m"));
 
 			/* This is to make sure the CD-TEXT stuff gets written */



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