Move Diskstream ownership to Track, so that Session no longer holds lists of Diskstre...
[ardour.git] / gtk2_ardour / editor_ops.cc
index f9022a04ff6d1dd243323ccb2830cc76a14aa829..7f3aa7f7a84347feef185d86eb0fb86b05e562c7 100644 (file)
@@ -79,6 +79,7 @@
 #include "editor_routes.h"
 #include "editor_regions.h"
 #include "quantize_dialog.h"
+#include "interthread_progress_window.h"
 
 #include "i18n.h"
 
@@ -636,8 +637,8 @@ Editor::build_region_boundary_cache ()
                        RouteTimeAxisView *rtav;
 
                        if (ontrack != 0 && (rtav = dynamic_cast<RouteTimeAxisView*>(ontrack)) != 0 ) {
-                               if (rtav->get_diskstream() != 0) {
-                                       speed = rtav->get_diskstream()->speed();
+                               if (rtav->track() != 0) {
+                                       speed = rtav->track()->speed();
                                }
                        }
 
@@ -691,8 +692,8 @@ Editor::find_next_region (nframes64_t frame, RegionPoint point, int32_t dir, Tra
 
                track_speed = 1.0f;
                if ( (rtav = dynamic_cast<RouteTimeAxisView*>(*i)) != 0 ) {
-                       if (rtav->get_diskstream()!=0)
-                               track_speed = rtav->get_diskstream()->speed();
+                       if (rtav->track()!=0)
+                               track_speed = rtav->track()->speed();
                }
 
                track_frame = session_frame_to_track_frame(frame, track_speed);
@@ -892,8 +893,8 @@ Editor::cursor_to_region_point (EditorCursor* cursor, RegionPoint point, int32_t
        RouteTimeAxisView *rtav;
 
        if ( ontrack != 0 && (rtav = dynamic_cast<RouteTimeAxisView*>(ontrack)) != 0 ) {
-               if (rtav->get_diskstream() != 0) {
-                       speed = rtav->get_diskstream()->speed();
+               if (rtav->track() != 0) {
+                       speed = rtav->track()->speed();
                }
        }
 
@@ -1089,8 +1090,8 @@ Editor::selected_marker_to_region_point (RegionPoint point, int32_t dir)
        RouteTimeAxisView *rtav;
 
        if (ontrack != 0 && (rtav = dynamic_cast<RouteTimeAxisView*>(ontrack)) != 0) {
-               if (rtav->get_diskstream() != 0) {
-                       speed = rtav->get_diskstream()->speed();
+               if (rtav->track() != 0) {
+                       speed = rtav->track()->speed();
                }
        }
 
@@ -2602,39 +2603,6 @@ Editor::audition_playlist_region_standalone (boost::shared_ptr<Region> region)
        _session->audition_region (region);
 }
 
-void
-Editor::build_interthread_progress_window ()
-{
-       interthread_progress_window = new ArdourDialog (X_("interthread progress"), true);
-
-       interthread_progress_bar.set_orientation (Gtk::PROGRESS_LEFT_TO_RIGHT);
-
-       interthread_progress_window->set_border_width (12);
-       interthread_progress_window->get_vbox()->set_spacing (6);
-
-       interthread_progress_label.set_alignment (0.5, 0.5);
-
-       interthread_progress_window->get_vbox()->pack_start (interthread_progress_label, false, false);
-       interthread_progress_window->get_vbox()->pack_start (interthread_progress_bar,false, false);
-
-       // GTK2FIX: this button needs a modifiable label
-
-       Button* b = interthread_progress_window->add_button (Stock::CANCEL, RESPONSE_CANCEL);
-       b->signal_clicked().connect (sigc::mem_fun(*this, &Editor::interthread_cancel_clicked));
-
-       interthread_cancel_button.add (interthread_cancel_label);
-
-       interthread_progress_window->set_default_size (200, 100);
-}
-
-void
-Editor::interthread_cancel_clicked ()
-{
-       if (current_interthread_info) {
-               current_interthread_info->cancel = true;
-       }
-}
-
 void
 Editor::region_from_selection ()
 {
@@ -2814,7 +2782,7 @@ Editor::separate_regions_between (const TimeSelection& ts)
 
                                /* no edits to destructive tracks */
 
-                               if (rtv->track()->diskstream()->destructive()) {
+                               if (rtv->track()->destructive()) {
                                        continue;
                                }
 
@@ -2824,7 +2792,7 @@ Editor::separate_regions_between (const TimeSelection& ts)
 
                                        /* XXX need to consider musical time selections here at some point */
 
-                                       double speed = rtv->get_diskstream()->speed();
+                                       double speed = rtv->track()->speed();
 
 
                                        for (list<AudioRange>::const_iterator t = ts.begin(); t != ts.end(); ++t) {
@@ -2971,7 +2939,7 @@ Editor::crop_region_to (nframes64_t start, nframes64_t end)
 
                        boost::shared_ptr<Track> t = rtv->track();
 
-                       if (t != 0 && ! t->diskstream()->destructive()) {
+                       if (t != 0 && ! t->destructive()) {
 
                                if ((playlist = rtv->playlist()) != 0) {
                                        playlists.push_back (playlist);
@@ -3443,8 +3411,8 @@ Editor::trim_region_to_location (const Location& loc, const char* str)
                nframes64_t start;
                nframes64_t end;
 
-               if (tav->get_diskstream() != 0) {
-                       speed = tav->get_diskstream()->speed();
+               if (tav->track() != 0) {
+                       speed = tav->track()->speed();
                }
 
                start = session_frame_to_track_frame (loc.start(), speed);
@@ -3484,8 +3452,8 @@ Editor::trim_region_to_edit_point ()
 
                float speed = 1.0;
 
-               if (tav->get_diskstream() != 0) {
-                       speed = tav->get_diskstream()->speed();
+               if (tav->track() != 0) {
+                       speed = tav->track()->speed();
                }
 
                 rv->region()->clear_history ();
@@ -3522,8 +3490,8 @@ Editor::trim_region_from_edit_point ()
 
                float speed = 1.0;
 
-               if (tav->get_diskstream() != 0) {
-                       speed = tav->get_diskstream()->speed();
+               if (tav->track() != 0) {
+                       speed = tav->track()->speed();
                }
 
                 rv->region()->clear_history ();
@@ -3573,8 +3541,8 @@ Editor::trim_to_region(bool forward)
 
                float speed = 1.0;
 
-               if (atav->get_diskstream() != 0) {
-                       speed = atav->get_diskstream()->speed();
+               if (atav->track() != 0) {
+                       speed = atav->track()->speed();
                }
 
 
@@ -3639,13 +3607,6 @@ Editor::freeze_thread ()
        return 0;
 }
 
-gint
-Editor::freeze_progress_timeout (void */*arg*/)
-{
-       interthread_progress_bar.set_fraction (current_interthread_info->progress);
-       return !(current_interthread_info->done || current_interthread_info->cancel);
-}
-
 void
 Editor::freeze_route ()
 {
@@ -3654,21 +3615,9 @@ Editor::freeze_route ()
        }
 
        InterThreadInfo itt;
-
-       if (interthread_progress_window == 0) {
-               build_interthread_progress_window ();
-       }
-
-       interthread_progress_window->set_title (_("Freeze"));
-       interthread_progress_window->set_position (Gtk::WIN_POS_MOUSE);
-       interthread_progress_window->show_all ();
-       interthread_progress_bar.set_fraction (0.0f);
-       interthread_progress_label.set_text ("");
-       interthread_cancel_label.set_text (_("Cancel Freeze"));
        current_interthread_info = &itt;
 
-       interthread_progress_connection =
-         Glib::signal_timeout().connect (sigc::bind (sigc::mem_fun(*this, &Editor::freeze_progress_timeout), (gpointer) 0), 100);
+       InterthreadProgressWindow ipw (current_interthread_info, _("Freeze"), _("Cancel Freeze"));
 
        itt.done = false;
        itt.cancel = false;
@@ -3682,8 +3631,6 @@ Editor::freeze_route ()
                gtk_main_iteration ();
        }
 
-       interthread_progress_connection.disconnect ();
-       interthread_progress_window->hide_all ();
        current_interthread_info = 0;
        track_canvas->get_window()->set_cursor (*current_canvas_cursor);
 }
@@ -5990,9 +5937,9 @@ Editor::tab_to_transient (bool forward)
                        RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*t);
 
                        if (rtv) {
-                               boost::shared_ptr<Diskstream> ds = rtv->get_diskstream();
-                               if (ds) {
-                                       boost::shared_ptr<Playlist> pl = rtv->get_diskstream()->playlist ();
+                               boost::shared_ptr<Track> tr = rtv->track();
+                               if (tr) {
+                                       boost::shared_ptr<Playlist> pl = tr->playlist ();
                                        if (pl) {
                                                nframes64_t result = pl->find_next_transient (pos, forward ? 1 : -1);