From badc087263990ecf360792c10e4d9f2d60828d43 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 8 Nov 2007 01:40:25 +0000 Subject: merged with 2.0-ongoing changes 2582-2605 (not thoroughly tested but it compiles, start up, and creates a new session) git-svn-id: svn://localhost/ardour2/trunk@2606 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/editor_timefx.cc | 51 +++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 22 deletions(-) (limited to 'gtk2_ardour/editor_timefx.cc') diff --git a/gtk2_ardour/editor_timefx.cc b/gtk2_ardour/editor_timefx.cc index 2efdc03f8f..df0a73c965 100644 --- a/gtk2_ardour/editor_timefx.cc +++ b/gtk2_ardour/editor_timefx.cc @@ -39,6 +39,7 @@ #include #include #include +#include #include "i18n.h" @@ -87,29 +88,29 @@ gint Editor::TimeStretchDialog::update_progress () { progress_bar.set_fraction (request.progress); - return request.running; + return !request.done; } void Editor::TimeStretchDialog::cancel_timestretch_in_progress () { status = -2; - request.running = false; + request.cancel = true; + first_cancel.disconnect(); } gint Editor::TimeStretchDialog::delete_timestretch_in_progress (GdkEventAny* ev) { status = -2; - request.running = false; + request.cancel = true; + first_delete.disconnect(); return TRUE; } int Editor::run_timestretch (RegionSelection& regions, float fraction) { - pthread_t thread; - if (current_timestretch == 0) { current_timestretch = new TimeStretchDialog (*this); } @@ -130,27 +131,30 @@ Editor::run_timestretch (RegionSelection& regions, float fraction) current_timestretch->request.quick_seek = current_timestretch->quick_button.get_active(); current_timestretch->request.antialias = !current_timestretch->antialias_button.get_active(); current_timestretch->request.progress = 0.0f; - current_timestretch->request.running = true; + current_timestretch->request.done = false; + current_timestretch->request.cancel = false; /* re-connect the cancel button and delete events */ current_timestretch->first_cancel.disconnect(); current_timestretch->first_delete.disconnect(); - current_timestretch->cancel_button->signal_clicked().connect (mem_fun (current_timestretch, &TimeStretchDialog::cancel_timestretch_in_progress)); - current_timestretch->signal_delete_event().connect (mem_fun (current_timestretch, &TimeStretchDialog::delete_timestretch_in_progress)); + current_timestretch->first_cancel = current_timestretch->cancel_button->signal_clicked().connect + (mem_fun (current_timestretch, &TimeStretchDialog::cancel_timestretch_in_progress)); + current_timestretch->first_delete = current_timestretch->signal_delete_event().connect + (mem_fun (current_timestretch, &TimeStretchDialog::delete_timestretch_in_progress)); - if (pthread_create_and_store ("timestretch", &thread, 0, timestretch_thread, current_timestretch)) { + if (pthread_create_and_store ("timestretch", ¤t_timestretch->request.thread, 0, timestretch_thread, current_timestretch)) { current_timestretch->hide (); error << _("timestretch cannot be started - thread creation error") << endmsg; return -1; } - pthread_detach (thread); + pthread_detach (current_timestretch->request.thread); sigc::connection c = Glib::signal_timeout().connect (mem_fun (current_timestretch, &TimeStretchDialog::update_progress), 100); - while (current_timestretch->request.running) { + while (!current_timestretch->request.done) { gtk_main_iteration (); } @@ -195,31 +199,34 @@ Editor::do_timestretch (TimeStretchDialog& dialog) continue; } - dialog.request.region = region; - - if (!dialog.request.running) { + if (dialog.request.cancel) { /* we were cancelled */ dialog.status = 1; return; } - if ((new_region = session->tempoize_region (dialog.request)) == 0) { + Stretch stretch (*session, dialog.request); + + if (stretch.run (region)) { dialog.status = -1; - dialog.request.running = false; + dialog.request.done = true; return; } - XMLNode &before = playlist->get_state(); - playlist->replace_region (region, new_region, region->position()); - XMLNode &after = playlist->get_state(); - session->add_command (new MementoCommand(*playlist, &before, &after)); + if (!stretch.results.empty()) { + new_region = stretch.results.front(); + + XMLNode &before = playlist->get_state(); + playlist->replace_region (region, new_region, region->position()); + XMLNode &after = playlist->get_state(); + session->add_command (new MementoCommand(*playlist, &before, &after)); + } i = tmp; } dialog.status = 0; - dialog.request.running = false; - dialog.request.region.reset (); + dialog.request.done = true; } void* -- cgit v1.2.3