From 061a85191c301ac18f2e8ca59d43127a4499ba96 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 21 Apr 2010 20:42:22 +0000 Subject: Move Diskstream ownership to Track, so that Session no longer holds lists of Diskstreams. Breaks 3.0 file format again. git-svn-id: svn://localhost/ardour2/branches/3.0@6945 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/ardour_ui.cc | 8 +- gtk2_ardour/audio_region_view.cc | 9 +- gtk2_ardour/audio_streamview.cc | 52 +++--- gtk2_ardour/audio_streamview.h | 9 +- gtk2_ardour/audio_time_axis.cc | 1 - gtk2_ardour/audio_time_axis.h | 1 - gtk2_ardour/automation_streamview.cc | 4 +- gtk2_ardour/automation_streamview.h | 2 +- gtk2_ardour/editor.cc | 30 ++-- gtk2_ardour/editor.h | 1 - gtk2_ardour/editor_audio_import.cc | 6 +- gtk2_ardour/editor_canvas.cc | 2 +- gtk2_ardour/editor_canvas_events.cc | 3 +- gtk2_ardour/editor_drag.cc | 16 +- gtk2_ardour/editor_export_audio.cc | 4 +- gtk2_ardour/editor_mouse.cc | 12 +- gtk2_ardour/editor_ops.cc | 44 ++--- gtk2_ardour/editor_routes.cc | 3 +- gtk2_ardour/editor_selection.cc | 13 +- gtk2_ardour/editor_timefx.cc | 5 +- gtk2_ardour/midi_region_view.cc | 9 +- gtk2_ardour/midi_streamview.cc | 29 ++- gtk2_ardour/midi_streamview.h | 5 +- gtk2_ardour/midi_time_axis.cc | 9 +- gtk2_ardour/mixer_strip.cc | 2 +- gtk2_ardour/mixer_ui.cc | 1 - gtk2_ardour/mixer_ui.h | 1 - gtk2_ardour/playlist_selector.cc | 38 ++-- gtk2_ardour/playlist_selector.h | 4 +- gtk2_ardour/processor_box.cc | 1 - gtk2_ardour/route_time_axis.cc | 147 +++++++-------- gtk2_ardour/route_time_axis.h | 2 - gtk2_ardour/route_ui.cc | 16 +- gtk2_ardour/route_ui.h | 2 - gtk2_ardour/streamview.cc | 56 +++--- gtk2_ardour/streamview.h | 12 +- gtk2_ardour/tape_region_view.cc | 1 - gtk2_ardour/time_fx_dialog.cc | 1 - libs/ardour/ardour/audio_diskstream.h | 2 +- libs/ardour/ardour/audio_track.h | 3 + libs/ardour/ardour/diskstream.h | 26 +-- libs/ardour/ardour/midi_diskstream.h | 2 +- libs/ardour/ardour/midi_track.h | 3 + libs/ardour/ardour/playlist.h | 1 + libs/ardour/ardour/public_diskstream.h | 80 +++++++++ libs/ardour/ardour/route.h | 2 +- libs/ardour/ardour/session.h | 51 +++--- libs/ardour/ardour/session_event.h | 2 +- libs/ardour/ardour/track.h | 67 ++++++- libs/ardour/audio_diskstream.cc | 17 +- libs/ardour/audio_track.cc | 69 +++----- libs/ardour/audio_track_importer.cc | 3 +- libs/ardour/butler.cc | 37 ++-- libs/ardour/diskstream.cc | 37 ++-- libs/ardour/enums.cc | 2 +- libs/ardour/midi_diskstream.cc | 13 +- libs/ardour/midi_track.cc | 63 +++---- libs/ardour/playlist.cc | 4 +- libs/ardour/session.cc | 314 ++++++++++----------------------- libs/ardour/session_butler.cc | 20 ++- libs/ardour/session_export.cc | 10 +- libs/ardour/session_process.cc | 37 ++-- libs/ardour/session_state.cc | 213 ++++++++++++---------- libs/ardour/session_transport.cc | 244 +++++++++++++------------ libs/ardour/track.cc | 298 ++++++++++++++++++++++++++++++- 65 files changed, 1238 insertions(+), 943 deletions(-) create mode 100755 libs/ardour/ardour/public_diskstream.h diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 0944686f4e..2613faa11e 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -934,7 +934,7 @@ void ARDOUR_UI::count_recenabled_streams (Route& route) { Track* track = dynamic_cast(&route); - if (track && track->diskstream()->record_enabled()) { + if (track && track->record_enabled()) { rec_enabled_streams += track->n_inputs().n_total(); } } @@ -1701,7 +1701,7 @@ ARDOUR_UI::toggle_record_enable (uint32_t dstream) Track* t; if ((t = dynamic_cast(r.get())) != 0) { - t->diskstream()->set_record_enabled (!t->diskstream()->record_enabled()); + t->set_record_enabled (!t->record_enabled()); } } if (_session == 0) { @@ -2102,7 +2102,7 @@ ARDOUR_UI::transport_rec_enable_blink (bool onoff) } Session::RecordState const r = _session->record_status (); - bool const h = _session->have_rec_enabled_diskstream (); + bool const h = _session->have_rec_enabled_track (); if (r == Session::Enabled || (r == Session::Recording && !h)) { if (onoff) { @@ -3399,7 +3399,7 @@ ARDOUR_UI::record_state_changed () } Session::RecordState const r = _session->record_status (); - bool const h = _session->have_rec_enabled_diskstream (); + bool const h = _session->have_rec_enabled_track (); if (r == Session::Recording && h) { big_clock.set_widget_name ("BigClockRecording"); diff --git a/gtk2_ardour/audio_region_view.cc b/gtk2_ardour/audio_region_view.cc index 13e21b9a63..394751b88c 100644 --- a/gtk2_ardour/audio_region_view.cc +++ b/gtk2_ardour/audio_region_view.cc @@ -27,7 +27,6 @@ #include "ardour/playlist.h" #include "ardour/audioregion.h" #include "ardour/audiosource.h" -#include "ardour/audio_diskstream.h" #include "ardour/profile.h" #include "ardour/session.h" @@ -847,11 +846,11 @@ AudioRegionView::create_waves () // cerr << "AudioRegionView::create_waves() called on " << this << endl;//DEBUG RouteTimeAxisView& atv (*(dynamic_cast(&trackview))); // ick - if (!atv.get_diskstream()) { + if (!atv.track()) { return; } - ChanCount nchans = atv.get_diskstream()->n_channels(); + ChanCount nchans = atv.track()->n_channels(); // cerr << "creating waves for " << _region->name() << " with wfd = " << wait_for_data // << " and channels = " << nchans.n_audio() << endl; @@ -894,7 +893,7 @@ AudioRegionView::create_one_wave (uint32_t which, bool /*direct*/) { //cerr << "AudioRegionView::create_one_wave() called which: " << which << " this: " << this << endl;//DEBUG RouteTimeAxisView& atv (*(dynamic_cast(&trackview))); // ick - uint32_t nchans = atv.get_diskstream()->n_channels().n_audio(); + uint32_t nchans = atv.track()->n_channels().n_audio(); uint32_t n; uint32_t nwaves = std::min (nchans, audio_region()->n_channels()); gdouble ht; @@ -1163,7 +1162,7 @@ AudioRegionView::add_ghost (TimeAxisView& tv) AudioGhostRegion* ghost = new AudioGhostRegion (tv, trackview, unit_position); uint32_t nchans; - nchans = rtv->get_diskstream()->n_channels().n_audio(); + nchans = rtv->track()->n_channels().n_audio(); for (uint32_t n = 0; n < nchans; ++n) { diff --git a/gtk2_ardour/audio_streamview.cc b/gtk2_ardour/audio_streamview.cc index 80498f5a7e..7c76cd7876 100644 --- a/gtk2_ardour/audio_streamview.cc +++ b/gtk2_ardour/audio_streamview.cc @@ -29,7 +29,6 @@ #include "ardour/audioplaylist.h" #include "ardour/audioregion.h" #include "ardour/audiofilesource.h" -#include "ardour/audio_diskstream.h" #include "ardour/audio_track.h" #include "ardour/source.h" #include "ardour/region_factory.h" @@ -230,9 +229,9 @@ AudioStreamView::remove_region_view (boost::weak_ptr weak_r) } void -AudioStreamView::undisplay_diskstream () +AudioStreamView::undisplay_track () { - StreamView::undisplay_diskstream(); + StreamView::undisplay_track (); for (CrossfadeViewList::iterator i = crossfade_views.begin(); i != crossfade_views.end(); ++i) { delete i->second; @@ -242,15 +241,15 @@ AudioStreamView::undisplay_diskstream () } void -AudioStreamView::playlist_layered (boost::weak_ptr wds) +AudioStreamView::playlist_layered (boost::weak_ptr wtr) { - boost::shared_ptr ds (wds.lock()); + boost::shared_ptr tr (wtr.lock()); - if (!ds) { + if (!tr) { return; } - StreamView::playlist_layered (wds); + StreamView::playlist_layered (wtr); /* make sure xfades are on top and all the regionviews are stacked correctly. */ @@ -260,19 +259,19 @@ AudioStreamView::playlist_layered (boost::weak_ptr wds) } void -AudioStreamView::playlist_switched (boost::weak_ptr wds) +AudioStreamView::playlist_switched (boost::weak_ptr wtr) { - boost::shared_ptr ds (wds.lock()); + boost::shared_ptr tr (wtr.lock()); - if (!ds) { + if (!tr) { return; } playlist_connections.drop_connections (); - StreamView::playlist_switched (ds); + StreamView::playlist_switched (tr); - boost::shared_ptr apl = boost::dynamic_pointer_cast(ds->playlist()); + boost::shared_ptr apl = boost::dynamic_pointer_cast (tr->playlist()); if (apl) { apl->NewCrossfade.connect (playlist_connections, invalidator (*this), ui_bind (&AudioStreamView::add_crossfade, this, _1), gui_context()); @@ -350,7 +349,7 @@ AudioStreamView::remove_crossfade (boost::shared_ptr r) } void -AudioStreamView::redisplay_diskstream () +AudioStreamView::redisplay_track () { list::iterator i; CrossfadeViewList::iterator xi, tmpx; @@ -372,12 +371,12 @@ AudioStreamView::redisplay_diskstream () // Add and display region and crossfade views, and flag them as valid if (_trackview.is_audio_track()) { - _trackview.get_diskstream()->playlist()->foreach_region( + _trackview.track()->playlist()->foreach_region( sigc::hide_return (sigc::mem_fun (*this, &StreamView::add_region_view)) ); boost::shared_ptr apl = boost::dynamic_pointer_cast( - _trackview.get_diskstream()->playlist() + _trackview.track()->playlist() ); if (apl) { @@ -445,7 +444,7 @@ AudioStreamView::setup_rec_box () if (!rec_active && _trackview.session()->record_status() == Session::Recording && - _trackview.get_diskstream()->record_enabled()) { + _trackview.track()->record_enabled()) { if (_trackview.audio_track()->mode() == Normal && Config->get_show_waveforms_while_recording() && rec_regions.size() == rec_rects.size()) { /* add a new region, but don't bother if they set show-waveforms-while-recording mid-record */ @@ -453,10 +452,10 @@ AudioStreamView::setup_rec_box () SourceList sources; rec_data_ready_connections.drop_connections (); - boost::shared_ptr ads = _trackview.audio_track()->audio_diskstream(); + boost::shared_ptr tr = _trackview.audio_track(); - for (uint32_t n=0; n < ads->n_channels().n_audio(); ++n) { - boost::shared_ptr src = ads->write_source (n); + for (uint32_t n = 0; n < tr->n_channels().n_audio(); ++n) { + boost::shared_ptr src = tr->write_source (n); if (src) { sources.push_back (src); src->PeakRangeReady.connect (rec_data_ready_connections, @@ -471,7 +470,7 @@ AudioStreamView::setup_rec_box () nframes_t start = 0; if (rec_regions.size() > 0) { start = rec_regions.back().first->start() - + _trackview.get_diskstream()->get_captured_frames(rec_regions.size()-1); + + _trackview.track()->get_captured_frames(rec_regions.size()-1); } PropertyList plist; @@ -495,8 +494,7 @@ AudioStreamView::setup_rec_box () boost::shared_ptr at; at = _trackview.audio_track(); /* we know what it is already */ - boost::shared_ptr ds = at->audio_diskstream(); - nframes_t frame_pos = ds->current_capture_start (); + nframes_t frame_pos = at->current_capture_start (); gdouble xstart = _trackview.editor().frame_to_pixel (frame_pos); gdouble xend; uint32_t fill_color; @@ -543,7 +541,7 @@ AudioStreamView::setup_rec_box () } else if (rec_active && (_trackview.session()->record_status() != Session::Recording || - !_trackview.get_diskstream()->record_enabled())) { + !_trackview.track()->record_enabled())) { screen_update_connection.disconnect(); rec_active = false; rec_updating = false; @@ -617,7 +615,7 @@ AudioStreamView::rec_peak_range_ready (nframes_t start, nframes_t cnt, boost::we rec_data_ready_map[src] = true; - if (rec_data_ready_map.size() == _trackview.get_diskstream()->n_channels().n_audio()) { + if (rec_data_ready_map.size() == _trackview.track()->n_channels().n_audio()) { this->update_rec_regions (); rec_data_ready_map.clear(); } @@ -658,7 +656,7 @@ AudioStreamView::update_rec_regions () if (nlen != region->length()) { region->suspend_property_changes (); - region->set_position (_trackview.get_diskstream()->get_capture_start_frame(n), this); + region->set_position (_trackview.track()->get_capture_start_frame(n), this); region->set_length (nlen, this); region->resume_property_changes (); @@ -676,14 +674,14 @@ AudioStreamView::update_rec_regions () } else { - nframes_t nlen = _trackview.get_diskstream()->get_captured_frames(n); + nframes_t nlen = _trackview.track()->get_captured_frames(n); if (nlen != region->length()) { if (region->source_length(0) >= region->start() + nlen) { region->suspend_property_changes (); - region->set_position (_trackview.get_diskstream()->get_capture_start_frame(n), this); + region->set_position (_trackview.track()->get_capture_start_frame(n), this); region->set_length (nlen, this); region->resume_property_changes (); diff --git a/gtk2_ardour/audio_streamview.h b/gtk2_ardour/audio_streamview.h index 1443bd5b8f..93c74c5bb2 100644 --- a/gtk2_ardour/audio_streamview.h +++ b/gtk2_ardour/audio_streamview.h @@ -36,7 +36,6 @@ namespace Gdk { namespace ARDOUR { class Route; - class Diskstream; class Crossfade; class PeakData; class AudioRegion; @@ -85,10 +84,10 @@ class AudioStreamView : public StreamView void remove_region_view (boost::weak_ptr ); void remove_audio_region_view (boost::shared_ptr ); - void undisplay_diskstream (); - void redisplay_diskstream (); - void playlist_layered (boost::weak_ptr); - void playlist_switched (boost::weak_ptr); + void undisplay_track (); + void redisplay_track (); + void playlist_layered (boost::weak_ptr); + void playlist_switched (boost::weak_ptr); void add_crossfade (boost::weak_ptr); void remove_crossfade (boost::shared_ptr); diff --git a/gtk2_ardour/audio_time_axis.cc b/gtk2_ardour/audio_time_axis.cc index 192c9ffdcb..4a53b6fabd 100644 --- a/gtk2_ardour/audio_time_axis.cc +++ b/gtk2_ardour/audio_time_axis.cc @@ -38,7 +38,6 @@ #include #include "ardour/amp.h" -#include "ardour/audio_diskstream.h" #include "ardour/audioplaylist.h" #include "ardour/event_type_map.h" #include "ardour/location.h" diff --git a/gtk2_ardour/audio_time_axis.h b/gtk2_ardour/audio_time_axis.h index 80450e9f61..513627e095 100644 --- a/gtk2_ardour/audio_time_axis.h +++ b/gtk2_ardour/audio_time_axis.h @@ -42,7 +42,6 @@ namespace ARDOUR { class Session; - class AudioDiskstream; class RouteGroup; class IOProcessor; class Processor; diff --git a/gtk2_ardour/automation_streamview.cc b/gtk2_ardour/automation_streamview.cc index 90cc96414f..e861522fd7 100644 --- a/gtk2_ardour/automation_streamview.cc +++ b/gtk2_ardour/automation_streamview.cc @@ -152,7 +152,7 @@ AutomationStreamView::set_automation_state (AutoState state) } void -AutomationStreamView::redisplay_diskstream () +AutomationStreamView::redisplay_track () { list::iterator i, tmp; @@ -164,7 +164,7 @@ AutomationStreamView::redisplay_diskstream () // Add and display region views, and flag them as valid if (_trackview.is_track()) { - _trackview.get_diskstream()->playlist()->foreach_region ( + _trackview.track()->playlist()->foreach_region ( sigc::hide_return (sigc::mem_fun (*this, &StreamView::add_region_view)) ); } diff --git a/gtk2_ardour/automation_streamview.h b/gtk2_ardour/automation_streamview.h index de54ea58a9..37f13774a4 100644 --- a/gtk2_ardour/automation_streamview.h +++ b/gtk2_ardour/automation_streamview.h @@ -47,7 +47,7 @@ class AutomationStreamView : public StreamView void set_automation_state (ARDOUR::AutoState state); - void redisplay_diskstream (); + void redisplay_track (); inline double contents_height() const { return (_trackview.current_height() - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 2); diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index bb8996ba93..630499a9c4 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -1358,7 +1358,7 @@ Editor::popup_track_context_menu (int button, int32_t time, ItemType item_type, break; case StreamItem: - if (clicked_routeview->get_diskstream()) { + if (clicked_routeview->track()) { build_menu_function = &Editor::build_track_context_menu; } else { build_menu_function = &Editor::build_track_bus_context_menu; @@ -1480,11 +1480,11 @@ Editor::build_track_region_context_menu (nframes64_t frame) RouteTimeAxisView* rtv = dynamic_cast (clicked_axisview); if (rtv) { - boost::shared_ptr ds; + boost::shared_ptr tr; boost::shared_ptr pl; - if ((ds = rtv->get_diskstream()) && ((pl = ds->playlist()))) { - Playlist::RegionList* regions = pl->regions_at ((nframes64_t) floor ( (double)frame * ds->speed())); + if ((tr = rtv->track()) && ((pl = tr->playlist()))) { + Playlist::RegionList* regions = pl->regions_at ((nframes64_t) floor ( (double)frame * tr->speed())); if (selection->regions.size() > 1) { // there's already a multiple selection: just add a @@ -1517,11 +1517,11 @@ Editor::build_track_crossfade_context_menu (nframes64_t frame) AudioTimeAxisView* atv = dynamic_cast (clicked_axisview); if (atv) { - boost::shared_ptr ds; + boost::shared_ptr tr; boost::shared_ptr pl; boost::shared_ptr apl; - if ((ds = atv->get_diskstream()) && ((pl = ds->playlist()) != 0) && ((apl = boost::dynamic_pointer_cast (pl)) != 0)) { + if ((tr = atv->track()) && ((pl = tr->playlist()) != 0) && ((apl = boost::dynamic_pointer_cast (pl)) != 0)) { Playlist::RegionList* regions = pl->regions_at (frame); AudioPlaylist::Crossfades xfades; @@ -4537,13 +4537,13 @@ Editor::get_regions_at (RegionSelection& rs, nframes64_t where, const TrackViewL for (TrackViewList::const_iterator t = tracks->begin(); t != tracks->end(); ++t) { RouteTimeAxisView* rtv = dynamic_cast(*t); if (rtv) { - boost::shared_ptr ds; + boost::shared_ptr tr; boost::shared_ptr pl; - if ((ds = rtv->get_diskstream()) && ((pl = ds->playlist()))) { + if ((tr = rtv->track()) && ((pl = tr->playlist()))) { Playlist::RegionList* regions = pl->regions_at ( - (nframes64_t) floor ( (double)where * ds->speed())); + (nframes64_t) floor ( (double)where * tr->speed())); for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) { RegionView* rv = rtv->view()->find_view (*i); @@ -4572,13 +4572,13 @@ Editor::get_regions_after (RegionSelection& rs, nframes64_t where, const TrackVi for (TrackViewList::const_iterator t = tracks->begin(); t != tracks->end(); ++t) { RouteTimeAxisView* rtv = dynamic_cast(*t); if (rtv) { - boost::shared_ptr ds; + boost::shared_ptr tr; boost::shared_ptr pl; - if ((ds = rtv->get_diskstream()) && ((pl = ds->playlist()))) { + if ((tr = rtv->track()) && ((pl = tr->playlist()))) { Playlist::RegionList* regions = pl->regions_touched ( - (nframes64_t) floor ( (double)where * ds->speed()), max_frames); + (nframes64_t) floor ( (double)where * tr->speed()), max_frames); for (Playlist::RegionList::iterator i = regions->begin(); i != regions->end(); ++i) { @@ -4650,14 +4650,14 @@ Editor::get_regions_corresponding_to (boost::shared_ptr region, vector pl; vector > results; RegionView* marv; - boost::shared_ptr ds; + boost::shared_ptr tr; - if ((ds = tatv->get_diskstream()) == 0) { + if ((tr = tatv->track()) == 0) { /* bus */ continue; } - if ((pl = (ds->playlist())) != 0) { + if ((pl = (tr->playlist())) != 0) { pl->get_region_list_equivalent_regions (region, results); } diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index ca12393b3e..ebd735e335 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -76,7 +76,6 @@ namespace Gtkmm2ext { } namespace ARDOUR { - class AudioDiskstream; class RouteGroup; class Playlist; class AudioPlaylist; diff --git a/gtk2_ardour/editor_audio_import.cc b/gtk2_ardour/editor_audio_import.cc index e7572ce8c1..119ea3bc51 100644 --- a/gtk2_ardour/editor_audio_import.cc +++ b/gtk2_ardour/editor_audio_import.cc @@ -852,7 +852,7 @@ Editor::finish_bringing_in_material (boost::shared_ptr region, uint32_t } } - boost::shared_ptr playlist = existing_track->diskstream()->playlist(); + boost::shared_ptr playlist = existing_track->playlist(); boost::shared_ptr copy (RegionFactory::create (region, region->properties())); begin_reversible_command (_("insert file")); playlist->clear_history (); @@ -887,7 +887,7 @@ Editor::finish_bringing_in_material (boost::shared_ptr region, uint32_t } boost::shared_ptr copy (RegionFactory::create (region)); - existing_track->diskstream()->playlist()->add_region (copy, pos); + existing_track->playlist()->add_region (copy, pos); break; } @@ -901,7 +901,7 @@ Editor::finish_bringing_in_material (boost::shared_ptr region, uint32_t if (!at.empty()) { boost::shared_ptr copy (RegionFactory::create (region)); at.front()->set_name (basename_nosuffix (copy->name())); - at.front()->diskstream()->playlist()->add_region (copy, pos); + at.front()->playlist()->add_region (copy, pos); } break; } diff --git a/gtk2_ardour/editor_canvas.cc b/gtk2_ardour/editor_canvas.cc index 4ea6d27ea2..757445114f 100644 --- a/gtk2_ardour/editor_canvas.cc +++ b/gtk2_ardour/editor_canvas.cc @@ -480,7 +480,7 @@ Editor::drop_paths_part_two (const vector& paths, nframes64_t frame, do /* check that its an audio track, not a bus */ - if (tv->get_diskstream()) { + if (tv->track()) { /* select the track, then embed/import */ selection->set (tv); diff --git a/gtk2_ardour/editor_canvas_events.cc b/gtk2_ardour/editor_canvas_events.cc index 93402c7854..a670543512 100644 --- a/gtk2_ardour/editor_canvas_events.cc +++ b/gtk2_ardour/editor_canvas_events.cc @@ -24,7 +24,6 @@ #include "pbd/stacktrace.h" -#include "ardour/audio_diskstream.h" #include "ardour/audioplaylist.h" #include "ardour/audioregion.h" #include "ardour/region_factory.h" @@ -587,7 +586,7 @@ Editor::canvas_crossfade_view_event (GdkEvent* event, ArdourCanvas::Item* item, if (atv->is_audio_track()) { boost::shared_ptr pl; - if ((pl = boost::dynamic_pointer_cast (atv->get_diskstream()->playlist())) != 0) { + if ((pl = boost::dynamic_pointer_cast (atv->track()->playlist())) != 0) { Playlist::RegionList* rl = pl->regions_at (event_frame (event)); if (!rl->empty()) { diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 8d6838eb76..d9da60e0c8 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -22,11 +22,9 @@ #include "pbd/memento_command.h" #include "pbd/basename.h" #include "pbd/stateful_diff_command.h" -#include "ardour/diskstream.h" #include "ardour/session.h" #include "ardour/dB.h" #include "ardour/region_factory.h" -#include "ardour/midi_diskstream.h" #include "editor.h" #include "i18n.h" #include "keyboard.h" @@ -826,7 +824,7 @@ void RegionMoveDrag::finished (GdkEvent* /*event*/, bool movement_occurred) { vector copies; - boost::shared_ptr ds; + boost::shared_ptr tr; boost::shared_ptr from_playlist; boost::shared_ptr to_playlist; RegionSelection new_views; @@ -1016,11 +1014,11 @@ RegionMoveDrag::finished (GdkEvent* /*event*/, bool movement_occurred) */ source_tv = dynamic_cast (&rv->get_time_axis_view()); - ds = source_tv->get_diskstream(); - from_playlist = ds->playlist(); + tr = source_tv->track(); + from_playlist = tr->playlist(); assert (source_tv); - assert (ds); + assert (tr); assert (from_playlist); /* moved to a different audio track, without copying */ @@ -1370,7 +1368,7 @@ RegionMoveDrag::RegionMoveDrag (Editor* e, ArdourCanvas::Item* i, RegionView* p, double speed = 1; RouteTimeAxisView* rtv = dynamic_cast (tv); if (rtv && rtv->is_track()) { - speed = rtv->get_diskstream()->speed (); + speed = rtv->track()->speed (); } _last_frame_position = static_cast (_primary->region()->position() / speed); @@ -1697,7 +1695,7 @@ TrimDrag::start_grab (GdkEvent* event, Gdk::Cursor *) RouteTimeAxisView* tv = dynamic_cast(tvp); if (tv && tv->is_track()) { - speed = tv->get_diskstream()->speed(); + speed = tv->track()->speed(); } nframes64_t region_start = (nframes64_t) (_primary->region()->position() / speed); @@ -1754,7 +1752,7 @@ TrimDrag::motion (GdkEvent* event, bool first_move) pair >::iterator,bool> insert_result; if (tv && tv->is_track()) { - speed = tv->get_diskstream()->speed(); + speed = tv->track()->speed(); } nframes64_t const pf = adjusted_current_frame (event); diff --git a/gtk2_ardour/editor_export_audio.cc b/gtk2_ardour/editor_export_audio.cc index 7d0fcc1bf9..1af4fc4764 100644 --- a/gtk2_ardour/editor_export_audio.cc +++ b/gtk2_ardour/editor_export_audio.cc @@ -297,9 +297,9 @@ Editor::write_audio_selection (TimeSelection& ts) if (atv->is_audio_track()) { - boost::shared_ptr playlist = boost::dynamic_pointer_cast(atv->get_diskstream()->playlist()); + boost::shared_ptr playlist = boost::dynamic_pointer_cast(atv->track()->playlist()); - if (playlist && write_audio_range (*playlist, atv->get_diskstream()->n_channels(), ts) == 0) { + if (playlist && write_audio_range (*playlist, atv->track()->n_channels(), ts) == 0) { ret = -1; break; } diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index a67406f93c..479ffd9933 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -777,7 +777,7 @@ Editor::button_press_handler_1 (ArdourCanvas::Item* item, GdkEvent* event, ItemT if (rtv && _join_object_range_state == JOIN_OBJECT_RANGE_OBJECT) { boost::shared_ptr t = boost::dynamic_pointer_cast (rtv->route ()); if (t) { - boost::shared_ptr pl = t->diskstream()->playlist (); + boost::shared_ptr pl = t->playlist (); if (pl) { boost::shared_ptr r = pl->top_region_at (event_frame (event)); @@ -1927,7 +1927,7 @@ Editor::region_view_item_click (AudioRegionView& rv, GdkEventButton* event) RouteTimeAxisView* rtv = dynamic_cast(tv); double speed = 1.0; if (rtv && rtv->is_track()) { - speed = rtv->get_diskstream()->speed(); + speed = rtv->track()->speed(); } nframes64_t where = get_preferred_edit_position(); @@ -2131,7 +2131,7 @@ Editor::single_contents_trim (RegionView& rv, nframes64_t frame_delta, bool left RouteTimeAxisView* tv = dynamic_cast(tvp); if (tv && tv->is_track()) { - speed = tv->get_diskstream()->speed(); + speed = tv->track()->speed(); } if (left_direction) { @@ -2171,7 +2171,7 @@ Editor::single_start_trim (RegionView& rv, nframes64_t frame_delta, bool left_di RouteTimeAxisView* tv = dynamic_cast(tvp); if (tv && tv->is_track()) { - speed = tv->get_diskstream()->speed(); + speed = tv->track()->speed(); } if (left_direction) { @@ -2226,7 +2226,7 @@ Editor::single_end_trim (RegionView& rv, nframes64_t frame_delta, bool left_dire RouteTimeAxisView* tv = dynamic_cast(tvp); if (tv && tv->is_track()) { - speed = tv->get_diskstream()->speed(); + speed = tv->track()->speed(); } if (left_direction) { @@ -2442,7 +2442,7 @@ Editor::mouse_brush_insert_region (RegionView* rv, nframes64_t pos) } boost::shared_ptr playlist = rtv->playlist(); - double speed = rtv->get_diskstream()->speed(); + double speed = rtv->track()->speed(); playlist->clear_history (); boost::shared_ptr new_region (RegionFactory::create (rv->region())); diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index a38998ba73..7f3aa7f7a8 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -637,8 +637,8 @@ Editor::build_region_boundary_cache () RouteTimeAxisView *rtav; if (ontrack != 0 && (rtav = dynamic_cast(ontrack)) != 0 ) { - if (rtav->get_diskstream() != 0) { - speed = rtav->get_diskstream()->speed(); + if (rtav->track() != 0) { + speed = rtav->track()->speed(); } } @@ -692,8 +692,8 @@ Editor::find_next_region (nframes64_t frame, RegionPoint point, int32_t dir, Tra track_speed = 1.0f; if ( (rtav = dynamic_cast(*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); @@ -893,8 +893,8 @@ Editor::cursor_to_region_point (EditorCursor* cursor, RegionPoint point, int32_t RouteTimeAxisView *rtav; if ( ontrack != 0 && (rtav = dynamic_cast(ontrack)) != 0 ) { - if (rtav->get_diskstream() != 0) { - speed = rtav->get_diskstream()->speed(); + if (rtav->track() != 0) { + speed = rtav->track()->speed(); } } @@ -1090,8 +1090,8 @@ Editor::selected_marker_to_region_point (RegionPoint point, int32_t dir) RouteTimeAxisView *rtav; if (ontrack != 0 && (rtav = dynamic_cast(ontrack)) != 0) { - if (rtav->get_diskstream() != 0) { - speed = rtav->get_diskstream()->speed(); + if (rtav->track() != 0) { + speed = rtav->track()->speed(); } } @@ -2782,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; } @@ -2792,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::const_iterator t = ts.begin(); t != ts.end(); ++t) { @@ -2939,7 +2939,7 @@ Editor::crop_region_to (nframes64_t start, nframes64_t end) boost::shared_ptr t = rtv->track(); - if (t != 0 && ! t->diskstream()->destructive()) { + if (t != 0 && ! t->destructive()) { if ((playlist = rtv->playlist()) != 0) { playlists.push_back (playlist); @@ -3411,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); @@ -3452,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 (); @@ -3490,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 (); @@ -3541,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(); } @@ -5937,9 +5937,9 @@ Editor::tab_to_transient (bool forward) RouteTimeAxisView* rtv = dynamic_cast (*t); if (rtv) { - boost::shared_ptr ds = rtv->get_diskstream(); - if (ds) { - boost::shared_ptr pl = rtv->get_diskstream()->playlist (); + boost::shared_ptr tr = rtv->track(); + if (tr) { + boost::shared_ptr pl = tr->playlist (); if (pl) { nframes64_t result = pl->find_next_transient (pos, forward ? 1 : -1); diff --git a/gtk2_ardour/editor_routes.cc b/gtk2_ardour/editor_routes.cc index b9ed2a935f..3d5cb3522c 100644 --- a/gtk2_ardour/editor_routes.cc +++ b/gtk2_ardour/editor_routes.cc @@ -24,7 +24,6 @@ #include #include -#include "ardour/diskstream.h" #include "ardour/session.h" #include "editor.h" @@ -458,7 +457,7 @@ EditorRoutes::routes_added (list routes) if ((*x)->is_track()) { boost::shared_ptr t = boost::dynamic_pointer_cast ((*x)->route()); - t->diskstream()->RecordEnableChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_rec_display, this), gui_context()); + t->RecordEnableChanged.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_rec_display, this), gui_context()); } (*x)->route()->mute_changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_mute_display, this), gui_context()); diff --git a/gtk2_ardour/editor_selection.cc b/gtk2_ardour/editor_selection.cc index e8feb7c085..fda5155e03 100644 --- a/gtk2_ardour/editor_selection.cc +++ b/gtk2_ardour/editor_selection.cc @@ -23,7 +23,6 @@ #include "pbd/stacktrace.h" #include "ardour/session.h" -#include "ardour/diskstream.h" #include "ardour/playlist.h" #include "ardour/route_group.h" #include "ardour/profile.h" @@ -329,9 +328,9 @@ Editor::mapped_get_equivalent_regions (RouteTimeAxisView& tv, uint32_t, RegionVi boost::shared_ptr pl; vector > results; RegionView* marv; - boost::shared_ptr ds; + boost::shared_ptr tr; - if ((ds = tv.get_diskstream()) == 0) { + if ((tr = tv.track()) == 0) { /* bus */ return; } @@ -341,7 +340,7 @@ Editor::mapped_get_equivalent_regions (RouteTimeAxisView& tv, uint32_t, RegionVi return; } - if ((pl = ds->playlist()) != 0) { + if ((pl = tr->playlist()) != 0) { pl->get_equivalent_regions (basis->region(), results); } @@ -401,14 +400,14 @@ Editor::get_regionview_count_from_region_list (boost::shared_ptr region) boost::shared_ptr pl; vector > results; RegionView* marv; - boost::shared_ptr ds; + boost::shared_ptr tr; - if ((ds = tatv->get_diskstream()) == 0) { + if ((tr = tatv->track()) == 0) { /* bus */ continue; } - if ((pl = (ds->playlist())) != 0) { + if ((pl = (tr->playlist())) != 0) { pl->get_region_list_equivalent_regions (region, results); } diff --git a/gtk2_ardour/editor_timefx.cc b/gtk2_ardour/editor_timefx.cc index fcd7e9baf4..6a1f0d021a 100644 --- a/gtk2_ardour/editor_timefx.cc +++ b/gtk2_ardour/editor_timefx.cc @@ -41,7 +41,6 @@ #include "ardour/audioplaylist.h" #include "ardour/audio_track.h" #include "ardour/audioregion.h" -#include "ardour/audio_diskstream.h" #include "ardour/stretch.h" #include "ardour/midi_stretch.h" #include "ardour/pitch.h" @@ -74,7 +73,7 @@ Editor::time_stretch (RegionSelection& regions, float fraction) return -1; boost::shared_ptr playlist - = rtv->track()->diskstream()->playlist(); + = rtv->track()->playlist(); ARDOUR::TimeFXRequest request; request.time_fraction = fraction; @@ -277,7 +276,7 @@ Editor::do_timefx (TimeFXDialog& dialog) continue; } - if ((playlist = t->diskstream()->playlist()) == 0) { + if ((playlist = t->playlist()) == 0) { i = tmp; continue; } diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index 91538cebea..26490f76e7 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -35,7 +35,6 @@ #include "ardour/tempo.h" #include "ardour/midi_region.h" #include "ardour/midi_source.h" -#include "ardour/midi_diskstream.h" #include "ardour/midi_model.h" #include "ardour/midi_patch_manager.h" #include "ardour/session.h" @@ -678,7 +677,7 @@ MidiRegionView::apply_delta() _model->apply_command(*trackview.session(), _delta_command); _delta_command = 0; - midi_view()->midi_track()->diskstream()->playlist_modified(); + midi_view()->midi_track()->playlist_modified(); _marked_for_selection.clear(); _marked_for_velocity.clear(); @@ -693,7 +692,7 @@ MidiRegionView::apply_diff () _model->apply_command(*trackview.session(), _diff_command); _diff_command = 0; - midi_view()->midi_track()->diskstream()->playlist_modified(); + midi_view()->midi_track()->playlist_modified(); _marked_for_velocity.clear(); } @@ -712,7 +711,7 @@ MidiRegionView::apply_delta_as_subcommand() _model->apply_command_as_subcommand(*trackview.session(), _delta_command); _delta_command = 0; - midi_view()->midi_track()->diskstream()->playlist_modified(); + midi_view()->midi_track()->playlist_modified(); _marked_for_selection.clear(); _marked_for_velocity.clear(); @@ -732,7 +731,7 @@ MidiRegionView::apply_diff_as_subcommand() _model->apply_command_as_subcommand(*trackview.session(), _diff_command); _diff_command = 0; - midi_view()->midi_track()->diskstream()->playlist_modified(); + midi_view()->midi_track()->playlist_modified(); _marked_for_selection.clear(); _marked_for_velocity.clear(); diff --git a/gtk2_ardour/midi_streamview.cc b/gtk2_ardour/midi_streamview.cc index 430a92503d..7992051ade 100644 --- a/gtk2_ardour/midi_streamview.cc +++ b/gtk2_ardour/midi_streamview.cc @@ -209,9 +209,9 @@ MidiStreamView::display_region(MidiRegionView* region_view, bool load_model) } void -MidiStreamView::display_diskstream (boost::shared_ptr ds) +MidiStreamView::display_track (boost::shared_ptr tr) { - StreamView::display_diskstream(ds); + StreamView::display_track (tr); draw_note_lines(); NoteRangeChanged(); } @@ -244,7 +244,7 @@ MidiStreamView::update_data_note_range(uint8_t min, uint8_t max) } void -MidiStreamView::redisplay_diskstream () +MidiStreamView::redisplay_track () { if (!_trackview.is_midi_track()) { return; @@ -256,7 +256,7 @@ MidiStreamView::redisplay_diskstream () _range_dirty = false; _data_note_min = 127; _data_note_max = 0; - _trackview.get_diskstream()->playlist()->foreach_region( + _trackview.track()->playlist()->foreach_region( sigc::mem_fun (*this, &StreamView::update_contents_metrics) ); @@ -279,7 +279,7 @@ MidiStreamView::redisplay_diskstream () } // Add and display region views, and flag them as valid - _trackview.get_diskstream()->playlist()->foreach_region( + _trackview.track()->playlist()->foreach_region( sigc::hide_return (sigc::mem_fun (*this, &StreamView::add_region_view)) ); @@ -385,7 +385,7 @@ MidiStreamView::setup_rec_box () if (!rec_active && _trackview.session()->record_status() == Session::Recording && - _trackview.get_diskstream()->record_enabled()) { + _trackview.track()->record_enabled()) { if (Config->get_show_waveforms_while_recording() && rec_regions.size() == rec_rects.size()) { @@ -397,12 +397,12 @@ MidiStreamView::setup_rec_box () boost::shared_ptr mds = _trackview.midi_track()->midi_diskstream(); - sources.push_back(mds->write_source()); + sources.push_back (_trackview.midi_track()->write_source()); mds->write_source()->ViewDataRangeReady.connect (rec_data_ready_connections, invalidator (*this), - ui_bind (&MidiStreamView::rec_data_range_ready, this, _1, _2, boost::weak_ptr(mds->write_source())), + ui_bind (&MidiStreamView::rec_data_range_ready, this, _1, _2, boost::weak_ptr(_trackview.midi_track()->write_source())), gui_context()); // handle multi @@ -410,7 +410,7 @@ MidiStreamView::setup_rec_box () nframes_t start = 0; if (rec_regions.size() > 0) { start = rec_regions.back().first->start() - + _trackview.get_diskstream()->get_captured_frames(rec_regions.size()-1); + + _trackview.track()->get_captured_frames(rec_regions.size()-1); } PropertyList plist; @@ -436,8 +436,7 @@ MidiStreamView::setup_rec_box () /* start a new rec box */ boost::shared_ptr mt = _trackview.midi_track(); /* we know what it is already */ - boost::shared_ptr ds = mt->midi_diskstream(); - nframes_t frame_pos = ds->current_capture_start (); + nframes_t frame_pos = mt->current_capture_start (); gdouble xstart = _trackview.editor().frame_to_pixel (frame_pos); gdouble xend; uint32_t fill_color; @@ -471,7 +470,7 @@ MidiStreamView::setup_rec_box () } else if (rec_active && (_trackview.session()->record_status() != Session::Recording || - !_trackview.get_diskstream()->record_enabled())) { + !_trackview.track()->record_enabled())) { screen_update_connection.disconnect(); rec_active = false; rec_updating = false; @@ -558,7 +557,7 @@ MidiStreamView::update_rec_regions (boost::shared_ptr data, nframes_t if (nlen != region->length()) { region->suspend_property_changes (); - region->set_position (_trackview.get_diskstream()->get_capture_start_frame(n), this); + region->set_position (_trackview.track()->get_capture_start_frame(n), this); region->set_length (start + dur - region->position(), this); region->resume_property_changes (); @@ -615,14 +614,14 @@ MidiStreamView::update_rec_regions (boost::shared_ptr data, nframes_t } else { - nframes_t nlen = _trackview.get_diskstream()->get_captured_frames(n); + nframes_t nlen = _trackview.track()->get_captured_frames(n); if (nlen != region->length()) { if (region->source_length(0) >= region->position() + nlen) { region->suspend_property_changes (); - region->set_position (_trackview.get_diskstream()->get_capture_start_frame(n), this); + region->set_position (_trackview.track()->get_capture_start_frame(n), this); region->set_length (nlen, this); region->resume_property_changes (); diff --git a/gtk2_ardour/midi_streamview.h b/gtk2_ardour/midi_streamview.h index ae2b907d1e..1ab832986a 100644 --- a/gtk2_ardour/midi_streamview.h +++ b/gtk2_ardour/midi_streamview.h @@ -35,7 +35,6 @@ namespace Gdk { namespace ARDOUR { class Route; - class Diskstream; class Crossfade; class PeakData; class MidiRegion; @@ -76,7 +75,7 @@ class MidiStreamView : public StreamView void update_note_range(uint8_t note_num); - void redisplay_diskstream (); + void redisplay_track (); inline double contents_height() const { return (_trackview.current_height() - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 2); } @@ -119,7 +118,7 @@ class MidiStreamView : public StreamView bool recording = false); void display_region(MidiRegionView* region_view, bool load_model); - void display_diskstream (boost::shared_ptr ds); + void display_track (boost::shared_ptr tr); void update_contents_height (); void draw_note_lines(); diff --git a/gtk2_ardour/midi_time_axis.cc b/gtk2_ardour/midi_time_axis.cc index 318ec62769..83567c42d9 100644 --- a/gtk2_ardour/midi_time_axis.cc +++ b/gtk2_ardour/midi_time_axis.cc @@ -738,7 +738,7 @@ MidiTimeAxisView::set_note_mode(NoteMode mode) _note_mode = mode; midi_track()->set_note_mode(mode); xml_node->add_property ("note-mode", enum_2_string(_note_mode)); - _view->redisplay_diskstream(); + _view->redisplay_track(); } } @@ -754,7 +754,7 @@ MidiTimeAxisView::set_color_mode(ColorMode mode) _color_mode = mode; xml_node->add_property ("color-mode", enum_2_string(_color_mode)); - _view->redisplay_diskstream(); + _view->redisplay_track(); } } @@ -975,10 +975,7 @@ MidiTimeAxisView::add_region (nframes64_t pos) const Tempo& t = _session->tempo_map().tempo_at(start); double length = floor (m.frames_per_bar(t, _session->frame_rate())); - const boost::shared_ptr diskstream = - boost::dynamic_pointer_cast(view()->trackview().track()->diskstream()); - - boost::shared_ptr src = _session->create_midi_source_for_session (*diskstream.get()); + boost::shared_ptr src = _session->create_midi_source_for_session (view()->trackview().track()->name()); PropertyList plist; diff --git a/gtk2_ardour/mixer_strip.cc b/gtk2_ardour/mixer_strip.cc index 5e7064ee8d..cb030287ca 100644 --- a/gtk2_ardour/mixer_strip.cc +++ b/gtk2_ardour/mixer_strip.cc @@ -41,13 +41,13 @@ #include "ardour/route.h" #include "ardour/route_group.h" #include "ardour/audio_track.h" -#include "ardour/audio_diskstream.h" #include "ardour/panner.h" #include "ardour/send.h" #include "ardour/processor.h" #include "ardour/profile.h" #include "ardour/ladspa_plugin.h" #include "ardour/user_bundle.h" +#include "ardour/port.h" #include "ardour_ui.h" #include "ardour_dialog.h" diff --git a/gtk2_ardour/mixer_ui.cc b/gtk2_ardour/mixer_ui.cc index c1dc4aff9f..2bb2548164 100644 --- a/gtk2_ardour/mixer_ui.cc +++ b/gtk2_ardour/mixer_ui.cc @@ -33,7 +33,6 @@ #include #include -#include "ardour/audio_diskstream.h" #include "ardour/audio_track.h" #include "ardour/plugin_manager.h" #include "ardour/route_group.h" diff --git a/gtk2_ardour/mixer_ui.h b/gtk2_ardour/mixer_ui.h index ba72ba2cba..935e85559e 100644 --- a/gtk2_ardour/mixer_ui.h +++ b/gtk2_ardour/mixer_ui.h @@ -44,7 +44,6 @@ namespace ARDOUR { class Route; class RouteGroup; - class AudioDiskstream; }; class MixerStrip; diff --git a/gtk2_ardour/playlist_selector.cc b/gtk2_ardour/playlist_selector.cc index aa678e80a3..c8a9255c62 100644 --- a/gtk2_ardour/playlist_selector.cc +++ b/gtk2_ardour/playlist_selector.cc @@ -79,10 +79,10 @@ PlaylistSelector::~PlaylistSelector () void PlaylistSelector::clear_map () { - for (DSPL_Map::iterator x = dspl_map.begin(); x != dspl_map.end(); ++x) { + for (TrackPlaylistMap::iterator x = trpl_map.begin(); x != trpl_map.end(); ++x) { delete x->second; } - dspl_map.clear (); + trpl_map.clear (); } bool @@ -99,7 +99,6 @@ void PlaylistSelector::show_for (RouteUI* ruix) { vector item; - boost::shared_ptr this_ds; string str; rui = ruix; @@ -113,7 +112,7 @@ PlaylistSelector::show_for (RouteUI* ruix) _session->playlists->foreach (this, &PlaylistSelector::add_playlist_to_map); - this_ds = rui->get_diskstream(); + boost::shared_ptr this_track = rui->track(); TreeModel::Row others = *(model->append ()); @@ -121,29 +120,29 @@ PlaylistSelector::show_for (RouteUI* ruix) boost::shared_ptr proxy = others[columns.playlist]; proxy.reset (); - for (DSPL_Map::iterator x = dspl_map.begin(); x != dspl_map.end(); ++x) { + for (TrackPlaylistMap::iterator x = trpl_map.begin(); x != trpl_map.end(); ++x) { - boost::shared_ptr ds = _session->diskstream_by_id (x->first); + boost::shared_ptr tr = boost::dynamic_pointer_cast (_session->route_by_id (x->first)); - if (ds == 0) { + if (tr == 0) { continue; } - /* add a node for the diskstream */ + /* add a node for the track */ string nodename; - if (ds->name().empty()) { + if (tr->name().empty()) { nodename = _("unassigned"); } else { - nodename = ds->name().c_str(); + nodename = tr->name().c_str(); } TreeModel::Row row; TreeModel::Row* selected_row = 0; TreePath this_path; - if (ds == this_ds) { + if (tr == this_track) { row = *(model->prepend()); row[columns.text] = nodename; boost::shared_ptr proxy = row[columns.playlist]; @@ -157,7 +156,7 @@ PlaylistSelector::show_for (RouteUI* ruix) /* Now insert all the playlists for this diskstream/track in a subtree */ - list > *pls = x->second; + list >* pls = x->second; for (list >::iterator p = pls->begin(); p != pls->end(); ++p) { @@ -167,7 +166,7 @@ PlaylistSelector::show_for (RouteUI* ruix) child_row[columns.text] = (*p)->name(); child_row[columns.playlist] = *p; - if (*p == this_ds->playlist()) { + if (*p == this_track->playlist()) { selected_row = &child_row; } } @@ -197,7 +196,7 @@ PlaylistSelector::show_for (RouteUI* ruix) child_row[columns.text] = (*p)->name(); child_row[columns.playlist] = *p; - if (*p == this_ds->playlist()) { + if (*p == this_track->playlist()) { selected_row = &child_row; } @@ -223,13 +222,10 @@ PlaylistSelector::add_playlist_to_map (boost::shared_ptr pl) return; } - DSPL_Map::iterator x; + TrackPlaylistMap::iterator x; - if ((x = dspl_map.find (apl->get_orig_diskstream_id())) == dspl_map.end()) { - - pair >*> newp (apl->get_orig_diskstream_id(), new list >); - - x = dspl_map.insert (dspl_map.end(), newp); + if ((x = trpl_map.find (apl->get_orig_diskstream_id())) == trpl_map.end()) { + x = trpl_map.insert (trpl_map.end(), make_pair (apl->get_orig_diskstream_id(), new list >)); } x->second->push_back (pl); @@ -269,7 +265,7 @@ PlaylistSelector::selection_changed () return; } - at->diskstream()->use_playlist (apl); + at->use_playlist (apl); hide (); } diff --git a/gtk2_ardour/playlist_selector.h b/gtk2_ardour/playlist_selector.h index d0b36fae48..c792179776 100644 --- a/gtk2_ardour/playlist_selector.h +++ b/gtk2_ardour/playlist_selector.h @@ -51,10 +51,10 @@ class PlaylistSelector : public ArdourDialog bool on_unmap_event (GdkEventAny*); private: - typedef std::map >*> DSPL_Map; + typedef std::map >*> TrackPlaylistMap; Gtk::ScrolledWindow scroller; - DSPL_Map dspl_map; + TrackPlaylistMap trpl_map; RouteUI* rui; sigc::connection select_connection; diff --git a/gtk2_ardour/processor_box.cc b/gtk2_ardour/processor_box.cc index 42711b4936..4b34bd0f68 100644 --- a/gtk2_ardour/processor_box.cc +++ b/gtk2_ardour/processor_box.cc @@ -42,7 +42,6 @@ #include "ardour/amp.h" #include "ardour/ardour.h" -#include "ardour/audio_diskstream.h" #include "ardour/audio_track.h" #include "ardour/audioengine.h" #include "ardour/internal_send.h" diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc index cee28fc5c1..91748707f4 100644 --- a/gtk2_ardour/route_time_axis.cc +++ b/gtk2_ardour/route_time_axis.cc @@ -242,8 +242,7 @@ RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session* sess, boost::sh track()->TrackModeChanged.connect (*this, invalidator (*this), boost::bind (&RouteTimeAxisView::track_mode_changed, this), gui_context()); track()->FreezeChange.connect (*this, invalidator (*this), boost::bind (&RouteTimeAxisView::map_frozen, this), gui_context()); - track()->DiskstreamChanged.connect (*this, invalidator (*this), boost::bind (&RouteTimeAxisView::diskstream_changed, this), gui_context()); - get_diskstream()->SpeedChanged.connect (*this, invalidator (*this), boost::bind (&RouteTimeAxisView::speed_changed, this), gui_context()); + track()->SpeedChanged.connect (*this, invalidator (*this), boost::bind (&RouteTimeAxisView::speed_changed, this), gui_context()); /* pick up the correct freeze state */ map_frozen (); @@ -509,19 +508,21 @@ RouteTimeAxisView::build_display_menu () alignment_items.push_back (RadioMenuElem (align_group, _("Align With Existing Material"), sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::set_align_style), ExistingMaterial))); align_existing_item = dynamic_cast(&alignment_items.back()); - if (get_diskstream()->alignment_style() == ExistingMaterial) + if (track()->alignment_style() == ExistingMaterial) { align_existing_item->set_active(); + } alignment_items.push_back (RadioMenuElem (align_group, _("Align With Capture Time"), sigc::bind (sigc::mem_fun(*this, &RouteTimeAxisView::set_align_style), CaptureTime))); align_capture_item = dynamic_cast(&alignment_items.back()); - if (get_diskstream()->alignment_style() == CaptureTime) + if (track()->alignment_style() == CaptureTime) { align_capture_item->set_active(); + } if (!Profile->get_sae()) { items.push_back (MenuElem (_("Alignment"), *alignment_menu)); - get_diskstream()->AlignmentStyleChanged.connect (route_connections, invalidator (*this), boost::bind (&RouteTimeAxisView::align_style_changed, this), gui_context()); + track()->AlignmentStyleChanged.connect (route_connections, invalidator (*this), boost::bind (&RouteTimeAxisView::align_style_changed, this), gui_context()); RadioMenuItem::Group mode_group; items.push_back (RadioMenuElem (mode_group, _("Normal Mode"), sigc::bind ( @@ -556,7 +557,7 @@ RouteTimeAxisView::build_display_menu () _ignore_track_mode_change = false; } - get_diskstream()->AlignmentStyleChanged.connect (route_connections, invalidator (*this), boost::bind (&RouteTimeAxisView::align_style_changed, this), gui_context()); + track()->AlignmentStyleChanged.connect (route_connections, invalidator (*this), boost::bind (&RouteTimeAxisView::align_style_changed, this), gui_context()); color_mode_menu = build_color_mode_menu(); if (color_mode_menu) { @@ -900,8 +901,8 @@ RouteTimeAxisView::set_samples_per_unit (double spu) { double speed = 1.0; - if (get_diskstream() != 0) { - speed = get_diskstream()->speed(); + if (track()) { + speed = track()->speed(); } if (_view) { @@ -914,7 +915,7 @@ RouteTimeAxisView::set_samples_per_unit (double spu) void RouteTimeAxisView::align_style_changed () { - switch (get_diskstream()->alignment_style()) { + switch (track()->alignment_style()) { case ExistingMaterial: if (!align_existing_item->get_active()) { align_existing_item->set_active(); @@ -947,7 +948,7 @@ RouteTimeAxisView::set_align_style (AlignStyle style) } if (item->get_active()) { - get_diskstream()->set_align_style (style); + track()->set_align_style (style); } } @@ -957,13 +958,15 @@ RouteTimeAxisView::rename_current_playlist () ArdourPrompter prompter (true); string name; - boost::shared_ptr ds = get_diskstream(); - if (!ds || ds->destructive()) + boost::shared_ptr tr = track(); + if (!tr || tr->destructive()) { return; + } - boost::shared_ptr pl = ds->playlist(); - if (!pl) + boost::shared_ptr pl = tr->playlist(); + if (!pl) { return; + } prompter.set_prompt (_("Name for playlist")); prompter.set_initial_text (pl->name()); @@ -1023,13 +1026,15 @@ RouteTimeAxisView::use_copy_playlist (bool prompt, vector ds = get_diskstream(); - if (!ds || ds->destructive()) + boost::shared_ptr tr = track (); + if (!tr || tr->destructive()) { return; + } - boost::shared_ptr pl = ds->playlist(); - if (!pl) + boost::shared_ptr pl = tr->playlist(); + if (!pl) { return; + } name = pl->name(); @@ -1065,8 +1070,8 @@ RouteTimeAxisView::use_copy_playlist (bool prompt, vectoruse_copy_playlist (); - ds->playlist()->set_name (name); + tr->use_copy_playlist (); + tr->playlist()->set_name (name); } } @@ -1075,13 +1080,15 @@ RouteTimeAxisView::use_new_playlist (bool prompt, vector ds = get_diskstream(); - if (!ds || ds->destructive()) + boost::shared_ptr tr = track (); + if (!tr || tr->destructive()) { return; + } - boost::shared_ptr pl = ds->playlist(); - if (!pl) + boost::shared_ptr pl = tr->playlist(); + if (!pl) { return; + } name = pl->name(); @@ -1114,21 +1121,23 @@ RouteTimeAxisView::use_new_playlist (bool prompt, vectoruse_new_playlist (); - ds->playlist()->set_name (name); + tr->use_new_playlist (); + tr->playlist()->set_name (name); } } void RouteTimeAxisView::clear_playlist () { - boost::shared_ptr ds = get_diskstream(); - if (!ds || ds->destructive()) + boost::shared_ptr tr = track (); + if (!tr || tr->destructive()) { return; + } - boost::shared_ptr pl = ds->playlist(); - if (!pl) + boost::shared_ptr pl = tr->playlist(); + if (!pl) { return; + } _editor.clear_playlist (pl); } @@ -1139,17 +1148,12 @@ RouteTimeAxisView::speed_changed () Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&RouteTimeAxisView::reset_samples_per_unit, this)); } -void -RouteTimeAxisView::diskstream_changed () -{ - Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&RouteTimeAxisView::update_diskstream_display, this)); -} - void RouteTimeAxisView::update_diskstream_display () { - if (!get_diskstream()) // bus + if (!track()) { return; + } map_frozen (); } @@ -1212,8 +1216,8 @@ RouteTimeAxisView::get_selectables (nframes_t start, nframes_t end, double top, { double speed = 1.0; - if (get_diskstream() != 0) { - speed = get_diskstream()->speed(); + if (track() != 0) { + speed = track()->speed(); } nframes_t start_adjusted = session_frame_to_track_frame(start, speed); @@ -1291,10 +1295,10 @@ RouteTimeAxisView::name() const boost::shared_ptr RouteTimeAxisView::playlist () const { - boost::shared_ptr ds; + boost::shared_ptr tr; - if ((ds = get_diskstream()) != 0) { - return ds->playlist(); + if ((tr = track()) != 0) { + return tr->playlist(); } else { return boost::shared_ptr (); } @@ -1349,11 +1353,10 @@ RouteTimeAxisView::hide_click () boost::shared_ptr RouteTimeAxisView::find_next_region (nframes_t pos, RegionPoint point, int32_t dir) { - boost::shared_ptr stream; - boost::shared_ptr playlist; + boost::shared_ptr pl = playlist (); - if ((stream = get_diskstream()) != 0 && (playlist = stream->playlist()) != 0) { - return playlist->find_next_region (pos, point, dir); + if (pl) { + return pl->find_next_region (pos, point, dir); } return boost::shared_ptr (); @@ -1362,11 +1365,10 @@ RouteTimeAxisView::find_next_region (nframes_t pos, RegionPoint point, int32_t d nframes64_t RouteTimeAxisView::find_next_region_boundary (nframes64_t pos, int32_t dir) { - boost::shared_ptr stream; - boost::shared_ptr playlist; + boost::shared_ptr pl = playlist (); - if ((stream = get_diskstream()) != 0 && (playlist = stream->playlist()) != 0) { - return playlist->find_next_region_boundary (pos, dir); + if (pl) { + return pl->find_next_region_boundary (pos, dir); } return -1; @@ -1376,19 +1378,19 @@ bool RouteTimeAxisView::cut_copy_clear (Selection& selection, CutCopyOp op) { boost::shared_ptr what_we_got; - boost::shared_ptr ds = get_diskstream(); + boost::shared_ptr tr = track (); boost::shared_ptr playlist; bool ret = false; - if (ds == 0) { + if (tr == 0) { /* route is a bus, not a track */ return false; } - playlist = ds->playlist(); + playlist = tr->playlist(); TimeSelection time (selection.time); - float speed = ds->speed(); + float const speed = tr->speed(); if (speed != 1.0f) { for (TimeSelection::iterator i = time.begin(); i != time.end(); ++i) { (*i).start = session_frame_to_track_frame((*i).start, speed); @@ -1447,7 +1449,7 @@ RouteTimeAxisView::paste (nframes_t pos, float times, Selection& selection, size return false; } - boost::shared_ptr playlist = get_diskstream()->playlist(); + boost::shared_ptr pl = playlist (); PlaylistSelection::iterator p; for (p = selection.playlists.begin(); p != selection.playlists.end() && nth; ++p, --nth) {} @@ -1456,13 +1458,13 @@ RouteTimeAxisView::paste (nframes_t pos, float times, Selection& selection, size return false; } - if (get_diskstream()->speed() != 1.0f) { - pos = session_frame_to_track_frame(pos, get_diskstream()->speed() ); + if (track()->speed() != 1.0f) { + pos = session_frame_to_track_frame (pos, track()->speed()); } - playlist->clear_history (); - playlist->paste (*p, pos, times); - _session->add_command (new StatefulDiffCommand (playlist)); + pl->clear_history (); + pl->paste (*p, pos, times); + _session->add_command (new StatefulDiffCommand (pl)); return true; } @@ -1504,30 +1506,30 @@ RouteTimeAxisView::build_playlist_menu (Gtk::Menu * menu) delete playlist_menu; - vector > playlists, playlists_ds; - boost::shared_ptr ds = get_diskstream(); + vector > playlists, playlists_tr; + boost::shared_ptr tr = track(); RadioMenuItem::Group playlist_group; _session->playlists->get (playlists); /* find the playlists for this diskstream */ for (vector >::iterator i = playlists.begin(); i != playlists.end(); ++i) { - if (((*i)->get_orig_diskstream_id() == ds->id()) || (ds->playlist()->id() == (*i)->id())) { - playlists_ds.push_back(*i); + if (((*i)->get_orig_diskstream_id() == tr->diskstream_id()) || (tr->playlist()->id() == (*i)->id())) { + playlists_tr.push_back(*i); } } /* sort the playlists */ PlaylistSorter cmp; - sort(playlists_ds.begin(), playlists_ds.end(), cmp); + sort (playlists_tr.begin(), playlists_tr.end(), cmp); /* add the playlists to the menu */ - for (vector >::iterator i = playlists_ds.begin(); i != playlists_ds.end(); ++i) { + for (vector >::iterator i = playlists_tr.begin(); i != playlists_tr.end(); ++i) { playlist_items.push_back (RadioMenuElem (playlist_group, (*i)->name())); RadioMenuItem *item = static_cast(&playlist_items.back()); item->signal_toggled().connect(sigc::bind (sigc::mem_fun (*this, &RouteTimeAxisView::use_playlist), item, boost::weak_ptr (*i))); - if (ds->playlist()->id() == (*i)->id()) { + if (tr->playlist()->id() == (*i)->id()) { item->set_active(); } @@ -1574,13 +1576,12 @@ RouteTimeAxisView::use_playlist (RadioMenuItem *item, boost::weak_ptr boost::shared_ptr apl = boost::dynamic_pointer_cast (pl); if (apl) { - if (get_diskstream()->playlist() == apl) { + if (track()->playlist() == apl) { // exit when use_playlist is called by the creation of the playlist menu // or the playlist choice is unchanged return; } - get_diskstream()->use_playlist (apl); - + track()->use_playlist (apl); if (route_group() && route_group()->is_active()) { std::string group_string = "."+route_group()->name()+"."; @@ -1611,10 +1612,10 @@ RouteTimeAxisView::use_playlist (RadioMenuItem *item, boost::weak_ptr boost::shared_ptr ipl = session()->playlists->by_name(playlist_name); if (!ipl) { // No playlist for this track for this take yet, make it - track->diskstream()->use_new_playlist(); - track->diskstream()->playlist()->set_name(playlist_name); + track->use_new_playlist(); + track->playlist()->set_name(playlist_name); } else { - track->diskstream()->use_playlist(ipl); + track->use_playlist(ipl); } } } diff --git a/gtk2_ardour/route_time_axis.h b/gtk2_ardour/route_time_axis.h index 7f35e54485..e24de4126f 100644 --- a/gtk2_ardour/route_time_axis.h +++ b/gtk2_ardour/route_time_axis.h @@ -48,7 +48,6 @@ namespace ARDOUR { class Session; class Region; - class Diskstream; class RouteGroup; class IOProcessor; class Processor; @@ -183,7 +182,6 @@ protected: }; - void diskstream_changed (); void update_diskstream_display (); gint edit_click (GdkEventButton *); diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc index 526d99cd94..ee66bf4c90 100644 --- a/gtk2_ardour/route_ui.cc +++ b/gtk2_ardour/route_ui.cc @@ -50,9 +50,7 @@ #include "ardour/session.h" #include "ardour/audioengine.h" #include "ardour/audio_track.h" -#include "ardour/audio_diskstream.h" #include "ardour/midi_track.h" -#include "ardour/midi_diskstream.h" #include "ardour/template_utils.h" #include "ardour/filename_extensions.h" #include "ardour/directory_names.h" @@ -221,7 +219,7 @@ RouteUI::set_route (boost::shared_ptr rp) if (_session->writable() && is_track()) { boost::shared_ptr t = boost::dynamic_pointer_cast(_route); - t->diskstream()->RecordEnableChanged.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::route_rec_enable_changed, this), gui_context()); + t->RecordEnableChanged.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::route_rec_enable_changed, this), gui_context()); rec_enable_button->show(); rec_enable_button->set_controllable (t->rec_enable_control()); @@ -1328,18 +1326,6 @@ RouteUI::midi_track() const return boost::dynamic_pointer_cast(_route); } -boost::shared_ptr -RouteUI::get_diskstream () const -{ - boost::shared_ptr t; - - if ((t = boost::dynamic_pointer_cast(_route)) != 0) { - return t->diskstream(); - } else { - return boost::shared_ptr ((Diskstream*) 0); - } -} - string RouteUI::name() const { diff --git a/gtk2_ardour/route_ui.h b/gtk2_ardour/route_ui.h index a01db6dd8e..bbe18bfc4f 100644 --- a/gtk2_ardour/route_ui.h +++ b/gtk2_ardour/route_ui.h @@ -69,8 +69,6 @@ class RouteUI : public virtual AxisView boost::shared_ptr audio_track() const; boost::shared_ptr midi_track() const; - boost::shared_ptr get_diskstream() const; - std::string name() const; // protected: XXX sigh this should be here diff --git a/gtk2_ardour/streamview.cc b/gtk2_ardour/streamview.cc index 83dd9fc4b8..8fa9ed8d28 100644 --- a/gtk2_ardour/streamview.cc +++ b/gtk2_ardour/streamview.cc @@ -25,7 +25,6 @@ #include "ardour/playlist.h" #include "ardour/region.h" #include "ardour/source.h" -#include "ardour/diskstream.h" #include "ardour/track.h" #include "ardour/session.h" @@ -79,7 +78,7 @@ StreamView::StreamView (RouteTimeAxisView& tv, ArdourCanvas::Group* group) if (_trackview.is_track()) { _trackview.track()->DiskstreamChanged.connect (*this, invalidator (*this), boost::bind (&StreamView::diskstream_changed, this), gui_context()); - _trackview.get_diskstream()->RecordEnableChanged.connect (*this, invalidator (*this), boost::bind (&StreamView::rec_enable_changed, this), gui_context()); + _trackview.track()->RecordEnableChanged.connect (*this, invalidator (*this), boost::bind (&StreamView::rec_enable_changed, this), gui_context()); _trackview.session()->TransportStateChange.connect (*this, invalidator (*this), boost::bind (&StreamView::transport_changed, this), gui_context()); _trackview.session()->TransportLooped.connect (*this, invalidator (*this), boost::bind (&StreamView::transport_looped, this), gui_context()); @@ -91,7 +90,7 @@ StreamView::StreamView (RouteTimeAxisView& tv, ArdourCanvas::Group* group) StreamView::~StreamView () { - undisplay_diskstream (); + undisplay_track (); delete canvas_rect; @@ -104,7 +103,7 @@ void StreamView::attach () { if (_trackview.is_track()) { - display_diskstream (_trackview.get_diskstream()); + display_track (_trackview.track ()); } } @@ -204,7 +203,7 @@ StreamView::remove_region_view (boost::weak_ptr weak_r) } void -StreamView::undisplay_diskstream () +StreamView::undisplay_track () { for (RegionViewList::iterator i = region_views.begin(); i != region_views.end() ; ) { RegionViewList::iterator next = i; @@ -217,11 +216,11 @@ StreamView::undisplay_diskstream () } void -StreamView::display_diskstream (boost::shared_ptr ds) +StreamView::display_track (boost::shared_ptr tr) { playlist_switched_connection.disconnect(); - playlist_switched (ds); - ds->PlaylistChanged.connect (playlist_switched_connection, invalidator (*this), boost::bind (&StreamView::playlist_switched, this, boost::weak_ptr (ds)), gui_context()); + playlist_switched (tr); + tr->PlaylistChanged.connect (playlist_switched_connection, invalidator (*this), boost::bind (&StreamView::playlist_switched, this, boost::weak_ptr (tr)), gui_context()); } void @@ -282,17 +281,17 @@ StreamView::layer_regions() } void -StreamView::playlist_layered (boost::weak_ptr wds) +StreamView::playlist_layered (boost::weak_ptr wtr) { - boost::shared_ptr ds (wds.lock()); + boost::shared_ptr tr (wtr.lock()); - if (!ds) { + if (!tr) { return; } /* update layers count and the y positions and heights of our regions */ - if (ds->playlist()) { - _layers = ds->playlist()->top_layer() + 1; + if (tr->playlist()) { + _layers = tr->playlist()->top_layer() + 1; } if (_layer_display == Stacked) { @@ -305,35 +304,35 @@ StreamView::playlist_layered (boost::weak_ptr wds) } void -StreamView::playlist_switched (boost::weak_ptr wds) +StreamView::playlist_switched (boost::weak_ptr wtr) { - boost::shared_ptr ds (wds.lock()); + boost::shared_ptr tr (wtr.lock()); - if (!ds) { + if (!tr) { return; } /* disconnect from old playlist */ playlist_connections.drop_connections (); - undisplay_diskstream (); + undisplay_track (); /* update layers count and the y positions and heights of our regions */ - _layers = ds->playlist()->top_layer() + 1; + _layers = tr->playlist()->top_layer() + 1; update_contents_height (); update_coverage_frames (); - ds->playlist()->set_explicit_relayering (_layer_display == Stacked); + tr->playlist()->set_explicit_relayering (_layer_display == Stacked); /* draw it */ - redisplay_diskstream (); + redisplay_track (); /* catch changes */ - ds->playlist()->LayeringChanged.connect (playlist_connections, invalidator (*this), boost::bind (&StreamView::playlist_layered, this, boost::weak_ptr(ds)), gui_context()); - ds->playlist()->RegionAdded.connect (playlist_connections, invalidator (*this), ui_bind (&StreamView::add_region_view, this, _1), gui_context()); - ds->playlist()->RegionRemoved.connect (playlist_connections, invalidator (*this), ui_bind (&StreamView::remove_region_view, this, _1), gui_context()); + tr->playlist()->LayeringChanged.connect (playlist_connections, invalidator (*this), boost::bind (&StreamView::playlist_layered, this, boost::weak_ptr (tr)), gui_context()); + tr->playlist()->RegionAdded.connect (playlist_connections, invalidator (*this), ui_bind (&StreamView::add_region_view, this, _1), gui_context()); + tr->playlist()->RegionRemoved.connect (playlist_connections, invalidator (*this), ui_bind (&StreamView::remove_region_view, this, _1), gui_context()); // ds->playlist()->ContentsChanged.connect (playlist_connections, invalidator (*this), boost::bind (&StreamView::redisplay_diskstream, this), gui_context()); } @@ -343,15 +342,14 @@ StreamView::diskstream_changed () boost::shared_ptr t; if ((t = _trackview.track()) != 0) { - Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&StreamView::display_diskstream, this, t->diskstream())); + Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&StreamView::display_track, this, t)); } else { - Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&StreamView::undisplay_diskstream, this)); + Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&StreamView::undisplay_track, this)); } } void StreamView::apply_color (Gdk::Color& color, ColorTarget target) - { list::iterator i; @@ -412,7 +410,7 @@ StreamView::update_rec_box () if (rec_active && rec_rects.size() > 0) { /* only update the last box */ RecBoxInfo & rect = rec_rects.back(); - nframes_t at = _trackview.get_diskstream()->current_capture_end(); + nframes_t at = _trackview.track()->current_capture_end(); double xstart; double xend; @@ -427,7 +425,7 @@ StreamView::update_rec_box () case Destructive: rect.length = 2; - xstart = _trackview.editor().frame_to_pixel (_trackview.get_diskstream()->current_capture_start()); + xstart = _trackview.editor().frame_to_pixel (_trackview.track()->current_capture_start()); xend = _trackview.editor().frame_to_pixel (at); break; } @@ -577,7 +575,7 @@ StreamView::set_layer_display (LayerDisplay d) _layer_display = d; update_contents_height (); update_coverage_frames (); - _trackview.get_diskstream()->playlist()->set_explicit_relayering (_layer_display == Stacked); + _trackview.track()->playlist()->set_explicit_relayering (_layer_display == Stacked); } void diff --git a/gtk2_ardour/streamview.h b/gtk2_ardour/streamview.h index 17a1c4182b..14b30a42fc 100644 --- a/gtk2_ardour/streamview.h +++ b/gtk2_ardour/streamview.h @@ -35,11 +35,11 @@ namespace Gdk { namespace ARDOUR { class Route; - class Diskstream; class Crossfade; class PeakData; class Region; class Source; + class Track; } struct RecBoxInfo { @@ -104,7 +104,7 @@ public: void region_layered (RegionView*); virtual void update_contents_height (); - virtual void redisplay_diskstream () = 0; + virtual void redisplay_track () = 0; double child_height () const; ARDOUR::layer_t layers () const { return _layers; } @@ -129,13 +129,13 @@ protected: bool wait_for_waves, bool recording = false) = 0; virtual void remove_region_view (boost::weak_ptr ); - void display_diskstream (boost::shared_ptr); - virtual void undisplay_diskstream (); + void display_track (boost::shared_ptr); + virtual void undisplay_track (); void diskstream_changed (); void layer_regions (); - virtual void playlist_switched (boost::weak_ptr); - virtual void playlist_layered (boost::weak_ptr); + virtual void playlist_switched (boost::weak_ptr); + virtual void playlist_layered (boost::weak_ptr); virtual void color_handler () = 0; diff --git a/gtk2_ardour/tape_region_view.cc b/gtk2_ardour/tape_region_view.cc index e4db441e74..5fef5e46ee 100644 --- a/gtk2_ardour/tape_region_view.cc +++ b/gtk2_ardour/tape_region_view.cc @@ -27,7 +27,6 @@ #include "ardour/playlist.h" #include "ardour/audioregion.h" #include "ardour/audiosource.h" -#include "ardour/audio_diskstream.h" #include "tape_region_view.h" #include "audio_time_axis.h" diff --git a/gtk2_ardour/time_fx_dialog.cc b/gtk2_ardour/time_fx_dialog.cc index 04280e0011..d1650430b2 100644 --- a/gtk2_ardour/time_fx_dialog.cc +++ b/gtk2_ardour/time_fx_dialog.cc @@ -41,7 +41,6 @@ #include "ardour/audioplaylist.h" #include "ardour/audio_track.h" #include "ardour/audioregion.h" -#include "ardour/audio_diskstream.h" #include "ardour/stretch.h" #include "ardour/midi_stretch.h" #include "ardour/pitch.h" diff --git a/libs/ardour/ardour/audio_diskstream.h b/libs/ardour/ardour/audio_diskstream.h index 0a8a7a0a8e..6cf064a61d 100644 --- a/libs/ardour/ardour/audio_diskstream.h +++ b/libs/ardour/ardour/audio_diskstream.h @@ -228,7 +228,7 @@ class AudioDiskstream : public Diskstream ChannelInfo* channel_info, int channel, bool reversed); void finish_capture (bool rec_monitors_input, boost::shared_ptr); - void transport_stopped (struct tm&, time_t, bool abort); + void transport_stopped_wallclock (struct tm&, time_t, bool abort); void transport_looped (nframes_t transport_frame); void init (); diff --git a/libs/ardour/ardour/audio_track.h b/libs/ardour/ardour/audio_track.h index 0c4f29ee86..d74f5e53b9 100644 --- a/libs/ardour/ardour/audio_track.h +++ b/libs/ardour/ardour/audio_track.h @@ -28,6 +28,7 @@ class Session; class AudioDiskstream; class AudioPlaylist; class RouteGroup; +class AudioFileSource; class AudioTrack : public Track { @@ -56,6 +57,8 @@ class AudioTrack : public Track int set_state(const XMLNode&, int version); + boost::shared_ptr write_source (uint32_t n = 0); + protected: XMLNode& state (bool full); diff --git a/libs/ardour/ardour/diskstream.h b/libs/ardour/ardour/diskstream.h index da6297e0fb..97a512cf3f 100644 --- a/libs/ardour/ardour/diskstream.h +++ b/libs/ardour/ardour/diskstream.h @@ -37,6 +37,7 @@ #include "ardour/session_object.h" #include "ardour/types.h" #include "ardour/utils.h" +#include "ardour/public_diskstream.h" struct tm; @@ -46,10 +47,10 @@ class IO; class Playlist; class Processor; class Region; -class Route; class Session; +class Track; -class Diskstream : public SessionObject +class Diskstream : public SessionObject, public PublicDiskstream { public: enum Flag { @@ -66,7 +67,7 @@ class Diskstream : public SessionObject bool set_name (const std::string& str); boost::shared_ptr io() const { return _io; } - void set_route (ARDOUR::Route&); + void set_track (ARDOUR::Track *); virtual float playback_buffer_load() const = 0; virtual float capture_buffer_load() const = 0; @@ -99,7 +100,6 @@ class Diskstream : public SessionObject virtual void punch_in() {} virtual void punch_out() {} - void set_speed (double); void non_realtime_set_speed (); virtual void non_realtime_locate (nframes_t /*location*/) {}; virtual void playlist_modified (); @@ -143,6 +143,14 @@ class Diskstream : public SessionObject void move_processor_automation (boost::weak_ptr, std::list > const &); + /** For non-butler contexts (allocates temporary working buffers) */ + virtual int do_refill_with_alloc() = 0; + virtual void set_block_size (nframes_t) = 0; + + bool pending_overwrite () const { + return _pending_overwrite; + } + PBD::Signal0 RecordEnableChanged; PBD::Signal0 SpeedChanged; PBD::Signal0 ReverseChanged; @@ -163,7 +171,6 @@ class Diskstream : public SessionObject virtual void set_pending_overwrite (bool) = 0; virtual int overwrite_existing_buffers () = 0; - virtual void set_block_size (nframes_t) = 0; virtual int internal_playback_seek (nframes_t distance) = 0; virtual int can_internal_playback_seek (nframes_t distance) = 0; virtual int rename_write_sources () = 0; @@ -199,16 +206,13 @@ class Diskstream : public SessionObject virtual int do_flush (RunContext context, bool force = false) = 0; virtual int do_refill () = 0; - /** For non-butler contexts (allocates temporary working buffers) */ - virtual int do_refill_with_alloc() = 0; - /* XXX fix this redundancy ... */ virtual void playlist_changed (const PBD::PropertyChange&); virtual void playlist_deleted (boost::weak_ptr); virtual void playlist_ranges_moved (std::list< Evoral::RangeMove > const &); - virtual void transport_stopped (struct tm&, time_t, bool abort) = 0; + virtual void transport_stopped_wallclock (struct tm&, time_t, bool abort) = 0; virtual void transport_looped (nframes_t transport_frame) = 0; struct CaptureInfo { @@ -245,7 +249,7 @@ class Diskstream : public SessionObject uint32_t i_am_the_modifier; boost::shared_ptr _io; - Route* _route; + Track* _track; ChanCount _n_channels; boost::shared_ptr _playlist; @@ -273,7 +277,7 @@ class Diskstream : public SessionObject Location* loop_location; nframes_t overwrite_frame; off_t overwrite_offset; - bool pending_overwrite; + bool _pending_overwrite; bool overwrite_queued; IOChange input_change_pending; nframes_t wrap_buffer_size; diff --git a/libs/ardour/ardour/midi_diskstream.h b/libs/ardour/ardour/midi_diskstream.h index 81f2979f3f..abbfc28feb 100644 --- a/libs/ardour/ardour/midi_diskstream.h +++ b/libs/ardour/ardour/midi_diskstream.h @@ -151,7 +151,7 @@ class MidiDiskstream : public Diskstream int read (nframes_t& start, nframes_t cnt, bool reversed); void finish_capture (bool rec_monitors_input); - void transport_stopped (struct tm&, time_t, bool abort); + void transport_stopped_wallclock (struct tm&, time_t, bool abort); void transport_looped (nframes_t transport_frame); void init (); diff --git a/libs/ardour/ardour/midi_track.h b/libs/ardour/ardour/midi_track.h index f4f29398b2..0399492a02 100644 --- a/libs/ardour/ardour/midi_track.h +++ b/libs/ardour/ardour/midi_track.h @@ -31,6 +31,7 @@ class Session; class MidiDiskstream; class MidiPlaylist; class RouteGroup; +class SMFSource; class MidiTrack : public Track { @@ -90,6 +91,8 @@ public: bool midi_thru() const { return _midi_thru; } void set_midi_thru (bool yn); + boost::shared_ptr write_source (uint32_t n = 0); + protected: XMLNode& state (bool full); diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h index d9a14c01fd..c5b79644c6 100644 --- a/libs/ardour/ardour/playlist.h +++ b/libs/ardour/ardour/playlist.h @@ -195,6 +195,7 @@ class Playlist : public SessionObject uint32_t read_data_count() const { return _read_data_count; } + /* XXX: use of diskstream here is a little unfortunate */ const PBD::ID& get_orig_diskstream_id () const { return _orig_diskstream_id; } void set_orig_diskstream_id (const PBD::ID& did) { _orig_diskstream_id = did; } diff --git a/libs/ardour/ardour/public_diskstream.h b/libs/ardour/ardour/public_diskstream.h new file mode 100755 index 0000000000..90ca030af1 --- /dev/null +++ b/libs/ardour/ardour/public_diskstream.h @@ -0,0 +1,80 @@ +/* + Copyright (C) 2010 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __ardour_public_diskstream_h__ +#define __ardour_public_diskstream_h__ + +namespace ARDOUR { + +class Playlist; +class Region; +class Location; + +/** Public interface to a Diskstream */ +class PublicDiskstream +{ +public: + + virtual boost::shared_ptr playlist () = 0; + virtual void monitor_input (bool) = 0; + virtual bool destructive () const = 0; + virtual std::list > & last_capture_regions () = 0; + virtual void set_capture_offset () = 0; + virtual void reset_write_sources (bool, bool force = false) = 0; + virtual float playback_buffer_load () const = 0; + virtual float capture_buffer_load () const = 0; + virtual int do_refill () = 0; + virtual int do_flush (RunContext, bool force = false) = 0; + virtual uint32_t read_data_count() const = 0; + virtual uint32_t write_data_count() const = 0; + virtual void set_pending_overwrite (bool) = 0; + virtual int seek (nframes_t, bool complete_refill = false) = 0; + virtual bool hidden () const = 0; + virtual int can_internal_playback_seek (nframes_t) = 0; + virtual int internal_playback_seek (nframes_t) = 0; + virtual void non_realtime_input_change () = 0; + virtual void non_realtime_locate (nframes_t) = 0; + virtual void non_realtime_set_speed () = 0; + virtual int overwrite_existing_buffers () = 0; + virtual nframes_t get_captured_frames (uint32_t n = 0) = 0; + virtual int set_loop (Location *) = 0; + virtual void transport_looped (nframes_t) = 0; + virtual bool realtime_set_speed (double, bool) = 0; + virtual void transport_stopped_wallclock (struct tm &, time_t, bool) = 0; + virtual bool pending_overwrite () const = 0; + virtual double speed () const = 0; + virtual void prepare_to_stop (framepos_t) = 0; + virtual void set_slaved (bool) = 0; + virtual ChanCount n_channels () = 0; + virtual nframes_t get_capture_start_frame (uint32_t n = 0) = 0; + virtual AlignStyle alignment_style () const = 0; + virtual void set_record_enabled (bool) = 0; + virtual nframes_t current_capture_start () const = 0; + virtual nframes_t current_capture_end () const = 0; + virtual void playlist_modified () = 0; + virtual int use_playlist (boost::shared_ptr) = 0; + virtual void set_align_style (AlignStyle) = 0; + virtual int use_copy_playlist () = 0; + virtual int use_new_playlist () = 0; + +}; + +} + +#endif diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h index ae514e2f18..f9ba1a8e8a 100644 --- a/libs/ardour/ardour/route.h +++ b/libs/ardour/ardour/route.h @@ -338,10 +338,10 @@ class Route : public SessionObject, public AutomatableControls, public RouteGrou void catch_up_on_solo_mute_override (); void mod_solo_by_others (int32_t); - void set_block_size (nframes_t nframes); bool has_external_redirects() const; void curve_reallocate (); void just_meter_input (sframes_t start_frame, sframes_t end_frame, nframes_t nframes); + virtual void set_block_size (nframes_t nframes); protected: nframes_t check_initial_delay (nframes_t, nframes_t&); diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index ed1dc68f43..e2f3ff1625 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -77,7 +77,6 @@ namespace Evoral { namespace ARDOUR { -class AudioDiskstream; class AudioEngine; class AudioFileSource; class AudioRegion; @@ -96,7 +95,6 @@ class ExportStatus; class IO; class IOProcessor; class ImportStatus; -class MidiDiskstream; class MidiRegion; class MidiSource; class MidiTrack; @@ -121,6 +119,7 @@ class Slave; class Source; class TempoMap; class VSTPlugin; +class Track; extern void setup_enum_writer (); @@ -193,26 +192,18 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi BufferSet& get_scratch_buffers (ChanCount count = ChanCount::ZERO); BufferSet& get_mix_buffers (ChanCount count = ChanCount::ZERO); - void add_diskstream (boost::shared_ptr); - boost::shared_ptr diskstream_by_id (const PBD::ID& id); - boost::shared_ptr diskstream_by_name (std::string name); - bool have_rec_enabled_diskstream () const; + bool have_rec_enabled_track () const; bool have_captured() const { return _have_captured; } - void refill_all_diskstream_buffers (); + void refill_all_track_buffers (); Butler* butler() { return _butler; } void butler_transport_work (); - uint32_t get_next_diskstream_id() const { return n_diskstreams(); } - uint32_t n_diskstreams() const; - void refresh_disk_space (); - typedef std::list > DiskstreamList; - - SerializedRCUManager& diskstream_list() { return diskstreams; } - + int load_diskstreams_2X (XMLNode const &, int); + int load_routes (const XMLNode&, int); boost::shared_ptr get_routes() const { return routes.reader (); @@ -307,8 +298,8 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi void use_rf_shuttle_speed (); void allow_auto_play (bool yn); void request_transport_speed (double speed); - void request_overwrite_buffer (Diskstream*); - void request_diskstream_speed (Diskstream&, double speed); + void request_overwrite_buffer (Track *); + void request_track_speed (Track *, double speed); void request_input_change_handling (); bool locate_pending() const { return static_cast(post_transport_work()&PostTransportLocate); } @@ -542,9 +533,9 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi */ static PBD::Signal0 AskAboutPendingState; - boost::shared_ptr create_audio_source_for_session (ARDOUR::AudioDiskstream&, uint32_t which_channel, bool destructive); + boost::shared_ptr create_audio_source_for_session (size_t, std::string const &, uint32_t, bool); - boost::shared_ptr create_midi_source_for_session (ARDOUR::MidiDiskstream&); + boost::shared_ptr create_midi_source_for_session (std::string const &); boost::shared_ptr source_by_id (const PBD::ID&); boost::shared_ptr source_by_path_and_channel (const Glib::ustring&, uint16_t); @@ -932,7 +923,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi PBD::ScopedConnection export_freewheel_connection; - void get_diskstream_statistics (); + void get_track_statistics (); int process_routes (nframes_t, bool& need_butler); int silent_process_routes (nframes_t, bool& need_butler); @@ -1174,13 +1165,13 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi void set_play_loop (bool yn); void unset_play_loop (); - void overwrite_some_buffers (Diskstream*); + void overwrite_some_buffers (Track *); void flush_all_inserts (); int micro_locate (nframes_t distance); void locate (nframes64_t, bool with_roll, bool with_flush, bool with_loop=false, bool force=false); void start_locate (nframes64_t, bool with_roll, bool with_flush, bool with_loop=false, bool force=false); void force_locate (nframes64_t frame, bool with_roll = false); - void set_diskstream_speed (Diskstream*, double speed); + void set_track_speed (Track *, double speed); void set_transport_speed (double speed, bool abort = false, bool clear_state = false); void stop_transport (bool abort = false, bool clear_state = false); void start_transport (); @@ -1203,12 +1194,6 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi std::list _route_groups; - /* disk-streams */ - - SerializedRCUManager diskstreams; - - int load_diskstreams (const XMLNode&); - /* routes stuff */ SerializedRCUManager routes; @@ -1217,6 +1202,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi uint32_t destructive_index; boost::shared_ptr XMLRouteFactory (const XMLNode&, int); + boost::shared_ptr XMLRouteFactory_2X (const XMLNode&, int); void route_processors_changed (RouteProcessorChange); @@ -1265,7 +1251,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi void remove_playlist (boost::weak_ptr); void playlist_length_changed (); - void diskstream_playlist_changed (boost::weak_ptr); + void track_playlist_changed (boost::weak_ptr); /* NAMED SELECTIONS */ @@ -1342,7 +1328,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi XMLNode* _bundle_xml_node; int load_bundles (XMLNode const &); - void reverse_diskstream_buffers (); + void reverse_track_buffers (); UndoHistory _history; std::stack _current_trans; @@ -1436,8 +1422,8 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi mutable bool have_looped; ///< Used in ::audible_frame(*) - void update_have_rec_enabled_diskstream (); - gint _have_rec_enabled_diskstream; + void update_have_rec_enabled_track (); + gint _have_rec_enabled_track; static int ask_about_playlist_deletion (boost::shared_ptr); @@ -1450,6 +1436,9 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi void rt_set_mute (boost::shared_ptr, bool yn, bool group_override); void rt_set_listen (boost::shared_ptr, bool yn, bool group_override); void rt_set_record_enable (boost::shared_ptr, bool yn, bool group_override); + + /** temporary list of Diskstreams used only during load of 2.X sessions */ + std::list > _diskstreams_2X; }; } // namespace ARDOUR diff --git a/libs/ardour/ardour/session_event.h b/libs/ardour/ardour/session_event.h index 2306bb7c1a..726c5be47b 100644 --- a/libs/ardour/ardour/session_event.h +++ b/libs/ardour/ardour/session_event.h @@ -19,7 +19,7 @@ class Region; struct SessionEvent { enum Type { SetTransportSpeed, - SetDiskstreamSpeed, + SetTrackSpeed, Locate, LocateRoll, LocateRollLocate, diff --git a/libs/ardour/ardour/track.h b/libs/ardour/ardour/track.h index c05d222cc2..a40b82916b 100644 --- a/libs/ardour/ardour/track.h +++ b/libs/ardour/ardour/track.h @@ -22,16 +22,17 @@ #include #include "ardour/route.h" +#include "ardour/public_diskstream.h" namespace ARDOUR { class Session; -class Diskstream; class Playlist; class RouteGroup; class Region; +class Diskstream; -class Track : public Route +class Track : public Route, public PublicDiskstream { public: Track (Session&, std::string name, Route::Flag f = Route::Flag (0), TrackMode m = Normal, DataType default_type = DataType::AUDIO); @@ -60,10 +61,8 @@ class Track : public Route bool can_record(); - boost::shared_ptr diskstream() const { return _diskstream; } - virtual void use_new_diskstream () = 0; - virtual void set_diskstream (boost::shared_ptr) = 0; + virtual void set_diskstream (boost::shared_ptr); nframes_t update_total_latency(); void set_latency_delay (nframes_t); @@ -92,8 +91,60 @@ class Track : public Route bool record_enabled() const; void set_record_enable (bool yn, void *src); + /* XXX: unfortunate that this is exposed */ + PBD::ID const & diskstream_id () const; + + void set_block_size (nframes_t); + + /* PublicDiskstream interface */ + boost::shared_ptr playlist (); + void monitor_input (bool); + bool destructive () const; + std::list > & last_capture_regions (); + void set_capture_offset (); + void reset_write_sources (bool, bool force = false); + float playback_buffer_load () const; + float capture_buffer_load () const; + int do_refill (); + int do_flush (RunContext, bool force = false); + uint32_t read_data_count() const; + uint32_t write_data_count() const; + void set_pending_overwrite (bool); + int seek (nframes_t, bool complete_refill = false); + bool hidden () const; + int can_internal_playback_seek (nframes_t); + int internal_playback_seek (nframes_t); + void non_realtime_input_change (); + void non_realtime_locate (nframes_t); + void non_realtime_set_speed (); + int overwrite_existing_buffers (); + nframes_t get_captured_frames (uint32_t n = 0); + int set_loop (Location *); + void transport_looped (nframes_t); + bool realtime_set_speed (double, bool); + void transport_stopped_wallclock (struct tm &, time_t, bool); + bool pending_overwrite () const; + double speed () const; + void prepare_to_stop (framepos_t); + void set_slaved (bool); + ChanCount n_channels (); + nframes_t get_capture_start_frame (uint32_t n = 0); + AlignStyle alignment_style () const; + void set_record_enabled (bool); + nframes_t current_capture_start () const; + nframes_t current_capture_end () const; + void playlist_modified (); + int use_playlist (boost::shared_ptr); + void set_align_style (AlignStyle); + int use_copy_playlist (); + int use_new_playlist (); + PBD::Signal0 DiskstreamChanged; PBD::Signal0 FreezeChange; + PBD::Signal0 PlaylistChanged; + PBD::Signal0 RecordEnableChanged; + PBD::Signal0 SpeedChanged; + PBD::Signal0 AlignmentStyleChanged; protected: virtual XMLNode& state (bool full) = 0; @@ -144,6 +195,12 @@ class Track : public Route bool _destructive; boost::shared_ptr _rec_enable_control; + +private: + void diskstream_playlist_changed (); + void diskstream_record_enable_changed (); + void diskstream_speed_changed (); + void diskstream_alignment_style_changed (); }; }; /* namespace ARDOUR*/ diff --git a/libs/ardour/audio_diskstream.cc b/libs/ardour/audio_diskstream.cc index c8cc1c9ebf..91ca6a8f64 100644 --- a/libs/ardour/audio_diskstream.cc +++ b/libs/ardour/audio_diskstream.cc @@ -59,6 +59,7 @@ #include "ardour/source_factory.h" #include "ardour/utils.h" #include "ardour/session_playlists.h" +#include "ardour/route.h" #include "i18n.h" #include @@ -321,7 +322,7 @@ AudioDiskstream::use_copy_playlist () newname = Playlist::bump_name (_playlist->name(), _session); - if ((playlist = boost::dynamic_pointer_cast(PlaylistFactory::create (audio_playlist(), newname))) != 0) { + if ((playlist = boost::dynamic_pointer_cast(PlaylistFactory::create (audio_playlist(), newname))) != 0) { playlist->set_orig_diskstream_id (id()); return use_playlist (playlist); } else { @@ -729,7 +730,7 @@ AudioDiskstream::set_pending_overwrite (bool yn) { /* called from audio thread, so we can use the read ptr and playback sample as we wish */ - pending_overwrite = yn; + _pending_overwrite = yn; overwrite_frame = playback_sample; overwrite_offset = channels.reader()->front()->playback_buf->get_read_ptr(); @@ -798,7 +799,7 @@ AudioDiskstream::overwrite_existing_buffers () ret = 0; out: - pending_overwrite = false; + _pending_overwrite = false; delete [] gain_buffer; delete [] mixdown_buffer; return ret; @@ -1334,7 +1335,7 @@ AudioDiskstream::do_flush (RunContext /*context*/, bool force_flush) } void -AudioDiskstream::transport_stopped (struct tm& when, time_t twhen, bool abort_capture) +AudioDiskstream::transport_stopped_wallclock (struct tm& when, time_t twhen, bool abort_capture) { uint32_t buffer_position; bool more_work = true; @@ -1701,7 +1702,7 @@ AudioDiskstream::disengage_record_enable () XMLNode& AudioDiskstream::get_state () { - XMLNode* node = new XMLNode ("AudioDiskstream"); + XMLNode* node = new XMLNode ("Diskstream"); char buf[64] = ""; LocaleGuard lg (X_("POSIX")); boost::shared_ptr c = channels.reader(); @@ -1827,7 +1828,7 @@ AudioDiskstream::set_state (const XMLNode& node, int /*version*/) } if (!had_playlist) { - _playlist->set_orig_diskstream_id (_id); + _playlist->set_orig_diskstream_id (id()); } if (!destructive() && capture_pending_node) { @@ -1884,7 +1885,7 @@ AudioDiskstream::use_new_write_source (uint32_t n) } try { - if ((chan->write_source = _session.create_audio_source_for_session (*this, n, destructive())) == 0) { + if ((chan->write_source = _session.create_audio_source_for_session (n_channels().n_audio(), name(), n, destructive())) == 0) { throw failed_constructor(); } } @@ -1991,7 +1992,7 @@ AudioDiskstream::allocate_temporary_buffers () when slaving to MTC, Timecode etc. */ - double sp = max (fabsf (_actual_speed), 1.2f); + double const sp = max (fabsf (_actual_speed), 1.2f); nframes_t required_wrap_size = (nframes_t) floor (_session.get_block_size() * sp) + 1; if (required_wrap_size > wrap_buffer_size) { diff --git a/libs/ardour/audio_track.cc b/libs/ardour/audio_track.cc index f46e22143b..862f15b68c 100644 --- a/libs/ardour/audio_track.cc +++ b/libs/ardour/audio_track.cc @@ -81,7 +81,8 @@ AudioTrack::use_new_diskstream () AudioDiskstream* dsp (new AudioDiskstream (_session, name(), dflags)); boost::shared_ptr ds (dsp); - _session.add_diskstream (ds); + ds->do_refill_with_alloc (); + ds->set_block_size (_session.get_block_size ()); set_diskstream (ds); } @@ -89,8 +90,9 @@ AudioTrack::use_new_diskstream () void AudioTrack::set_diskstream (boost::shared_ptr ds) { - _diskstream = ds; - _diskstream->set_route (*this); + Track::set_diskstream (ds); + + _diskstream->set_track (this); _diskstream->set_destructive (_mode == Destructive); _diskstream->set_non_layered (_mode == NonLayered); @@ -234,6 +236,14 @@ AudioTrack::_set_state (const XMLNode& node, int version, bool call_base) } } + if (version >= 3000) { + if ((child = find_named_node (node, X_("Diskstream"))) != 0) { + boost::shared_ptr ds (new AudioDiskstream (_session, *child)); + ds->do_refill_with_alloc (); + set_diskstream (ds); + } + } + pending_state = const_cast (&node); if (_session.state_of_the_state() & Session::Loading) { @@ -246,7 +256,7 @@ AudioTrack::_set_state (const XMLNode& node, int version, bool call_base) } XMLNode& -AudioTrack::state(bool full_state) +AudioTrack::state (bool full_state) { XMLNode& root (Route::state(full_state)); XMLNode* freeze_node; @@ -271,25 +281,9 @@ AudioTrack::state(bool full_state) root.add_child_nocopy (*freeze_node); } - /* Alignment: act as a proxy for the diskstream */ - - XMLNode* align_node = new XMLNode (X_("Alignment")); - AlignStyle as = _diskstream->alignment_style (); - align_node->add_property (X_("style"), enum_2_string (as)); - root.add_child_nocopy (*align_node); - root.add_property (X_("mode"), enum_2_string (_mode)); - - /* we don't return diskstream state because we don't - own the diskstream exclusively. control of the diskstream - state is ceded to the Session, even if we create the - diskstream. - */ - - _diskstream->id().print (buf, sizeof (buf)); - root.add_property ("diskstream-id", buf); - root.add_child_nocopy (_rec_enable_control->get_state()); + root.add_child_nocopy (_diskstream->get_state ()); return root; } @@ -351,30 +345,6 @@ AudioTrack::set_state_part_two () _freeze_record.processor_info.push_back (frii); } } - - /* Alignment: act as a proxy for the diskstream */ - - if ((fnode = find_named_node (*pending_state, X_("Alignment"))) != 0) { - - if ((prop = fnode->property (X_("style"))) != 0) { - - /* fix for older sessions from before EnumWriter */ - - string pstr; - - if (prop->value() == "capture") { - pstr = "CaptureTime"; - } else if (prop->value() == "existing") { - pstr = "ExistingMaterial"; - } else { - pstr = prop->value(); - } - - AlignStyle as = AlignStyle (string_2_enum (pstr, as)); - _diskstream->set_persistent_align_style (as); - } - } - return; } int @@ -713,7 +683,7 @@ AudioTrack::freeze_me (InterThreadInfo& itt) boost::shared_ptr region (RegionFactory::create (srcs, plist, false)); - new_playlist->set_orig_diskstream_id (diskstream->id()); + new_playlist->set_orig_diskstream_id (_diskstream->id()); new_playlist->add_region (region, _session.current_start_frame()); new_playlist->set_frozen (true); region->set_locked (true); @@ -757,3 +727,10 @@ AudioTrack::unfreeze () FreezeChange (); /* EMIT SIGNAL */ } +boost::shared_ptr +AudioTrack::write_source (uint32_t n) +{ + boost::shared_ptr ds = boost::dynamic_pointer_cast (_diskstream); + assert (ds); + return ds->write_source (n); +} diff --git a/libs/ardour/audio_track_importer.cc b/libs/ardour/audio_track_importer.cc index aad20f9317..c5a584a7f4 100644 --- a/libs/ardour/audio_track_importer.cc +++ b/libs/ardour/audio_track_importer.cc @@ -278,7 +278,8 @@ AudioTrackImporter::_move () boost::shared_ptr new_ds (new AudioDiskstream (session, *ds_node)); new_ds->set_name (name); - session.add_diskstream (new_ds); + new_ds->do_refill_with_alloc (); + new_ds->set_block_size (session.get_block_size ()); /* Import playlists */ diff --git a/libs/ardour/butler.cc b/libs/ardour/butler.cc index b201960e0e..35fb6bcc03 100644 --- a/libs/ardour/butler.cc +++ b/libs/ardour/butler.cc @@ -28,6 +28,7 @@ #include "ardour/io.h" #include "ardour/midi_diskstream.h" #include "ardour/session.h" +#include "ardour/track.h" #include "i18n.h" @@ -131,7 +132,7 @@ Butler::thread_work () struct pollfd pfd[1]; bool disk_work_outstanding = false; - Session::DiskstreamList::iterator i; + RouteList::iterator i; while (true) { pfd[0].fd = request_pipe[0]; @@ -207,30 +208,33 @@ Butler::thread_work () begin = get_microseconds(); - boost::shared_ptr dsl = _session.diskstream_list().reader (); + boost::shared_ptr rl = _session.get_routes(); // for (i = dsl->begin(); i != dsl->end(); ++i) { // cerr << "BEFORE " << (*i)->name() << ": pb = " << (*i)->playback_buffer_load() << " cp = " << (*i)->capture_buffer_load() << endl; // } - for (i = dsl->begin(); !transport_work_requested() && should_run && i != dsl->end(); ++i) { + for (i = rl->begin(); !transport_work_requested() && should_run && i != rl->end(); ++i) { - boost::shared_ptr ds = *i; + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (!tr) { + continue; + } /* don't read inactive tracks */ - boost::shared_ptr io = ds->io(); + boost::shared_ptr io = tr->input (); if (io && !io->active()) { continue; } - switch (ds->do_refill ()) { + switch (tr->do_refill ()) { case 0: - bytes += ds->read_data_count(); + bytes += tr->read_data_count(); break; case 1: - bytes += ds->read_data_count(); + bytes += tr->read_data_count(); disk_work_outstanding = true; break; @@ -242,7 +246,7 @@ Butler::thread_work () } - if (i != dsl->begin() && i != dsl->end()) { + if (i != rl->begin() && i != rl->end()) { /* we didn't get to all the streams */ disk_work_outstanding = true; } @@ -264,18 +268,23 @@ Butler::thread_work () compute_io = true; begin = get_microseconds(); - for (i = dsl->begin(); !transport_work_requested() && should_run && i != dsl->end(); ++i) { + for (i = rl->begin(); !transport_work_requested() && should_run && i != rl->end(); ++i) { // cerr << "write behind for " << (*i)->name () << endl; + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (!tr) { + continue; + } + /* note that we still try to flush diskstreams attached to inactive routes */ - switch ((*i)->do_flush (ButlerContext)) { + switch (tr->do_flush (ButlerContext)) { case 0: - bytes += (*i)->write_data_count(); + bytes += tr->write_data_count(); break; case 1: - bytes += (*i)->write_data_count(); + bytes += tr->write_data_count(); disk_work_outstanding = true; break; @@ -296,7 +305,7 @@ Butler::thread_work () _session.request_stop (); } - if (i != dsl->begin() && i != dsl->end()) { + if (i != rl->begin() && i != rl->end()) { /* we didn't get to all the streams */ disk_work_outstanding = true; } diff --git a/libs/ardour/diskstream.cc b/libs/ardour/diskstream.cc index ab4bd71663..40a2714dc0 100644 --- a/libs/ardour/diskstream.cc +++ b/libs/ardour/diskstream.cc @@ -52,7 +52,7 @@ #include "ardour/panner.h" #include "ardour/session.h" #include "ardour/io.h" -#include "ardour/route.h" +#include "ardour/track.h" #include "i18n.h" #include @@ -74,7 +74,7 @@ PBD::Signal0 Diskstream::DiskUnderrun; Diskstream::Diskstream (Session &sess, const string &name, Flag flag) : SessionObject(sess, name) , i_am_the_modifier (0) - , _route (0) + , _track (0) , _record_enabled (0) , _visible_speed (1.0f) , _actual_speed (1.0f) @@ -96,7 +96,7 @@ Diskstream::Diskstream (Session &sess, const string &name, Flag flag) , loop_location (0) , overwrite_frame (0) , overwrite_offset (0) - , pending_overwrite (false) + , _pending_overwrite (false) , overwrite_queued (false) , input_change_pending (NoChange) , wrap_buffer_size (0) @@ -122,7 +122,7 @@ Diskstream::Diskstream (Session &sess, const string &name, Flag flag) Diskstream::Diskstream (Session& sess, const XMLNode& /*node*/) : SessionObject(sess, "unnamed diskstream") , i_am_the_modifier (0) - , _route (0) + , _track (0) , _record_enabled (0) , _visible_speed (1.0f) , _actual_speed (1.0f) @@ -144,7 +144,7 @@ Diskstream::Diskstream (Session& sess, const XMLNode& /*node*/) , loop_location (0) , overwrite_frame (0) , overwrite_offset (0) - , pending_overwrite (false) + , _pending_overwrite (false) , overwrite_queued (false) , input_change_pending (NoChange) , wrap_buffer_size (0) @@ -176,10 +176,10 @@ Diskstream::~Diskstream () } void -Diskstream::set_route (Route& r) +Diskstream::set_track (Track* t) { - _route = &r; - _io = _route->input(); + _track = t; + _io = _track->input(); ic_connection.disconnect(); _io->changed.connect_same_thread (ic_connection, boost::bind (&Diskstream::handle_input_change, this, _1, _2)); @@ -188,7 +188,7 @@ Diskstream::set_route (Route& r) non_realtime_input_change (); set_align_style_from_io (); - _route->Destroyed.connect_same_thread (*this, boost::bind (&Diskstream::route_going_away, this)); + _track->Destroyed.connect_same_thread (*this, boost::bind (&Diskstream::route_going_away, this)); } void @@ -331,15 +331,6 @@ Diskstream::set_roll_delay (ARDOUR::nframes_t nframes) _roll_delay = nframes; } -void -Diskstream::set_speed (double sp) -{ - _session.request_diskstream_speed (*this, sp); - - /* to force a rebuffering at the right place */ - playlist_modified(); -} - int Diskstream::use_playlist (boost::shared_ptr playlist) { @@ -381,7 +372,7 @@ Diskstream::use_playlist (boost::shared_ptr playlist) */ if (!overwrite_queued && prior_playlist) { - _session.request_overwrite_buffer (this); + _session.request_overwrite_buffer (_track); overwrite_queued = true; } @@ -401,7 +392,7 @@ void Diskstream::playlist_modified () { if (!i_am_the_modifier && !overwrite_queued) { - _session.request_overwrite_buffer (this); + _session.request_overwrite_buffer (_track); overwrite_queued = true; } } @@ -459,7 +450,7 @@ Diskstream::remove_region_from_last_capture (boost::weak_ptr wregion) void Diskstream::playlist_ranges_moved (list< Evoral::RangeMove > const & movements_frames) { - if (!_route || Config->get_automation_follows_regions () == false) { + if (!_track || Config->get_automation_follows_regions () == false) { return; } @@ -473,7 +464,7 @@ Diskstream::playlist_ranges_moved (list< Evoral::RangeMove > const & } /* move panner automation */ - boost::shared_ptr p = _route->main_outs()->panner (); + boost::shared_ptr p = _track->main_outs()->panner (); if (p) { for (uint32_t i = 0; i < p->npanners (); ++i) { boost::shared_ptr pan_alist = p->streampanner(i).pan_control()->alist(); @@ -485,7 +476,7 @@ Diskstream::playlist_ranges_moved (list< Evoral::RangeMove > const & } /* move processor automation */ - _route->foreach_processor (boost::bind (&Diskstream::move_processor_automation, this, _1, movements_frames)); + _track->foreach_processor (boost::bind (&Diskstream::move_processor_automation, this, _1, movements_frames)); } void diff --git a/libs/ardour/enums.cc b/libs/ardour/enums.cc index a758804564..3f7fee3aee 100644 --- a/libs/ardour/enums.cc +++ b/libs/ardour/enums.cc @@ -290,7 +290,7 @@ setup_enum_writer () REGISTER (_Session_RecordState); REGISTER_CLASS_ENUM (SessionEvent, SetTransportSpeed); - REGISTER_CLASS_ENUM (SessionEvent, SetDiskstreamSpeed); + REGISTER_CLASS_ENUM (SessionEvent, SetTrackSpeed); REGISTER_CLASS_ENUM (SessionEvent, Locate); REGISTER_CLASS_ENUM (SessionEvent, LocateRoll); REGISTER_CLASS_ENUM (SessionEvent, LocateRollLocate); diff --git a/libs/ardour/midi_diskstream.cc b/libs/ardour/midi_diskstream.cc index 8bf5ce89b7..8b047490e7 100644 --- a/libs/ardour/midi_diskstream.cc +++ b/libs/ardour/midi_diskstream.cc @@ -55,6 +55,7 @@ #include "ardour/smf_source.h" #include "ardour/utils.h" #include "ardour/session_playlists.h" +#include "ardour/route.h" #include "midi++/types.h" @@ -608,7 +609,7 @@ MidiDiskstream::set_pending_overwrite (bool yn) { /* called from audio thread, so we can use the read ptr and playback sample as we wish */ - pending_overwrite = yn; + _pending_overwrite = yn; overwrite_frame = playback_sample; } @@ -618,7 +619,7 @@ MidiDiskstream::overwrite_existing_buffers () { //read(overwrite_frame, disk_io_chunk_frames, false); overwrite_queued = false; - pending_overwrite = false; + _pending_overwrite = false; return 0; } @@ -882,7 +883,7 @@ out: } void -MidiDiskstream::transport_stopped (struct tm& /*when*/, time_t /*twhen*/, bool abort_capture) +MidiDiskstream::transport_stopped_wallclock (struct tm& /*when*/, time_t /*twhen*/, bool abort_capture) { bool more_work = true; int err = 0; @@ -1160,7 +1161,7 @@ MidiDiskstream::disengage_record_enable () XMLNode& MidiDiskstream::get_state () { - XMLNode* node = new XMLNode ("MidiDiskstream"); + XMLNode* node = new XMLNode ("Diskstream"); char buf[64]; LocaleGuard lg (X_("POSIX")); @@ -1276,7 +1277,7 @@ MidiDiskstream::set_state (const XMLNode& node, int /*version*/) } if (!had_playlist) { - _playlist->set_orig_diskstream_id (_id); + _playlist->set_orig_diskstream_id (id()); } if (capture_pending_node) { @@ -1329,7 +1330,7 @@ MidiDiskstream::use_new_write_source (uint32_t n) } try { - _write_source = boost::dynamic_pointer_cast(_session.create_midi_source_for_session (*this)); + _write_source = boost::dynamic_pointer_cast(_session.create_midi_source_for_session (name ())); if (!_write_source) { throw failed_constructor(); } diff --git a/libs/ardour/midi_track.cc b/libs/ardour/midi_track.cc index 2c543ed877..10bd7a23a5 100644 --- a/libs/ardour/midi_track.cc +++ b/libs/ardour/midi_track.cc @@ -77,7 +77,8 @@ MidiTrack::use_new_diskstream () assert(_mode != Destructive); boost::shared_ptr ds (new MidiDiskstream (_session, name(), dflags)); - _session.add_diskstream (ds); + ds->do_refill_with_alloc (); + ds->set_block_size (_session.get_block_size ()); set_diskstream (boost::dynamic_pointer_cast (ds)); } @@ -85,8 +86,9 @@ MidiTrack::use_new_diskstream () void MidiTrack::set_diskstream (boost::shared_ptr ds) { - _diskstream = ds; - _diskstream->set_route (*this); + Track::set_diskstream (ds); + + _diskstream->set_track (this); _diskstream->set_destructive (_mode == Destructive); _diskstream->set_record_enabled (false); @@ -185,25 +187,9 @@ MidiTrack::state(bool full_state) root.add_child_nocopy (*freeze_node); } - /* Alignment: act as a proxy for the diskstream */ - - XMLNode* align_node = new XMLNode (X_("Alignment")); - AlignStyle as = _diskstream->alignment_style (); - align_node->add_property (X_("style"), enum_2_string (as)); - root.add_child_nocopy (*align_node); - root.add_property (X_("note-mode"), enum_2_string (_note_mode)); - - /* we don't return diskstream state because we don't - own the diskstream exclusively. control of the diskstream - state is ceded to the Session, even if we create the - diskstream. - */ - - _diskstream->id().print (buf, sizeof(buf)); - root.add_property ("diskstream-id", buf); - root.add_child_nocopy (_rec_enable_control->get_state()); + root.add_child_nocopy (_diskstream->get_state ()); root.add_property ("step-editing", (_step_editing ? "yes" : "no")); root.add_property ("note-mode", enum_2_string (_note_mode)); @@ -272,28 +258,13 @@ MidiTrack::set_state_part_two () } } - /* Alignment: act as a proxy for the diskstream */ - - if ((fnode = find_named_node (*pending_state, X_("Alignment"))) != 0) { - - if ((prop = fnode->property (X_("style"))) != 0) { - - /* fix for older sessions from before EnumWriter */ - - string pstr; - - if (prop->value() == "capture") { - pstr = "CaptureTime"; - } else if (prop->value() == "existing") { - pstr = "ExistingMaterial"; - } else { - pstr = prop->value(); - } - - AlignStyle as = AlignStyle (string_2_enum (pstr, as)); - _diskstream->set_persistent_align_style (as); - } + if ((fnode = find_named_node (*pending_state, X_("Diskstream"))) != 0) { + boost::shared_ptr ds (new MidiDiskstream (_session, *fnode)); + ds->do_refill_with_alloc (); + ds->set_block_size (_session.get_block_size ()); + set_diskstream (ds); } + return; } @@ -392,7 +363,7 @@ MidiTrack::no_roll (nframes_t nframes, sframes_t start_frame, sframes_t end_fram { int ret = Track::no_roll (nframes, start_frame, end_frame, state_changing, can_record, rec_monitors_input); - if (ret == 0 && diskstream()->record_enabled() && _step_editing) { + if (ret == 0 && _diskstream->record_enabled() && _step_editing) { push_midi_input_to_step_edit_ringbuffer (nframes); } @@ -595,3 +566,11 @@ MidiTrack::set_midi_thru (bool yn) { _midi_thru = yn; } + +boost::shared_ptr +MidiTrack::write_source (uint32_t n) +{ + boost::shared_ptr ds = boost::dynamic_pointer_cast (_diskstream); + assert (ds); + return ds->write_source (); +} diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc index 6fc7fdc2cf..649d549b86 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -178,7 +178,7 @@ Playlist::Playlist (boost::shared_ptr other, string namestr, boo : SessionObject(other->_session, namestr) , regions (*this) , _type(other->_type) - , _orig_diskstream_id(other->_orig_diskstream_id) + , _orig_diskstream_id (other->_orig_diskstream_id) { init (hide); @@ -213,7 +213,7 @@ Playlist::Playlist (boost::shared_ptr other, framepos_t start, f : SessionObject(other->_session, str) , regions (*this) , _type(other->_type) - , _orig_diskstream_id(other->_orig_diskstream_id) + , _orig_diskstream_id (other->_orig_diskstream_id) { RegionLock rlock2 (const_cast (other.get())); diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 7f316c953a..5c9ee380c9 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -141,7 +141,6 @@ Session::Session (AudioEngine &eng, _butler (new Butler (*this)), _post_transport_work (0), _send_timecode_update (false), - diskstreams (new DiskstreamList), routes (new RouteList), _total_free_4k_blocks (0), _bundles (new BundleList), @@ -151,7 +150,7 @@ Session::Session (AudioEngine &eng, click_emphasis_data (0), main_outs (0), _metadata (new SessionMetadata()), - _have_rec_enabled_diskstream (false) + _have_rec_enabled_track (false) { playlists.reset (new SessionPlaylists); @@ -246,7 +245,6 @@ Session::destroy () /* clear out any pending dead wood from RCU managed objects */ routes.flush (); - diskstreams.flush (); _bundles.flush (); AudioDiskstream::free_working_buffers(); @@ -286,19 +284,6 @@ Session::destroy () boost::shared_ptr r = routes.reader (); - DEBUG_TRACE (DEBUG::Destruction, "delete diskstreams\n"); - { - RCUWriter dwriter (diskstreams); - boost::shared_ptr dsl = dwriter.get_copy(); - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - DEBUG_TRACE(DEBUG::Destruction, string_compose ("Dropping for diskstream %1 ; pre-ref = %2\n", (*i)->name(), (*i).use_count())); - (*i)->drop_references (); - } - - dsl->clear (); - } - diskstreams.flush (); - DEBUG_TRACE (DEBUG::Destruction, "delete sources\n"); for (SourceMap::iterator i = sources.begin(); i != sources.end(); ++i) { DEBUG_TRACE(DEBUG::Destruction, string_compose ("Dropping for source %1 ; pre-ref = %2\n", i->second->path(), i->second.use_count())); @@ -722,16 +707,16 @@ Session::playlist_length_changed () } void -Session::diskstream_playlist_changed (boost::weak_ptr wp) +Session::track_playlist_changed (boost::weak_ptr wp) { - boost::shared_ptr dstream = wp.lock (); - if (!dstream) { + boost::shared_ptr track = wp.lock (); + if (!track) { return; } boost::shared_ptr playlist; - if ((playlist = dstream->playlist()) != 0) { + if ((playlist = track->playlist()) != 0) { playlist->LengthChanged.connect_same_thread (*this, boost::bind (&Session::playlist_length_changed, this)); } @@ -758,21 +743,23 @@ Session::reset_input_monitor_state () { if (transport_rolling()) { - boost::shared_ptr dsl = diskstreams.reader(); - - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - if ((*i)->record_enabled ()) { + boost::shared_ptr rl = routes.reader (); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr && tr->record_enabled ()) { //cerr << "switching to input = " << !auto_input << __FILE__ << __LINE__ << endl << endl; - (*i)->monitor_input (Config->get_monitoring_model() == HardwareMonitoring && !config.get_auto_input()); + tr->monitor_input (Config->get_monitoring_model() == HardwareMonitoring && !config.get_auto_input()); } } + } else { - boost::shared_ptr dsl = diskstreams.reader(); - - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - if ((*i)->record_enabled ()) { + + boost::shared_ptr rl = routes.reader (); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr && tr->record_enabled ()) { //cerr << "switching to input = " << !Config->get_auto_input() << __FILE__ << __LINE__ << endl << endl; - (*i)->monitor_input (Config->get_monitoring_model() == HardwareMonitoring); + tr->monitor_input (Config->get_monitoring_model() == HardwareMonitoring); } } } @@ -979,10 +966,12 @@ Session::enable_record () deliver_mmc(MIDI::MachineControl::cmdRecordStrobe, _last_record_location); if (Config->get_monitoring_model() == HardwareMonitoring && config.get_auto_input()) { - boost::shared_ptr dsl = diskstreams.reader(); - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - if ((*i)->record_enabled ()) { - (*i)->monitor_input (true); + + boost::shared_ptr rl = routes.reader (); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr && tr->record_enabled ()) { + tr->monitor_input (true); } } } @@ -1014,11 +1003,12 @@ Session::disable_record (bool rt_context, bool force) } if (Config->get_monitoring_model() == HardwareMonitoring && config.get_auto_input()) { - boost::shared_ptr dsl = diskstreams.reader(); - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - if ((*i)->record_enabled ()) { - (*i)->monitor_input (false); + boost::shared_ptr rl = routes.reader (); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr && tr->record_enabled ()) { + tr->monitor_input (false); } } } @@ -1037,12 +1027,12 @@ Session::step_back_from_record () if (g_atomic_int_compare_and_exchange (&_record_status, Recording, Enabled)) { if (Config->get_monitoring_model() == HardwareMonitoring && config.get_auto_input()) { - boost::shared_ptr dsl = diskstreams.reader(); - - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - if ((*i)->record_enabled ()) { + boost::shared_ptr rl = routes.reader (); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr && tr->record_enabled ()) { //cerr << "switching from input" << __FILE__ << __LINE__ << endl << endl; - (*i)->monitor_input (false); + tr->monitor_input (false); } } } @@ -1194,9 +1184,12 @@ Session::set_block_size (nframes_t nframes) (*i)->set_block_size (nframes); } - boost::shared_ptr dsl = diskstreams.reader(); - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - (*i)->set_block_size (nframes); + boost::shared_ptr rl = routes.reader (); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr) { + tr->set_block_size (nframes); + } } set_worst_io_latencies (); @@ -1482,36 +1475,12 @@ Session::new_midi_track (TrackMode mode, RouteGroup* route_group, uint32_t how_m catch (failed_constructor &err) { error << _("Session: could not create new midi track.") << endmsg; - - if (track) { - /* we need to get rid of this, since the track failed to be created */ - /* XXX arguably, AudioTrack::AudioTrack should not do the Session::add_diskstream() */ - - { - RCUWriter writer (diskstreams); - boost::shared_ptr ds = writer.get_copy(); - ds->remove (track->midi_diskstream()); - } - } - goto failed; } catch (AudioEngine::PortRegistrationFailure& pfe) { error << string_compose (_("No more JACK ports are available. You will need to stop %1 and restart JACK with ports if you need this many tracks."), PROGRAM_NAME) << endmsg; - - if (track) { - /* we need to get rid of this, since the track failed to be created */ - /* XXX arguably, MidiTrack::MidiTrack should not do the Session::add_diskstream() */ - - { - RCUWriter writer (diskstreams); - boost::shared_ptr ds = writer.get_copy(); - ds->remove (track->midi_diskstream()); - } - } - goto failed; } @@ -1673,36 +1642,12 @@ Session::new_audio_track (int input_channels, int output_channels, TrackMode mod catch (failed_constructor &err) { error << _("Session: could not create new audio track.") << endmsg; - - if (track) { - /* we need to get rid of this, since the track failed to be created */ - /* XXX arguably, AudioTrack::AudioTrack should not do the Session::add_diskstream() */ - - { - RCUWriter writer (diskstreams); - boost::shared_ptr ds = writer.get_copy(); - ds->remove (track->audio_diskstream()); - } - } - goto failed; } catch (AudioEngine::PortRegistrationFailure& pfe) { error << pfe.what() << endmsg; - - if (track) { - /* we need to get rid of this, since the track failed to be created */ - /* XXX arguably, AudioTrack::AudioTrack should not do the Session::add_diskstream() */ - - { - RCUWriter writer (diskstreams); - boost::shared_ptr ds = writer.get_copy(); - ds->remove (track->audio_diskstream()); - } - } - goto failed; } @@ -1947,6 +1892,13 @@ Session::add_routes (RouteList& new_routes, bool save) if (r->is_monitor()) { _monitor_out = r; } + + boost::shared_ptr tr = boost::dynamic_pointer_cast (r); + if (tr) { + tr->PlaylistChanged.connect_same_thread (*this, boost::bind (&Session::track_playlist_changed, this, boost::weak_ptr (tr))); + track_playlist_changed (boost::weak_ptr (tr)); + tr->RecordEnableChanged.connect_same_thread (*this, boost::bind (&Session::update_have_rec_enabled_track, this)); + } } if (_monitor_out && IO::connecting_legal) { @@ -2067,28 +2019,6 @@ Session::add_internal_sends (boost::shared_ptr dest, Placement p, boost:: graph_reordered (); } -void -Session::add_diskstream (boost::shared_ptr dstream) -{ - /* need to do this in case we're rolling at the time, to prevent false underruns */ - dstream->do_refill_with_alloc (); - - dstream->set_block_size (current_block_size); - - { - RCUWriter writer (diskstreams); - boost::shared_ptr ds = writer.get_copy(); - ds->push_back (dstream); - /* writer goes out of scope, copies ds back to main */ - } - - dstream->PlaylistChanged.connect_same_thread (*this, boost::bind (&Session::diskstream_playlist_changed, this, boost::weak_ptr (dstream))); - /* this will connect to future changes, and check the current length */ - diskstream_playlist_changed (boost::weak_ptr (dstream)); - - dstream->RecordEnableChanged.connect_same_thread (*this, boost::bind (&Session::update_have_rec_enabled_diskstream, this)); -} - void Session::remove_route (shared_ptr route) { @@ -2123,22 +2053,6 @@ Session::remove_route (shared_ptr route) /* writer goes out of scope, forces route list update */ } - boost::shared_ptr t; - boost::shared_ptr ds; - - if ((t = boost::dynamic_pointer_cast(route)) != 0) { - ds = t->diskstream(); - } - - if (ds) { - - { - RCUWriter dsl (diskstreams); - boost::shared_ptr d = dsl.get_copy(); - d->remove (ds); - } - } - find_current_end (); // We need to disconnect the routes inputs and outputs @@ -2385,13 +2299,16 @@ Session::get_maximum_extent () const { nframes_t max = 0; nframes_t me; - - boost::shared_ptr dsl = diskstreams.reader(); - - for (DiskstreamList::const_iterator i = dsl->begin(); i != dsl->end(); ++i) { - if ((*i)->destructive()) //ignore tape tracks when getting max extents + + boost::shared_ptr rl = routes.reader (); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (!tr || tr->destructive()) { + //ignore tape tracks when getting max extents continue; - boost::shared_ptr pl = (*i)->playlist(); + } + + boost::shared_ptr pl = tr->playlist(); if ((me = pl->get_maximum_extent()) > max) { max = me; } @@ -2400,34 +2317,6 @@ Session::get_maximum_extent () const return max; } -boost::shared_ptr -Session::diskstream_by_name (string name) -{ - boost::shared_ptr dsl = diskstreams.reader(); - - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - if ((*i)->name() == name) { - return *i; - } - } - - return boost::shared_ptr((Diskstream*) 0); -} - -boost::shared_ptr -Session::diskstream_by_id (const PBD::ID& id) -{ - boost::shared_ptr dsl = diskstreams.reader(); - - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - if ((*i)->id() == id) { - return *i; - } - } - - return boost::shared_ptr((Diskstream*) 0); -} - /* Region management */ boost::shared_ptr @@ -2496,10 +2385,14 @@ Session::remove_last_capture () { list > r; - boost::shared_ptr dsl = diskstreams.reader(); - - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - list >& l = (*i)->last_capture_regions(); + boost::shared_ptr rl = routes.reader (); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (!tr) { + continue; + } + + list >& l = tr->last_capture_regions(); if (!l.empty()) { r.insert (r.end(), l.begin(), l.end()); @@ -2840,10 +2733,9 @@ Session::new_audio_source_name (const string& base, uint32_t nchan, uint32_t cha /** Create a new within-session audio source */ boost::shared_ptr -Session::create_audio_source_for_session (AudioDiskstream& ds, uint32_t chan, bool destructive) +Session::create_audio_source_for_session (size_t n_chans, string const & n, uint32_t chan, bool destructive) { - const size_t n_chans = ds.n_channels().n_audio(); - const string name = new_audio_source_name (ds.name(), n_chans, chan, destructive); + const string name = new_audio_source_name (n, n_chans, chan, destructive); const string path = new_source_path_from_name(DataType::AUDIO, name); return boost::dynamic_pointer_cast ( @@ -2901,9 +2793,9 @@ Session::new_midi_source_name (const string& base) /** Create a new within-session MIDI source */ boost::shared_ptr -Session::create_midi_source_for_session (MidiDiskstream& ds) +Session::create_midi_source_for_session (string const & n) { - const string name = new_midi_source_name (ds.name()); + const string name = new_midi_source_name (n); const string path = new_source_path_from_name (DataType::MIDI, name); return boost::dynamic_pointer_cast ( @@ -3050,21 +2942,6 @@ Session::is_auditioning () const } } -uint32_t -Session::n_diskstreams () const -{ - uint32_t n = 0; - - boost::shared_ptr dsl = diskstreams.reader(); - - for (DiskstreamList::const_iterator i = dsl->begin(); i != dsl->end(); ++i) { - if (!(*i)->hidden()) { - n++; - } - } - return n; -} - void Session::graph_reordered () { @@ -3088,10 +2965,12 @@ Session::graph_reordered () reflect any changes in latencies within the graph. */ - boost::shared_ptr dsl = diskstreams.reader(); - - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - (*i)->set_capture_offset (); + boost::shared_ptr rl = routes.reader (); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr) { + tr->set_capture_offset (); + } } } @@ -3381,10 +3260,12 @@ Session::remove_named_selection (boost::shared_ptr named_selecti void Session::reset_native_file_format () { - boost::shared_ptr dsl = diskstreams.reader(); - - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - (*i)->reset_write_sources (false); + boost::shared_ptr rl = routes.reader (); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr) { + tr->reset_write_sources (false); + } } } @@ -3469,7 +3350,7 @@ Session::write_one_track (AudioTrack& track, nframes_t start, nframes_t end, /* call tree *MUST* hold route_lock */ - if ((playlist = track.diskstream()->playlist()) == 0) { + if ((playlist = track.playlist()) == 0) { goto out; } @@ -3725,28 +3606,34 @@ Session::sync_order_keys (std::string const & base) set_remote_control_ids (); } -/** @return true if there is at least one record-enabled diskstream, otherwise false */ +/** @return true if there is at least one record-enabled track, otherwise false */ bool -Session::have_rec_enabled_diskstream () const +Session::have_rec_enabled_track () const { - return g_atomic_int_get (&_have_rec_enabled_diskstream) == 1; + return g_atomic_int_get (&_have_rec_enabled_track) == 1; } -/** Update the state of our rec-enabled diskstreams flag */ +/** Update the state of our rec-enabled tracks flag */ void -Session::update_have_rec_enabled_diskstream () +Session::update_have_rec_enabled_track () { - boost::shared_ptr dsl = diskstreams.reader (); - DiskstreamList::iterator i = dsl->begin (); - while (i != dsl->end () && (*i)->record_enabled () == false) { + boost::shared_ptr rl = routes.reader (); + RouteList::iterator i = rl->begin(); + while (i != rl->end ()) { + + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr && tr->record_enabled ()) { + break; + } + ++i; } - int const old = g_atomic_int_get (&_have_rec_enabled_diskstream); + int const old = g_atomic_int_get (&_have_rec_enabled_track); - g_atomic_int_set (&_have_rec_enabled_diskstream, i != dsl->end () ? 1 : 0); + g_atomic_int_set (&_have_rec_enabled_track, i != rl->end () ? 1 : 0); - if (g_atomic_int_get (&_have_rec_enabled_diskstream) != old) { + if (g_atomic_int_get (&_have_rec_enabled_track) != old) { RecordStateChanged (); /* EMIT SIGNAL */ } } @@ -3821,12 +3708,7 @@ Session::get_routes_with_regions_at (nframes64_t const p) const continue; } - boost::shared_ptr ds = tr->diskstream (); - if (!ds) { - continue; - } - - boost::shared_ptr pl = ds->playlist (); + boost::shared_ptr pl = tr->playlist (); if (!pl) { continue; } diff --git a/libs/ardour/session_butler.cc b/libs/ardour/session_butler.cc index 156784875a..1aa061313d 100644 --- a/libs/ardour/session_butler.cc +++ b/libs/ardour/session_butler.cc @@ -40,6 +40,7 @@ #include "ardour/midi_diskstream.h" #include "ardour/session.h" #include "ardour/timestamps.h" +#include "ardour/track.h" #include "i18n.h" @@ -73,30 +74,33 @@ Session::schedule_curve_reallocation () } void -Session::request_overwrite_buffer (Diskstream* stream) +Session::request_overwrite_buffer (Track* t) { SessionEvent *ev = new SessionEvent (SessionEvent::Overwrite, SessionEvent::Add, SessionEvent::Immediate, 0, 0, 0.0); - ev->set_ptr (stream); + ev->set_ptr (t); queue_event (ev); } /** Process thread. */ void -Session::overwrite_some_buffers (Diskstream* ds) +Session::overwrite_some_buffers (Track* t) { if (actively_recording()) { return; } - if (ds) { + if (t) { - ds->set_pending_overwrite (true); + t->set_pending_overwrite (true); } else { - boost::shared_ptr dsl = diskstreams.reader(); - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - (*i)->set_pending_overwrite (true); + boost::shared_ptr rl = routes.reader(); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr) { + tr->set_pending_overwrite (true); + } } } diff --git a/libs/ardour/session_export.cc b/libs/ardour/session_export.cc index ea215e6058..17387ebd5e 100644 --- a/libs/ardour/session_export.cc +++ b/libs/ardour/session_export.cc @@ -21,14 +21,13 @@ #include "pbd/error.h" #include -#include "ardour/audio_diskstream.h" #include "ardour/audioengine.h" #include "ardour/butler.h" #include "ardour/export_failed.h" #include "ardour/export_handler.h" #include "ardour/export_status.h" -#include "ardour/route.h" #include "ardour/session.h" +#include "ardour/track.h" #include "i18n.h" @@ -105,10 +104,11 @@ Session::start_audio_export (nframes_t position, bool /* realtime */) /* get everyone to the right position */ { - boost::shared_ptr dsl = diskstreams.reader(); + boost::shared_ptr rl = routes.reader(); - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - if ((*i)-> seek (position, true)) { + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr && tr->seek (position, true)) { error << string_compose (_("%1: cannot seek to %2 for export"), (*i)->name(), position) << endmsg; diff --git a/libs/ardour/session_process.cc b/libs/ardour/session_process.cc index 85c424e40c..e24b660fb6 100644 --- a/libs/ardour/session_process.cc +++ b/libs/ardour/session_process.cc @@ -28,7 +28,6 @@ #include #include "ardour/ardour.h" -#include "ardour/audio_diskstream.h" #include "ardour/audioengine.h" #include "ardour/auditioner.h" #include "ardour/butler.h" @@ -37,6 +36,7 @@ #include "ardour/session.h" #include "ardour/slave.h" #include "ardour/timestamps.h" +#include "ardour/port.h" #include "midi++/manager.h" @@ -194,20 +194,22 @@ Session::silent_process_routes (nframes_t nframes, bool& need_butler) } void -Session::get_diskstream_statistics () +Session::get_track_statistics () { float pworst = 1.0f; float cworst = 1.0f; - boost::shared_ptr dsl = diskstreams.reader(); - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { + boost::shared_ptr rl = routes.reader(); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { - if ((*i)->hidden()) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + + if (!tr || tr->hidden()) { continue; } - pworst = min (pworst, (*i)->playback_buffer_load()); - cworst = min (cworst, (*i)->capture_buffer_load()); + pworst = min (pworst, tr->playback_buffer_load()); + cworst = min (cworst, tr->capture_buffer_load()); } uint32_t pmin = g_atomic_int_get (&_playback_load); @@ -639,18 +641,21 @@ Session::track_slave_state (float slave_speed, nframes_t slave_transport_frame, bool ok = true; nframes_t frame_delta = slave_transport_frame - _transport_frame; - boost::shared_ptr dsl = diskstreams.reader(); - - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - if (!(*i)->can_internal_playback_seek (frame_delta)) { + boost::shared_ptr rl = routes.reader(); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr && !tr->can_internal_playback_seek (frame_delta)) { ok = false; break; } } if (ok) { - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - (*i)->internal_playback_seek (frame_delta); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr) { + tr->internal_playback_seek (frame_delta); + } } _transport_frame += frame_delta; @@ -1048,11 +1053,11 @@ Session::process_event (SessionEvent* ev) break; case SessionEvent::Overwrite: - overwrite_some_buffers (static_cast(ev->ptr)); + overwrite_some_buffers (static_cast(ev->ptr)); break; - case SessionEvent::SetDiskstreamSpeed: - set_diskstream_speed (static_cast (ev->ptr), ev->speed); + case SessionEvent::SetTrackSpeed: + set_track_speed (static_cast (ev->ptr), ev->speed); break; case SessionEvent::SetSyncSource: diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 9f1adcfe99..833ead56e2 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -605,40 +605,6 @@ Session::create (const string& mix_template, nframes_t initial_length, BusProfil return 0; } - -int -Session::load_diskstreams (const XMLNode& node) -{ - XMLNodeList clist; - XMLNodeConstIterator citer; - - clist = node.children(); - - for (citer = clist.begin(); citer != clist.end(); ++citer) { - - try { - /* diskstreams added automatically by DiskstreamCreated handler */ - if ((*citer)->name() == "AudioDiskstream" || (*citer)->name() == "DiskStream") { - AudioDiskstream* dsp (new AudioDiskstream (*this, **citer)); - boost::shared_ptr dstream (dsp); - add_diskstream (dstream); - } else if ((*citer)->name() == "MidiDiskstream") { - boost::shared_ptr dstream (new MidiDiskstream (*this, **citer)); - add_diskstream (dstream); - } else { - error << _("Session: unknown diskstream type in XML") << endmsg; - } - } - - catch (failed_constructor& err) { - error << _("Session: could not load diskstream via XML state") << endmsg; - return -1; - } - } - - return 0; -} - void Session::maybe_write_autosave() { @@ -1075,17 +1041,6 @@ Session::state(bool full_state) } } - child = node->add_child ("DiskStreams"); - - { - boost::shared_ptr dsl = diskstreams.reader(); - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - if (!(*i)->hidden()) { - child->add_child_nocopy ((*i)->get_state()); - } - } - } - if (full_state) { node->add_child_nocopy (_locations.get_state()); } else { @@ -1236,7 +1191,6 @@ Session::set_state (const XMLNode& node, int version) Locations Sources AudioRegions - AudioDiskstreams Connections Routes RouteGroups @@ -1327,13 +1281,6 @@ Session::set_state (const XMLNode& node, int version) } } - if ((child = find_named_node (node, "DiskStreams")) == 0) { - error << _("Session: XML state has no diskstreams section") << endmsg; - goto out; - } else if (load_diskstreams (*child)) { - goto out; - } - if (version >= 3000) { if ((child = find_named_node (node, "Bundles")) == 0) { warning << _("Session: XML state has no bundles section") << endmsg; @@ -1353,6 +1300,13 @@ Session::set_state (const XMLNode& node, int version) goto out; } + if (version < 3000 && ((child = find_named_node (node, X_("DiskStreams"))) == 0)) { + error << _("Session: XML state has no diskstreams section") << endmsg; + goto out; + } else if (load_diskstreams_2X (*child, version)) { + goto out; + } + if ((child = find_named_node (node, "Routes")) == 0) { error << _("Session: XML state has no routes section") << endmsg; goto out; @@ -1360,6 +1314,9 @@ Session::set_state (const XMLNode& node, int version) goto out; } + /* our diskstreams list is no longer needed as they are now all owned by their Route */ + _diskstreams_2X.clear (); + if (version >= 3000) { if ((child = find_named_node (node, "RouteGroups")) == 0) { @@ -1419,8 +1376,13 @@ Session::load_routes (const XMLNode& node, int version) for (niter = nlist.begin(); niter != nlist.end(); ++niter) { - boost::shared_ptr route (XMLRouteFactory (**niter, version)); - + boost::shared_ptr route; + if (version < 3000) { + route = XMLRouteFactory_2X (**niter, version); + } else { + route = XMLRouteFactory (**niter, version); + } + if (route == 0) { error << _("Session: cannot create Route from XML description.") << endmsg; return -1; @@ -1445,12 +1407,8 @@ Session::XMLRouteFactory (const XMLNode& node, int version) return ret; } - const XMLProperty* dsprop; + XMLNode* ds_child = find_named_node (node, X_("Diskstream")); - if ((dsprop = node.property (X_("diskstream-id"))) == 0) { - dsprop = node.property (X_("diskstream")); - } - DataType type = DataType::AUDIO; const XMLProperty* prop = node.property("default-type"); @@ -1460,28 +1418,80 @@ Session::XMLRouteFactory (const XMLNode& node, int version) assert (type != DataType::NIL); - if (dsprop) { + if (ds_child) { - boost::shared_ptr ds; - PBD::ID diskstream_id (dsprop->value()); - PBD::ID zero ("0"); - - /* this wierd hack is used when creating - tracks from a template. We have a special - ID for the diskstream that means "you - should create a new diskstream here, not - look for an old one." - */ + Track* track; + + if (type == DataType::AUDIO) { + track = new AudioTrack (*this, X_("toBeResetFroXML")); + + } else { + track = new MidiTrack (*this, X_("toBeResetFroXML")); + } + + if (track->init()) { + delete track; + return ret; + } + + if (track->set_state (node, version)) { + delete track; + return ret; + } + + boost_debug_shared_ptr_mark_interesting (track, "Track"); + ret.reset (track); - if (diskstream_id != zero) { + } else { + Route* rt = new Route (*this, X_("toBeResetFroXML")); - ds = diskstream_by_id (diskstream_id); + if (rt->init () == 0 && rt->set_state (node, version) == 0) { + boost_debug_shared_ptr_mark_interesting (rt, "Route"); + ret.reset (rt); + } else { + delete rt; + } + } - if (!ds) { - error << string_compose (_("cannot find diskstream ID %1"), diskstream_id.to_s()) << endmsg; - return ret; - } - } + return ret; +} + +boost::shared_ptr +Session::XMLRouteFactory_2X (const XMLNode& node, int version) +{ + boost::shared_ptr ret; + + if (node.name() != "Route") { + return ret; + } + + XMLProperty const * ds_prop = node.property (X_("diskstream-id")); + if (!ds_prop) { + ds_prop = node.property (X_("diskstream")); + } + + cout << "ds_prop " << ds_prop << "\n"; + + DataType type = DataType::AUDIO; + const XMLProperty* prop = node.property("default-type"); + + if (prop) { + type = DataType (prop->value()); + } + + assert (type != DataType::NIL); + + if (ds_prop) { + + list >::iterator i = _diskstreams_2X.begin (); + while (i != _diskstreams_2X.end() && (*i)->id() != ds_prop->value()) { + ++i; + } + + if (i == _diskstreams_2X.end()) { + error << _("Could not find diskstream for route") << endmsg; + return boost::shared_ptr (); + } Track* track; @@ -1497,16 +1507,12 @@ Session::XMLRouteFactory (const XMLNode& node, int version) return ret; } - if (ds) { - track->set_diskstream (ds); - } else { - track->use_new_diskstream (); - } - if (track->set_state (node, version)) { delete track; return ret; } + + track->set_diskstream (*i); boost_debug_shared_ptr_mark_interesting (track, "Track"); ret.reset (track); @@ -3099,11 +3105,11 @@ Session::config_changed (std::string p, bool ours) if (Config->get_monitoring_model() == HardwareMonitoring && transport_rolling()) { /* auto-input only makes a difference if we're rolling */ - boost::shared_ptr dsl = diskstreams.reader(); - - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - if ((*i)->record_enabled ()) { - (*i)->monitor_input (!config.get_auto_input()); + boost::shared_ptr rl = routes.reader (); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr && tr->record_enabled ()) { + tr->monitor_input (!config.get_auto_input()); } } } @@ -3317,3 +3323,32 @@ Session::set_history_depth (uint32_t d) { _history.set_depth (d); } + +int +Session::load_diskstreams_2X (XMLNode const & node, int) +{ + XMLNodeList clist; + XMLNodeConstIterator citer; + + clist = node.children(); + + for (citer = clist.begin(); citer != clist.end(); ++citer) { + + try { + /* diskstreams added automatically by DiskstreamCreated handler */ + if ((*citer)->name() == "AudioDiskstream" || (*citer)->name() == "DiskStream") { + boost::shared_ptr dsp (new AudioDiskstream (*this, **citer)); + _diskstreams_2X.push_back (dsp); + } else { + error << _("Session: unknown diskstream type in XML") << endmsg; + } + } + + catch (failed_constructor& err) { + error << _("Session: could not load diskstream via XML state") << endmsg; + return -1; + } + } + + return 0; +} diff --git a/libs/ardour/session_transport.cc b/libs/ardour/session_transport.cc index c5e6795325..aab27fe68b 100644 --- a/libs/ardour/session_transport.cc +++ b/libs/ardour/session_transport.cc @@ -32,7 +32,6 @@ #include "midi++/port.h" #include "ardour/ardour.h" -#include "ardour/audio_diskstream.h" #include "ardour/audioengine.h" #include "ardour/auditioner.h" #include "ardour/butler.h" @@ -107,10 +106,10 @@ Session::request_transport_speed (double speed) } void -Session::request_diskstream_speed (Diskstream& ds, double speed) +Session::request_track_speed (Track* tr, double speed) { - SessionEvent* ev = new SessionEvent (SessionEvent::SetDiskstreamSpeed, SessionEvent::Add, SessionEvent::Immediate, 0, speed); - ev->set_ptr (&ds); + SessionEvent* ev = new SessionEvent (SessionEvent::SetTrackSpeed, SessionEvent::Add, SessionEvent::Immediate, 0, speed); + ev->set_ptr (tr); queue_event (ev); } @@ -155,7 +154,7 @@ Session::request_play_loop (bool yn, bool leave_rolling) queue_event (ev); if (!leave_rolling && !yn && Config->get_seamless_loop() && transport_rolling()) { - // request an immediate locate to refresh the diskstreams + // request an immediate locate to refresh the tracks // after disabling looping request_locate (_transport_frame-1, false); } @@ -252,7 +251,6 @@ Session::butler_transport_work () bool finished; PostTransportWork ptw; boost::shared_ptr r = routes.reader (); - boost::shared_ptr dsl = diskstreams.reader(); int on_entry = g_atomic_int_get (&_butler->should_do_transport_work); finished = true; @@ -267,8 +265,11 @@ Session::butler_transport_work () } if (ptw & PostTransportInputChange) { - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - (*i)->non_realtime_input_change (); + for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr) { + tr->non_realtime_input_change (); + } } } @@ -286,9 +287,10 @@ Session::butler_transport_work () if (!(ptw & PostTransportLocate)) { - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - if (!(*i)->hidden()) { - (*i)->non_realtime_locate (_transport_frame); + for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr && !tr->hidden()) { + tr->non_realtime_locate (_transport_frame); } if (on_entry != g_atomic_int_get (&_butler->should_do_transport_work)) { /* new request, stop seeking, and start again */ @@ -331,21 +333,23 @@ Session::butler_transport_work () void Session::non_realtime_set_speed () { - boost::shared_ptr dsl = diskstreams.reader(); - - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - (*i)->non_realtime_set_speed (); + boost::shared_ptr rl = routes.reader(); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr) { + tr->non_realtime_set_speed (); + } } } void Session::non_realtime_overwrite (int on_entry, bool& finished) { - boost::shared_ptr dsl = diskstreams.reader(); - - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - if ((*i)->pending_overwrite) { - (*i)->overwrite_existing_buffers (); + boost::shared_ptr rl = routes.reader(); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr && tr->pending_overwrite ()) { + tr->overwrite_existing_buffers (); } if (on_entry != g_atomic_int_get (&_butler->should_do_transport_work)) { finished = false; @@ -358,10 +362,12 @@ Session::non_realtime_overwrite (int on_entry, bool& finished) void Session::non_realtime_locate () { - boost::shared_ptr dsl = diskstreams.reader(); - - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - (*i)->non_realtime_locate (_transport_frame); + boost::shared_ptr rl = routes.reader(); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr) { + tr->non_realtime_locate (_transport_frame); + } } } @@ -378,10 +384,10 @@ Session::non_realtime_stop (bool abort, int on_entry, bool& finished) did_record = false; saved = false; - boost::shared_ptr dsl = diskstreams.reader(); - - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - if ((*i)->get_captured_frames () != 0) { + boost::shared_ptr rl = routes.reader(); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr && tr->get_captured_frames () != 0) { did_record = true; break; } @@ -436,8 +442,11 @@ Session::non_realtime_stop (bool abort, int on_entry, bool& finished) } DEBUG_TRACE (DEBUG::Transport, X_("Butler PTW: DS stop\n")); - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - (*i)->transport_stopped (*now, xnow, abort); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr) { + tr->transport_stopped_wallclock (*now, xnow, abort); + } } boost::shared_ptr r = routes.reader (); @@ -531,7 +540,7 @@ Session::non_realtime_stop (bool abort, int on_entry, bool& finished) } - /* do this before seeking, because otherwise the Diskstreams will do the wrong thing in seamless loop mode. + /* do this before seeking, because otherwise the tracks will do the wrong thing in seamless loop mode. */ if (ptw & PostTransportClearSubstate) { @@ -541,13 +550,12 @@ Session::non_realtime_stop (bool abort, int on_entry, bool& finished) /* this for() block can be put inside the previous if() and has the effect of ... ??? what */ - DEBUG_TRACE (DEBUG::Transport, X_("Butler PTW: locate\n")); - - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - if (!(*i)->hidden()) { - DEBUG_TRACE (DEBUG::Transport, string_compose ("Butler PTW: locate on %1\n", (*i)->name())); - (*i)->non_realtime_locate (_transport_frame); + for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { + DEBUG_TRACE (DEBUG::Transport, string_compose ("Butler PTW: locate on %1\n", (*i)->name())); + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr && !tr->hidden()) { + tr->non_realtime_locate (_transport_frame); } if (on_entry != g_atomic_int_get (&_butler->should_do_transport_work)) { @@ -631,11 +639,12 @@ Session::unset_play_loop () play_loop = false; clear_events (SessionEvent::AutoLoop); - // set all diskstreams to NOT use internal looping - boost::shared_ptr dsl = diskstreams.reader(); - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - if (!(*i)->hidden()) { - (*i)->set_loop (0); + // set all tracks to NOT use internal looping + boost::shared_ptr rl = routes.reader (); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr && !tr->hidden()) { + tr->set_loop (0); } } } @@ -670,20 +679,22 @@ Session::set_play_loop (bool yn) unset_play_range (); if (Config->get_seamless_loop()) { - // set all diskstreams to use internal looping - boost::shared_ptr dsl = diskstreams.reader(); - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - if (!(*i)->hidden()) { - (*i)->set_loop (loc); + // set all tracks to use internal looping + boost::shared_ptr rl = routes.reader (); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr && !tr->hidden()) { + tr->set_loop (loc); } } } else { - // set all diskstreams to NOT use internal looping - boost::shared_ptr dsl = diskstreams.reader(); - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - if (!(*i)->hidden()) { - (*i)->set_loop (0); + // set all tracks to NOT use internal looping + boost::shared_ptr rl = routes.reader (); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr && !tr->hidden()) { + tr->set_loop (0); } } } @@ -749,16 +760,19 @@ Session::start_locate (nframes64_t target_frame, bool with_roll, bool with_flush int Session::micro_locate (nframes_t distance) { - boost::shared_ptr dsl = diskstreams.reader(); - - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - if (!(*i)->can_internal_playback_seek (distance)) { + boost::shared_ptr rl = routes.reader(); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr && !tr->can_internal_playback_seek (distance)) { return -1; } } - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - (*i)->internal_playback_seek (distance); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr) { + tr->internal_playback_seek (distance); + } } _transport_frame += distance; @@ -834,24 +848,25 @@ Session::locate (nframes64_t target_frame, bool with_roll, bool with_flush, bool /* switch from input if we're going to roll */ if (Config->get_monitoring_model() == HardwareMonitoring) { - boost::shared_ptr dsl = diskstreams.reader(); - - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - if ((*i)->record_enabled ()) { + boost::shared_ptr rl = routes.reader(); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr && tr->record_enabled ()) { //cerr << "switching from input" << __FILE__ << __LINE__ << endl << endl; - (*i)->monitor_input (!config.get_auto_input()); + tr->monitor_input (!config.get_auto_input()); } } } } else { /* otherwise we're going to stop, so do the opposite */ if (Config->get_monitoring_model() == HardwareMonitoring) { - boost::shared_ptr dsl = diskstreams.reader(); - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - if ((*i)->record_enabled ()) { + boost::shared_ptr rl = routes.reader(); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr && tr->record_enabled ()) { //cerr << "switching to input" << __FILE__ << __LINE__ << endl << endl; - (*i)->monitor_input (true); + tr->monitor_input (true); } } } @@ -869,12 +884,12 @@ Session::locate (nframes64_t target_frame, bool with_roll, bool with_flush, bool if (with_loop) { // this is only necessary for seamless looping - boost::shared_ptr dsl = diskstreams.reader(); - - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - if ((*i)->record_enabled ()) { + boost::shared_ptr rl = routes.reader(); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr && tr->record_enabled ()) { // tell it we've looped, so it can deal with the record state - (*i)->transport_looped(_transport_frame); + tr->transport_looped(_transport_frame); } } } @@ -921,12 +936,12 @@ Session::set_transport_speed (double speed, bool abort, bool clear_state) if (Config->get_monitoring_model() == HardwareMonitoring) { - boost::shared_ptr dsl = diskstreams.reader(); - - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - if ((*i)->record_enabled ()) { + boost::shared_ptr rl = routes.reader(); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr && tr->record_enabled ()) { //cerr << "switching to input" << __FILE__ << __LINE__ << endl << endl; - (*i)->monitor_input (true); + tr->monitor_input (true); } } } @@ -950,12 +965,12 @@ Session::set_transport_speed (double speed, bool abort, bool clear_state) if (Config->get_monitoring_model() == HardwareMonitoring) { - boost::shared_ptr dsl = diskstreams.reader(); - - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - if (config.get_auto_input() && (*i)->record_enabled ()) { + boost::shared_ptr rl = routes.reader(); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (config.get_auto_input() && tr && tr->record_enabled ()) { //cerr << "switching from input" << __FILE__ << __LINE__ << endl << endl; - (*i)->monitor_input (false); + tr->monitor_input (false); } } } @@ -1002,9 +1017,10 @@ Session::set_transport_speed (double speed, bool abort, bool clear_state) _last_transport_speed = _transport_speed; _transport_speed = speed; - boost::shared_ptr dsl = diskstreams.reader(); - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - if ((*i)->realtime_set_speed ((*i)->speed(), true)) { + boost::shared_ptr rl = routes.reader(); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr && tr->realtime_set_speed (tr->speed(), true)) { todo = PostTransportWork (todo | PostTransportSpeed); break; } @@ -1028,10 +1044,12 @@ Session::stop_transport (bool abort, bool clear_state) if (actively_recording() && !(transport_sub_state & StopPendingCapture) && _worst_output_latency > current_block_size) { - boost::shared_ptr dsl = diskstreams.reader(); - - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - (*i)->prepare_to_stop (_transport_frame); + boost::shared_ptr rl = routes.reader(); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr) { + tr->prepare_to_stop (_transport_frame); + } } /* we need to capture the audio that has still not yet been received by the system @@ -1056,10 +1074,12 @@ Session::stop_transport (bool abort, bool clear_state) if ((transport_sub_state & PendingDeclickOut) == 0) { if (!(transport_sub_state & StopPendingCapture)) { - boost::shared_ptr dsl = diskstreams.reader(); - - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - (*i)->prepare_to_stop (_transport_frame); + boost::shared_ptr rl = routes.reader(); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr) { + tr->prepare_to_stop (_transport_frame); + } } } @@ -1105,9 +1125,12 @@ Session::start_transport () _transport_speed = 1.0; _target_transport_speed = 1.0; - boost::shared_ptr dsl = diskstreams.reader(); - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - (*i)->realtime_set_speed ((*i)->speed(), true); + boost::shared_ptr rl = routes.reader(); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr) { + tr->realtime_set_speed (tr->speed(), true); + } } deliver_mmc(MIDI::MachineControl::cmdDeferredPlay, _transport_frame); @@ -1185,13 +1208,14 @@ Session::use_sync_source (Slave* new_slave) delete _slave; _slave = new_slave; - boost::shared_ptr dsl = diskstreams.reader(); - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - if (!(*i)->hidden()) { - if ((*i)->realtime_set_speed ((*i)->speed(), true)) { + boost::shared_ptr rl = routes.reader(); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr && !tr->hidden()) { + if (tr->realtime_set_speed (tr->speed(), true)) { non_rt_required = true; } - (*i)->set_slaved (_slave != 0); + tr->set_slaved (_slave != 0); } } @@ -1274,16 +1298,16 @@ Session::switch_to_sync_source (SyncSource src) } void -Session::reverse_diskstream_buffers () +Session::reverse_track_buffers () { add_post_transport_work (PostTransportReverse); _butler->schedule_transport_work (); } void -Session::set_diskstream_speed (Diskstream* stream, double speed) +Session::set_track_speed (Track* track, double speed) { - if (stream->realtime_set_speed (speed, false)) { + if (track->realtime_set_speed (speed, false)) { add_post_transport_work (PostTransportSpeed); _butler->schedule_transport_work (); set_dirty (); @@ -1501,11 +1525,13 @@ Session::update_latency_compensation (bool with_stop, bool abort) /* reflect any changes in latencies into capture offsets */ - - boost::shared_ptr dsl = diskstreams.reader(); - - for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) { - (*i)->set_capture_offset (); + + boost::shared_ptr rl = routes.reader(); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr) { + tr->set_capture_offset (); + } } } diff --git a/libs/ardour/track.cc b/libs/ardour/track.cc index 47ec248d59..a7325189c8 100644 --- a/libs/ardour/track.cc +++ b/libs/ardour/track.cc @@ -261,7 +261,7 @@ Track::no_roll (nframes_t nframes, framepos_t start_frame, framepos_t end_frame, */ } - diskstream()->check_record_status (start_frame, nframes, can_record); + _diskstream->check_record_status (start_frame, nframes, can_record); bool send_silence; @@ -346,7 +346,7 @@ Track::silent_roll (nframes_t nframes, framepos_t /*start_frame*/, framepos_t /* silence (nframes); - return diskstream()->process (_session.transport_frame(), nframes, can_record, rec_monitors_input, need_butler); + return _diskstream->process (_session.transport_frame(), nframes, can_record, rec_monitors_input, need_butler); } ChanCount @@ -361,3 +361,297 @@ Track::input_streams () const return cc; } +void +Track::set_diskstream (boost::shared_ptr ds) +{ + _diskstream = ds; + + ds->PlaylistChanged.connect_same_thread (*this, boost::bind (&Track::diskstream_playlist_changed, this)); + diskstream_playlist_changed (); + ds->RecordEnableChanged.connect_same_thread (*this, boost::bind (&Track::diskstream_record_enable_changed, this)); + ds->SpeedChanged.connect_same_thread (*this, boost::bind (&Track::diskstream_speed_changed, this)); + ds->AlignmentStyleChanged.connect_same_thread (*this, boost::bind (&Track::diskstream_alignment_style_changed, this)); +} + +void +Track::diskstream_playlist_changed () +{ + PlaylistChanged (); /* EMIT SIGNAL */ +} + +void +Track::diskstream_record_enable_changed () +{ + RecordEnableChanged (); /* EMIT SIGNAL */ +} + +void +Track::diskstream_speed_changed () +{ + SpeedChanged (); /* EMIT SIGNAL */ +} + +void +Track::diskstream_alignment_style_changed () +{ + AlignmentStyleChanged (); /* EMIT SIGNAL */ +} + +boost::shared_ptr +Track::playlist () +{ + return _diskstream->playlist (); +} + +void +Track::monitor_input (bool m) +{ + _diskstream->monitor_input (m); +} + +bool +Track::destructive () const +{ + return _diskstream->destructive (); +} + +list > & +Track::last_capture_regions () +{ + return _diskstream->last_capture_regions (); +} + +void +Track::set_capture_offset () +{ + _diskstream->set_capture_offset (); +} + +void +Track::reset_write_sources (bool r, bool force) +{ + _diskstream->reset_write_sources (r, force); +} + +float +Track::playback_buffer_load () const +{ + return _diskstream->playback_buffer_load (); +} + +float +Track::capture_buffer_load () const +{ + return _diskstream->capture_buffer_load (); +} + +int +Track::do_refill () +{ + return _diskstream->do_refill (); +} + +int +Track::do_flush (RunContext c, bool force) +{ + return _diskstream->do_flush (c, force); +} + +void +Track::set_pending_overwrite (bool o) +{ + _diskstream->set_pending_overwrite (o); +} + +int +Track::seek (nframes_t s, bool complete_refill) +{ + return _diskstream->seek (s, complete_refill); +} + +bool +Track::hidden () const +{ + return _diskstream->hidden (); +} + +int +Track::can_internal_playback_seek (nframes_t d) +{ + return _diskstream->can_internal_playback_seek (d); +} + +int +Track::internal_playback_seek (nframes_t d) +{ + return _diskstream->internal_playback_seek (d); +} + +void +Track::non_realtime_input_change () +{ + _diskstream->non_realtime_input_change (); +} + +void +Track::non_realtime_locate (nframes_t p) +{ + _diskstream->non_realtime_locate (p); +} + +void +Track::non_realtime_set_speed () +{ + _diskstream->non_realtime_set_speed (); +} + +int +Track::overwrite_existing_buffers () +{ + return _diskstream->overwrite_existing_buffers (); +} + +nframes_t +Track::get_captured_frames (uint32_t n) +{ + return _diskstream->get_captured_frames (n); +} + +int +Track::set_loop (Location* l) +{ + return _diskstream->set_loop (l); +} + +void +Track::transport_looped (nframes_t f) +{ + _diskstream->transport_looped (f); +} + +bool +Track::realtime_set_speed (double s, bool g) +{ + return _diskstream->realtime_set_speed (s, g); +} + +void +Track::transport_stopped_wallclock (struct tm & n, time_t t, bool g) +{ + _diskstream->transport_stopped_wallclock (n, t, g); +} + +bool +Track::pending_overwrite () const +{ + return _diskstream->pending_overwrite (); +} + +double +Track::speed () const +{ + return _diskstream->speed (); +} + +void +Track::prepare_to_stop (framepos_t p) +{ + _diskstream->prepare_to_stop (p); +} + +void +Track::set_slaved (bool s) +{ + _diskstream->set_slaved (s); +} + +ChanCount +Track::n_channels () +{ + return _diskstream->n_channels (); +} + +nframes_t +Track::get_capture_start_frame (uint32_t n) +{ + return _diskstream->get_capture_start_frame (n); +} + +AlignStyle +Track::alignment_style () const +{ + return _diskstream->alignment_style (); +} + +void +Track::set_record_enabled (bool r) +{ + _diskstream->set_record_enabled (r); +} + +nframes_t +Track::current_capture_start () const +{ + return _diskstream->current_capture_start (); +} + +nframes_t +Track::current_capture_end () const +{ + return _diskstream->current_capture_end (); +} + +void +Track::playlist_modified () +{ + _diskstream->playlist_modified (); +} + +int +Track::use_playlist (boost::shared_ptr p) +{ + return _diskstream->use_playlist (p); +} + +int +Track::use_copy_playlist () +{ + return _diskstream->use_copy_playlist (); +} + +int +Track::use_new_playlist () +{ + return _diskstream->use_new_playlist (); +} + +uint32_t +Track::read_data_count () const +{ + return _diskstream->read_data_count (); +} + +void +Track::set_align_style (AlignStyle s) +{ + _diskstream->set_align_style (s); +} + +uint32_t +Track::write_data_count () const +{ + return _diskstream->write_data_count (); +} + +PBD::ID const & +Track::diskstream_id () const +{ + return _diskstream->id (); +} + +void +Track::set_block_size (nframes_t n) +{ + Route::set_block_size (n); + _diskstream->set_block_size (n); +} -- cgit v1.2.3