[Xfce4-commits] [apps/xfburn] 02/02: Stream recording, auto formatting of media

noreply at xfce.org noreply at xfce.org
Sat Mar 22 20:32:46 CET 2014


This is an automated email from the git hooks/post-receive script.

squisher pushed a commit to branch master
in repository apps/xfburn.

commit b0a6b80cb0fe735abfe8e4f482418ff66fb5d15a
Author: David Mohr <david at mcbf.net>
Date:   Sat Mar 22 13:24:24 2014 -0600

    Stream recording, auto formatting of media
    
    Based on a patch by Thomas:
    * Automatically format DVD-RAM or BD if needed
    * Use stream recording by default (BD only, ignored otherwise)
      Faster burning, but disabled error correction
---
 xfburn/xfburn-blank-dialog.c                      |    2 +-
 xfburn/xfburn-burn-data-composition-base-dialog.c |   12 ++-
 xfburn/xfburn-copy-cd-progress-dialog.c           |    6 +-
 xfburn/xfburn-create-iso-progress-dialog.c        |    2 +-
 xfburn/xfburn-perform-burn.c                      |  108 ++++++++++++++++++++-
 xfburn/xfburn-progress-dialog.c                   |   48 ++++-----
 xfburn/xfburn-progress-dialog.h                   |    1 +
 7 files changed, 150 insertions(+), 29 deletions(-)

diff --git a/xfburn/xfburn-blank-dialog.c b/xfburn/xfburn-blank-dialog.c
index b59abab..8920a3c 100644
--- a/xfburn/xfburn-blank-dialog.c
+++ b/xfburn/xfburn-blank-dialog.c
@@ -418,7 +418,7 @@ thread_blank_perform_blank (ThreadBlankParams * params, struct burn_drive_info *
     if(progress.sectors>0 && progress.sector>=0) {
       gdouble percent = 1.0 + ((gdouble) progress.sector+1.0) / ((gdouble) progress.sectors) * 98.0;
       
-      xfburn_progress_dialog_set_progress_bar_fraction (XFBURN_PROGRESS_DIALOG (dialog_progress), percent / 100.0);
+      xfburn_progress_dialog_set_progress_bar_fraction (XFBURN_PROGRESS_DIALOG (dialog_progress), percent);
     }
     usleep(500000);
   }
diff --git a/xfburn/xfburn-burn-data-composition-base-dialog.c b/xfburn/xfburn-burn-data-composition-base-dialog.c
index 35a13de..f9cad63 100644
--- a/xfburn/xfburn-burn-data-composition-base-dialog.c
+++ b/xfburn/xfburn-burn-data-composition-base-dialog.c
@@ -54,6 +54,7 @@ typedef struct
   GtkWidget *entry;
   GtkWidget *check_eject;
   GtkWidget *check_burnfree;
+  GtkWidget *check_stream_recording;
   GtkWidget *check_only_iso;
   GtkWidget *hbox_iso;
   GtkWidget *entry_path_iso;
@@ -242,6 +243,11 @@ xfburn_burn_data_composition_base_dialog_constructor (GType type, guint n_constr
   gtk_widget_show (priv->check_burnfree);
   gtk_box_pack_start (GTK_BOX (vbox), priv->check_burnfree, FALSE, FALSE, BORDER);
 
+  priv->check_stream_recording = gtk_check_button_new_with_mnemonic (_("Stream _Recording"));
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->check_stream_recording), TRUE);
+  gtk_widget_show (priv->check_stream_recording);
+  gtk_box_pack_start (GTK_BOX (vbox), priv->check_stream_recording, FALSE, FALSE, BORDER);
+
   /* create ISO ? */
   priv->check_only_iso = gtk_check_button_new_with_mnemonic (_("Only create _ISO"));
   gtk_widget_show (priv->check_only_iso);
