[brasero] Add and use a new macro to convert sectors into length for audio CDs



commit cf0801f24bb6d2e69005f04c0ddab73196ec8bbe
Author: Philippe Rouquier <bonfire-app wanadoo fr>
Date:   Sat Nov 14 13:09:25 2009 +0100

    Add and use a new macro to convert sectors into length for audio CDs

 libbrasero-burn/brasero-dest-selection.c |    2 --
 libbrasero-media/brasero-units.h         |   23 +++++++++++++++++------
 src/brasero-audio-disc.c                 |   10 +++++-----
 3 files changed, 22 insertions(+), 13 deletions(-)
---
diff --git a/libbrasero-burn/brasero-dest-selection.c b/libbrasero-burn/brasero-dest-selection.c
index 4b8f7c4..17b369a 100644
--- a/libbrasero-burn/brasero-dest-selection.c
+++ b/libbrasero-burn/brasero-dest-selection.c
@@ -59,8 +59,6 @@
 #include "brasero-session.h"
 #include "brasero-session-cfg.h"
 
-#define BRASERO_SECTORS_TO_DURATION(sectors)	(guint64) ((sectors) * 1000000000LL / 75LL)
-
 typedef struct _BraseroDestSelectionPrivate BraseroDestSelectionPrivate;
 struct _BraseroDestSelectionPrivate
 {
diff --git a/libbrasero-media/brasero-units.h b/libbrasero-media/brasero-units.h
index 3b92485..0be8ab8 100644
--- a/libbrasero-media/brasero-units.h
+++ b/libbrasero-media/brasero-units.h
@@ -71,19 +71,30 @@ G_BEGIN_DECLS
  **/
 
 #define BRASERO_DURATION_TO_BYTES(duration)					\
-	((gint64) (duration) * 75 * 2352 / 1000000000 +				\
-	(((gint64) ((duration) * 75 * 2352) % 1000000000) ? 1:0))
+	((gint64) (duration) * 75LL * 2352LL / 1000000000LL +				\
+	(((gint64) ((duration) * 75LL * 2352LL) % 1000000000LL) ? 1:0))
 
 #define BRASERO_DURATION_TO_SECTORS(duration)					\
-	((gint64) (duration) * 75 / 1000000000 +				\
-	(((gint64) ((duration) * 75) % 1000000000) ? 1:0))
+	((gint64) (duration) * 75LL / 1000000000LL +				\
+	(((gint64) ((duration) * 75LL) % 1000000000LL) ? 1:0))
 
 #define BRASERO_BYTES_TO_SECTORS(size, secsize)					\
 	(((size) / (secsize)) + (((size) % (secsize)) ? 1:0))
 
 #define BRASERO_BYTES_TO_DURATION(bytes)					\
-	(guint64) ((guint64) ((guint64) (bytes) * 1000000000) / (guint64) (2352 * 75) + 				\
-	(guint64) (((guint64) ((guint64) (bytes) * 1000000000) % (guint64) (2352 * 75)) ? 1:0))
+	(guint64) ((guint64) ((guint64) (bytes) * 1000000000LL) / (guint64) (2352LL * 75LL) + 				\
+	(guint64) (((guint64) ((guint64) (bytes) * 1000000000LL) % (guint64) (2352LL * 75LL)) ? 1:0))
+
+/* NOTE: 1 sec = 75 sectors */
+
+/**
+ * BRASERO_SECTORS_TO_DURATION:
+ * This macro is used to convert sector sizes in
+ * in length (in nanoseconds).
+ *
+**/
+#define BRASERO_SECTORS_TO_DURATION(sectors)	\
+	(guint64) ((sectors) * 1000000000LL / 75LL)
 
 /**
  * Used to get string
diff --git a/src/brasero-audio-disc.c b/src/brasero-audio-disc.c
index dd3e7c9..8ad20d3 100644
--- a/src/brasero-audio-disc.c
+++ b/src/brasero-audio-disc.c
@@ -43,6 +43,8 @@
 #include "brasero-io.h"
 #include "brasero-notify.h"
 
+#include "brasero-units.h"
+
 #include "brasero-tags.h"
 #include "brasero-track-stream-cfg.h"
 #include "brasero-session-cfg.h"
@@ -217,8 +219,6 @@ enum {
 	PROP_REJECT_FILE,
 };
 
-/* 1 sec = 75 sectors, len is in nanosecond */
-#define BRASERO_SECTORS_TO_TIME(sectors)	(gint64) (sectors * GST_SECOND / 75)
 #define COL_KEY "column_key"
 
 #define BRASERO_AUDIO_DISC_CONTEXT		1000
@@ -614,7 +614,7 @@ brasero_audio_disc_add_uri_real (BraseroAudioDisc *disc,
 	brasero_track_stream_set_boundaries (BRASERO_TRACK_STREAM (track),
 					     start,
 					     end,
-					     BRASERO_SECTORS_TO_TIME (gap_sectors));
+					     BRASERO_SECTORS_TO_DURATION (gap_sectors));
 
 	session = brasero_video_tree_model_get_session (BRASERO_VIDEO_TREE_MODEL (store));
 	if (pos > 0) {
@@ -1654,7 +1654,7 @@ brasero_audio_disc_edit_single_song_properties (BraseroAudioDisc *disc,
 	brasero_track_stream_set_boundaries (BRASERO_TRACK_STREAM (track),
                                                                       start,
                                                                       end,
-                                                                      BRASERO_SECTORS_TO_TIME (gap));
+                                                                      BRASERO_SECTORS_TO_DURATION (gap));
 
 	if (title)
 		brasero_track_tag_add_string (BRASERO_TRACK (track),
@@ -1676,7 +1676,7 @@ brasero_audio_disc_edit_single_song_properties (BraseroAudioDisc *disc,
 					   BRASERO_TRACK_STREAM_ISRC_TAG,
 					   isrc);
 
-	if (end - start + BRASERO_SECTORS_TO_TIME (gap) < BRASERO_MIN_STREAM_LENGTH)
+	if (end - start + BRASERO_SECTORS_TO_DURATION (gap) < BRASERO_MIN_STREAM_LENGTH)
 		brasero_audio_disc_short_track_dialog (disc);
 
 	g_free (title);



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