Go back to one progress bar with several passes in export.

Don't calculate the progress bar position in the engine, let the UI decide. 
Work around progress bar bug (not verified, as I could not reproduce).


git-svn-id: svn://localhost/ardour2/branches/3.0@11377 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Sakari Bergen 2012-01-28 18:14:19 +00:00
parent ab8cea1d7c
commit db384a6f14
5 changed files with 30 additions and 26 deletions

View file

@ -125,10 +125,6 @@ ExportDialog::init ()
progress_widget.pack_start (progress_label, false, false, 6); progress_widget.pack_start (progress_label, false, false, 6);
progress_widget.pack_start (progress_bar, false, false, 6); progress_widget.pack_start (progress_bar, false, false, 6);
progress_widget.pack_start (normalizing_widget, false, false, 0);
normalizing_widget.pack_start (normalizing_label, false, false, 6);
normalizing_widget.pack_start (normalizing_bar, false, false, 6);
/* Buttons */ /* Buttons */
cancel_button = add_button (Gtk::Stock::CANCEL, RESPONSE_CANCEL); cancel_button = add_button (Gtk::Stock::CANCEL, RESPONSE_CANCEL);
@ -314,7 +310,6 @@ ExportDialog::show_progress ()
warning_widget.hide_all(); warning_widget.hide_all();
progress_widget.show (); progress_widget.show ();
progress_widget.show_all_children (); progress_widget.show_all_children ();
normalizing_widget.hide();
progress_connection = Glib::signal_timeout().connect (sigc::mem_fun(*this, &ExportDialog::progress_timeout), 100); progress_connection = Glib::signal_timeout().connect (sigc::mem_fun(*this, &ExportDialog::progress_timeout), 100);
gtk_main_iteration (); gtk_main_iteration ();
@ -334,20 +329,27 @@ ExportDialog::show_progress ()
gint gint
ExportDialog::progress_timeout () ExportDialog::progress_timeout ()
{ {
std::string status_text;
float progress = 0.0;
if (status->normalizing) { if (status->normalizing) {
normalizing_widget.show(); status_text = string_compose (_("Normalizing timespan %1 of %2"),
normalizing_label.set_text (string_compose (_("Normalizing timespan %1 of %2"), status->timespan, status->total_timespans);
status->timespan, status->total_timespans)); progress = ((float) status->current_normalize_cycle) / status->total_normalize_cycles;
normalizing_bar.set_fraction (status->progress);
} else { } else {
normalizing_bar.set_fraction (0); status_text = string_compose (_("Exporting timespan %1 of %2"),
normalizing_label.set_text (""); status->timespan, status->total_timespans);
progress = ((float) status->processed_frames_current_timespan) / status->total_frames_current_timespan;
progress_label.set_text (string_compose (_("Exporting timespan %1 of %2"),
status->timespan, status->total_timespans));
progress_bar.set_fraction (status->progress);
} }
progress_label.set_text (status_text);
if (progress < previous_progress) {
// Work around gtk bug
progress_bar.hide();
progress_bar.show();
}
previous_progress = progress;
progress_bar.set_fraction (progress);
return TRUE; return TRUE;
} }

View file

@ -131,11 +131,7 @@ class ExportDialog : public ArdourDialog {
Gtk::ProgressBar progress_bar; Gtk::ProgressBar progress_bar;
sigc::connection progress_connection; sigc::connection progress_connection;
/* Normalizing */ float previous_progress; // Needed for gtk bug workaround
Gtk::VBox normalizing_widget;
Gtk::Label normalizing_label;
Gtk::ProgressBar normalizing_bar;
/* Buttons */ /* Buttons */

View file

@ -52,7 +52,6 @@ struct ExportStatus {
/* Progress info */ /* Progress info */
volatile float progress;
volatile bool normalizing; volatile bool normalizing;
volatile uint32_t total_timespans; volatile uint32_t total_timespans;
@ -61,6 +60,9 @@ struct ExportStatus {
volatile framecnt_t total_frames; volatile framecnt_t total_frames;
volatile framecnt_t processed_frames; volatile framecnt_t processed_frames;
volatile framecnt_t total_frames_current_timespan;
volatile framecnt_t processed_frames_current_timespan;
volatile uint32_t total_normalize_cycles; volatile uint32_t total_normalize_cycles;
volatile uint32_t current_normalize_cycle; volatile uint32_t current_normalize_cycle;

View file

@ -163,6 +163,8 @@ ExportHandler::start_timespan ()
} }
current_timespan = config_map.begin()->first; current_timespan = config_map.begin()->first;
export_status->total_frames_current_timespan = current_timespan->get_length();
export_status->processed_frames_current_timespan = 0;
/* Register file configurations to graph builder */ /* Register file configurations to graph builder */
@ -215,8 +217,7 @@ ExportHandler::process_timespan (framecnt_t frames)
process_position += frames_to_read; process_position += frames_to_read;
export_status->processed_frames += frames_to_read; export_status->processed_frames += frames_to_read;
export_status->progress = (float) export_status->processed_frames / export_status->processed_frames_current_timespan += frames_to_read;
export_status->total_frames;
/* Do actual processing */ /* Do actual processing */
int ret = graph_builder->process (frames_to_read, last_cycle); int ret = graph_builder->process (frames_to_read, last_cycle);
@ -246,8 +247,6 @@ ExportHandler::process_normalize ()
export_status->normalizing = true; export_status->normalizing = true;
} }
export_status->progress = (float) export_status->current_normalize_cycle /
export_status->total_normalize_cycles;
export_status->current_normalize_cycle++; export_status->current_normalize_cycle++;
return 0; return 0;

View file

@ -37,7 +37,6 @@ ExportStatus::init ()
_finished = false; _finished = false;
_errors = false; _errors = false;
progress = 0.0;
normalizing = false; normalizing = false;
total_timespans = 0; total_timespans = 0;
@ -45,6 +44,12 @@ ExportStatus::init ()
total_frames = 0; total_frames = 0;
processed_frames = 0; processed_frames = 0;
total_frames_current_timespan = 0;
processed_frames_current_timespan = 0;
total_normalize_cycles = 0;
current_normalize_cycle = 0;
} }
void void