@@ -396,6 +402,7 @@ cb_check_only_iso_toggled (GtkToggleButton * button, XfburnBurnDataCompositionBa
   gtk_widget_set_sensitive (priv->hbox_iso, gtk_toggle_button_get_active (button));
   gtk_widget_set_sensitive (priv->check_eject, !gtk_toggle_button_get_active (button));
   gtk_widget_set_sensitive (priv->check_burnfree, !gtk_toggle_button_get_active (button));
+  gtk_widget_set_sensitive (priv->check_stream_recording, !gtk_toggle_button_get_active (button));
   gtk_widget_set_sensitive (priv->check_dummy, !gtk_toggle_button_get_active (button));
   if (!gtk_toggle_button_get_active (button)) {
     g_object_get (G_OBJECT (priv->device_box), "valid", &valid_disc, NULL);
@@ -503,7 +510,7 @@ thread_write_iso (ThreadWriteIsoParams * params)
 	gdouble percent = 0;
 	i = 0;
 
-	percent = ((gdouble) written / (gdouble) size);
+	percent = ((gdouble) written / (gdouble) size) * 100.0;
 
 	xfburn_progress_dialog_set_progress_bar_fraction (XFBURN_PROGRESS_DIALOG (dialog_progress), percent);
       }
@@ -529,6 +536,7 @@ typedef struct {
   gboolean eject;
   gboolean dummy;
   gboolean burnfree;
+  gboolean stream_recording;
 } ThreadBurnCompositionParams;
 
 static void 
@@ -566,6 +574,7 @@ thread_burn_prep_and_burn (ThreadBurnCompositionParams * params, struct burn_dri
   */
   burn_write_opts_set_simulate(burn_options, params->dummy ? 1 : 0);
   burn_write_opts_set_underrun_proof (burn_options, params->burnfree ? 1 : 0);
+  burn_write_opts_set_stream_recording (burn_options, params->stream_recording ? 32 : 0);
 
   if (!xfburn_set_write_mode (burn_options, params->write_mode, disc, WRITE_MODE_TAO)) {
     xfburn_progress_dialog_burning_failed (XFBURN_PROGRESS_DIALOG (dialog_progress), _("The write mode is not supported currently."));
@@ -698,6 +707,7 @@ cb_dialog_response (XfburnBurnDataCompositionBaseDialog * dialog, gint response_
       params->eject = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->check_eject));
       params->dummy = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->check_dummy));
       params->burnfree = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->check_burnfree));
+      params->stream_recording = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->check_stream_recording));
       g_thread_new ("burn_composition", (GThreadFunc) thread_burn_composition, params);
     }
   }
diff --git a/xfburn/xfburn-copy-cd-progress-dialog.c b/xfburn/xfburn-copy-cd-progress-dialog.c
index e983089..cb76db4 100644
--- a/xfburn/xfburn-copy-cd-progress-dialog.c
+++ b/xfburn/xfburn-copy-cd-progress-dialog.c
@@ -125,9 +125,9 @@ cb_new_output (XfburnCopyCdProgressDialog * dialog, const gchar * output, gpoint
       }
 
       xfburn_progress_dialog_set_action_text (XFBURN_PROGRESS_DIALOG (dialog), _("Writing CD..."));
