Fix #4094: show total export progress instead of per timespan progress
authorSakari Bergen <sakari.bergen@beatwaves.net>
Sat, 11 Jun 2011 21:12:24 +0000 (21:12 +0000)
committerSakari Bergen <sakari.bergen@beatwaves.net>
Sat, 11 Jun 2011 21:12:24 +0000 (21:12 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@9710 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/export_dialog.cc
libs/ardour/ardour/export_graph_builder.h
libs/ardour/ardour/export_status.h
libs/ardour/export_handler.cc
libs/ardour/export_status.cc

index e51f5771d3c32f011c8a77fa51f38c144a836e64..50796f2fccd4bc092ebbcd00a806e7d8f8b7f88d 100644 (file)
@@ -328,26 +328,15 @@ ExportDialog::show_progress ()
 gint
 ExportDialog::progress_timeout ()
 {
-       switch (status->stage) {
-         case export_None:
-               progress_label.set_text ("");
-               break;
-         case export_ReadTimespan:
-               progress_label.set_text (string_compose (_("Reading timespan %1 of %2"), status->timespan, status->total_timespans));
-               break;
-         case export_PostProcess:
-               progress_label.set_text (string_compose (_("Processing file %2 of %3 (%1) from timespan %4 of %5"),
-                                                        file_notebook->get_nth_format_name (status->format),
-                                                        status->format, status->total_formats,
-                                                        status->timespan, status->total_timespans));
-               break;
-         case export_Write:
-               progress_label.set_text (string_compose (_("Encoding file %2 of %3 (%1) from timespan %4 of %5"),
-                                                        file_notebook->get_nth_format_name (status->format),
-                                                        status->format, status->total_formats,
-                                                        status->timespan, status->total_timespans));
-               break;
+       std::string status_text;
+       if (status->normalizing) {
+                status_text = string_compose (_("Normalizing timespan %1 of %2"),
+                                              status->timespan, status->total_timespans);
+       } else {
+               status_text = string_compose (_("Exporting timespan %1 of %2"),
+                                             status->timespan, status->total_timespans);
        }
+       progress_label.set_text (status_text);
 
        progress_bar.set_fraction (status->progress);
        return TRUE;
index bce6838d02a28547bb55eb1fd55a9db3987e0c24..b4ef0a1d94a6f95d5bb16169485fcfd030b9ba90 100644 (file)
@@ -63,6 +63,7 @@ class ExportGraphBuilder
 
        int process (framecnt_t frames, bool last_cycle);
        bool process_normalize (); // returns true when finished
+       bool will_normalize() { return !normalizers.empty(); }
 
        void reset ();
        void set_current_timespan (boost::shared_ptr<ExportTimespan> span);
index 1613fffe525377db80f341ec0c27257ae92b3445..a42327c8aae0d421ceccabcbb0890d53de863648 100644 (file)
 #define __ardour_export_status_h__
 
 #include <list>
-#include "pbd/signals.h"
-
 #include <stdint.h>
 
+#include "ardour/types.h"
+
+#include "pbd/signals.h"
+
 namespace ARDOUR
 {
 
-enum ExportStage {
-       export_None,
-       export_ReadTimespan,
-       export_PostProcess,
-       export_Write
-};
-
 struct ExportStatus {
 
        ExportStatus ();
@@ -57,17 +52,14 @@ struct ExportStatus {
 
        /* Progress info */
 
-       volatile ExportStage    stage;
        volatile float          progress;
+       volatile bool           normalizing;
 
        volatile uint32_t       total_timespans;
        volatile uint32_t       timespan;
 
-       volatile uint32_t       total_channel_configs;
-       volatile uint32_t       channel_config;
-
-       volatile uint32_t       total_formats;
-       volatile uint32_t       format;
+       volatile framecnt_t     total_frames;
+       volatile framecnt_t     processed_frames;
 
   private:
        volatile bool          _aborted;
index 9279c73266bc1aeaee2c28bdc7613788ce9d2576..f34e8c326b498f5144316e10b47c59a3ef3ab9f0 100644 (file)
@@ -138,6 +138,7 @@ ExportHandler::do_export (bool rt)
        std::set<ExportTimespanPtr> timespan_set;
        for (ConfigMap::iterator it = config_map.begin(); it != config_map.end(); ++it) {
                timespan_set.insert (it->first);
+               export_status->total_frames += it->first->get_length();
        }
        export_status->total_timespans = timespan_set.size();
 
@@ -198,7 +199,6 @@ ExportHandler::process_timespan (framecnt_t frames)
        /* update position */
 
        framecnt_t frames_to_read = 0;
-       framepos_t const start = current_timespan->get_start();
        framepos_t const end = current_timespan->get_end();
 
        bool const last_cycle = (process_position + frames >= end);
@@ -212,7 +212,8 @@ ExportHandler::process_timespan (framecnt_t frames)
        }
 
        process_position += frames_to_read;
-       export_status->progress = (float) (process_position - start) / (end - start);
+       export_status->processed_frames += frames_to_read;
+       export_status->progress = (float) export_status->processed_frames / export_status->total_frames;
 
        /* Do actual processing */
 
@@ -224,6 +225,9 @@ ExportHandler::process_normalize ()
 {
        if (graph_builder->process_normalize ()) {
                finish_timespan ();
+               export_status->normalizing = false;
+       } else {
+               export_status->normalizing = true;
        }
 
        return 0;
index eb0a3504b45e0e19a372eba79add08467c710026..dbb96432ee5fb68aac8eded0611d069d51d68c6a 100644 (file)
@@ -37,17 +37,14 @@ ExportStatus::init ()
        _finished = false;
        _errors = false;
 
-       stage = export_None;
        progress = 0.0;
+       normalizing = false;
 
        total_timespans = 0;
        timespan = 0;
 
-       total_channel_configs = 0;
-       channel_config = 0;
-
-       total_formats = 0;
-       format = 0;
+       total_frames = 0;
+       processed_frames = 0;
 }
 
 void