-      xfburn_progress_dialog_set_progress_bar_fraction (XFBURN_PROGRESS_DIALOG (dialog), fraction);
-      xfburn_progress_dialog_set_fifo_bar_fraction (XFBURN_PROGRESS_DIALOG (dialog), ((gdouble) buffer1) / 100);
-      xfburn_progress_dialog_set_buffer_bar_fraction (XFBURN_PROGRESS_DIALOG (dialog), ((gdouble) buffer2) / 100);
+      xfburn_progress_dialog_set_progress_bar_fraction (XFBURN_PROGRESS_DIALOG (dialog), fraction * 100.0);
+      xfburn_progress_dialog_set_fifo_bar_fraction (XFBURN_PROGRESS_DIALOG (dialog), ((gdouble) buffer1));
+      xfburn_progress_dialog_set_buffer_bar_fraction (XFBURN_PROGRESS_DIALOG (dialog), ((gdouble) buffer2));
     }
     else if (sscanf (output, "%d:%d:%d", &min, &sec, &cent) == 3) {
       gint readcd_done = -1;
diff --git a/xfburn/xfburn-create-iso-progress-dialog.c b/xfburn/xfburn-create-iso-progress-dialog.c
index 704c1fc..45815cf 100644
--- a/xfburn/xfburn-create-iso-progress-dialog.c
+++ b/xfburn/xfburn-create-iso-progress-dialog.c
@@ -96,7 +96,7 @@ cb_new_output (XfburnCreateIsoProgressDialog * dialog, const gchar * output, gpo
     sscanf (output, "%*s %d", &readcd_done);
     fraction = ((gdouble) readcd_done) / readcd_end;
 
-    xfburn_progress_dialog_set_progress_bar_fraction (XFBURN_PROGRESS_DIALOG (dialog), fraction);
+    xfburn_progress_dialog_set_progress_bar_fraction (XFBURN_PROGRESS_DIALOG (dialog), fraction * 100.0);
   }
   else if (strstr (output, READCD_CAPACITY)) {
     xfburn_progress_dialog_set_action_text (XFBURN_PROGRESS_DIALOG (dialog), _("Reading CD..."));
diff --git a/xfburn/xfburn-perform-burn.c b/xfburn/xfburn-perform-burn.c
index e1a84ae..c803c11 100644
--- a/xfburn/xfburn-perform-burn.c
+++ b/xfburn/xfburn-perform-burn.c
@@ -35,6 +35,108 @@
 /* internals */
 /*************/
 
+/* ts B40225 : Automatically format unformatted BD-RE and DVD-RAM
+   Return: <= 0 = failure, 1 = formatting happened, 2 = no formatting needed
+*/
+static int
+xfburn_auto_format(GtkWidget *dialog_progress, struct burn_drive *drive)
+{
+  int ret, profile, status, num_formats;
+  char profile_name[80];
+  off_t size;
+  unsigned int dummy;
+  struct burn_progress p;
+  double percent;
+  int format_flag = 64 | (3 << 1); /* Fast formatting with default size */
+
+/* Test mock-up for non-BD burners with DVD+RW
+#define XFBURN_DVD_PLUS_RW_FOR_BD_RE 1
+*/
+/* Test mock-up for already formatted DVD-RAM and BD-RE
+#define XFBURN_PRETEND_UNFORMATTED 1
+*/
+/* Test mock-up for protecting your only unformatted BD-RE from formatting.
+   Will keep burning from happening and make xfburn stall, so that it has to
+   be killed externally.
+#define XFBURN_KEEP_UNFORMATTED 1
+*/
+
+ ret = burn_disc_get_profile (drive, &profile, profile_name);
+
+#ifdef XFBURN_DVD_PLUS_RW_FOR_BD_RE
+ if (profile == 0x1a) {
+    DBG("Pretending DVD+RW is a BD RE");
+    profile = 0x43;           /* Pretend (for this function only) to be BD-RE */
+    format_flag |= 16;        /* Re-format already formatted medium */
+    strcpy(profile_name, "DVD+RW as BD-RE");
+  }
+#endif
+
+  if (ret <= 0 || (profile != 0x12 &&  profile != 0x43))
+    return 2;
+  /* The medium is DVD-RAM or BD-RE */
+  ret= burn_disc_get_formats (drive, &status, &size, &dummy, &num_formats);
+
+#ifdef XFBURN_DVD_PLUS_RW_FOR_BD_RE
+  if (strncmp(profile_name, "DVD+RW", 6) == 0) {
+    DBG("Pretending to be unformatted");
+    ret = 1;
+    status = BURN_FORMAT_IS_UNFORMATTED;
+  }
+#endif
+#ifdef XFBURN_PRETEND_UNFORMATTED
+  DBG("Pretending to be unformatted (using re-format)");
+  status = BURN_FORMAT_IS_UNFORMATTED;
+  format_flag |= 16;        /* Re-format already formatted medium */
+#endif
+
+  if(ret <= 0 || status != BURN_FORMAT_IS_UNFORMATTED)
+    return 2;
+
+  /* The medium is unformatted */
+
+  //g_object_set (dialog_progress, "animate", TRUE, NULL);
+  xfburn_progress_dialog_set_status_with_text (XFBURN_PROGRESS_DIALOG (dialog_progress),
+                                               XFBURN_PROGRESS_DIALOG_STATUS_FORMATTING,
+                                               _("Formatting..."));
+
+#ifdef XFBURN_KEEP_UNFORMATTED
+  g_warning ("Will Not Format");
+  return -1;
+#endif
+
+  /* Apply formatting */
+  percent = 0.0;
+  burn_disc_format (drive, 0, format_flag);
+  while (burn_drive_get_status (drive, &p) != BURN_DRIVE_IDLE) {
+    if (p.sectors > 0 && p.sector >= 0) /* display 1 to 99 percent */
+      percent = 1.0 + ((double) p.sector + 1.0) / ((double) p.sectors) * 98.0;
+      xfburn_progress_dialog_set_progress_bar_fraction (XFBURN_PROGRESS_DIALOG (dialog_progress),
+                                                        percent);
+ 
+    //DBG ("Formatting (%.f%%)", percent);
+ 
+    usleep (500000);
+  }
+ 
+  /* Check for success */
+  if (burn_drive_wrote_well (drive)) {
+    percent = 100.0;
+ 
+    DBG ("Formatting done");
+ 
+    xfburn_progress_dialog_set_progress_bar_fraction (XFBURN_PROGRESS_DIALOG (dialog_progress),
+                                                      percent);
+  } else {
+    DBG ("Formatting failed");
+
+    xfburn_progress_dialog_burning_failed (XFBURN_PROGRESS_DIALOG (dialog_progress), _("Formatting failed."));
+ 
+    return 0;
+  }
+  return 1;
+}
+
 
 /**************/
 /* public API */
@@ -164,6 +266,10 @@ xfburn_perform_burn_write (GtkWidget *dialog_progress,
     return;
   }
 
+  ret = xfburn_auto_format (dialog_progress, drive);
+  if (ret <= 0)
+    return;
+
   total_sectors = burn_disc_get_sectors (disc);
 
   disc_size = burn_disc_available_space (drive, burn_options);
@@ -244,7 +350,7 @@ xfburn_perform_burn_write (GtkWidget *dialog_progress,
           DBG ("%.0f ; track = %d\tsector %d/%d", percent, progress.track, progress.sector, progress.sectors);
         }
         */
-	xfburn_progress_dialog_set_progress_bar_fraction (XFBURN_PROGRESS_DIALOG (dialog_progress), percent / 100.0);
+	xfburn_progress_dialog_set_progress_bar_fraction (XFBURN_PROGRESS_DIALOG (dialog_progress), percent);
 
         cur_speed = ((gdouble) ((gdouble)(glong)progress.sector * 2048L) / (gdouble) (time_now - time_start)) / ((gdouble) (factor * 1000.0));
         //DBG ("(%f / %f) / %f = %f\n", (gdouble) ((gdouble)(glong)progress.sector * 2048L), (gdouble) (time_now - time_start), ((gdouble) (factor * 1000.0)), cur_speed);
diff --git a/xfburn/xfburn-progress-dialog.c b/xfburn/xfburn-progress-dialog.c
index 7aac682..44651ee 100644
--- a/xfburn/xfburn-progress-dialog.c
+++ b/xfburn/xfburn-progress-dialog.c
@@ -103,6 +103,7 @@ xfburn_progress_dialog_status_get_type (void)
   static GType type = 0;
   if (type == 0) {
     static const GEnumValue values[] = {
+      {XFBURN_PROGRESS_DIALOG_STATUS_FORMATTING, "XFBURN_PROGRESS_DIALOG_STATUS_FORMATTING", "formatting"},
       {XFBURN_PROGRESS_DIALOG_STATUS_RUNNING, "XFBURN_PROGRESS_DIALOG_STATUS_RUNNING", "running"},
       {XFBURN_PROGRESS_DIALOG_STATUS_FAILED, "XFBURN_PROGRESS_DIALOG_STATUS_FAILED", "failed"},
       {XFBURN_PROGRESS_DIALOG_STATUS_CANCELLED, "XFBURN_PROGRESS_DIALOG_STATUS_CANCELLED", "cancelled"},
@@ -213,7 +214,7 @@ xfburn_progress_dialog_init (XfburnProgressDialog * obj)
   frame = gtk_frame_new (_("Estimated writing speed:"));
   gtk_widget_show (frame);
   gtk_box_pack_start (GTK_BOX (priv->hbox_buffers), frame, FALSE, FALSE, 0);
-  priv->label_speed = gtk_label_new (_("no info"));
+  priv->label_speed = gtk_label_new (_("unknown"));
   set_writing_speed (obj, -1);
   gtk_widget_show (priv->label_speed);
   gtk_container_add (GTK_CONTAINER (frame), priv->label_speed);
@@ -230,7 +231,7 @@ xfburn_progress_dialog_init (XfburnProgressDialog * obj)
   gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
   gtk_widget_show (label);
   priv->fifo_bar = gtk_progress_bar_new ();
-  gtk_progress_bar_set_text (GTK_PROGRESS_BAR (priv->fifo_bar), _("no info"));
+  gtk_progress_bar_set_text (GTK_PROGRESS_BAR (priv->fifo_bar), _("unknown"));
   gtk_table_attach (GTK_TABLE (table), priv->fifo_bar, 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
   gtk_widget_show (priv->fifo_bar);
 
@@ -240,7 +241,7 @@ xfburn_progress_dialog_init (XfburnProgressDialog * obj)
   gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_FILL, GTK_FILL, 0, 0);
   gtk_widget_show (label);
   priv->buffer_bar = gtk_progress_bar_new ();
-  gtk_progress_bar_set_text (GTK_PROGRESS_BAR (priv->buffer_bar), _("no info"));
+  gtk_progress_bar_set_text (GTK_PROGRESS_BAR (priv->buffer_bar), _("unknown"));
   gtk_table_attach (GTK_TABLE (table), priv->buffer_bar, 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
   gtk_widget_show (priv->buffer_bar);
 
@@ -329,7 +330,7 @@ set_writing_speed (XfburnProgressDialog * dialog, gfloat speed)
   gchar *temp;
 
   if (speed < 0)
-    temp = g_strdup_printf ("<b><i>%s</i></b>", _("no info"));
+    temp = g_strdup_printf ("<b><i>%s</i></b>", _("unknown"));
   else
     temp = g_strdup_printf ("<b><i>%.1f x</i></b>", speed);
   
@@ -468,14 +469,14 @@ xfburn_progress_dialog_set_buffer_bar_fraction (XfburnProgressDialog * dialog, g
   XfburnProgressDialogPrivate *priv = XFBURN_PROGRESS_DIALOG_GET_PRIVATE (dialog);
   gchar *text = NULL;
 
-  if (fraction > 1.0) {
-    fraction = 1.0;
+  if (fraction > 100.0) {
+    fraction = 100.0;
     text = g_strdup ("100%");
   } else if (fraction < 0.0) {
     fraction = 0.0;
-    text = g_strdup (_("no info"));
+    text = g_strdup (_("unknown"));
   } else {
-    text = g_strdup_printf ("%d%%", (int) (fraction * 100));
+    text = g_strdup_printf ("%d%%", (int) (fraction));
   }
 
   gdk_threads_enter ();  
@@ -492,14 +493,14 @@ xfburn_progress_dialog_set_buffer_bar_min_fill (XfburnProgressDialog * dialog, g
   XfburnProgressDialogPrivate *priv = XFBURN_PROGRESS_DIALOG_GET_PRIVATE (dialog);
   gchar *text = NULL;
 
-  if (fraction > 1.0) {
-    fraction = 1.0;
+  if (fraction > 100.0) {
+    fraction = 100.0;
     text = g_strdup ("100%");
   } else if (fraction < 0.0) {
     fraction = 0.0;
-    text = g_strdup (_("no info"));
+    text = g_strdup (_("unknown"));
   } else {
-    text = g_strdup_printf (_("Min. fill was %2d%%"), (int) (fraction * 100));
+    text = g_strdup_printf (_("Min. fill was %2d%%"), (int) (fraction));
   }
 
   gdk_threads_enter ();    
@@ -516,14 +517,14 @@ xfburn_progress_dialog_set_fifo_bar_fraction (XfburnProgressDialog * dialog, gdo
   XfburnProgressDialogPrivate *priv = XFBURN_PROGRESS_DIALOG_GET_PRIVATE (dialog);
   gchar *text = NULL;
 
-  if (fraction > 1.0) {
-    fraction = 1.0;
+  if (fraction > 100.0) {
+    fraction = 100.0;
     text = g_strdup ("100%");
   } else if (fraction < 0.0) {
     fraction = 0.0;
-    text = g_strdup (_("no info"));
+    text = g_strdup (_("unknown"));
   } else {
-    text = g_strdup_printf ("%d%%", (int) (fraction * 100));
+    text = g_strdup_printf ("%d%%", (int) (fraction));
   }
   
   gdk_threads_enter ();
@@ -549,17 +550,20 @@ void
 xfburn_progress_dialog_set_progress_bar_fraction (XfburnProgressDialog * dialog, gdouble fraction)
 {
   XfburnProgressDialogPrivate *priv = XFBURN_PROGRESS_DIALOG_GET_PRIVATE (dialog);
-  gdouble cur_fraction = 0;
+  gdouble cur_fraction = 0.0;
   gchar *text = NULL;
 
   cur_fraction = gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (priv->progress_bar));
 
-  if (fraction >= 1.0) {
-    fraction = 1.0;
+  if (fraction >= 100.0) {
+    fraction = 100.0;
     switch (priv->status) {
     case XFBURN_PROGRESS_DIALOG_STATUS_STOPPING:
       text = g_strdup (_("Aborted"));
       break;
+    case XFBURN_PROGRESS_DIALOG_STATUS_FORMATTING:
+      text = g_strdup (_("Formatted."));
+      break;
     case XFBURN_PROGRESS_DIALOG_STATUS_RUNNING:
       text = g_strdup ("100%");
       break;
@@ -583,10 +587,10 @@ xfburn_progress_dialog_set_progress_bar_fraction (XfburnProgressDialog * dialog,
   }
   else if (priv->status == XFBURN_PROGRESS_DIALOG_STATUS_RUNNING && fraction >= cur_fraction) {
     if (priv->animate) {
-      text = g_strdup_printf ("%2d%% %c", (int) (fraction * 100), animation[priv->ani_index]);
+      text = g_strdup_printf ("%2d%% %c", (int) (fraction), animation[priv->ani_index]);
       priv->ani_index = (priv->ani_index + 1) % 4;
     } else {
-      text = g_strdup_printf ("%d%%  ", (int) (fraction * 100));
+      text = g_strdup_printf ("%d%%  ", (int) (fraction));
     }
   }
   else if (fraction < cur_fraction) {
@@ -618,7 +622,7 @@ xfburn_progress_dialog_set_status (XfburnProgressDialog * dialog, XfburnProgress
     gtk_widget_set_sensitive (priv->button_close, TRUE);
     gdk_threads_leave ();
 
-    xfburn_progress_dialog_set_progress_bar_fraction (dialog, 1.0);
+    xfburn_progress_dialog_set_progress_bar_fraction (dialog, 100.0);
   }
 }
 
diff --git a/xfburn/xfburn-progress-dialog.h b/xfburn/xfburn-progress-dialog.h
index 386c9f8..bec5161 100644
--- a/xfburn/xfburn-progress-dialog.h
+++ b/xfburn/xfburn-progress-dialog.h
@@ -32,6 +32,7 @@ G_BEGIN_DECLS
 #define XFBURN_TYPE_PROGRESS_DIALOG_STATUS (xfburn_progress_dialog_status_get_type ())
 typedef enum
 {
+  XFBURN_PROGRESS_DIALOG_STATUS_FORMATTING,
   XFBURN_PROGRESS_DIALOG_STATUS_STOPPING,
   XFBURN_PROGRESS_DIALOG_STATUS_RUNNING,
   XFBURN_PROGRESS_DIALOG_STATUS_META_DONE,

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list