diff options
82 files changed, 1213 insertions, 1215 deletions
diff --git a/gtk2_ardour/SConscript b/gtk2_ardour/SConscript index 68e07ebd22..c5409d7f8b 100644 --- a/gtk2_ardour/SConscript +++ b/gtk2_ardour/SConscript @@ -141,8 +141,6 @@ marker.cc marker_time_axis.cc marker_time_axis_view.cc marker_view.cc -meter_bridge.cc -meter_bridge_strip.cc mixer_strip.cc mixer_ui.cc new_session_dialog.cc diff --git a/gtk2_ardour/ardour.menus b/gtk2_ardour/ardour.menus index 9293883067..b1064b8e87 100644 --- a/gtk2_ardour/ardour.menus +++ b/gtk2_ardour/ardour.menus @@ -15,8 +15,10 @@ <separator/> <menu action='addExistingAudioFiles'> <menuitem action='addExternalAudioAsRegion'/> - <menuitem action='addExternalAudioAsTrack'/> <menuitem action='addExternalAudioToTrack'/> + <separator/> + <menuitem action='addExternalAudioAsTrack'/> + <menuitem action='addExternalAudioAsTapeTrack'/> </menu> <separator/> <menu name='Export' action='Export'> diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 732c829a38..c9116ac4e9 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -876,7 +876,7 @@ ARDOUR_UI::session_add_midi_track () void ARDOUR_UI::session_add_audio_route (bool disk, int32_t input_channels, int32_t output_channels, ARDOUR::TrackMode mode) { - Route* route; + boost::shared_ptr<Route> route; if (session == 0) { warning << _("You cannot add a track without a session already loaded.") << endmsg; @@ -1165,13 +1165,13 @@ ARDOUR_UI::toggle_record_enable (uint32_t dstream) return; } - Route* r; + boost::shared_ptr<Route> r; if ((r = session->route_by_remote_id (dstream)) != 0) { AudioTrack* at; - if ((at = dynamic_cast<AudioTrack*>(r)) != 0) { + if ((at = dynamic_cast<AudioTrack*>(r.get())) != 0) { at->disk_stream().set_record_enabled (!at->disk_stream().record_enabled(), this); } } diff --git a/gtk2_ardour/audio_time_axis.cc b/gtk2_ardour/audio_time_axis.cc index 42bf3f5647..5f6d29f9ff 100644 --- a/gtk2_ardour/audio_time_axis.cc +++ b/gtk2_ardour/audio_time_axis.cc @@ -86,7 +86,7 @@ using namespace Gtk; using namespace Editing; -AudioTimeAxisView::AudioTimeAxisView (PublicEditor& ed, Session& sess, Route& rt, Canvas& canvas) +AudioTimeAxisView::AudioTimeAxisView (PublicEditor& ed, Session& sess, boost::shared_ptr<Route> rt, Canvas& canvas) : AxisView(sess), RouteUI(rt, sess, _("m"), _("s"), _("r")), // mute, solo, and record TimeAxisView(sess,ed,(TimeAxisView*) 0, canvas), @@ -211,12 +211,12 @@ AudioTimeAxisView::AudioTimeAxisView (PublicEditor& ed, Session& sess, Route& rt set_state (*xml_node); - _route.mute_changed.connect (mem_fun(*this, &RouteUI::mute_changed)); - _route.solo_changed.connect (mem_fun(*this, &RouteUI::solo_changed)); - _route.redirects_changed.connect (mem_fun(*this, &AudioTimeAxisView::redirects_changed)); - _route.name_changed.connect (mem_fun(*this, &AudioTimeAxisView::route_name_changed)); - _route.solo_safe_changed.connect (mem_fun(*this, &RouteUI::solo_changed)); - _route.panner().Changed.connect (mem_fun(*this, &AudioTimeAxisView::update_pans)); + _route->mute_changed.connect (mem_fun(*this, &RouteUI::mute_changed)); + _route->solo_changed.connect (mem_fun(*this, &RouteUI::solo_changed)); + _route->redirects_changed.connect (mem_fun(*this, &AudioTimeAxisView::redirects_changed)); + _route->name_changed.connect (mem_fun(*this, &AudioTimeAxisView::route_name_changed)); + _route->solo_safe_changed.connect (mem_fun(*this, &RouteUI::solo_changed)); + _route->panner().Changed.connect (mem_fun(*this, &AudioTimeAxisView::update_pans)); if (is_audio_track()) { @@ -321,7 +321,7 @@ gint AudioTimeAxisView::edit_click (GdkEventButton *ev) { if (Keyboard::modifier_state_equals (ev->state, Keyboard::Control)) { - _route.set_edit_group (0, this); + _route->set_edit_group (0, this); return FALSE; } @@ -334,7 +334,7 @@ AudioTimeAxisView::edit_click (GdkEventButton *ev) items.push_back (RadioMenuElem (group, _("No group"), bind (mem_fun(*this, &AudioTimeAxisView::set_edit_group_from_menu), (RouteGroup *) 0))); - if (_route.edit_group() == 0) { + if (_route->edit_group() == 0) { static_cast<RadioMenuItem*>(&items.back())->set_active (); } @@ -354,7 +354,7 @@ AudioTimeAxisView::add_edit_group_menu_item (RouteGroup *eg, RadioMenuItem::Grou cerr << "adding edit group called " << eg->name() << endl; items.push_back (RadioMenuElem (*group, eg->name(), bind (mem_fun(*this, &AudioTimeAxisView::set_edit_group_from_menu), eg))); - if (_route.edit_group() == eg) { + if (_route->edit_group() == eg) { static_cast<RadioMenuItem*>(&items.back())->set_active (); } } @@ -363,7 +363,7 @@ void AudioTimeAxisView::set_edit_group_from_menu (RouteGroup *eg) { - _route.set_edit_group (eg, this); + _route->set_edit_group (eg, this); } void @@ -387,7 +387,7 @@ AudioTimeAxisView::playlist_changed () void AudioTimeAxisView::label_view () { - string x = _route.name(); + string x = _route->name(); if (x != name_entry.get_text()) { name_entry.set_text (x); @@ -460,14 +460,14 @@ AudioTimeAxisView::show_timestretch (jack_nframes_t start, jack_nframes_t end) remember that edit_group() == 0 implies the route is *not* in a edit group. */ - if (!(ts.track == this || (ts.group != 0 && ts.group == _route.edit_group()))) { + if (!(ts.track == this || (ts.group != 0 && ts.group == _route->edit_group()))) { /* this doesn't apply to us */ return; } /* ignore it if our edit group is not active */ - if ((ts.track != this) && _route.edit_group() && !_route.edit_group()->is_active()) { + if ((ts.track != this) && _route->edit_group() && !_route->edit_group()->is_active()) { return; } #endif @@ -515,8 +515,8 @@ AudioTimeAxisView::show_selection (TimeSelection& ts) that the track is not in an edit group). */ - if (((ts.track != this && !is_child (ts.track)) && _route.edit_group() && !_route.edit_group()->is_active()) || - (!(ts.track == this || is_child (ts.track) || (ts.group != 0 && ts.group == _route.edit_group())))) { + if (((ts.track != this && !is_child (ts.track)) && _route->edit_group() && !_route->edit_group()->is_active()) || + (!(ts.track == this || is_child (ts.track) || (ts.group != 0 && ts.group == _route->edit_group())))) { hide_selection (); return; } @@ -631,13 +631,13 @@ AudioTimeAxisView::set_height (TrackHeight h) controls_table.show (); hide_name_entry (); show_name_label (); - name_label.set_text (_route.name()); + name_label.set_text (_route->name()); break; } if (height_changed) { /* only emit the signal if the height really changed */ - _route.gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */ + _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */ } } @@ -788,7 +788,7 @@ AudioTimeAxisView::build_display_menu () items.push_back (SeparatorElem()); items.push_back (CheckMenuElem (_("Active"), mem_fun(*this, &RouteUI::toggle_route_active))); route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back()); - route_active_menu_item->set_active (_route.active()); + route_active_menu_item->set_active (_route->active()); items.push_back (SeparatorElem()); items.push_back (MenuElem (_("Remove"), mem_fun(*this, &RouteUI::remove_this_route))); @@ -1002,7 +1002,7 @@ AudioTimeAxisView::update_diskstream_display () void AudioTimeAxisView::selection_click (GdkEventButton* ev) { - PublicEditor::TrackViewList* tracks = editor.get_valid_views (this, _route.edit_group()); + PublicEditor::TrackViewList* tracks = editor.get_valid_views (this, _route->edit_group()); switch (Keyboard::selection_type (ev->state)) { case Selection::Toggle: @@ -1082,13 +1082,13 @@ AudioTimeAxisView::get_inverted_selectables (Selection& sel, list<Selectable*>& RouteGroup* AudioTimeAxisView::edit_group() const { - return _route.edit_group(); + return _route->edit_group(); } string AudioTimeAxisView::name() const { - return _route.name(); + return _route->name(); } Playlist * @@ -1110,22 +1110,22 @@ AudioTimeAxisView::name_entry_changed () x = name_entry.get_text (); - if (x == _route.name()) { + if (x == _route->name()) { return; } if (x.length() == 0) { - name_entry.set_text (_route.name()); + name_entry.set_text (_route->name()); return; } strip_whitespace_edges(x); if (_session.route_name_unique (x)) { - _route.set_name (x, this); + _route->set_name (x, this); } else { ARDOUR_UI::instance()->popup_error (_("a track already exists with that name")); - name_entry.set_text (_route.name()); + name_entry.set_text (_route->name()); } } @@ -1166,13 +1166,13 @@ AudioTimeAxisView::add_gain_automation_child () *this, parent_canvas, _("gain"), - _route.gain_automation_curve()); + _route->gain_automation_curve()); line = new AutomationGainLine ("automation gain", _session, *gain_track, *gain_track->canvas_display, - _route.gain_automation_curve()); + _route->gain_automation_curve()); line->set_line_color (color_map[cAutomationLine]); @@ -1241,11 +1241,11 @@ AudioTimeAxisView::update_pans () /* we don't draw lines for "greater than stereo" panning. */ - if (_route.n_outputs() > 2) { + if (_route->n_outputs() > 2) { return; } - for (p = _route.panner().begin(); p != _route.panner().end(); ++p) { + for (p = _route->panner().begin(); p != _route->panner().end(); ++p) { AutomationLine* line; @@ -1253,7 +1253,7 @@ AudioTimeAxisView::update_pans () *pan_track->canvas_display, (*p)->automation()); - if (p == _route.panner().begin()) { + if (p == _route->panner().begin()) { /* first line is a nice orange */ line->set_line_color (color_map[cLeftPanAutomationLine]); } else { @@ -1285,7 +1285,7 @@ AudioTimeAxisView::toggle_gain_track () /* now trigger a redisplay */ if (!no_redraw) { - _route.gui_changed (X_("track_height"), (void *) 0); /* EMIT_SIGNAL */ + _route->gui_changed (X_("track_height"), (void *) 0); /* EMIT_SIGNAL */ } } } @@ -1299,7 +1299,7 @@ AudioTimeAxisView::gain_hidden () gain_automation_item->set_active (false); } - _route.gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */ + _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */ } void @@ -1321,7 +1321,7 @@ AudioTimeAxisView::toggle_pan_track () /* now trigger a redisplay */ if (!no_redraw) { - _route.gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */ + _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */ } } } @@ -1335,7 +1335,7 @@ AudioTimeAxisView::pan_hidden () pan_automation_item->set_active (false); } - _route.gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */ + _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */ } AudioTimeAxisView::RedirectAutomationInfo::~RedirectAutomationInfo () @@ -1364,7 +1364,7 @@ AudioTimeAxisView::remove_ran (RedirectAutomationNode* ran) } AudioTimeAxisView::RedirectAutomationNode* -AudioTimeAxisView::find_redirect_automation_node (Redirect *redirect, uint32_t what) +AudioTimeAxisView::find_redirect_automation_node (boost::shared_ptr<Redirect> redirect, uint32_t what) { for (list<RedirectAutomationInfo*>::iterator i = redirect_automation.begin(); i != redirect_automation.end(); ++i) { @@ -1401,7 +1401,7 @@ legalize_for_xml_node (string str) void -AudioTimeAxisView::add_redirect_automation_curve (Redirect *redirect, uint32_t what) +AudioTimeAxisView::add_redirect_automation_curve (boost::shared_ptr<Redirect> redirect, uint32_t what) { RedirectAutomationLine* ral; string name; @@ -1454,7 +1454,7 @@ AudioTimeAxisView::add_redirect_automation_curve (Redirect *redirect, uint32_t w } void -AudioTimeAxisView::redirect_automation_track_hidden (AudioTimeAxisView::RedirectAutomationNode* ran, Redirect* r) +AudioTimeAxisView::redirect_automation_track_hidden (AudioTimeAxisView::RedirectAutomationNode* ran, boost::shared_ptr<Redirect> r) { if (!_hidden) { ran->menu_item->set_active (false); @@ -1462,11 +1462,11 @@ AudioTimeAxisView::redirect_automation_track_hidden (AudioTimeAxisView::Redirect r->mark_automation_visible (ran->what, false); - _route.gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */ + _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */ } void -AudioTimeAxisView::add_existing_redirect_automation_curves (Redirect *redirect) +AudioTimeAxisView::add_existing_redirect_automation_curves (boost::shared_ptr<Redirect> redirect) { set<uint32_t> s; RedirectAutomationLine *ral; @@ -1484,7 +1484,7 @@ AudioTimeAxisView::add_existing_redirect_automation_curves (Redirect *redirect) } void -AudioTimeAxisView::add_redirect_to_subplugin_menu (Redirect* r) +AudioTimeAxisView::add_redirect_to_subplugin_menu (boost::shared_ptr<Redirect> r) { using namespace Menu_Helpers; RedirectAutomationInfo *rai; @@ -1598,7 +1598,7 @@ AudioTimeAxisView::redirect_menu_item_toggled (AudioTimeAxisView::RedirectAutoma /* now trigger a redisplay */ - _route.gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */ + _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */ } } @@ -1614,8 +1614,8 @@ AudioTimeAxisView::redirects_changed (void *src) subplugin_menu.items().clear (); - _route.foreach_redirect (this, &AudioTimeAxisView::add_redirect_to_subplugin_menu); - _route.foreach_redirect (this, &AudioTimeAxisView::add_existing_redirect_automation_curves); + _route->foreach_redirect (this, &AudioTimeAxisView::add_redirect_to_subplugin_menu); + _route->foreach_redirect (this, &AudioTimeAxisView::add_existing_redirect_automation_curves); for (list<RedirectAutomationInfo*>::iterator i = redirect_automation.begin(); i != redirect_automation.end(); ) { @@ -1636,11 +1636,11 @@ AudioTimeAxisView::redirects_changed (void *src) /* change in visibility was possible */ - _route.gui_changed ("track_height", this); + _route->gui_changed ("track_height", this); } RedirectAutomationLine * -AudioTimeAxisView::find_redirect_automation_curve (Redirect *redirect, uint32_t what) +AudioTimeAxisView::find_redirect_automation_curve (boost::shared_ptr<Redirect> redirect, uint32_t what) { RedirectAutomationNode* ran; @@ -1673,7 +1673,7 @@ AudioTimeAxisView::show_all_automation () no_redraw = false; - _route.gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */ + _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */ } void @@ -1694,7 +1694,7 @@ AudioTimeAxisView::show_existing_automation () no_redraw = false; - _route.gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */ + _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */ } void @@ -1712,7 +1712,7 @@ AudioTimeAxisView::hide_all_automation () } no_redraw = false; - _route.gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */ + _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */ } bool @@ -1931,7 +1931,7 @@ AudioTimeAxisView::route_active_changed () RouteUI::route_active_changed (); if (is_audio_track()) { - if (_route.active()) { + if (_route->active()) { controls_ebox.set_name ("AudioTrackControlsBaseUnselected"); controls_base_selected_name = "AudioTrackControlsBaseSelected"; controls_base_unselected_name = "AudioTrackControlsBaseUnselected"; @@ -1941,7 +1941,7 @@ AudioTimeAxisView::route_active_changed () controls_base_unselected_name = "AudioTrackControlsBaseInactiveUnselected"; } } else { - if (_route.active()) { + if (_route->active()) { controls_ebox.set_name ("BusControlsBaseUnselected"); controls_base_selected_name = "BusControlsBaseSelected"; controls_base_unselected_name = "BusControlsBaseUnselected"; diff --git a/gtk2_ardour/audio_time_axis.h b/gtk2_ardour/audio_time_axis.h index b319d0ea99..8a7cf4f9a2 100644 --- a/gtk2_ardour/audio_time_axis.h +++ b/gtk2_ardour/audio_time_axis.h @@ -77,7 +77,7 @@ class AutomationTimeAxisView; class AudioTimeAxisView : public RouteUI, public TimeAxisView { public: - AudioTimeAxisView (PublicEditor&, ARDOUR::Session&, ARDOUR::Route&, ArdourCanvas::Canvas& canvas); + AudioTimeAxisView (PublicEditor&, ARDOUR::Session&, boost::shared_ptr<ARDOUR::Route>, ArdourCanvas::Canvas& canvas); virtual ~AudioTimeAxisView (); void show_selection (TimeSelection&); @@ -177,7 +177,7 @@ class AudioTimeAxisView : public RouteUI, public TimeAxisView void redirect_edit (); void redirect_relist (); void redirect_row_selected (gint row, gint col, GdkEvent *ev); - void add_to_redirect_display (ARDOUR::Redirect *); + void add_to_redirect_display (boost::shared_ptr<ARDOUR::Redirect>); void redirects_changed (void *); sigc::connection modified_connection; @@ -259,33 +259,33 @@ class AudioTimeAxisView : public RouteUI, public TimeAxisView }; struct RedirectAutomationInfo { - ARDOUR::Redirect* redirect; + boost::shared_ptr<ARDOUR::Redirect> redirect; bool valid; Gtk::Menu* menu; vector<RedirectAutomationNode*> lines; - RedirectAutomationInfo (ARDOUR::Redirect* r) + RedirectAutomationInfo (boost::shared_ptr<ARDOUR::Redirect> r) : redirect (r), valid (true) {} ~RedirectAutomationInfo (); }; list<RedirectAutomationInfo*> redirect_automation; - RedirectAutomationNode* find_redirect_automation_node (ARDOUR::Redirect *redirect, uint32_t what); + RedirectAutomationNode* find_redirect_automation_node (boost::shared_ptr<ARDOUR::Redirect> redirect, uint32_t what); Gtk::Menu subplugin_menu; - void add_redirect_to_subplugin_menu (ARDOUR::Redirect *); + void add_redirect_to_subplugin_menu (boost::shared_ptr<ARDOUR::Redirect>); void remove_ran (RedirectAutomationNode* ran); void redirect_menu_item_toggled (AudioTimeAxisView::RedirectAutomationInfo*, AudioTimeAxisView::RedirectAutomationNode*); - void redirect_automation_track_hidden (RedirectAutomationNode*, ARDOUR::Redirect*); + void redirect_automation_track_hidden (RedirectAutomationNode*, boost::shared_ptr<ARDOUR::Redirect>); vector<RedirectAutomationLine*> redirect_automation_curves; - RedirectAutomationLine *find_redirect_automation_curve (ARDOUR::Redirect*,uint32_t); - void add_redirect_automation_curve (ARDOUR::Redirect*, uint32_t); - void add_existing_redirect_automation_curves (ARDOUR::Redirect*); + RedirectAutomationLine *find_redirect_automation_curve (boost::shared_ptr<ARDOUR::Redirect>,uint32_t); + void add_redirect_automation_curve (boost::shared_ptr<ARDOUR::Redirect>, uint32_t); + void add_existing_redirect_automation_curves (boost::shared_ptr<ARDOUR::Redirect>); ArdourCanvas::SimpleRect *timestretch_rect; diff --git a/gtk2_ardour/automation_time_axis.cc b/gtk2_ardour/automation_time_axis.cc index 90a9544f97..02a88b578b 100644 --- a/gtk2_ardour/automation_time_axis.cc +++ b/gtk2_ardour/automation_time_axis.cc @@ -20,7 +20,7 @@ using namespace PBD; using namespace Gtk; using namespace Editing; -AutomationTimeAxisView::AutomationTimeAxisView (Session& s, Route& r, PublicEditor& e, TimeAxisView& rent, +AutomationTimeAxisView::AutomationTimeAxisView (Session& s, boost::shared_ptr<Route> r, PublicEditor& e, TimeAxisView& rent, ArdourCanvas::Canvas& canvas, const string & nom, const string & state_name, const string & nomparent) @@ -410,7 +410,7 @@ AutomationTimeAxisView::set_height (TrackHeight ht) if (changed) { /* only emit the signal if the height really changed */ - route.gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */ + route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */ } } diff --git a/gtk2_ardour/automation_time_axis.h b/gtk2_ardour/automation_time_axis.h index b4d434610d..0c72ed14f9 100644 --- a/gtk2_ardour/automation_time_axis.h +++ b/gtk2_ardour/automation_time_axis.h @@ -4,6 +4,9 @@ #include <vector> #include <list> #include <string> + +#include <boost/shared_ptr.hpp> + #include <ardour/types.h> #include "canvas.h" @@ -31,7 +34,7 @@ class Selectable; class AutomationTimeAxisView : public TimeAxisView { public: AutomationTimeAxisView (ARDOUR::Session&, - ARDOUR::Route&, + boost::shared_ptr<ARDOUR::Route>, PublicEditor&, TimeAxisView& parent, ArdourCanvas::Canvas& canvas, @@ -75,7 +78,7 @@ class AutomationTimeAxisView : public TimeAxisView { XMLNode* get_state_node (); protected: - ARDOUR::Route& route; + boost::shared_ptr<ARDOUR::Route> route; ArdourCanvas::SimpleRect* base_rect; string _name; string _state_name; diff --git a/gtk2_ardour/crossfade_edit.cc b/gtk2_ardour/crossfade_edit.cc index 5b587594de..b2967dc4a9 100644 --- a/gtk2_ardour/crossfade_edit.cc +++ b/gtk2_ardour/crossfade_edit.cc @@ -1077,7 +1077,7 @@ CrossfadeEditor::peaks_ready (AudioRegion* r, WhichFade which) void CrossfadeEditor::audition_both () { - AudioPlaylist& pl (session.the_auditioner().prepare_playlist()); + AudioPlaylist& pl (session.the_auditioner()->prepare_playlist()); jack_nframes_t preroll; jack_nframes_t postroll; jack_nframes_t length; @@ -1140,7 +1140,7 @@ CrossfadeEditor::audition_left_dry () void CrossfadeEditor::audition_left () { - AudioPlaylist& pl (session.the_auditioner().prepare_playlist()); + AudioPlaylist& pl (session.the_auditioner()->prepare_playlist()); AudioRegion* left = new AudioRegion (xfade.out(), xfade.out().length() - xfade.length(), xfade.length(), "xfade left", 0, Region::DefaultFlags, false); @@ -1172,7 +1172,7 @@ CrossfadeEditor::audition_right_dry () void CrossfadeEditor::audition_right () { - AudioPlaylist& pl (session.the_auditioner().prepare_playlist()); + AudioPlaylist& pl (session.the_auditioner()->prepare_playlist()); AudioRegion* left = new AudioRegion (xfade.out(), xfade.out().length() - xfade.length(), xfade.length(), "xfade out", 0, Region::DefaultFlags, false); diff --git a/gtk2_ardour/editing_syms.h b/gtk2_ardour/editing_syms.h index cf36550fb4..654ddc8852 100644 --- a/gtk2_ardour/editing_syms.h +++ b/gtk2_ardour/editing_syms.h @@ -56,4 +56,5 @@ DISPLAYCONTROL(ShowWaveformsRecording) IMPORTMODE(ImportAsRegion) IMPORTMODE(ImportAsTrack) +IMPORTMODE(ImportAsTapeTrack) IMPORTMODE(ImportToTrack) diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 24b367e921..95bcf785f9 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -1376,7 +1376,7 @@ Editor::connect_to_session (Session *t) AudioTimeAxisView *atv; if ((atv = dynamic_cast<AudioTimeAxisView*>(tv)) != 0) { - if (atv->route().master()) { + if (atv->route()->master()) { route_list_display.get_selection()->unselect (i); } } @@ -3054,7 +3054,7 @@ Editor::get_relevant_audio_tracks (AudioTimeAxisView& base, set<AudioTimeAxisVie continue; } - RouteGroup* group = atv->route().edit_group(); + RouteGroup* group = atv->route()->edit_group(); if (group && group->is_active()) { @@ -3066,7 +3066,7 @@ Editor::get_relevant_audio_tracks (AudioTimeAxisView& base, set<AudioTimeAxisVie if ((tatv = dynamic_cast<AudioTimeAxisView*> (*i)) != 0) { - if (tatv->route().edit_group() == group) { + if (tatv->route()->edit_group() == group) { relevant_tracks.insert (tatv); } } diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 9e2fda142e..bfc49b7d0d 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -459,8 +459,8 @@ class Editor : public PublicEditor void add_crossfade_context_items (StreamView*, ARDOUR::Crossfade*, Gtk::Menu_Helpers::MenuList&, bool many); void add_selection_context_items (Gtk::Menu_Helpers::MenuList&); - void handle_new_route (ARDOUR::Route&); - void handle_new_route_p (ARDOUR::Route*); + void handle_new_route (boost::shared_ptr<ARDOUR::Route>); + void handle_new_route_p (boost::shared_ptr<ARDOUR::Route>); void remove_route (TimeAxisView *); bool route_removal; diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc index e20e6ee8eb..65195ca822 100644 --- a/gtk2_ardour/editor_actions.cc +++ b/gtk2_ardour/editor_actions.cc @@ -357,6 +357,8 @@ Editor::register_actions () ActionManager::session_sensitive_actions.push_back (act); act = ActionManager::register_action (editor_actions, X_("addExternalAudioAsTrack"), _("as Tracks"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportAsTrack)); ActionManager::session_sensitive_actions.push_back (act); + act = ActionManager::register_action (editor_actions, X_("addExternalAudioAsTapeTrack"), _("as Tape Tracks"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportAsTapeTrack)); + ActionManager::session_sensitive_actions.push_back (act); act = ActionManager::register_action (editor_actions, X_("addExternalAudioToTrack"), _("to Tracks"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportToTrack)); ActionManager::session_sensitive_actions.push_back (act); diff --git a/gtk2_ardour/editor_audio_import.cc b/gtk2_ardour/editor_audio_import.cc index f3e2ee1cb2..68c481aa01 100644 --- a/gtk2_ardour/editor_audio_import.cc +++ b/gtk2_ardour/editor_audio_import.cc @@ -267,7 +267,7 @@ Editor::embed_sndfile (Glib::ustring path, bool split, bool multiple_files, bool idspec += string_compose(":%1", n); try { - source = AudioFileSource::create (idspec.c_str()); + source = AudioFileSource::create (idspec.c_str(), (mode == ImportAsTrack ? AudioFileSource::Destructive : AudioFileSource::Flag (0))); sources.push_back(source); } @@ -305,12 +305,14 @@ Editor::embed_sndfile (Glib::ustring path, bool split, bool multiple_files, bool } int - Editor::finish_bringing_in_audio (AudioRegion& region, uint32_t in_chans, uint32_t out_chans, AudioTrack* track, jack_nframes_t& pos, ImportMode mode) - { - switch (mode) { - case ImportAsRegion: - /* relax, its been done */ - break; +Editor::finish_bringing_in_audio (AudioRegion& region, uint32_t in_chans, uint32_t out_chans, AudioTrack* track, jack_nframes_t& pos, ImportMode mode) +{ + AudioRegion* copy; + + switch (mode) { + case ImportAsRegion: + /* relax, its been done */ + break; case ImportToTrack: if (track) { @@ -328,12 +330,22 @@ int break; case ImportAsTrack: - AudioTrack* at = session->new_audio_track (in_chans, out_chans); - AudioRegion* copy = new AudioRegion (region); + { + boost::shared_ptr<AudioTrack> at (session->new_audio_track (in_chans, out_chans, Normal)); + copy = new AudioRegion (region); at->disk_stream().playlist()->add_region (*copy, pos); break; } + case ImportAsTapeTrack: + { + boost::shared_ptr<AudioTrack> at (session->new_audio_track (in_chans, out_chans, Destructive)); + copy = new AudioRegion (region); + at->disk_stream().playlist()->add_region (*copy, pos); + break; + } + } + return 0; } diff --git a/gtk2_ardour/editor_export_audio.cc b/gtk2_ardour/editor_export_audio.cc index 7339536e42..0be0a61b23 100644 --- a/gtk2_ardour/editor_export_audio.cc +++ b/gtk2_ardour/editor_export_audio.cc @@ -140,7 +140,7 @@ Editor::bounce_region_selection () AudioRegion& region ((*i)->region); AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*>(&(*i)->get_time_axis_view()); - AudioTrack* track = dynamic_cast<AudioTrack*>(&(atv->route())); + AudioTrack* track = dynamic_cast<AudioTrack*>(atv->route().get()); InterThreadInfo itt; diff --git a/gtk2_ardour/editor_mixer.cc b/gtk2_ardour/editor_mixer.cc index a55b6f2066..1418ece574 100644 --- a/gtk2_ardour/editor_mixer.cc +++ b/gtk2_ardour/editor_mixer.cc @@ -131,7 +131,7 @@ Editor::set_selected_mixer_strip (TimeAxisView& view) /* might be nothing to do */ - if (¤t_mixer_strip->route() == &at->route()) { + if (current_mixer_strip->route() == at->route()) { return; } @@ -221,7 +221,7 @@ Editor::current_mixer_strip_hidden () AudioTimeAxisView* tmp; if ((tmp = dynamic_cast<AudioTimeAxisView*>(*i)) != 0) { - if (&(tmp->route()) == &(current_mixer_strip->route())) { + if (tmp->route() == current_mixer_strip->route()) { (*i)->set_selected (false); break; } diff --git a/gtk2_ardour/editor_route_list.cc b/gtk2_ardour/editor_route_list.cc index 95ac358095..12240dfb13 100644 --- a/gtk2_ardour/editor_route_list.cc +++ b/gtk2_ardour/editor_route_list.cc @@ -39,21 +39,21 @@ using namespace PBD; using namespace Gtk; void -Editor::handle_new_route_p (Route* route) +Editor::handle_new_route_p (boost::shared_ptr<Route> route) { ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::handle_new_route_p), route)); - handle_new_route (*route); + handle_new_route (route); } void -Editor::handle_new_route (Route& route) +Editor::handle_new_route (boost::shared_ptr<Route> route) { TimeAxisView *tv; AudioTimeAxisView *atv; TreeModel::Row parent; TreeModel::Row row; - if (route.hidden()) { + if (route->hidden()) { return; } @@ -75,7 +75,7 @@ Editor::handle_new_route (Route& route) } - if (dynamic_cast<AudioTrack*>(&route) != 0) { + if (dynamic_cast<AudioTrack*>(route.get()) != 0) { TreeModel::iterator iter = route_display_model->get_iter ("1"); // audio tracks parent = *iter; } else { @@ -89,7 +89,7 @@ Editor::handle_new_route (Route& route) row = *(route_display_model->append ()); #endif - row[route_display_columns.text] = route.name(); + row[route_display_columns.text] = route->name(); row[route_display_columns.visible] = tv->marked_for_display(); row[route_display_columns.tv] = tv; @@ -99,14 +99,14 @@ Editor::handle_new_route (Route& route) if ((atv = dynamic_cast<AudioTimeAxisView*> (tv)) != 0) { /* added a new fresh one at the end */ - if (atv->route().order_key(N_("editor")) == -1) { - atv->route().set_order_key (N_("editor"), route_display_model->children().size()-1); + if (atv->route()->order_key(N_("editor")) == -1) { + atv->route()->set_order_key (N_("editor"), route_display_model->children().size()-1); } } ignore_route_list_reorder = false; - route.gui_changed.connect (mem_fun(*this, &Editor::handle_gui_changes)); + route->gui_changed.connect (mem_fun(*this, &Editor::handle_gui_changes)); tv->GoingAway.connect (bind (mem_fun(*this, &Editor::remove_route), tv)); @@ -188,7 +188,7 @@ Editor::hide_track_in_display (TimeAxisView& tv) AudioTimeAxisView* atv = dynamic_cast<AudioTimeAxisView*> (&tv); - if (atv && current_mixer_strip && &(atv->route()) == &(current_mixer_strip->route())) { + if (atv && current_mixer_strip && (atv->route() == current_mixer_strip->route())) { // this will hide the mixer strip set_selected_mixer_strip (tv); } @@ -244,7 +244,7 @@ Editor::redisplay_route_list () */ if ((at = dynamic_cast<AudioTimeAxisView*> (tv)) != 0) { - at->route().set_order_key (N_("editor"), order); + at->route()->set_order_key (N_("editor"), order); ++order; } } @@ -477,7 +477,7 @@ Editor::route_list_selection_filter (const Glib::RefPtr<TreeModel>& model, const } struct EditorOrderRouteSorter { - bool operator() (Route* a, Route* b) { + bool operator() (boost::shared_ptr<Route> a, boost::shared_ptr<Route> b) { /* use of ">" forces the correct sort order */ return a->order_key ("editor") < b->order_key ("editor"); } @@ -486,17 +486,18 @@ struct EditorOrderRouteSorter { void Editor::initial_route_list_display () { - Session::RouteList routes = session->get_routes(); + boost::shared_ptr<Session::RouteList> routes = session->get_routes(); + Session::RouteList r (*routes); EditorOrderRouteSorter sorter; - routes.sort (sorter); + r.sort (sorter); no_route_list_redisplay = true; route_display_model->clear (); - for (Session::RouteList::iterator i = routes.begin(); i != routes.end(); ++i) { - handle_new_route (**i); + for (Session::RouteList::iterator i = r.begin(); i != r.end(); ++i) { + handle_new_route (*i); } no_route_list_redisplay = false; diff --git a/gtk2_ardour/editor_timefx.cc b/gtk2_ardour/editor_timefx.cc index 6ff467454d..278ab57ebd 100644 --- a/gtk2_ardour/editor_timefx.cc +++ b/gtk2_ardour/editor_timefx.cc @@ -179,7 +179,7 @@ Editor::do_timestretch (TimeStretchDialog& dialog) continue; } - if ((at = dynamic_cast<AudioTrack*> (&atv->route())) == 0) { + if ((at = atv->audio_track()) == 0) { i = tmp; continue; } diff --git a/gtk2_ardour/export_dialog.cc b/gtk2_ardour/export_dialog.cc index bcf8cd85ad..b5a4757090 100644 --- a/gtk2_ardour/export_dialog.cc +++ b/gtk2_ardour/export_dialog.cc @@ -1082,11 +1082,11 @@ ExportDialog::fill_lists () track_list->clear(); master_list->clear(); - Session::RouteList routes = session->get_routes (); + boost::shared_ptr<Session::RouteList> routes = session->get_routes (); - for (Session::RouteList::iterator ri = routes.begin(); ri != routes.end(); ++ri) { - - Route* route = (*ri); + for (Session::RouteList::iterator ri = routes->begin(); ri != routes->end(); ++ri) { + + boost::shared_ptr<Route> route = (*ri); if (route->hidden()) { continue; diff --git a/gtk2_ardour/gain_automation_time_axis.cc b/gtk2_ardour/gain_automation_time_axis.cc index 8f41f5def0..5352015f11 100644 --- a/gtk2_ardour/gain_automation_time_axis.cc +++ b/gtk2_ardour/gain_automation_time_axis.cc @@ -31,7 +31,9 @@ using namespace ARDOUR; using namespace PBD; using namespace Gtk; -GainAutomationTimeAxisView::GainAutomationTimeAxisView (Session& s, Route& r, PublicEditor& e, TimeAxisView& parent, ArdourCanvas::Canvas& canvas, const string & n, ARDOUR::Curve& c) +GainAutomationTimeAxisView::GainAutomationTimeAxisView (Session& s, boost::shared_ptr<Route> r, + PublicEditor& e, TimeAxisView& parent, + ArdourCanvas::Canvas& canvas, const string & n, ARDOUR::Curve& c) : AxisView (s), AutomationTimeAxisView (s, r, e, parent, canvas, n, X_("gain"), ""), @@ -72,6 +74,6 @@ void GainAutomationTimeAxisView::set_automation_state (AutoState state) { if (!ignore_state_request) { - route.set_gain_automation_state (state); + route->set_gain_automation_state (state); } } diff --git a/gtk2_ardour/gain_automation_time_axis.h b/gtk2_ardour/gain_automation_time_axis.h index 50f1cba3f9..dc6d5bd28e 100644 --- a/gtk2_ardour/gain_automation_time_axis.h +++ b/gtk2_ardour/gain_automation_time_axis.h @@ -13,7 +13,7 @@ class GainAutomationTimeAxisView : public AutomationTimeAxisView { public: GainAutomationTimeAxisView (ARDOUR::Session&, - ARDOUR::Route&, + boost::shared_ptr<ARDOUR::Route>, PublicEditor&, TimeAxisView& parent_axis, ArdourCanvas::Canvas& canvas, diff --git a/gtk2_ardour/gain_meter.cc b/gtk2_ardour/gain_meter.cc index 7fa2c33335..5fa8c462bc 100644 --- a/gtk2_ardour/gain_meter.cc +++ b/gtk2_ardour/gain_meter.cc @@ -79,7 +79,7 @@ GainMeter::setup_slider_pix () return 0; } -GainMeter::GainMeter (IO& io, Session& s) +GainMeter::GainMeter (boost::shared_ptr<IO> io, Session& s) : _io (io), _session (s), gain_slider (0), @@ -99,7 +99,7 @@ GainMeter::GainMeter (IO& io, Session& s) gain_slider = manage (new VSliderController (slider, rail, &gain_adjustment, - _io.gain_control(), + _io->gain_control(), false)); gain_slider->signal_button_press_event().connect (mem_fun(*this, &GainMeter::start_gain_touch)); @@ -152,7 +152,7 @@ GainMeter::GainMeter (IO& io, Session& s) Route* r; - if ((r = dynamic_cast<Route*> (&_io)) != 0) { + if ((r = dynamic_cast<Route*> (_io.get())) != 0) { /* if we don't have a route (if we're the click), pack some route-dependent stuff. @@ -165,13 +165,13 @@ GainMeter::GainMeter (IO& io, Session& s) using namespace Menu_Helpers; gain_astate_menu.items().push_back (MenuElem (_("Off"), - bind (mem_fun (&_io, &IO::set_gain_automation_state), (AutoState) Off))); + bind (mem_fun (*_io, &IO::set_gain_automation_state), (AutoState) Off))); gain_astate_menu.items().push_back (MenuElem (_("Play"), - bind (mem_fun (&_io, &IO::set_gain_automation_state), (AutoState) Play))); + bind (mem_fun (*_io, &IO::set_gain_automation_state), (AutoState) Play))); gain_astate_menu.items().push_back (MenuElem (_("Write"), - bind (mem_fun (&_io, &IO::set_gain_automation_state), (AutoState) Write))); + bind (mem_fun (*_io, &IO::set_gain_automation_state), (AutoState) Write))); gain_astate_menu.items().push_back (MenuElem (_("Touch"), - bind (mem_fun (&_io, &IO::set_gain_automation_state), (AutoState) Touch))); + bind (mem_fun (*_io, &IO::set_gain_automation_state), (AutoState) Touch))); gain_astyle_menu.items().push_back (MenuElem (_("Trim"))); gain_astyle_menu.items().push_back (MenuElem (_("Abs"))); @@ -195,7 +195,7 @@ GainMeter::GainMeter (IO& io, Session& s) pack_start (gain_display_box, Gtk::PACK_SHRINK); pack_start (hbox, Gtk::PACK_SHRINK); - _io.gain_changed.connect (mem_fun(*this, &GainMeter::gain_changed)); + _io->gain_changed.connect (mem_fun(*this, &GainMeter::gain_changed)); meter_metric_area.signal_expose_event().connect (mem_fun(*this, &GainMeter::meter_metrics_expose)); gain_adjustment.signal_value_changed().connect (mem_fun(*this, &GainMeter::gain_adjusted)); @@ -323,7 +323,7 @@ GainMeter::update_meters () for (n = 0, i = meters.begin(); i != meters.end(); ++i, ++n) { if ((*i).packed) { - peak = _io.peak_input_power (n); + peak = _io->peak_input_power (n); (*i).meter->set (log_meter (peak), peak); @@ -382,14 +382,14 @@ GainMeter::hide_all_meters () void GainMeter::setup_meters () { - uint32_t nmeters = _io.n_outputs(); + uint32_t nmeters = _io->n_outputs(); guint16 width; hide_all_meters (); Route* r; - if ((r = dynamic_cast<Route*> (&_io)) != 0) { + if ((r = dynamic_cast<Route*> (_io.get())) != 0) { switch (r->meter_point()) { case MeterPreFader: @@ -403,7 +403,7 @@ GainMeter::setup_meters () } else { - nmeters = _io.n_outputs(); + nmeters = _io->n_outputs(); } @@ -451,7 +451,7 @@ GainMeter::peak_button_release (GdkEventButton* ev) ResetAllPeakDisplays (); } else if (ev->button == 1 && Keyboard::modifier_state_equals (ev->state, Keyboard::Control)) { Route* r; - if ((r = dynamic_cast<Route*> (&_io)) != 0) { + if ((r = dynamic_cast<Route*> (_io.get())) != 0) { ResetGroupPeakDisplays (r->mix_group()); } } else { @@ -472,7 +472,7 @@ void GainMeter::reset_group_peak_display (RouteGroup* group) { Route* r; - if ((r = dynamic_cast<Route*> (&_io)) != 0) { + if ((r = dynamic_cast<Route*> (_io.get())) != 0) { if (group == r->mix_group()) { reset_peak_display (); } @@ -541,14 +541,14 @@ void GainMeter::gain_adjusted () { if (!ignore_toggle) { - _io.set_gain (slider_position_to_gain (gain_adjustment.get_value()), this); + _io->set_gain (slider_position_to_gain (gain_adjustment.get_value()), this); } } void GainMeter::effective_gain_display () { - gfloat value = gain_to_slider_position (_io.effective_gain()); + gfloat value = gain_to_slider_position (_io->effective_gain()); if (gain_adjustment.get_value() != value) { ignore_toggle = true; @@ -578,7 +578,7 @@ GainMeter::set_fader_name (const char * name) void GainMeter::update_gain_sensitive () { - static_cast<Gtkmm2ext::SliderController*>(gain_slider)->set_sensitive (!(_io.gain_automation_state() & Play)); + static_cast<Gtkmm2ext::SliderController*>(gain_slider)->set_sensitive (!(_io->gain_automation_state() & Play)); } @@ -609,7 +609,7 @@ GainMeter::meter_press(GdkEventButton* ev) wait_for_release = false; - if ((_route = dynamic_cast<Route*>(&_io)) == 0) { + if ((_route = dynamic_cast<Route*>(_io.get())) == 0) { return FALSE; } @@ -671,7 +671,7 @@ GainMeter::meter_release(GdkEventButton* ev) if(!ignore_toggle){ if (wait_for_release){ wait_for_release = false; - set_meter_point (*(dynamic_cast<Route*>(&_io)), old_meter_point); + set_meter_point (*(dynamic_cast<Route*>(_io.get())), old_meter_point); } } return true; @@ -700,7 +700,7 @@ GainMeter::meter_point_clicked () { Route* r; - if ((r = dynamic_cast<Route*> (&_io)) != 0) { + if ((r = dynamic_cast<Route*> (_io.get())) != 0) { } } @@ -708,14 +708,14 @@ GainMeter::meter_point_clicked () gint GainMeter::start_gain_touch (GdkEventButton* ev) { - _io.start_gain_touch (); + _io->start_gain_touch (); return FALSE; } gint GainMeter::end_gain_touch (GdkEventButton* ev) { - _io.end_gain_touch (); + _io->end_gain_touch (); return FALSE; } @@ -819,10 +819,10 @@ GainMeter::gain_automation_style_changed () // Route* _route = dynamic_cast<Route*>(&_io); switch (_width) { case Wide: - gain_automation_style_button.set_label (astyle_string(_io.gain_automation_curve().automation_style())); + gain_automation_style_button.set_label (astyle_string(_io->gain_automation_curve().automation_style())); break; case Narrow: - gain_automation_style_button.set_label (short_astyle_string(_io.gain_automation_curve().automation_style())); + gain_automation_style_button.set_label (short_astyle_string(_io->gain_automation_curve().automation_style())); break; } } @@ -837,14 +837,14 @@ GainMeter::gain_automation_state_changed () switch (_width) { case Wide: - gain_automation_state_button.set_label (astate_string(_io.gain_automation_curve().automation_state())); + gain_automation_state_button.set_label (astate_string(_io->gain_automation_curve().automation_state())); break; case Narrow: - gain_automation_state_button.set_label (short_astate_string(_io.gain_automation_curve().automation_state())); + gain_automation_state_button.set_label (short_astate_string(_io->gain_automation_curve().automation_state())); break; } - x = (_io.gain_automation_state() != Off); + x = (_io->gain_automation_state() != Off); if (gain_automation_state_button.get_active() != x) { ignore_toggle = true; diff --git a/gtk2_ardour/gain_meter.h b/gtk2_ardour/gain_meter.h index 0ed09ee383..1dfc088248 100644 --- a/gtk2_ardour/gain_meter.h +++ b/gtk2_ardour/gain_meter.h @@ -56,7 +56,7 @@ namespace Gtk { class GainMeter : public Gtk::VBox { public: - GainMeter (ARDOUR::IO&, ARDOUR::Session&); + GainMeter (boost::shared_ptr<ARDOUR::IO>, ARDOUR::Session&); ~GainMeter (); void update_gain_sensitive (); @@ -75,7 +75,7 @@ class GainMeter : public Gtk::VBox private: friend class MixerStrip; - ARDOUR::IO& _io; + boost::shared_ptr<ARDOUR::IO> _io; ARDOUR::Session& _session; bool ignore_toggle; diff --git a/gtk2_ardour/io_selector.cc b/gtk2_ardour/io_selector.cc index b0ecd05077..f754435112 100644 --- a/gtk2_ardour/io_selector.cc +++ b/gtk2_ardour/io_selector.cc @@ -52,7 +52,7 @@ using namespace ARDOUR; using namespace PBD; using namespace Gtkmm2ext; -IOSelectorWindow::IOSelectorWindow (Session& sess, IO& ior, bool input, bool can_cancel) +IOSelectorWindow::IOSelectorWindow (Session& sess, boost::shared_ptr<IO> ior, bool input, bool can_cancel) : ArdourDialog ("i/o selector"), _selector (sess, ior, input), ok_button (can_cancel ? _("OK"): _("Close")), @@ -65,9 +65,9 @@ IOSelectorWindow::IOSelectorWindow (Session& sess, IO& ior, bool input, bool can string title; if (input) { - title = string_compose(_("%1 input"), ior.name()); + title = string_compose(_("%1 input"), ior->name()); } else { - title = string_compose(_("%1 output"), ior.name()); + title = string_compose(_("%1 output"), ior->name()); } ok_button.set_name ("IOSelectorButton"); @@ -135,7 +135,7 @@ IOSelectorWindow::on_map () The IO Selector "widget" *************************/ -IOSelector::IOSelector (Session& sess, IO& ior, bool input) +IOSelector::IOSelector (Session& sess, boost::shared_ptr<IO> ior, bool input) : session (sess), io (ior), for_input (input), @@ -184,14 +184,14 @@ IOSelector::IOSelector (Session& sess, IO& ior, bool input) port_button_box.pack_start (add_port_button, false, false); if (for_input) { - if (io.input_maximum() < 0 || io.input_maximum() > (int) io.n_inputs()) { + if (io->input_maximum() < 0 || io->input_maximum() > (int) io->n_inputs()) { add_port_button.set_sensitive (true); } else { add_port_button.set_sensitive (false); } } else { - if (io.output_maximum() < 0 || io.output_maximum() > (int) io.n_outputs()) { + if (io->output_maximum() < 0 || io->output_maximum() > (int) io->n_outputs()) { add_port_button.set_sensitive (true); } else { add_port_button.set_sensitive (false); @@ -202,14 +202,14 @@ IOSelector::IOSelector (Session& sess, IO& ior, bool input) port_button_box.pack_start (remove_port_button, false, false); if (for_input) { - if (io.input_minimum() < 0 || io.input_minimum() < (int) io.n_inputs()) { + if (io->input_minimum() < 0 || io->input_minimum() < (int) io->n_inputs()) { remove_port_button.set_sensitive (true); } else { remove_port_button.set_sensitive (false); } } else { - if (io.output_minimum() < 0 || io.output_minimum() < (int) io.n_outputs()) { + if (io->output_minimum() < 0 || io->output_minimum() < (int) io->n_outputs()) { remove_port_button.set_sensitive (true); } else { remove_port_button.set_sensitive (false); @@ -241,12 +241,12 @@ IOSelector::IOSelector (Session& sess, IO& ior, bool input) remove_port_button.signal_clicked().connect (mem_fun(*this, &IOSelector::remove_port)); if (for_input) { - io.input_changed.connect (mem_fun(*this, &IOSelector::ports_changed)); + io->input_changed.connect (mem_fun(*this, &IOSelector::ports_changed)); } else { - io.output_changed.connect (mem_fun(*this, &IOSelector::ports_changed)); + io->output_changed.connect (mem_fun(*this, &IOSelector::ports_changed)); } - io.name_changed.connect (mem_fun(*this, &IOSelector::name_changed)); + io->name_changed.connect (mem_fun(*this, &IOSelector::name_changed)); } IOSelector::~IOSelector () @@ -265,9 +265,9 @@ void IOSelector::clear_connections () { if (for_input) { - io.disconnect_inputs (this); + io->disconnect_inputs (this); } else { - io.disconnect_outputs (this); + io->disconnect_outputs (this); } } @@ -374,9 +374,9 @@ IOSelector::display_ports () uint32_t limit; if (for_input) { - limit = io.n_inputs(); + limit = io->n_inputs(); } else { - limit = io.n_outputs(); + limit = io->n_outputs(); } for (slist<TreeView *>::iterator i = port_displays.begin(); i != port_displays.end(); ) { @@ -401,9 +401,9 @@ IOSelector::display_ports () string really_short_name; if (for_input) { - port = io.input (n); + port = io->input (n); } else { - port = io.output (n); + port = io->output (n); } /* we know there is '/' because we put it there */ @@ -443,7 +443,7 @@ IOSelector::display_ports () if (for_input) { - if (io.input_maximum() == 1) { + if (io->input_maximum() == 1) { selected_port = port; selected_port_tview = tview; } else { @@ -454,7 +454,7 @@ IOSelector::display_ports () } else { - if (io.output_maximum() == 1) { + if (io->output_maximum() == 1) { selected_port = port; selected_port_tview = tview; } else { @@ -516,12 +516,12 @@ IOSelector::port_selection_changed (GdkEventButton *ev, TreeView* treeview) ustring other_port_name = (*i)[port_display_columns.full_name]; if (for_input) { - if ((status = io.connect_input (selected_port, other_port_name, this)) == 0) { + if ((status = io->connect_input (selected_port, other_port_name, this)) == 0) { Port *p = session.engine().get_port_by_name (other_port_name); p->enable_metering(); } } else { - status = io.connect_output (selected_port, other_port_name, this); + status = io->connect_output (selected_port, other_port_name, this); } if (status == 0) { @@ -548,7 +548,7 @@ IOSelector::add_port () if (for_input) { try { - io.add_input_port ("", this); + io->add_input_port ("", this); } catch (AudioEngine::PortRegistrationFailure& err) { @@ -556,18 +556,18 @@ IOSelector::add_port () msg.run (); } - if (io.input_maximum() >= 0 && io.input_maximum() <= (int) io.n_inputs()) { + if (io->input_maximum() >= 0 && io->input_maximum() <= (int) io->n_inputs()) { add_port_button.set_sensitive (false); } - if (io.input_minimum() < (int) io.n_inputs()) { + if (io->input_minimum() < (int) io->n_inputs()) { remove_port_button.set_sensitive (true); } } else { try { - io.add_output_port ("", this); + io->add_output_port ("", this); } catch (AudioEngine::PortRegistrationFailure& err) { @@ -575,7 +575,7 @@ IOSelector::add_port () msg.run (); } - if (io.output_maximum() >= 0 && io.output_maximum() <= (int) io.n_outputs()) { + if (io->output_maximum() >= 0 && io->output_maximum() <= (int) io->n_outputs()) { add_port_button.set_sensitive (false); } } @@ -589,15 +589,15 @@ IOSelector::remove_port () // always remove last port if (for_input) { - if ((nports = io.n_inputs()) > 0) { - io.remove_input_port (io.input(nports-1), this); + if ((nports = io->n_inputs()) > 0) { + io->remove_input_port (io->input(nports-1), this); } - if (io.input_minimum() == (int) io.n_inputs()) { + if (io->input_minimum() == (int) io->n_inputs()) { remove_port_button.set_sensitive (false); } } else { - if ((nports = io.n_outputs()) > 0) { - io.remove_output_port (io.output(nports-1), this); + if ((nports = io->n_outputs()) > 0) { + io->remove_output_port (io->output(nports-1), this); } } } @@ -606,9 +606,9 @@ gint IOSelector::remove_port_when_idle (Port *port) { if (for_input) { - io.remove_input_port (port, this); + io->remove_input_port (port, this); } else { - io.remove_output_port (port, this); + io->remove_output_port (port, this); } return FALSE; @@ -651,9 +651,9 @@ IOSelector::connection_button_release (GdkEventButton *ev, TreeView *treeview) if (for_input) { Port *p = session.engine().get_port_by_name (connected_port_name); p->disable_metering(); - io.disconnect_input (port, connected_port_name, this); + io->disconnect_input (port, connected_port_name, this); } else { - io.disconnect_output (port, connected_port_name, this); + io->disconnect_output (port, connected_port_name, this); } } @@ -749,17 +749,17 @@ IOSelector::redisplay () display_ports (); if (for_input) { - if (io.input_maximum() != 0) { + if (io->input_maximum() != 0) { rescan (); } } else { - if (io.output_maximum() != 0) { + if (io->output_maximum() != 0) { rescan(); } } } -PortInsertUI::PortInsertUI (Session& sess, PortInsert& pi) +PortInsertUI::PortInsertUI (Session& sess, boost::shared_ptr<PortInsert> pi) : input_selector (sess, pi, true), output_selector (sess, pi, false) { @@ -786,9 +786,9 @@ PortInsertUI::finished(IOSelector::Result r) } -PortInsertWindow::PortInsertWindow (Session& sess, PortInsert& pi, bool can_cancel) +PortInsertWindow::PortInsertWindow (Session& sess, boost::shared_ptr<PortInsert> pi, bool can_cancel) : ArdourDialog ("port insert dialog"), - _portinsertui(sess, pi), + _portinsertui (sess, pi), ok_button (can_cancel ? _("OK"): _("Close")), cancel_button (_("Cancel")), rescan_button (_("Rescan")) @@ -796,7 +796,7 @@ PortInsertWindow::PortInsertWindow (Session& sess, PortInsert& pi, bool can_canc set_name ("IOSelectorWindow"); string title = _("ardour: "); - title += pi.name(); + title += pi->name(); set_title (title); ok_button.set_name ("IOSelectorButton"); @@ -823,7 +823,7 @@ PortInsertWindow::PortInsertWindow (Session& sess, PortInsert& pi, bool can_canc rescan_button.signal_clicked().connect (mem_fun(*this, &PortInsertWindow::rescan)); signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), reinterpret_cast<Window *> (this))); - pi.GoingAway.connect (mem_fun(*this, &PortInsertWindow::plugin_going_away)); + pi->GoingAway.connect (mem_fun(*this, &PortInsertWindow::plugin_going_away)); } void diff --git a/gtk2_ardour/io_selector.h b/gtk2_ardour/io_selector.h index 44518e6759..993d4aa1ad 100644 --- a/gtk2_ardour/io_selector.h +++ b/gtk2_ardour/io_selector.h @@ -53,7 +53,7 @@ namespace ARDOUR { class IOSelector : public Gtk::VBox { public: - IOSelector (ARDOUR::Session&, ARDOUR::IO&, bool for_input); + IOSelector (ARDOUR::Session&, boost::shared_ptr<ARDOUR::IO>, bool for_input); ~IOSelector (); void redisplay (); @@ -67,9 +67,9 @@ class IOSelector : public Gtk::VBox { protected: ARDOUR::Session& session; - + private: - ARDOUR::IO& io; + boost::shared_ptr<ARDOUR::IO> io; bool for_input; ARDOUR::Port *selected_port; @@ -135,7 +135,7 @@ class IOSelector : public Gtk::VBox { class IOSelectorWindow : public ArdourDialog { public: - IOSelectorWindow (ARDOUR::Session&, ARDOUR::IO&, bool for_input, bool can_cancel=false); + IOSelectorWindow (ARDOUR::Session&, boost::shared_ptr<ARDOUR::IO>, bool for_input, bool can_cancel=false); ~IOSelectorWindow (); IOSelector& selector() { return _selector; } @@ -162,7 +162,7 @@ class IOSelectorWindow : public ArdourDialog class PortInsertUI : public Gtk::VBox { public: - PortInsertUI (ARDOUR::Session&, ARDOUR::PortInsert&); + PortInsertUI (ARDOUR::Session&, boost::shared_ptr<ARDOUR::PortInsert>); void redisplay (); void finished (IOSelector::Result); @@ -178,7 +178,7 @@ class PortInsertUI : public Gtk::VBox class PortInsertWindow : public ArdourDialog { public: - PortInsertWindow (ARDOUR::Session&, ARDOUR::PortInsert&, bool can_cancel=false); + PortInsertWindow (ARDOUR::Session&, boost::shared_ptr<ARDOUR::PortInsert>, bool can_cancel=false); protected: void on_map (); diff --git a/gtk2_ardour/mixer_strip.cc b/gtk2_ardour/mixer_strip.cc index 9913e483fa..1313fc4082 100644 --- a/gtk2_ardour/mixer_strip.cc +++ b/gtk2_ardour/mixer_strip.cc @@ -80,7 +80,7 @@ speed_printer (char buf[32], Gtk::Adjustment& adj, void* arg) } #endif -MixerStrip::MixerStrip (Mixer_UI& mx, Session& sess, Route& rt, bool in_mixer) +MixerStrip::MixerStrip (Mixer_UI& mx, Session& sess, boost::shared_ptr<Route> rt, bool in_mixer) : AxisView(sess), RouteUI (rt, sess, _("Mute"), _("Solo"), _("Record")), _mixer(mx), @@ -125,12 +125,12 @@ MixerStrip::MixerStrip (Mixer_UI& mx, Session& sess, Route& rt, bool in_mixer) output_button.set_name ("MixerIOButton"); output_label.set_name ("MixerIOButtonLabel"); - _route.meter_change.connect (mem_fun(*this, &MixerStrip::meter_changed)); + _route->meter_change.connect (mem_fun(*this, &MixerStrip::meter_changed)); meter_point_button.add (meter_point_label); meter_point_button.set_name ("MixerStripMeterPreButton"); meter_point_label.set_name ("MixerStripMeterPreButton"); - switch (_route.meter_point()) { + switch (_route->meter_point()) { case MeterInput: meter_point_label.set_text (_("input")); break; @@ -191,7 +191,7 @@ MixerStrip::MixerStrip (Mixer_UI& mx, Session& sess, Route& rt, bool in_mixer) rec_enable_button->unset_flags (Gtk::CAN_FOCUS); rec_enable_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::rec_enable_press)); - AudioTrack* at = dynamic_cast<AudioTrack*>(&_route); + AudioTrack* at = audio_track(); at->FreezeChange.connect (mem_fun(*this, &MixerStrip::map_frozen)); @@ -217,10 +217,10 @@ MixerStrip::MixerStrip (Mixer_UI& mx, Session& sess, Route& rt, bool in_mixer) Gtkmm2ext::set_size_request_to_display_given_text (name_button, "longest label", 2, 2); name_label.set_name ("MixerNameButtonLabel"); - if (_route.phase_invert()) { + if (_route->phase_invert()) { name_label.set_text (X_("Ø ") + name_label.get_text()); } else { - name_label.set_text (_route.name()); + name_label.set_text (_route->name()); } group_button.add (group_label); @@ -229,9 +229,9 @@ MixerStrip::MixerStrip (Mixer_UI& mx, Session& sess, Route& rt, bool in_mixer) comment_button.set_name ("MixerCommentButton"); - ARDOUR_UI::instance()->tooltips().set_tip (comment_button, _route.comment()=="" ? + ARDOUR_UI::instance()->tooltips().set_tip (comment_button, _route->comment()=="" ? _("Click to Add/Edit Comments"): - _route.comment()); + _route->comment()); comment_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::comment_button_clicked)); @@ -281,22 +281,22 @@ MixerStrip::MixerStrip (Mixer_UI& mx, Session& sess, Route& rt, bool in_mixer) _session.engine().Stopped.connect (mem_fun(*this, &MixerStrip::engine_stopped)); _session.engine().Running.connect (mem_fun(*this, &MixerStrip::engine_running)); - _route.input_changed.connect (mem_fun(*this, &MixerStrip::input_changed)); - _route.output_changed.connect (mem_fun(*this, &MixerStrip::output_changed)); - _route.mute_changed.connect (mem_fun(*this, &RouteUI::mute_changed)); - _route.solo_changed.connect (mem_fun(*this, &RouteUI::solo_changed)); - _route.solo_safe_changed.connect (mem_fun(*this, &RouteUI::solo_changed)); - _route.mix_group_changed.connect (mem_fun(*this, &MixerStrip::mix_group_changed)); - _route.panner().Changed.connect (mem_fun(*this, &MixerStrip::connect_to_pan)); + _route->input_changed.connect (mem_fun(*this, &MixerStrip::input_changed)); + _route->output_changed.connect (mem_fun(*this, &MixerStrip::output_changed)); + _route->mute_changed.connect (mem_fun(*this, &RouteUI::mute_changed)); + _route->solo_changed.connect (mem_fun(*this, &RouteUI::solo_changed)); + _route->solo_safe_changed.connect (mem_fun(*this, &RouteUI::solo_changed)); + _route->mix_group_changed.connect (mem_fun(*this, &MixerStrip::mix_group_changed)); + _route->panner().Changed.connect (mem_fun(*this, &MixerStrip::connect_to_pan)); if (is_audio_track()) { audio_track()->diskstream_changed.connect (mem_fun(*this, &MixerStrip::diskstream_changed)); get_diskstream()->speed_changed.connect (mem_fun(*this, &MixerStrip::speed_changed)); } - _route.name_changed.connect (mem_fun(*this, &RouteUI::name_changed)); - _route.comment_changed.connect (mem_fun(*this, &MixerStrip::comment_changed)); - _route.gui_changed.connect (mem_fun(*this, &MixerStrip::route_gui_changed)); + _route->name_changed.connect (mem_fun(*this, &RouteUI::name_changed)); + _route->comment_changed.connect (mem_fun(*this, &MixerStrip::comment_changed)); + _route->gui_changed.connect (mem_fun(*this, &MixerStrip::route_gui_changed)); input_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::input_press), false); output_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::output_press), false); @@ -419,16 +419,16 @@ MixerStrip::set_width (Width w) mute_button->set_label (_("mute")); solo_button->set_label (_("solo")); - if (_route.comment() == "") { + if (_route->comment() == "") { comment_button.set_label (_("comments")); } else { comment_button.set_label (_("*comments*")); } - gpm.gain_automation_style_button.set_label (gpm.astyle_string(_route.gain_automation_curve().automation_style())); - gpm.gain_automation_state_button.set_label (gpm.astate_string(_route.gain_automation_curve().automation_state())); - panners.pan_automation_style_button.set_label (panners.astyle_string(_route.panner().automation_style())); - panners.pan_automation_state_button.set_label (panners.astate_string(_route.panner().automation_state())); + gpm.gain_automation_style_button.set_label (gpm.astyle_string(_route->gain_automation_curve().automation_style())); + gpm.gain_automation_state_button.set_label (gpm.astate_string(_route->gain_automation_curve().automation_state())); + panners.pan_automation_style_button.set_label (panners.astyle_string(_route->panner().automation_style())); + panners.pan_automation_state_button.set_label (panners.astate_string(_route->panner().automation_state())); Gtkmm2ext::set_size_request_to_display_given_text (name_button, "long", 2, 2); break; @@ -442,16 +442,16 @@ MixerStrip::set_width (Width w) mute_button->set_label (_("M")); solo_button->set_label (_("S")); - if (_route.comment() == "") { + if (_route->comment() == "") { comment_button.set_label (_("Cmt")); } else { comment_button.set_label (_("*Cmt*")); } - gpm.gain_automation_style_button.set_label (gpm.short_astyle_string(_route.gain_automation_curve().automation_style())); - gpm.gain_automation_state_button.set_label (gpm.short_astate_string(_route.gain_automation_curve().automation_state())); - panners.pan_automation_style_button.set_label (panners.short_astyle_string(_route.panner().automation_style())); - panners.pan_automation_state_button.set_label (panners.short_astate_string(_route.panner().automation_state())); + gpm.gain_automation_style_button.set_label (gpm.short_astyle_string(_route->gain_automation_curve().automation_style())); + gpm.gain_automation_state_button.set_label (gpm.short_astate_string(_route->gain_automation_curve().automation_state())); + panners.pan_automation_style_button.set_label (panners.short_astyle_string(_route->panner().automation_style())); + panners.pan_automation_state_button.set_label (panners.short_astate_string(_route->panner().automation_state())); Gtkmm2ext::set_size_request_to_display_given_text (name_button, "longest label", 2, 2); break; } @@ -584,7 +584,7 @@ MixerStrip::connection_input_chosen (ARDOUR::Connection *c) if (!ignore_toggle) { try { - _route.use_input_connection (*c, this); + _route->use_input_connection (*c, this); } catch (AudioEngine::PortRegistrationFailure& err) { @@ -600,7 +600,7 @@ MixerStrip::connection_output_chosen (ARDOUR::Connection *c) if (!ignore_toggle) { try { - _route.use_output_connection (*c, this); + _route->use_output_connection (*c, this); } catch (AudioEngine::PortRegistrationFailure& err) { @@ -621,11 +621,11 @@ MixerStrip::add_connection_to_input_menu (ARDOUR::Connection* c) MenuList& citems = input_menu.items(); - if (c->nports() == _route.n_inputs()) { + if (c->nports() == _route->n_inputs()) { citems.push_back (CheckMenuElem (c->name(), bind (mem_fun(*this, &MixerStrip::connection_input_chosen), c))); - ARDOUR::Connection *current = _route.input_connection(); + ARDOUR::Connection *current = _route->input_connection(); if (current == c) { ignore_toggle = true; @@ -644,12 +644,12 @@ MixerStrip::add_connection_to_output_menu (ARDOUR::Connection* c) return; } - if (c->nports() == _route.n_outputs()) { + if (c->nports() == _route->n_outputs()) { MenuList& citems = output_menu.items(); citems.push_back (CheckMenuElem (c->name(), bind (mem_fun(*this, &MixerStrip::connection_output_chosen), c))); - ARDOUR::Connection *current = _route.output_connection(); + ARDOUR::Connection *current = _route->output_connection(); if (current == c) { ignore_toggle = true; @@ -727,8 +727,8 @@ MixerStrip::connect_to_pan () panstate_connection.disconnect (); panstyle_connection.disconnect (); - if (!_route.panner().empty()) { - StreamPanner* sp = _route.panner().front(); + if (!_route->panner().empty()) { + StreamPanner* sp = _route->panner().front(); panstate_connection = sp->automation().automation_state_changed.connect (mem_fun(panners, &PannerUI::pan_automation_state_changed)); panstyle_connection = sp->automation().automation_style_changed.connect (mem_fun(panners, &PannerUI::pan_automation_style_changed)); @@ -742,7 +742,7 @@ MixerStrip::update_input_display () { ARDOUR::Connection *c; - if ((c = _route.input_connection()) != 0) { + if ((c = _route->input_connection()) != 0) { input_label.set_text (c->name()); } else { switch (_width) { @@ -762,7 +762,7 @@ MixerStrip::update_output_display () { ARDOUR::Connection *c; - if ((c = _route.output_connection()) != 0) { + if ((c = _route->output_connection()) != 0) { output_label.set_text (c->name()); } else { switch (_width) { @@ -813,8 +813,8 @@ MixerStrip::comment_button_clicked () if (comment_window->is_visible()) { string str = comment_area->get_buffer()->get_text(); - if (_route.comment() != str) { - _route.set_comment (str, this); + if (_route->comment() != str) { + _route->set_comment (str, this); switch (_width) { @@ -858,7 +858,7 @@ void MixerStrip::setup_comment_editor () { string title; - title = _route.name(); + title = _route->name(); title += _(": comment editor"); comment_window = new ArdourDialog (title, false); @@ -870,7 +870,7 @@ MixerStrip::setup_comment_editor () comment_area->set_size_request (110, 178); comment_area->set_wrap_mode (WRAP_WORD); comment_area->set_editable (true); - comment_area->get_buffer()->set_text (_route.comment()); + comment_area->get_buffer()->set_text (_route->comment()); comment_area->show (); comment_window->get_vbox()->pack_start (*comment_area); @@ -885,7 +885,7 @@ MixerStrip::comment_changed (void *src) if (src != this) { ignore_comment_edit = true; if (comment_area) { - comment_area->get_buffer()->set_text (_route.comment()); + comment_area->get_buffer()->set_text (_route->comment()); } ignore_comment_edit = false; } @@ -894,7 +894,7 @@ MixerStrip::comment_changed (void *src) void MixerStrip::set_mix_group (RouteGroup *rg) { - _route.set_mix_group (rg, this); + _route->set_mix_group (rg, this); } void @@ -906,7 +906,7 @@ MixerStrip::add_mix_group_to_menu (RouteGroup *rg, RadioMenuItem::Group* group) items.push_back (RadioMenuElem (*group, rg->name(), bind (mem_fun(*this, &MixerStrip::set_mix_group), rg))); - if (_route.mix_group() == rg) { + if (_route->mix_group() == rg) { static_cast<RadioMenuItem*>(&items.back())->set_active (); } } @@ -946,7 +946,7 @@ MixerStrip::mix_group_changed (void *ignored) { ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::mix_group_changed), ignored)); - RouteGroup *rg = _route.mix_group(); + RouteGroup *rg = _route->mix_group(); if (rg) { group_label.set_text (rg->name()); @@ -1002,11 +1002,11 @@ MixerStrip::build_route_ops_menu () items.push_back (SeparatorElem()); items.push_back (CheckMenuElem (_("Active"), mem_fun (*this, &RouteUI::toggle_route_active))); route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back()); - route_active_menu_item->set_active (_route.active()); + route_active_menu_item->set_active (_route->active()); items.push_back (SeparatorElem()); items.push_back (CheckMenuElem (_("Invert Polarity"), mem_fun (*this, &RouteUI::toggle_polarity))); polarity_menu_item = dynamic_cast<CheckMenuItem *> (&items.back()); - polarity_menu_item->set_active (_route.phase_invert()); + polarity_menu_item->set_active (_route->phase_invert()); build_remote_control_menu (); @@ -1096,10 +1096,10 @@ MixerStrip::name_changed (void *src) RouteUI::name_changed (src); break; case Narrow: - name_label.set_text (PBD::short_version (_route.name(), 5)); + name_label.set_text (PBD::short_version (_route->name(), 5)); break; } - if (_route.phase_invert()) { + if (_route->phase_invert()) { name_label.set_text (X_("Ø ") + name_label.get_text()); } } @@ -1138,7 +1138,7 @@ MixerStrip::map_frozen () { ENSURE_GUI_THREAD (mem_fun(*this, &MixerStrip::map_frozen)); - AudioTrack* at = dynamic_cast<AudioTrack*>(&_route); + AudioTrack* at = audio_track(); if (at) { switch (at->freeze_state()) { @@ -1154,11 +1154,11 @@ MixerStrip::map_frozen () break; } } - _route.foreach_redirect (this, &MixerStrip::hide_redirect_editor); + _route->foreach_redirect (this, &MixerStrip::hide_redirect_editor); } void -MixerStrip::hide_redirect_editor (Redirect* redirect) +MixerStrip::hide_redirect_editor (boost::shared_ptr<Redirect> redirect) { void* gui = redirect->get_gui (); @@ -1173,7 +1173,7 @@ MixerStrip::route_active_changed () RouteUI::route_active_changed (); if (is_audio_track()) { - if (_route.active()) { + if (_route->active()) { set_name ("AudioTrackStripBase"); gpm.set_meter_strip_name ("AudioTrackStripBase"); } else { @@ -1182,7 +1182,7 @@ MixerStrip::route_active_changed () } gpm.set_fader_name ("AudioTrackFader"); } else { - if (_route.active()) { + if (_route->active()) { set_name ("AudioBusStripBase"); gpm.set_meter_strip_name ("AudioBusStripBase"); } else { @@ -1196,7 +1196,7 @@ MixerStrip::route_active_changed () RouteGroup* MixerStrip::mix_group() const { - return _route.mix_group(); + return _route->mix_group(); } void @@ -1225,7 +1225,7 @@ MixerStrip::meter_changed (void *src) ENSURE_GUI_THREAD (bind (mem_fun(*this, &MixerStrip::meter_changed), src)); - switch (_route.meter_point()) { + switch (_route->meter_point()) { case MeterInput: meter_point_label.set_text (_("input")); break; diff --git a/gtk2_ardour/mixer_strip.h b/gtk2_ardour/mixer_strip.h index c914d12404..e7b68ade48 100644 --- a/gtk2_ardour/mixer_strip.h +++ b/gtk2_ardour/mixer_strip.h @@ -84,7 +84,7 @@ class Mixer_UI; class MixerStrip : public RouteUI, public Gtk::EventBox { public: - MixerStrip (Mixer_UI&, ARDOUR::Session&, ARDOUR::Route &, bool in_mixer = true); + MixerStrip (Mixer_UI&, ARDOUR::Session&, boost::shared_ptr<ARDOUR::Route>, bool in_mixer = true); ~MixerStrip (); void set_width (Width); @@ -239,7 +239,7 @@ class MixerStrip : public RouteUI, public Gtk::EventBox void name_changed (void *src); void update_speed_display (); void map_frozen (); - void hide_redirect_editor (ARDOUR::Redirect* redirect); + void hide_redirect_editor (boost::shared_ptr<ARDOUR::Redirect> redirect); bool ignore_speed_adjustment; diff --git a/gtk2_ardour/mixer_ui.cc b/gtk2_ardour/mixer_ui.cc index 983903d6dd..c2eb588b2f 100644 --- a/gtk2_ardour/mixer_ui.cc +++ b/gtk2_ardour/mixer_ui.cc @@ -251,7 +251,7 @@ Mixer_UI::show_window () } void -Mixer_UI::add_strip (Route* route) +Mixer_UI::add_strip (boost::shared_ptr<Route> route) { ENSURE_GUI_THREAD(bind (mem_fun(*this, &Mixer_UI::add_strip), route)); @@ -261,7 +261,7 @@ Mixer_UI::add_strip (Route* route) return; } - strip = new MixerStrip (*this, *session, *route); + strip = new MixerStrip (*this, *session, route); strips.push_back (strip); strip->set_width (_strip_width); @@ -310,7 +310,7 @@ void Mixer_UI::follow_strip_selection () { for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) { - (*i)->set_selected (_selection.selected (&(*i)->route())); + (*i)->set_selected (_selection.selected ((*i)->route())); } } @@ -324,13 +324,13 @@ Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip) at the same time. */ - if (_selection.selected (&strip->route())) { - _selection.remove (&strip->route()); + if (_selection.selected (strip->route())) { + _selection.remove (strip->route()); } else { if (Keyboard::modifier_state_equals (ev->state, Keyboard::Shift)) { - _selection.add (&strip->route()); + _selection.add (strip->route()); } else { - _selection.set (&strip->route()); + _selection.set (strip->route()); } } } @@ -444,7 +444,7 @@ Mixer_UI::set_all_strips_visibility (bool yn) continue; } - if (strip->route().master() || strip->route().control()) { + if (strip->route()->master() || strip->route()->control()) { continue; } @@ -472,11 +472,11 @@ Mixer_UI::set_all_audio_visibility (int tracks, bool yn) continue; } - if (strip->route().master() || strip->route().control()) { + if (strip->route()->master() || strip->route()->control()) { continue; } - AudioTrack* at = dynamic_cast<AudioTrack*> (&strip->route()); + AudioTrack* at = strip->audio_track(); switch (tracks) { case 0: @@ -570,11 +570,11 @@ Mixer_UI::redisplay_track_list () if (visible) { strip->set_marked_for_display (true); - strip->route().set_order_key (N_("signal"), order); + strip->route()->set_order_key (N_("signal"), order); if (strip->packed()) { - if (strip->route().master() || strip->route().control()) { + if (strip->route()->master() || strip->route()->control()) { out_packer.reorder_child (*strip, -1); } else { strip_packer.reorder_child (*strip, -1); /* put at end */ @@ -582,7 +582,7 @@ Mixer_UI::redisplay_track_list () } else { - if (strip->route().master() || strip->route().control()) { + if (strip->route()->master() || strip->route()->control()) { out_packer.pack_start (*strip, false, false); } else { strip_packer.pack_start (*strip, false, false); @@ -593,7 +593,7 @@ Mixer_UI::redisplay_track_list () } else { - if (strip->route().master() || strip->route().control()) { + if (strip->route()->master() || strip->route()->control()) { /* do nothing, these cannot be hidden */ } else { strip_packer.remove (*strip); @@ -604,7 +604,7 @@ Mixer_UI::redisplay_track_list () } struct SignalOrderRouteSorter { - bool operator() (Route* a, Route* b) { + bool operator() (boost::shared_ptr<Route> a, boost::shared_ptr<Route> b) { /* use of ">" forces the correct sort order */ return a->order_key ("signal") < b->order_key ("signal"); } @@ -613,16 +613,17 @@ struct SignalOrderRouteSorter { void Mixer_UI::initial_track_display () { - Session::RouteList routes = session->get_routes(); + boost::shared_ptr<Session::RouteList> routes = session->get_routes(); + Session::RouteList copy (*routes); SignalOrderRouteSorter sorter; - routes.sort (sorter); + copy.sort (sorter); no_track_list_redisplay = true; track_model->clear (); - for (Session::RouteList::iterator i = routes.begin(); i != routes.end(); ++i) { + for (Session::RouteList::iterator i = copy.begin(); i != copy.end(); ++i) { add_strip (*i); } @@ -670,7 +671,7 @@ Mixer_UI::track_display_button_press (GdkEventButton* ev) MixerStrip* strip = (*iter)[track_columns.strip]; if (strip) { - if (!strip->route().master() && !strip->route().control()) { + if (!strip->route()->master() && !strip->route()->control()) { bool visible = (*iter)[track_columns.visible]; (*iter)[track_columns.visible] = !visible; } @@ -715,7 +716,7 @@ Mixer_UI::strip_name_changed (void* src, MixerStrip* mx) for (i = rows.begin(); i != rows.end(); ++i) { if ((*i)[track_columns.strip] == mx) { - (*i)[track_columns.text] = mx->route().name(); + (*i)[track_columns.text] = mx->route()->name(); return; } } diff --git a/gtk2_ardour/mixer_ui.h b/gtk2_ardour/mixer_ui.h index 864a110de7..6fe4120427 100644 --- a/gtk2_ardour/mixer_ui.h +++ b/gtk2_ardour/mixer_ui.h @@ -111,7 +111,7 @@ class Mixer_UI : public Gtk::Window bool strip_scroller_button_release (GdkEventButton*); - void add_strip (ARDOUR::Route*); + void add_strip (boost::shared_ptr<ARDOUR::Route>); void remove_strip (MixerStrip *); void hide_all_strips (bool with_select); @@ -194,7 +194,7 @@ class Mixer_UI : public Gtk::Window } Gtk::TreeModelColumn<bool> visible; Gtk::TreeModelColumn<Glib::ustring> text; - Gtk::TreeModelColumn<ARDOUR::Route*> route; + Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Route> > route; Gtk::TreeModelColumn<MixerStrip*> strip; }; diff --git a/gtk2_ardour/pan_automation_time_axis.cc b/gtk2_ardour/pan_automation_time_axis.cc index a39f2996f8..de1fae1732 100644 --- a/gtk2_ardour/pan_automation_time_axis.cc +++ b/gtk2_ardour/pan_automation_time_axis.cc @@ -34,7 +34,8 @@ using namespace ARDOUR; using namespace PBD; using namespace Gtk; -PanAutomationTimeAxisView::PanAutomationTimeAxisView (Session& s, Route& r, PublicEditor& e, TimeAxisView& parent, Canvas& canvas, std::string n) +PanAutomationTimeAxisView::PanAutomationTimeAxisView (Session& s, boost::shared_ptr<Route> r, PublicEditor& e, + TimeAxisView& parent, Canvas& canvas, std::string n) : AxisView (s), AutomationTimeAxisView (s, r, e, parent, canvas, n, X_("pan"), "") @@ -140,6 +141,6 @@ void PanAutomationTimeAxisView::set_automation_state (AutoState state) { if (!ignore_state_request) { - route.panner().set_automation_state (state); + route->panner().set_automation_state (state); } } diff --git a/gtk2_ardour/pan_automation_time_axis.h b/gtk2_ardour/pan_automation_time_axis.h index 638c17cb3b..ca4a4db8e7 100644 --- a/gtk2_ardour/pan_automation_time_axis.h +++ b/gtk2_ardour/pan_automation_time_axis.h @@ -14,11 +14,11 @@ class PanAutomationTimeAxisView : public AutomationTimeAxisView { public: PanAutomationTimeAxisView (ARDOUR::Session&, - ARDOUR::Route&, - PublicEditor&, - TimeAxisView& parent_axis, - ArdourCanvas::Canvas& canvas, - std::string name); + boost::shared_ptr<ARDOUR::Route>, + PublicEditor&, + TimeAxisView& parent_axis, + ArdourCanvas::Canvas& canvas, + std::string name); ~PanAutomationTimeAxisView(); diff --git a/gtk2_ardour/panner_ui.cc b/gtk2_ardour/panner_ui.cc index fac92a2844..f4720c6ed5 100644 --- a/gtk2_ardour/panner_ui.cc +++ b/gtk2_ardour/panner_ui.cc @@ -47,7 +47,7 @@ using namespace Gtk; using namespace sigc; -PannerUI::PannerUI (IO& io, Session& s) +PannerUI::PannerUI (boost::shared_ptr<IO> io, Session& s) : _io (io), _session (s), hAdjustment(0.0, 0.0, 0.0), @@ -87,13 +87,13 @@ PannerUI::PannerUI (IO& io, Session& s) using namespace Menu_Helpers; pan_astate_menu.items().push_back (MenuElem (_("Off"), - bind (mem_fun (_io.panner(), &Panner::set_automation_state), (AutoState) Off))); + bind (mem_fun (_io->panner(), &Panner::set_automation_state), (AutoState) Off))); pan_astate_menu.items().push_back (MenuElem (_("Play"), - bind (mem_fun (_io.panner(), &Panner::set_automation_state), (AutoState) Play))); + bind (mem_fun (_io->panner(), &Panner::set_automation_state), (AutoState) Play))); pan_astate_menu.items().push_back (MenuElem (_("Write"), - bind (mem_fun (_io.panner(), &Panner::set_automation_state), (AutoState) Write))); + bind (mem_fun (_io->panner(), &Panner::set_automation_state), (AutoState) Write))); pan_astate_menu.items().push_back (MenuElem (_("Touch"), - bind (mem_fun (_io.panner(), &Panner::set_automation_state), (AutoState) Touch))); + bind (mem_fun (_io->panner(), &Panner::set_automation_state), (AutoState) Touch))); pan_astyle_menu.items().push_back (MenuElem (_("Trim"))); pan_astyle_menu.items().push_back (MenuElem (_("Abs"))); @@ -143,9 +143,9 @@ PannerUI::PannerUI (IO& io, Session& s) set_width(Narrow); - _io.panner().Changed.connect (mem_fun(*this, &PannerUI::panner_changed)); - _io.panner().LinkStateChanged.connect (mem_fun(*this, &PannerUI::update_pan_linkage)); - _io.panner().StateChanged.connect (mem_fun(*this, &PannerUI::update_pan_state)); + _io->panner().Changed.connect (mem_fun(*this, &PannerUI::panner_changed)); + _io->panner().LinkStateChanged.connect (mem_fun(*this, &PannerUI::update_pan_linkage)); + _io->panner().StateChanged.connect (mem_fun(*this, &PannerUI::update_pan_state)); pan_changed (0); update_pan_sensitive (); @@ -165,7 +165,7 @@ PannerUI::panning_link_button_release (GdkEventButton* ev) { cerr << "link release\n"; if (!ignore_toggle) { - _io.panner().set_linked (!_io.panner().linked()); + _io->panner().set_linked (!_io->panner().linked()); } return true; } @@ -173,12 +173,12 @@ PannerUI::panning_link_button_release (GdkEventButton* ev) void PannerUI::panning_link_direction_clicked() { - switch (_io.panner().link_direction()) { + switch (_io->panner().link_direction()) { case Panner::SameDirection: - _io.panner().set_link_direction (Panner::OppositeDirection); + _io->panner().set_link_direction (Panner::OppositeDirection); break; default: - _io.panner().set_link_direction (Panner::SameDirection); + _io->panner().set_link_direction (Panner::SameDirection); break; } } @@ -188,7 +188,7 @@ PannerUI::update_pan_linkage () { ENSURE_GUI_THREAD(mem_fun(*this, &PannerUI::update_pan_linkage)); - bool x = _io.panner().linked(); + bool x = _io->panner().linked(); bool bx = panning_link_button.get_active(); if (x != bx) { @@ -200,7 +200,7 @@ PannerUI::update_pan_linkage () panning_link_direction_button.set_sensitive (x); - switch (_io.panner().link_direction()) { + switch (_io->panner().link_direction()) { case Panner::SameDirection: panning_link_direction_button.set_image (*(manage (new Image (get_xpm ("forwardblarrow.xpm"))))); break; @@ -278,7 +278,7 @@ PannerUI::update_pan_state () void PannerUI::setup_pan () { - uint32_t nouts = _io.n_outputs (); + uint32_t nouts = _io->n_outputs (); if (nouts == 0 || nouts == 1) { @@ -292,7 +292,7 @@ PannerUI::setup_pan () } else if (nouts == 2) { vector<Adjustment*>::size_type asz; - uint32_t npans = _io.panner().size(); + uint32_t npans = _io->panner().size(); while (!pan_adjustments.empty()) { delete pan_bars.back(); @@ -308,23 +308,23 @@ PannerUI::setup_pan () /* initialize adjustment with current value of panner */ - _io.panner()[asz]->get_position (x); + _io->panner()[asz]->get_position (x); pan_adjustments.push_back (new Adjustment (x, 0, 1.0, 0.05, 0.1)); pan_adjustments.back()->signal_value_changed().connect (bind (mem_fun(*this, &PannerUI::pan_adjustment_changed), (uint32_t) asz)); - _io.panner()[asz]->Changed.connect (bind (mem_fun(*this, &PannerUI::pan_value_changed), (uint32_t) asz)); + _io->panner()[asz]->Changed.connect (bind (mem_fun(*this, &PannerUI::pan_value_changed), (uint32_t) asz)); bc = new BarController (*pan_adjustments[asz], - _io.panner()[asz]->control(), + _io->panner()[asz]->control(), bind (mem_fun(*this, &PannerUI::pan_printer), pan_adjustments[asz])); bc->set_name ("PanSlider"); bc->set_shadow_type (Gtk::SHADOW_NONE); bc->set_style (BarController::Line); - bc->StartGesture.connect (bind (mem_fun (_io, &IO::start_pan_touch), (uint32_t) asz)); - bc->StopGesture.connect (bind (mem_fun (_io, &IO::end_pan_touch), (uint32_t) asz)); + bc->StartGesture.connect (bind (mem_fun (*_io, &IO::start_pan_touch), (uint32_t) asz)); + bc->StopGesture.connect (bind (mem_fun (*_io, &IO::end_pan_touch), (uint32_t) asz)); char buf[64]; #ifdef __APPLE__ @@ -375,13 +375,13 @@ PannerUI::setup_pan () } if (panner == 0) { - panner = new Panner2d (_io.panner(), w, 61); + panner = new Panner2d (_io->panner(), w, 61); panner->set_name ("MixerPanZone"); panner->show (); } update_pan_sensitive (); - panner->reset (_io.n_inputs()); + panner->reset (_io->n_inputs()); panner->set_size_request (w, 61); /* and finally, add it to the panner frame */ @@ -424,7 +424,7 @@ PannerUI::build_pan_menu (uint32_t which) /* set state first, connect second */ - (dynamic_cast<CheckMenuItem*> (&items.back()))->set_active (_io.panner()[which]->muted()); + (dynamic_cast<CheckMenuItem*> (&items.back()))->set_active (_io->panner()[which]->muted()); (dynamic_cast<CheckMenuItem*> (&items.back()))->signal_toggled().connect (bind (mem_fun(*this, &PannerUI::pan_mute), which)); @@ -433,7 +433,7 @@ PannerUI::build_pan_menu (uint32_t which) /* set state first, connect second */ - bypass_menu_item->set_active (_io.panner().bypassed()); + bypass_menu_item->set_active (_io->panner().bypassed()); bypass_menu_item->signal_toggled().connect (mem_fun(*this, &PannerUI::pan_bypass_toggle)); items.push_back (MenuElem (_("Reset"), mem_fun(*this, &PannerUI::pan_reset))); @@ -444,15 +444,15 @@ PannerUI::build_pan_menu (uint32_t which) void PannerUI::pan_mute (uint32_t which) { - StreamPanner* sp = _io.panner()[which]; + StreamPanner* sp = _io->panner()[which]; sp->set_muted (!sp->muted()); } void PannerUI::pan_bypass_toggle () { - if (bypass_menu_item && (_io.panner().bypassed() != bypass_menu_item->get_active())) { - _io.panner().set_bypassed (!_io.panner().bypassed()); + if (bypass_menu_item && (_io->panner().bypassed() != bypass_menu_item->get_active())) { + _io->panner().set_bypassed (!_io->panner().bypassed()); } } @@ -464,11 +464,11 @@ PannerUI::pan_reset () void PannerUI::effective_pan_display () { - if (_io.panner().empty()) { + if (_io->panner().empty()) { return; } - switch (_io.n_outputs()) { + switch (_io->n_outputs()) { case 0: case 1: /* relax */ @@ -491,7 +491,7 @@ PannerUI::pan_changed (void *src) return; } - switch (_io.panner().size()) { + switch (_io->panner().size()) { case 0: panning_link_direction_button.set_sensitive (false); panning_link_button.set_sensitive (false); @@ -505,7 +505,7 @@ PannerUI::pan_changed (void *src) panning_link_button.set_sensitive (true); } - uint32_t nouts = _io.n_outputs(); + uint32_t nouts = _io->n_outputs(); switch (nouts) { case 0: @@ -526,11 +526,11 @@ PannerUI::pan_changed (void *src) void PannerUI::pan_adjustment_changed (uint32_t which) { - if (!in_pan_update && which < _io.panner().size()) { + if (!in_pan_update && which < _io->panner().size()) { float xpos; float val = pan_adjustments[which]->get_value (); - _io.panner()[which]->get_position (xpos); + _io->panner()[which]->get_position (xpos); /* add a kinda-sorta detent for the middle */ @@ -547,7 +547,7 @@ PannerUI::pan_adjustment_changed (uint32_t which) if (!Panner::equivalent (val, xpos)) { - _io.panner()[which]->set_position (val); + _io->panner()[which]->set_position (val); /* XXX the panner objects have no access to the session, so do this here. ick. @@ -562,11 +562,11 @@ PannerUI::pan_value_changed (uint32_t which) { ENSURE_GUI_THREAD (bind (mem_fun(*this, &PannerUI::pan_value_changed), which)); - if (_io.n_outputs() > 1 && which < _io.panner().size()) { + if (_io->n_outputs() > 1 && which < _io->panner().size()) { float xpos; float val = pan_adjustments[which]->get_value (); - _io.panner()[which]->get_position (xpos); + _io->panner()[which]->get_position (xpos); if (!Panner::equivalent (val, xpos)) { in_pan_update = true; @@ -592,14 +592,14 @@ PannerUI::update_pan_bars (bool only_if_aplay) float xpos, val; if (only_if_aplay) { - AutomationList& alist (_io.panner()[n]->automation()); + AutomationList& alist (_io->panner()[n]->automation()); if (!alist.automation_playback()) { continue; } } - _io.panner()[n]->get_effective_position (xpos); + _io->panner()[n]->get_effective_position (xpos); val = (*i)->get_value (); if (!Panner::equivalent (val, xpos)) { @@ -630,9 +630,9 @@ PannerUI::pan_printer (char *buf, uint32_t len, Adjustment* adj) void PannerUI::update_pan_sensitive () { - bool sensitive = !(_io.panner().automation_state() & Play); + bool sensitive = !(_io->panner().automation_state() & Play); - switch (_io.n_outputs()) { + switch (_io->n_outputs()) { case 0: case 1: break; @@ -693,10 +693,10 @@ PannerUI::pan_automation_style_changed () switch (_width) { case Wide: - pan_automation_style_button.set_label (astyle_string(_io.panner().automation_style())); + pan_automation_style_button.set_label (astyle_string(_io->panner().automation_style())); break; case Narrow: - pan_automation_style_button.set_label (short_astyle_string(_io.panner().automation_style())); + pan_automation_style_button.set_label (short_astyle_string(_io->panner().automation_style())); break; } } @@ -710,10 +710,10 @@ PannerUI::pan_automation_state_changed () switch (_width) { case Wide: - pan_automation_state_button.set_label (astate_string(_io.panner().automation_state())); + pan_automation_state_button.set_label (astate_string(_io->panner().automation_state())); break; case Narrow: - pan_automation_state_button.set_label (short_astate_string(_io.panner().automation_state())); + pan_automation_state_button.set_label (short_astate_string(_io->panner().automation_state())); break; } @@ -722,11 +722,11 @@ PannerUI::pan_automation_state_changed () here. */ - if (_io.panner().empty()) { + if (_io->panner().empty()) { return; } - x = (_io.panner().front()->automation().automation_state() != Off); + x = (_io->panner().front()->automation().automation_state() != Off); if (pan_automation_state_button.get_active() != x) { ignore_toggle = true; diff --git a/gtk2_ardour/panner_ui.h b/gtk2_ardour/panner_ui.h index 86a8575802..7658978233 100644 --- a/gtk2_ardour/panner_ui.h +++ b/gtk2_ardour/panner_ui.h @@ -55,7 +55,7 @@ namespace Gtk { class PannerUI : public Gtk::HBox { public: - PannerUI (ARDOUR::IO&, ARDOUR::Session&); + PannerUI (boost::shared_ptr<ARDOUR::IO>, ARDOUR::Session&); ~PannerUI (); void pan_changed (void *); @@ -72,7 +72,7 @@ class PannerUI : public Gtk::HBox private: friend class MixerStrip; - ARDOUR::IO& _io; + boost::shared_ptr<ARDOUR::IO> _io; ARDOUR::Session& _session; bool ignore_toggle; diff --git a/gtk2_ardour/playlist_selector.cc b/gtk2_ardour/playlist_selector.cc index 9022c8acb4..5633404094 100644 --- a/gtk2_ardour/playlist_selector.cc +++ b/gtk2_ardour/playlist_selector.cc @@ -96,7 +96,7 @@ PlaylistSelector::show_for (RouteUI* ruix) rui = ruix; str = _("ardour: playlist for "); - str += rui->route().name(); + str += rui->route()->name(); set_title (str); @@ -223,7 +223,7 @@ PlaylistSelector::selection_changed () TreeModel::iterator iter = tree.get_selection()->get_selected(); - if (!iter) { + if (!iter || rui == 0) { /* nothing selected */ return; } @@ -233,7 +233,7 @@ PlaylistSelector::selection_changed () AudioTrack* at; AudioPlaylist* apl; - if ((at = dynamic_cast<AudioTrack*> (&rui->route())) == 0) { + if ((at = rui->audio_track()) == 0) { /* eh? */ return; } diff --git a/gtk2_ardour/plugin_selector.cc b/gtk2_ardour/plugin_selector.cc index 16796df160..a762a0b186 100644 --- a/gtk2_ardour/plugin_selector.cc +++ b/gtk2_ardour/plugin_selector.cc @@ -253,7 +253,7 @@ PluginSelector::use_plugin (PluginInfo* pi) return; } - Plugin *plugin = manager->load (*session, pi); + boost::shared_ptr<Plugin> plugin = manager->load (*session, pi); if (plugin) { PluginCreated (plugin); diff --git a/gtk2_ardour/plugin_selector.h b/gtk2_ardour/plugin_selector.h index 125ce1b80a..220de74871 100644 --- a/gtk2_ardour/plugin_selector.h +++ b/gtk2_ardour/plugin_selector.h @@ -35,7 +35,7 @@ class PluginSelector : public ArdourDialog { public: PluginSelector (ARDOUR::PluginManager *); - sigc::signal<void,ARDOUR::Plugin *> PluginCreated; + sigc::signal<void,boost::shared_ptr<ARDOUR::Plugin> > PluginCreated; int run (); // XXX should we try not to overload the non-virtual Gtk::Dialog::run() ? diff --git a/gtk2_ardour/plugin_ui.cc b/gtk2_ardour/plugin_ui.cc index e5c8534df6..beddad4e16 100644 --- a/gtk2_ardour/plugin_ui.cc +++ b/gtk2_ardour/plugin_ui.cc @@ -61,19 +61,19 @@ using namespace Gtkmm2ext; using namespace Gtk; using namespace sigc; -PluginUIWindow::PluginUIWindow (AudioEngine &engine, PluginInsert& insert, bool scrollable) +PluginUIWindow::PluginUIWindow (AudioEngine &engine, boost::shared_ptr<PluginInsert> insert, bool scrollable) : ArdourDialog ("plugin ui") { - if (insert.plugin().has_editor()) { + if (insert->plugin()->has_editor()) { #ifdef VST_SUPPORT - VSTPlugin* vp; + boost::shared_ptr<VSTPlugin> vp; - if ((vp = dynamic_cast<VSTPlugin*> (&insert.plugin())) != 0) { + if ((vp = boost::dynamic_pointer_cast<VSTPlugin> (insert->plugin())) != 0) { - VSTPluginUI* vpu = new VSTPluginUI (insert, *vp); + VSTPluginUI* vpu = new VSTPluginUI (insert, vp); _pluginui = vpu; get_vbox()->add (*vpu); @@ -104,7 +104,7 @@ PluginUIWindow::PluginUIWindow (AudioEngine &engine, PluginInsert& insert, bool add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK|Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK); signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), reinterpret_cast<Window*> (this))); - insert.GoingAway.connect (mem_fun(*this, &PluginUIWindow::plugin_going_away)); + insert->GoingAway.connect (mem_fun(*this, &PluginUIWindow::plugin_going_away)); if (scrollable) { gint h = _pluginui->get_preferred_height (); @@ -117,7 +117,7 @@ PluginUIWindow::~PluginUIWindow () { } -PluginUI::PluginUI (AudioEngine &engine, PluginInsert& pi, bool scrollable) +PluginUI::PluginUI (AudioEngine &engine, boost::shared_ptr<PluginInsert> pi, bool scrollable) : PlugUIBase (pi), engine(engine), button_table (initial_button_rows, initial_button_cols), @@ -165,8 +165,8 @@ PluginUI::PluginUI (AudioEngine &engine, PluginInsert& pi, bool scrollable) pack_start (hpacker, false, false); } - insert.active_changed.connect (mem_fun(*this, &PluginUI::redirect_active_changed)); - bypass_button.set_active (!insert.active()); + insert->active_changed.connect (mem_fun(*this, &PluginUI::redirect_active_changed)); + bypass_button.set_active (!insert->active()); build (engine); } @@ -233,13 +233,13 @@ PluginUI::build (AudioEngine &engine) /* find all ports. build control elements for all appropriate control ports */ - for (i = 0; i < plugin.parameter_count(); ++i) { + for (i = 0; i < plugin->parameter_count(); ++i) { - if (plugin.parameter_is_control (i)) { + if (plugin->parameter_is_control (i)) { /* Don't show latency control ports */ - if (plugin.describe_parameter (i) == X_("latency")) { + if (plugin->describe_parameter (i) == X_("latency")) { continue; } @@ -263,7 +263,7 @@ PluginUI::build (AudioEngine &engine) } } - if ((cui = build_control_ui (engine, i, plugin.get_nth_control (i))) == 0) { + if ((cui = build_control_ui (engine, i, plugin->get_nth_control (i))) == 0) { error << string_compose(_("Plugin Editor: could not build control element for port %1"), i) << endmsg; continue; } @@ -326,8 +326,8 @@ PluginUI::build (AudioEngine &engine) } } - n_ins = plugin.get_info().n_inputs; - n_outs = plugin.get_info().n_outputs; + n_ins = plugin->get_info().n_inputs; + n_outs = plugin->get_info().n_outputs; if (box->children().empty()) { hpacker.remove (*frame); @@ -387,7 +387,7 @@ PluginUI::automation_state_changed (ControlUI* cui) { /* update button label */ - switch (insert.get_port_automation_state (cui->port_index) & (Off|Play|Touch|Write)) { + switch (insert->get_port_automation_state (cui->port_index) & (Off|Play|Touch|Write)) { case Off: cui->automate_button.set_label (_("Off")); break; @@ -415,7 +415,7 @@ static void integer_printer (char buf[32], Adjustment &adj, void *arg) void PluginUI::print_parameter (char *buf, uint32_t len, uint32_t param) { - plugin.print_parameter (param, buf, len); + plugin->print_parameter (param, buf, len); } PluginUI::ControlUI* @@ -425,7 +425,7 @@ PluginUI::build_control_ui (AudioEngine &engine, guint32 port_index, PBD::Contro ControlUI* control_ui; Plugin::ParameterDescriptor desc; - plugin.get_parameter_descriptor (port_index, desc); + plugin->get_parameter_descriptor (port_index, desc); control_ui = manage (new ControlUI ()); control_ui->adjustment = 0; @@ -439,11 +439,11 @@ PluginUI::build_control_ui (AudioEngine &engine, guint32 port_index, PBD::Contro control_ui->set_spacing (5); - if (plugin.parameter_is_input (port_index)) { + if (plugin->parameter_is_input (port_index)) { - LadspaPlugin* lp; + boost::shared_ptr<LadspaPlugin> lp; - if ((lp = dynamic_cast<LadspaPlugin*>(&plugin)) != 0) { + if ((lp = boost::dynamic_pointer_cast<LadspaPlugin>(plugin)) != 0) { lrdf_defaults* defaults = lrdf_get_scale_values(lp->unique_id(), port_index); @@ -453,7 +453,7 @@ PluginUI::build_control_ui (AudioEngine &engine, guint32 port_index, PBD::Contro //control_ui->combo->set_value_in_list(true, false); set_popdown_strings (*control_ui->combo, setup_scale_values(port_index, control_ui)); control_ui->combo->signal_changed().connect (bind (mem_fun(*this, &PluginUI::control_combo_changed), control_ui)); - plugin.ParameterChanged.connect (bind (mem_fun (*this, &PluginUI::parameter_changed), control_ui)); + plugin->ParameterChanged.connect (bind (mem_fun (*this, &PluginUI::parameter_changed), control_ui)); control_ui->pack_start(control_ui->label, true, true); control_ui->pack_start(*control_ui->combo, false, true); @@ -478,7 +478,7 @@ PluginUI::build_control_ui (AudioEngine &engine, guint32 port_index, PBD::Contro control_ui->button->signal_clicked().connect (bind (mem_fun(*this, &PluginUI::control_port_toggled), control_ui)); - if(plugin.get_parameter (port_index) == 1){ + if(plugin->get_parameter (port_index) == 1){ control_ui->button->set_active(true); } @@ -529,9 +529,9 @@ PluginUI::build_control_ui (AudioEngine &engine, guint32 port_index, PBD::Contro } if (control_ui->logarithmic) { - control_ui->adjustment->set_value(log(plugin.get_parameter(port_index))); + control_ui->adjustment->set_value(log(plugin->get_parameter(port_index))); } else{ - control_ui->adjustment->set_value(plugin.get_parameter(port_index)); + control_ui->adjustment->set_value(plugin->get_parameter(port_index)); } /* XXX memory leak: SliderController not destroyed by ControlUI @@ -552,11 +552,11 @@ PluginUI::build_control_ui (AudioEngine &engine, guint32 port_index, PBD::Contro automation_state_changed (control_ui); - plugin.ParameterChanged.connect (bind (mem_fun(*this, &PluginUI::parameter_changed), control_ui)); - insert.automation_list (port_index).automation_state_changed.connect + plugin->ParameterChanged.connect (bind (mem_fun(*this, &PluginUI::parameter_changed), control_ui)); + insert->automation_list (port_index).automation_state_changed.connect (bind (mem_fun(*this, &PluginUI::automation_state_changed), control_ui)); - } else if (plugin.parameter_is_output (port_index)) { + } else if (plugin->parameter_is_output (port_index)) { control_ui->display = manage (new EventBox); control_ui->display->set_name ("ParameterValueDisplay"); @@ -603,20 +603,20 @@ PluginUI::build_control_ui (AudioEngine &engine, guint32 port_index, PBD::Contro output_controls.push_back (control_ui); } - plugin.ParameterChanged.connect (bind (mem_fun(*this, &PluginUI::parameter_changed), control_ui)); + plugin->ParameterChanged.connect (bind (mem_fun(*this, &PluginUI::parameter_changed), control_ui)); return control_ui; } void PluginUI::start_touch (PluginUI::ControlUI* cui) { - insert.automation_list (cui->port_index).start_touch (); + insert->automation_list (cui->port_index).start_touch (); } void PluginUI::stop_touch (PluginUI::ControlUI* cui) { - insert.automation_list (cui->port_index).stop_touch (); + insert->automation_list (cui->port_index).stop_touch (); } void @@ -647,7 +647,7 @@ PluginUI::astate_clicked (ControlUI* cui, uint32_t port) void PluginUI::set_automation_state (AutoState state, ControlUI* cui) { - insert.set_port_automation_state (cui->port_index, state); + insert->set_port_automation_state (cui->port_index, state); } void @@ -663,7 +663,7 @@ PluginUI::control_adjustment_changed (ControlUI* cui) value = exp(value); } - insert.set_parameter (cui->port_index, (float) value); + insert->set_parameter (cui->port_index, (float) value); } void @@ -684,7 +684,7 @@ PluginUI::update_control_display (ControlUI* cui) cui->update_pending = false; - float val = plugin.get_parameter (cui->port_index); + float val = plugin->get_parameter (cui->port_index); cui->ignore_change++; if (cui->combo) { @@ -718,7 +718,7 @@ void PluginUI::control_port_toggled (ControlUI* cui) { if (!cui->ignore_change) { - insert.set_parameter (cui->port_index, cui->button->get_active()); + insert->set_parameter (cui->port_index, cui->button->get_active()); } } @@ -728,7 +728,7 @@ PluginUI::control_combo_changed (ControlUI* cui) if (!cui->ignore_change) { string value = cui->combo->get_active_text(); std::map<string,float> mapping = *cui->combo_map; - insert.set_parameter (cui->port_index, mapping[value]); + insert->set_parameter (cui->port_index, mapping[value]); } } @@ -774,7 +774,7 @@ void PluginUI::output_update () { for (vector<ControlUI*>::iterator i = output_controls.begin(); i != output_controls.end(); ++i) { - float val = plugin.get_parameter ((*i)->port_index); + float val = plugin->get_parameter ((*i)->port_index); char buf[32]; snprintf (buf, sizeof(buf), "%.2f", val); (*i)->display_label->set_text (buf); @@ -808,7 +808,7 @@ vector<string> PluginUI::setup_scale_values(guint32 port_index, ControlUI* cui) { vector<string> enums; - LadspaPlugin* lp = dynamic_cast<LadspaPlugin*> (&plugin); + boost::shared_ptr<LadspaPlugin> lp = boost::dynamic_pointer_cast<LadspaPlugin> (plugin); cui->combo_map = new std::map<string, float>; lrdf_defaults* defaults = lrdf_get_scale_values(lp->unique_id(), port_index); @@ -827,14 +827,14 @@ PluginUI::setup_scale_values(guint32 port_index, ControlUI* cui) return enums; } -PlugUIBase::PlugUIBase (PluginInsert& pi) +PlugUIBase::PlugUIBase (boost::shared_ptr<PluginInsert> pi) : insert (pi), - plugin (insert.plugin()), + plugin (insert->plugin()), save_button(_("Add")), bypass_button (_("Bypass")) { //combo.set_use_arrows_always(true); - set_popdown_strings (combo, plugin.get_presets()); + set_popdown_strings (combo, plugin->get_presets()); combo.set_size_request (100, -1); combo.set_active_text (""); combo.signal_changed().connect(mem_fun(*this, &PlugUIBase::setting_selected)); @@ -850,7 +850,7 @@ void PlugUIBase::setting_selected() { if (combo.get_active_text().length() > 0) { - if (!plugin.load_preset(combo.get_active_text())) { + if (!plugin->load_preset(combo.get_active_text())) { warning << string_compose(_("Plugin preset %1 not found"), combo.get_active_text()) << endmsg; } } @@ -875,8 +875,8 @@ PlugUIBase::save_plugin_setting () prompter.get_result(name); if (name.length()) { - if(plugin.save_preset(name)){ - set_popdown_strings (combo, plugin.get_presets()); + if(plugin->save_preset(name)){ + set_popdown_strings (combo, plugin->get_presets()); combo.set_active_text (name); } } @@ -889,8 +889,8 @@ PlugUIBase::bypass_toggled () { bool x; - if ((x = bypass_button.get_active()) == insert.active()) { - insert.set_active (!x, this); + if ((x = bypass_button.get_active()) == insert->active()) { + insert->set_active (!x, this); } } diff --git a/gtk2_ardour/plugin_ui.h b/gtk2_ardour/plugin_ui.h index 351ab0dc2b..570a224b66 100644 --- a/gtk2_ardour/plugin_ui.h +++ b/gtk2_ardour/plugin_ui.h @@ -67,7 +67,7 @@ namespace Gtkmm2ext { class PlugUIBase : public virtual sigc::trackable { public: - PlugUIBase (ARDOUR::PluginInsert&); + PlugUIBase (boost::shared_ptr<ARDOUR::PluginInsert>); virtual ~PlugUIBase() {} virtual gint get_preferred_height () = 0; @@ -75,8 +75,8 @@ class PlugUIBase : public virtual sigc::trackable virtual bool stop_updating(GdkEventAny*) = 0; protected: - ARDOUR::PluginInsert& insert; - ARDOUR::Plugin& plugin; + boost::shared_ptr<ARDOUR::PluginInsert> insert; + boost::shared_ptr<ARDOUR::Plugin> plugin; Gtk::ComboBoxText combo; Gtk::Button save_button; Gtk::ToggleButton bypass_button; @@ -89,7 +89,7 @@ class PlugUIBase : public virtual sigc::trackable class PluginUI : public PlugUIBase, public Gtk::VBox { public: - PluginUI (ARDOUR::AudioEngine &, ARDOUR::PluginInsert& plug, bool scrollable=false); + PluginUI (ARDOUR::AudioEngine &, boost::shared_ptr<ARDOUR::PluginInsert> plug, bool scrollable=false); ~PluginUI (); gint get_preferred_height () { return prefheight; } @@ -196,7 +196,7 @@ class PluginUI : public PlugUIBase, public Gtk::VBox class PluginUIWindow : public ArdourDialog { public: - PluginUIWindow (ARDOUR::AudioEngine &, ARDOUR::PluginInsert& insert, bool scrollable=false); + PluginUIWindow (ARDOUR::AudioEngine &, boost::shared_ptr<ARDOUR::PluginInsert> insert, bool scrollable=false); ~PluginUIWindow (); PlugUIBase& pluginui() { return *_pluginui; } @@ -213,7 +213,7 @@ class PluginUIWindow : public ArdourDialog class VSTPluginUI : public PlugUIBase, public Gtk::VBox { public: - VSTPluginUI (ARDOUR::PluginInsert&, ARDOUR::VSTPlugin&); + VSTPluginUI (boost::shared_ptr<ARDOUR::PluginInsert>, boost::shared_ptr<ARDOUR::VSTPlugin>); ~VSTPluginUI (); gint get_preferred_height (); @@ -223,7 +223,7 @@ class VSTPluginUI : public PlugUIBase, public Gtk::VBox int package (Gtk::Window&); private: - ARDOUR::VSTPlugin& vst; + boost::shared_ptr<ARDOUR::VSTPlugin> vst; Gtk::Socket socket; Gtk::HBox preset_box; Gtk::VBox vpacker; diff --git a/gtk2_ardour/redirect_automation_line.cc b/gtk2_ardour/redirect_automation_line.cc index 8971e8ff10..1ea5013295 100644 --- a/gtk2_ardour/redirect_automation_line.cc +++ b/gtk2_ardour/redirect_automation_line.cc @@ -55,7 +55,7 @@ RedirectAutomationLine::RedirectAutomationLine (const string & name, Redirect& r /*NOTREACHED*/ } - pi->plugin().get_parameter_descriptor (_port, desc); + pi->plugin()->get_parameter_descriptor (_port, desc); upper = desc.upper; lower = desc.lower; diff --git a/gtk2_ardour/redirect_automation_time_axis.cc b/gtk2_ardour/redirect_automation_time_axis.cc index e1b71310ac..a53c1a20e4 100644 --- a/gtk2_ardour/redirect_automation_time_axis.cc +++ b/gtk2_ardour/redirect_automation_time_axis.cc @@ -32,7 +32,8 @@ using namespace ARDOUR; using namespace PBD; using namespace Gtk; -RedirectAutomationTimeAxisView::RedirectAutomationTimeAxisView (Session& s, Route& r, PublicEditor& e, TimeAxisView& parent, Canvas& canvas, std::string n, +RedirectAutomationTimeAxisView::RedirectAutomationTimeAxisView (Session& s, boost::shared_ptr<Route> r, + PublicEditor& e, TimeAxisView& parent, Canvas& canvas, std::string n, uint32_t prt, Redirect& rd, string state_name) : AxisView (s), diff --git a/gtk2_ardour/redirect_automation_time_axis.h b/gtk2_ardour/redirect_automation_time_axis.h index b8d94b2a3e..6976dc2358 100644 --- a/gtk2_ardour/redirect_automation_time_axis.h +++ b/gtk2_ardour/redirect_automation_time_axis.h @@ -14,7 +14,7 @@ class RedirectAutomationTimeAxisView : public AutomationTimeAxisView { public: RedirectAutomationTimeAxisView (ARDOUR::Session&, - ARDOUR::Route&, + boost::shared_ptr<ARDOUR::Route>, PublicEditor&, TimeAxisView& parent, ArdourCanvas::Canvas& canvas, diff --git a/gtk2_ardour/redirect_box.cc b/gtk2_ardour/redirect_box.cc index f5cb9522e0..0455dfdeb4 100644 --- a/gtk2_ardour/redirect_box.cc +++ b/gtk2_ardour/redirect_box.cc @@ -76,7 +76,7 @@ bool RedirectBox::get_colors = true; Gdk::Color* RedirectBox::active_redirect_color; Gdk::Color* RedirectBox::inactive_redirect_color; -RedirectBox::RedirectBox (Placement pcmnt, Session& sess, Route& rt, PluginSelector &plugsel, +RedirectBox::RedirectBox (Placement pcmnt, Session& sess, boost::shared_ptr<Route> rt, PluginSelector &plugsel, RouteRedirectSelection & rsel, bool owner_is_mixer) : _route(rt), _session(sess), @@ -132,7 +132,7 @@ RedirectBox::RedirectBox (Placement pcmnt, Session& sess, Route& rt, PluginSelec pack_start (redirect_eventbox, true, true); - _route.redirects_changed.connect (mem_fun(*this, &RedirectBox::redisplay_redirects)); + _route->redirects_changed.connect (mem_fun(*this, &RedirectBox::redisplay_redirects)); redirect_eventbox.signal_enter_notify_event().connect (bind (sigc::ptr_fun (RedirectBox::enter_box), this)); @@ -161,10 +161,10 @@ RedirectBox::object_drop (string type, uint32_t cnt, void** ptr) /* do something with the dropped redirects */ - list<Redirect*> redirects; - + list<boost::shared_ptr<Redirect> > redirects; + for (uint32_t n = 0; n < cnt; ++n) { - redirects.push_back ((Redirect*) ptr[n]); + redirects.push_back (boost::shared_ptr<Redirect> ((Redirect*) ptr[n])); } paste_redirect_list (redirects); @@ -189,21 +189,21 @@ RedirectBox::set_width (Width w) } void -RedirectBox::remove_redirect_gui (Redirect *redirect) +RedirectBox::remove_redirect_gui (boost::shared_ptr<Redirect> redirect) { - Insert *insert = 0; - Send *send = 0; - PortInsert *port_insert = 0; + boost::shared_ptr<Insert> insert; + boost::shared_ptr<Send> send; + boost::shared_ptr<PortInsert> port_insert; - if ((insert = dynamic_cast<Insert *> (redirect)) != 0) { + if ((insert = boost::dynamic_pointer_cast<Insert> (redirect)) != 0) { - if ((port_insert = dynamic_cast<PortInsert *> (insert)) != 0) { + if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (insert)) != 0) { PortInsertUI *io_selector = reinterpret_cast<PortInsertUI *> (port_insert->get_gui()); port_insert->set_gui (0); delete io_selector; } - } else if ((send = dynamic_cast<Send *> (insert)) != 0) { + } else if ((send = boost::dynamic_pointer_cast<Send> (insert)) != 0) { SendUIWindow *sui = reinterpret_cast<SendUIWindow*> (send->get_gui()); send->set_gui (0); delete sui; @@ -268,7 +268,7 @@ RedirectBox::redirect_button_press_event (GdkEventButton *ev) TreeViewColumn* column; int cellx; int celly; - Redirect* redirect = 0; + boost::shared_ptr<Redirect> redirect; int ret = false; bool selected = false; @@ -353,25 +353,25 @@ RedirectBox::choose_plugin () } void -RedirectBox::insert_plugin_chosen (Plugin *plugin) +RedirectBox::insert_plugin_chosen (boost::shared_ptr<Plugin> plugin) { if (plugin) { - Redirect *redirect = new PluginInsert (_session, *plugin, _placement); + boost::shared_ptr<Redirect> redirect (new PluginInsert (_session, plugin, _placement)); redirect->active_changed.connect (mem_fun(*this, &RedirectBox::show_redirect_active)); uint32_t err_streams; - if (_route.add_redirect (redirect, this, &err_streams)) { + if (_route->add_redirect (redirect, this, &err_streams)) { wierd_plugin_dialog (*plugin, err_streams, _route); - delete redirect; + // XXX SHAREDPTR delete plugin here .. do we even need to care? } } } void -RedirectBox::wierd_plugin_dialog (Plugin& p, uint32_t streams, IO& io) +RedirectBox::wierd_plugin_dialog (Plugin& p, uint32_t streams, boost::shared_ptr<IO> io) { ArdourDialog dialog ("wierd plugin dialog"); Label label; @@ -417,8 +417,8 @@ RedirectBox::wierd_plugin_dialog (Plugin& p, uint32_t streams, IO& io) p.name(), p.get_info().n_inputs, p.get_info().n_outputs, - io.n_inputs(), - io.n_outputs(), + io->n_inputs(), + io->n_outputs(), streams)); } @@ -436,36 +436,36 @@ RedirectBox::wierd_plugin_dialog (Plugin& p, uint32_t streams, IO& io) void RedirectBox::choose_insert () { - Redirect *redirect = new PortInsert (_session, _placement); + boost::shared_ptr<Redirect> redirect (new PortInsert (_session, _placement)); redirect->active_changed.connect (mem_fun(*this, &RedirectBox::show_redirect_active)); - _route.add_redirect (redirect, this); + _route->add_redirect (redirect, this); } void RedirectBox::choose_send () { - Send *send = new Send (_session, _placement); + boost::shared_ptr<Send> send (new Send (_session, _placement)); /* XXX need redirect lock on route */ - send->ensure_io (0, _route.max_redirect_outs(), false, this); + send->ensure_io (0, _route->max_redirect_outs(), false, this); - IOSelectorWindow *ios = new IOSelectorWindow (_session, *send, false, true); + IOSelectorWindow *ios = new IOSelectorWindow (_session, send, false, true); ios->show_all (); - ios->selector().Finished.connect (bind (mem_fun(*this, &RedirectBox::send_io_finished), static_cast<Redirect*>(send), ios)); + ios->selector().Finished.connect (bind (mem_fun(*this, &RedirectBox::send_io_finished), boost::static_pointer_cast<Redirect>(send), ios)); } void -RedirectBox::send_io_finished (IOSelector::Result r, Redirect* redirect, IOSelectorWindow* ios) +RedirectBox::send_io_finished (IOSelector::Result r, boost::shared_ptr<Redirect> redirect, IOSelectorWindow* ios) { switch (r) { case IOSelector::Cancelled: - delete redirect; + // delete redirect; XXX SHAREDPTR HOW TO DESTROY THE REDIRECT ? do we even need to think about it? break; case IOSelector::Accepted: - _route.add_redirect (redirect, this); + _route->add_redirect (redirect, this); break; } @@ -488,7 +488,8 @@ RedirectBox::redisplay_redirects (void *src) redirect_active_connections.clear (); redirect_name_connections.clear (); - _route.foreach_redirect (this, &RedirectBox::add_redirect_to_display); + void (RedirectBox::*pmf)(boost::shared_ptr<Redirect>) = &RedirectBox::add_redirect_to_display; + _route->foreach_redirect (this, pmf); switch (_placement) { case PreFader: @@ -501,33 +502,33 @@ RedirectBox::redisplay_redirects (void *src) } void -RedirectBox::add_redirect_to_display (Redirect *redirect) +RedirectBox::add_redirect_to_display (boost::shared_ptr<Redirect> redirect) { if (redirect->placement() != _placement) { return; } Gtk::TreeModel::Row row = *(model->append()); - row[columns.text] = redirect_name (*redirect); + row[columns.text] = redirect_name (redirect); row[columns.redirect] = redirect; - show_redirect_active (redirect, this); + show_redirect_active (redirect.get(), this); redirect_active_connections.push_back (redirect->active_changed.connect (mem_fun(*this, &RedirectBox::show_redirect_active))); redirect_name_connections.push_back (redirect->name_changed.connect (bind (mem_fun(*this, &RedirectBox::show_redirect_name), redirect))); } string -RedirectBox::redirect_name (Redirect& redirect) +RedirectBox::redirect_name (boost::shared_ptr<Redirect> redirect) { - Send *send; + boost::shared_ptr<Send> send; string name_display; - if (!redirect.active()) { + if (!redirect->active()) { name_display = " ("; } - if ((send = dynamic_cast<Send *> (&redirect)) != 0) { + if ((send = boost::dynamic_pointer_cast<Send> (redirect)) != 0) { name_display += '>'; @@ -550,16 +551,16 @@ RedirectBox::redirect_name (Redirect& redirect) switch (_width) { case Wide: - name_display += redirect.name(); + name_display += redirect->name(); break; case Narrow: - name_display += PBD::short_version (redirect.name(), 5); + name_display += PBD::short_version (redirect->name(), 5); break; } } - if (!redirect.active()) { + if (!redirect->active()) { name_display += ')'; } @@ -581,34 +582,36 @@ RedirectBox::build_redirect_tooltip (EventBox& box, string start) } void -RedirectBox::show_redirect_name (void* src, Redirect *redirect) +RedirectBox::show_redirect_name (void* src, boost::shared_ptr<Redirect> redirect) { ENSURE_GUI_THREAD(bind (mem_fun(*this, &RedirectBox::show_redirect_name), src, redirect)); - - show_redirect_active (redirect, src); + show_redirect_active (redirect.get(), src); } void -RedirectBox::show_redirect_active (Redirect *redirect, void *src) +RedirectBox::show_redirect_active (Redirect* redirect, void *src) { ENSURE_GUI_THREAD(bind (mem_fun(*this, &RedirectBox::show_redirect_active), redirect, src)); Gtk::TreeModel::Children children = model->children(); Gtk::TreeModel::Children::iterator iter = children.begin(); - while( iter != children.end()) - { - if ((*iter)[columns.redirect] == redirect) - break; - iter++; - } + while (iter != children.end()) { - (*iter)[columns.text] = redirect_name (*redirect); + boost::shared_ptr<Redirect> r = (*iter)[columns.redirect]; - if (redirect->active()) { - (*iter)[columns.color] = *active_redirect_color; - } else { - (*iter)[columns.color] = *inactive_redirect_color; + if (r.get() == redirect) { + (*iter)[columns.text] = redirect_name (r); + + if (redirect->active()) { + (*iter)[columns.color] = *active_redirect_color; + } else { + (*iter)[columns.color] = *inactive_redirect_color; + } + break; + } + + iter++; } } @@ -627,12 +630,12 @@ RedirectBox::compute_redirect_sort_keys () Gtk::TreeModel::Children children = model->children(); for (Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) { - Redirect *redirect = (*iter)[columns.redirect]; - redirect->set_sort_key (sort_key); + boost::shared_ptr<Redirect> r = (*iter)[columns.redirect]; + r->set_sort_key (sort_key); sort_key++; } - if (_route.sort_redirects ()) { + if (_route->sort_redirects ()) { redisplay_redirects (0); @@ -661,7 +664,7 @@ outputs do not work correctly.")); void RedirectBox::rename_redirects () { - vector<Redirect*> to_be_renamed; + vector<boost::shared_ptr<Redirect> > to_be_renamed; get_selected_redirects (to_be_renamed); @@ -669,7 +672,7 @@ RedirectBox::rename_redirects () return; } - for (vector<Redirect*>::iterator i = to_be_renamed.begin(); i != to_be_renamed.end(); ++i) { + for (vector<boost::shared_ptr<Redirect> >::iterator i = to_be_renamed.begin(); i != to_be_renamed.end(); ++i) { rename_redirect (*i); } } @@ -677,7 +680,7 @@ RedirectBox::rename_redirects () void RedirectBox::cut_redirects () { - vector<Redirect*> to_be_removed; + vector<boost::shared_ptr<Redirect> > to_be_removed; get_selected_redirects (to_be_removed); @@ -692,7 +695,7 @@ RedirectBox::cut_redirects () _rr_selection.set (to_be_removed); - for (vector<Redirect*>::iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) { + for (vector<boost::shared_ptr<Redirect> >::iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) { void* gui = (*i)->get_gui (); @@ -700,7 +703,7 @@ RedirectBox::cut_redirects () static_cast<Gtk::Widget*>(gui)->hide (); } - if (_route.remove_redirect (*i, this)) { + if (_route->remove_redirect (*i, this)) { /* removal failed */ _rr_selection.remove (*i); } @@ -711,8 +714,8 @@ RedirectBox::cut_redirects () void RedirectBox::copy_redirects () { - vector<Redirect*> to_be_copied; - vector<Redirect*> copies; + vector<boost::shared_ptr<Redirect> > to_be_copied; + vector<boost::shared_ptr<Redirect> > copies; get_selected_redirects (to_be_copied); @@ -720,29 +723,24 @@ RedirectBox::copy_redirects () return; } - for (vector<Redirect*>::iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) { - copies.push_back (Redirect::clone (**i)); + for (vector<boost::shared_ptr<Redirect> >::iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) { + copies.push_back (Redirect::clone (*i)); } _rr_selection.set (copies); } gint -RedirectBox::idle_delete_redirect (Redirect *redirect) +RedirectBox::idle_delete_redirect (boost::shared_ptr<Redirect> redirect) { /* NOT copied to _mixer.selection() */ - if (_route.remove_redirect (redirect, this)) { - /* removal failed */ - return FALSE; - } - - delete redirect; + _route->remove_redirect (redirect, this); return FALSE; } void -RedirectBox::rename_redirect (Redirect* redirect) +RedirectBox::rename_redirect (boost::shared_ptr<Redirect> redirect) { ArdourPrompter name_prompter (true); string result; @@ -767,7 +765,7 @@ RedirectBox::rename_redirect (Redirect* redirect) } void -RedirectBox::cut_redirect (Redirect *redirect) +RedirectBox::cut_redirect (boost::shared_ptr<Redirect> redirect) { /* this essentially transfers ownership of the redirect of the redirect from the route to the mixer @@ -782,15 +780,15 @@ RedirectBox::cut_redirect (Redirect *redirect) static_cast<Gtk::Widget*>(gui)->hide (); } - if (_route.remove_redirect (redirect, this)) { + if (_route->remove_redirect (redirect, this)) { _rr_selection.remove (redirect); } } void -RedirectBox::copy_redirect (Redirect *redirect) +RedirectBox::copy_redirect (boost::shared_ptr<Redirect> redirect) { - Redirect* copy = Redirect::clone (*redirect); + boost::shared_ptr<Redirect> copy = Redirect::clone (redirect); _rr_selection.add (copy); } @@ -805,22 +803,19 @@ RedirectBox::paste_redirects () } void -RedirectBox::paste_redirect_list (list<Redirect*>& redirects) +RedirectBox::paste_redirect_list (list<boost::shared_ptr<Redirect> >& redirects) { - list<Redirect*> copies; + list<boost::shared_ptr<Redirect> > copies; - for (list<Redirect*>::iterator i = redirects.begin(); i != redirects.end(); ++i) { + for (list<boost::shared_ptr<Redirect> >::iterator i = redirects.begin(); i != redirects.end(); ++i) { - Redirect* copy = Redirect::clone (**i); + boost::shared_ptr<Redirect> copy = Redirect::clone (*i); copy->set_placement (_placement, this); copies.push_back (copy); } - if (_route.add_redirects (copies, this)) { - for (list<Redirect*>::iterator i = copies.begin(); i != copies.end(); ++i) { - delete *i; - } + if (_route->add_redirects (copies, this)) { string msg = _( "Copying the set of redirects on the clipboard failed,\n\ @@ -832,19 +827,19 @@ could not match the configuration of this track."); } void -RedirectBox::activate_redirect (Redirect *r) +RedirectBox::activate_redirect (boost::shared_ptr<Redirect> r) { r->set_active (true, 0); } void -RedirectBox::deactivate_redirect (Redirect *r) +RedirectBox::deactivate_redirect (boost::shared_ptr<Redirect> r) { r->set_active (false, 0); } void -RedirectBox::get_selected_redirects (vector<Redirect*>& redirects) +RedirectBox::get_selected_redirects (vector<boost::shared_ptr<Redirect> >& redirects) { vector<Gtk::TreeModel::Path> pathlist = redirect_display.get_selection()->get_selected_rows(); @@ -853,12 +848,12 @@ RedirectBox::get_selected_redirects (vector<Redirect*>& redirects) } void -RedirectBox::for_selected_redirects (void (RedirectBox::*pmf)(Redirect*)) +RedirectBox::for_selected_redirects (void (RedirectBox::*pmf)(boost::shared_ptr<Redirect>)) { vector<Gtk::TreeModel::Path> pathlist = redirect_display.get_selection()->get_selected_rows(); for (vector<Gtk::TreeModel::Path>::iterator iter = pathlist.begin(); iter != pathlist.end(); ++iter) { - Redirect* redirect = (*(model->get_iter(*iter)))[columns.redirect]; + boost::shared_ptr<Redirect> redirect = (*(model->get_iter(*iter)))[columns.redirect]; (this->*pmf)(redirect); } } @@ -869,7 +864,7 @@ RedirectBox::clone_redirects () RouteSelection& routes (_rr_selection.routes); if (!routes.empty()) { - if (_route.copy_redirects (*routes.front(), _placement)) { + if (_route->copy_redirects (*routes.front(), _placement)) { string msg = _( "Copying the set of redirects on the clipboard failed,\n\ probably because the I/O configuration of the plugins\n\ @@ -883,7 +878,7 @@ could not match the configuration of this track."); void RedirectBox::all_redirects_active (bool state) { - _route.all_redirects_active (state); + _route->all_redirects_active (state); } void @@ -892,7 +887,7 @@ RedirectBox::clear_redirects() string prompt; vector<string> choices; - if (dynamic_cast<AudioTrack*>(&_route) != 0) { + if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) { prompt = _("Do you really want to remove all redirects from this track?\n" "(this cannot be undone)"); } else { @@ -906,23 +901,23 @@ RedirectBox::clear_redirects() Gtkmm2ext::Choice prompter (prompt, choices); if (prompter.run () == 1) { - _route.clear_redirects (this); + _route->clear_redirects (this); } } void -RedirectBox::edit_redirect (Redirect* redirect) +RedirectBox::edit_redirect (boost::shared_ptr<Redirect> redirect) { - Insert *insert; + boost::shared_ptr<Insert> insert; - if (dynamic_cast<AudioTrack*>(&_route) != 0) { + if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) { - if (dynamic_cast<AudioTrack*> (&_route)->freeze_state() == AudioTrack::Frozen) { + if (boost::dynamic_pointer_cast<AudioTrack> (_route)->freeze_state() == AudioTrack::Frozen) { return; } } - if ((insert = dynamic_cast<Insert *> (redirect)) == 0) { + if ((insert = boost::dynamic_pointer_cast<Insert> (redirect)) == 0) { /* its a send */ @@ -930,7 +925,7 @@ RedirectBox::edit_redirect (Redirect* redirect) return; } - Send *send = dynamic_cast<Send*> (redirect); + boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (redirect); SendUIWindow *send_ui; @@ -939,7 +934,7 @@ RedirectBox::edit_redirect (Redirect* redirect) string title; title = string_compose(_("ardour: %1"), send->name()); - send_ui = new SendUIWindow (*send, _session); + send_ui = new SendUIWindow (send, _session); send_ui->set_title (title); send->set_gui (send_ui); @@ -957,17 +952,17 @@ RedirectBox::edit_redirect (Redirect* redirect) /* its an insert */ - PluginInsert *plugin_insert; - PortInsert *port_insert; + boost::shared_ptr<PluginInsert> plugin_insert; + boost::shared_ptr<PortInsert> port_insert; - if ((plugin_insert = dynamic_cast<PluginInsert *> (insert)) != 0) { + if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (insert)) != 0) { PluginUIWindow *plugin_ui; if (plugin_insert->get_gui() == 0) { string title; - string maker = plugin_insert->plugin().maker(); + string maker = plugin_insert->plugin()->maker(); string::size_type email_pos; if ((email_pos = maker.find_first_of ('<')) != string::npos) { @@ -979,9 +974,9 @@ RedirectBox::edit_redirect (Redirect* redirect) maker += " ..."; } - title = string_compose(_("ardour: %1: %2 (by %3)"), _route.name(), plugin_insert->name(), maker); + title = string_compose(_("ardour: %1: %2 (by %3)"), _route->name(), plugin_insert->name(), maker); - plugin_ui = new PluginUIWindow (_session.engine(), *plugin_insert); + plugin_ui = new PluginUIWindow (_session.engine(), plugin_insert); if (_owner_is_mixer) { ARDOUR_UI::instance()->the_mixer()->ensure_float (*plugin_ui); } else { @@ -1000,7 +995,7 @@ RedirectBox::edit_redirect (Redirect* redirect) plugin_ui->show_all (); } - } else if ((port_insert = dynamic_cast<PortInsert *> (insert)) != 0) { + } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (insert)) != 0) { if (!_session.engine().connected()) { MessageDialog msg ( _("Not connected to JACK - no I/O changes are possible")); @@ -1011,7 +1006,7 @@ RedirectBox::edit_redirect (Redirect* redirect) PortInsertWindow *io_selector; if (port_insert->get_gui() == 0) { - io_selector = new PortInsertWindow (_session, *port_insert); + io_selector = new PortInsertWindow (_session, port_insert); port_insert->set_gui (io_selector); } else { diff --git a/gtk2_ardour/redirect_box.h b/gtk2_ardour/redirect_box.h index 0a4a6d5dee..51c17cad51 100644 --- a/gtk2_ardour/redirect_box.h +++ b/gtk2_ardour/redirect_box.h @@ -65,7 +65,8 @@ namespace ARDOUR { class RedirectBox : public Gtk::HBox { public: - RedirectBox (ARDOUR::Placement, ARDOUR::Session&, ARDOUR::Route &, PluginSelector &, RouteRedirectSelection &, bool owner_is_mixer = false); + RedirectBox (ARDOUR::Placement, ARDOUR::Session&, + boost::shared_ptr<ARDOUR::Route>, PluginSelector &, RouteRedirectSelection &, bool owner_is_mixer = false); ~RedirectBox (); void set_width (Width); @@ -78,8 +79,8 @@ class RedirectBox : public Gtk::HBox void select_all_inserts (); void select_all_sends (); - sigc::signal<void,ARDOUR::Redirect *> RedirectSelected; - sigc::signal<void,ARDOUR::Redirect *> RedirectUnselected; + sigc::signal<void,boost::shared_ptr<ARDOUR::Redirect> > RedirectSelected; + sigc::signal<void,boost::shared_ptr<ARDOUR::Redirect> > RedirectUnselected; static void register_actions(); @@ -87,7 +88,7 @@ class RedirectBox : public Gtk::HBox void set_stuff_from_route (); private: - ARDOUR::Route & _route; + boost::shared_ptr<ARDOUR::Route> _route; ARDOUR::Session & _session; bool _owner_is_mixer; @@ -103,7 +104,7 @@ class RedirectBox : public Gtk::HBox add (color); } Gtk::TreeModelColumn<std::string> text; - Gtk::TreeModelColumn<ARDOUR::Redirect*> redirect; + Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Redirect> > redirect; Gtk::TreeModelColumn<Gdk::Color> color; }; @@ -138,24 +139,29 @@ class RedirectBox : public Gtk::HBox void show_redirect_menu (gint arg); void choose_send (); - void send_io_finished (IOSelector::Result, ARDOUR::Redirect*, IOSelectorWindow*); + void send_io_finished (IOSelector::Result, boost::shared_ptr<ARDOUR::Redirect>, IOSelectorWindow*); void choose_insert (); void choose_plugin (); - void insert_plugin_chosen (ARDOUR::Plugin *); + void insert_plugin_chosen (boost::shared_ptr<ARDOUR::Plugin>); bool no_redirect_redisplay; bool ignore_delete; bool redirect_button_press_event (GdkEventButton *); void redisplay_redirects (void* src); - void show_redirect_active (ARDOUR::Redirect *, void *); - void show_redirect_name (void*, ARDOUR::Redirect *); - void add_redirect_to_display (ARDOUR::Redirect *); + void add_redirect_to_display (boost::shared_ptr<ARDOUR::Redirect>); void row_deleted (const Gtk::TreeModel::Path& path); + void show_redirect_name (void*, boost::shared_ptr<ARDOUR::Redirect>); - string redirect_name (ARDOUR::Redirect&); + /* these are handlers for Redirect signals, so they take Redirect* + directly, rather than shared_ptr<Redirect> + */ - void remove_redirect_gui (ARDOUR::Redirect *); + void show_redirect_active (ARDOUR::Redirect*, void *); + + string redirect_name (boost::shared_ptr<ARDOUR::Redirect>); + + void remove_redirect_gui (boost::shared_ptr<ARDOUR::Redirect>); void redirects_reordered (const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator&, int*); void compute_redirect_sort_keys (); @@ -174,23 +180,23 @@ class RedirectBox : public Gtk::HBox void clone_redirects (); void rename_redirects (); - void for_selected_redirects (void (RedirectBox::*pmf)(ARDOUR::Redirect*)); - void get_selected_redirects (vector<ARDOUR::Redirect*>&); + void for_selected_redirects (void (RedirectBox::*pmf)(boost::shared_ptr<ARDOUR::Redirect>)); + void get_selected_redirects (vector<boost::shared_ptr<ARDOUR::Redirect> >&); static Glib::RefPtr<Gtk::Action> paste_action; - void paste_redirect_list (std::list<ARDOUR::Redirect*>& redirects); + void paste_redirect_list (std::list<boost::shared_ptr<ARDOUR::Redirect> >& redirects); - void activate_redirect (ARDOUR::Redirect*); - void deactivate_redirect (ARDOUR::Redirect*); - void cut_redirect (ARDOUR::Redirect*); - void copy_redirect (ARDOUR::Redirect*); - void edit_redirect (ARDOUR::Redirect*); - void hide_redirect_editor (ARDOUR::Redirect*); - void rename_redirect (ARDOUR::Redirect*); + void activate_redirect (boost::shared_ptr<ARDOUR::Redirect>); + void deactivate_redirect (boost::shared_ptr<ARDOUR::Redirect>); + void cut_redirect (boost::shared_ptr<ARDOUR::Redirect>); + void copy_redirect (boost::shared_ptr<ARDOUR::Redirect>); + void edit_redirect (boost::shared_ptr<ARDOUR::Redirect>); + void hide_redirect_editor (boost::shared_ptr<ARDOUR::Redirect>); + void rename_redirect (boost::shared_ptr<ARDOUR::Redirect>); - gint idle_delete_redirect (ARDOUR::Redirect *); + gint idle_delete_redirect (boost::shared_ptr<ARDOUR::Redirect>); - void wierd_plugin_dialog (ARDOUR::Plugin& p, uint32_t streams, ARDOUR::IO& io); + void wierd_plugin_dialog (ARDOUR::Plugin& p, uint32_t streams, boost::shared_ptr<ARDOUR::IO> io); static RedirectBox* _current_redirect_box; static bool enter_box (GdkEventCrossing*, RedirectBox*); diff --git a/gtk2_ardour/redirect_selection.h b/gtk2_ardour/redirect_selection.h index 3695f85c60..5bcd77cfe4 100644 --- a/gtk2_ardour/redirect_selection.h +++ b/gtk2_ardour/redirect_selection.h @@ -2,11 +2,12 @@ #define __ardour_gtk_redirect_selection_h__ #include <list> +#include <boost/shared_ptr.hpp> namespace ARDOUR { class Redirect; } -struct RedirectSelection : list<ARDOUR::Redirect*> {}; +struct RedirectSelection : list<boost::shared_ptr<ARDOUR::Redirect> > {}; #endif /* __ardour_gtk_redirect_selection_h__ */ diff --git a/gtk2_ardour/route_params_ui.cc b/gtk2_ardour/route_params_ui.cc index d6ec7eab6c..8b47a17511 100644 --- a/gtk2_ardour/route_params_ui.cc +++ b/gtk2_ardour/route_params_ui.cc @@ -59,14 +59,10 @@ using namespace sigc; RouteParams_UI::RouteParams_UI (AudioEngine& eng) : ArdourDialog ("track/bus inspector"), engine (eng), - _route(0), track_menu(0) { pre_redirect_box = 0; post_redirect_box = 0; - _route = 0; - _pre_redirect = 0; - _post_redirect = 0; _input_iosel = 0; _output_iosel = 0; _active_pre_view = 0; @@ -163,7 +159,7 @@ RouteParams_UI::~RouteParams_UI () } void -RouteParams_UI::add_route (Route* route) +RouteParams_UI::add_route (boost::shared_ptr<Route> route) { ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::add_route), route)); @@ -183,22 +179,22 @@ RouteParams_UI::add_route (Route* route) void -RouteParams_UI::route_name_changed (void *src, Route *route) +RouteParams_UI::route_name_changed (void *src, boost::shared_ptr<Route> route) { ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::route_name_changed), src, route)); bool found = false ; TreeModel::Children rows = route_display_model->children(); for(TreeModel::Children::iterator iter = rows.begin(); iter != rows.end(); ++iter) { - if((*iter)[route_display_columns.route] == route) { + boost::shared_ptr<Route> r =(*iter)[route_display_columns.route]; + if (r == route) { (*iter)[route_display_columns.text] = route->name() ; found = true ; break; } } - if(!found) - { + if(!found) { error << _("route display list item for renamed route not found!") << endmsg; } @@ -217,8 +213,8 @@ RouteParams_UI::setup_redirect_boxes() cleanup_redirect_boxes(); // construct new redirect boxes - pre_redirect_box = new RedirectBox(PreFader, *session, *_route, *_plugin_selector, _rr_selection); - post_redirect_box = new RedirectBox(PostFader, *session, *_route, *_plugin_selector, _rr_selection); + pre_redirect_box = new RedirectBox(PreFader, *session, _route, *_plugin_selector, _rr_selection); + post_redirect_box = new RedirectBox(PostFader, *session, _route, *_plugin_selector, _rr_selection); pre_redir_hpane.pack1 (*pre_redirect_box); post_redir_hpane.pack1 (*post_redirect_box); @@ -256,13 +252,13 @@ RouteParams_UI::setup_io_frames() cleanup_io_frames(); // input - _input_iosel = new IOSelector (*session, *_route, true); + _input_iosel = new IOSelector (*session, _route, true); _input_iosel->redisplay (); input_frame.add (*_input_iosel); input_frame.show_all(); // output - _output_iosel = new IOSelector (*session, *_route, false); + _output_iosel = new IOSelector (*session, _route, false); _output_iosel->redisplay (); output_frame.add (*_output_iosel); output_frame.show_all(); @@ -322,36 +318,31 @@ RouteParams_UI::cleanup_post_view (bool stopupdate) void -RouteParams_UI::route_removed (Route *route) +RouteParams_UI::route_removed (boost::shared_ptr<Route> route) { ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::route_removed), route)); - /* - route_select_list.freeze (); - route_select_list.clear (); - session->foreach_route (this, &RouteParams_UI::add_route); - route_select_list.thaw (); - */ TreeModel::Children rows = route_display_model->children(); TreeModel::Children::iterator ri; for(TreeModel::Children::iterator iter = rows.begin(); iter != rows.end(); ++iter) { - if((*iter)[route_display_columns.route] == route) { + boost::shared_ptr<Route> r =(*iter)[route_display_columns.route]; + + if (r == route) { route_display_model->erase(iter); break; } } - if (route == _route) - { + if (route == _route) { cleanup_io_frames(); cleanup_pre_view(); cleanup_post_view(); cleanup_redirect_boxes(); - _route = 0; - _pre_redirect = 0; - _post_redirect = 0; + _route.reset ((Route*) 0); + _pre_redirect.reset ((Redirect*) 0); + _post_redirect.reset ((Redirect*) 0); update_title(); } } @@ -390,9 +381,9 @@ RouteParams_UI::session_gone () cleanup_post_view(); cleanup_redirect_boxes(); - _route = 0; - _pre_redirect = 0; - _post_redirect = 0; + _route.reset ((Route*) 0); + _pre_redirect.reset ((Redirect*) 0); + _post_redirect.reset ((Redirect*) 0); update_title(); ArdourDialog::session_gone(); @@ -406,7 +397,7 @@ RouteParams_UI::route_selected() TreeModel::iterator iter = selection->get_selected(); // only used with Gtk::SELECTION_SINGLE if(iter) { //If anything is selected - Route* route = (*iter)[route_display_columns.route] ; + boost::shared_ptr<Route> route = (*iter)[route_display_columns.route] ; if (_route == route) { // do nothing @@ -447,9 +438,9 @@ RouteParams_UI::route_selected() cleanup_post_view(); cleanup_redirect_boxes(); - _route = 0; - _pre_redirect = 0; - _post_redirect = 0; + _route.reset ((Route*) 0); + _pre_redirect.reset ((Redirect*) 0); + _post_redirect.reset ((Redirect *) 0); track_input_label.set_text(_("NO TRACK")); update_title(); } @@ -468,7 +459,7 @@ RouteParams_UI::route_selected() // cleanup_post_view(); // cleanup_redirect_boxes(); -// _route = 0; +// _route.reset ((Route*)0); // _pre_redirect = 0; // _post_redirect = 0; // track_input_label.set_text(_("NO TRACK")); @@ -495,8 +486,8 @@ RouteParams_UI::redirects_changed (void *src) cleanup_pre_view(); cleanup_post_view(); - _pre_redirect = 0; - _post_redirect = 0; + _pre_redirect.reset ((Redirect*) 0); + _post_redirect.reset ((Redirect*) 0); //update_title(); } @@ -520,24 +511,24 @@ RouteParams_UI::show_track_menu() void -RouteParams_UI::redirect_selected (ARDOUR::Redirect *redirect, ARDOUR::Placement place) +RouteParams_UI::redirect_selected (boost::shared_ptr<ARDOUR::Redirect> redirect, ARDOUR::Placement place) { - Insert *insert; + boost::shared_ptr<Insert> insert; if ((place == PreFader && _pre_redirect == redirect) || (place == PostFader && _post_redirect == redirect)){ return; } - if ((insert = dynamic_cast<Insert *> (redirect)) == 0) { - - Send *send; + if ((insert = boost::dynamic_pointer_cast<Insert> (redirect)) == 0) { - if ((send = dynamic_cast<Send *> (redirect)) != 0) { + boost::shared_ptr<Send> send; + + if ((send = boost::dynamic_pointer_cast<Send> (redirect)) != 0) { /* its a send */ - SendUI *send_ui = new SendUI (*send, *session); + SendUI *send_ui = new SendUI (send, *session); if (place == PreFader) { cleanup_pre_view(); @@ -560,16 +551,16 @@ RouteParams_UI::redirect_selected (ARDOUR::Redirect *redirect, ARDOUR::Placement } else { /* its an insert, though we don't know what kind yet. */ - PluginInsert *plugin_insert; - PortInsert *port_insert; + boost::shared_ptr<PluginInsert> plugin_insert; + boost::shared_ptr<PortInsert> port_insert; - if ((plugin_insert = dynamic_cast<PluginInsert *> (insert)) != 0) { + if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (insert)) != 0) { - PluginUI *plugin_ui = new PluginUI (session->engine(), *plugin_insert, true); + PluginUI *plugin_ui = new PluginUI (session->engine(), plugin_insert, true); if (place == PreFader) { cleanup_pre_view(); - _pre_plugin_conn = plugin_insert->plugin().GoingAway.connect (bind (mem_fun(*this, &RouteParams_UI::plugin_going_away), PreFader)); + _pre_plugin_conn = plugin_insert->plugin()->GoingAway.connect (bind (mem_fun(*this, &RouteParams_UI::plugin_going_away), PreFader)); plugin_ui->start_updating (0); _active_pre_view = plugin_ui; pre_redir_hpane.pack2 (*_active_pre_view); @@ -577,16 +568,16 @@ RouteParams_UI::redirect_selected (ARDOUR::Redirect *redirect, ARDOUR::Placement } else { cleanup_post_view(); - _post_plugin_conn = plugin_insert->plugin().GoingAway.connect (bind (mem_fun(*this, &RouteParams_UI::plugin_going_away), PostFader)); + _post_plugin_conn = plugin_insert->plugin()->GoingAway.connect (bind (mem_fun(*this, &RouteParams_UI::plugin_going_away), PostFader)); plugin_ui->start_updating (0); _active_post_view = plugin_ui; post_redir_hpane.pack2 (*_active_post_view); post_redir_hpane.show_all(); } - } else if ((port_insert = dynamic_cast<PortInsert *> (insert)) != 0) { + } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (insert)) != 0) { - PortInsertUI *portinsert_ui = new PortInsertUI (*session, *port_insert); + PortInsertUI *portinsert_ui = new PortInsertUI (*session, port_insert); if (place == PreFader) { cleanup_pre_view(); @@ -610,8 +601,7 @@ RouteParams_UI::redirect_selected (ARDOUR::Redirect *redirect, ARDOUR::Placement if (place == PreFader) { _pre_redirect = redirect; - } - else { + } else { _post_redirect = redirect; } @@ -620,23 +610,6 @@ RouteParams_UI::redirect_selected (ARDOUR::Redirect *redirect, ARDOUR::Placement } void -RouteParams_UI::redirect_unselected (ARDOUR::Redirect *redirect) -{ - // not called anymore - - if (redirect == _pre_redirect) { - cleanup_pre_view(); - _pre_redirect = 0; - } - else if (redirect == _post_redirect) { - cleanup_post_view(); - _post_redirect = 0; - } -} - - - -void RouteParams_UI::plugin_going_away (Plugin *plugin, Placement place) { ENSURE_GUI_THREAD(bind (mem_fun(*this, &RouteParams_UI::plugin_going_away), plugin, place)); @@ -645,11 +618,11 @@ RouteParams_UI::plugin_going_away (Plugin *plugin, Placement place) if (place == PreFader) { cleanup_pre_view (false); - _pre_redirect = 0; + _pre_redirect.reset ((Redirect*) 0); } else { cleanup_post_view (false); - _post_redirect = 0; + _post_redirect.reset ((Redirect*) 0); } } @@ -661,13 +634,13 @@ RouteParams_UI::redirect_going_away (ARDOUR::Redirect *plugin) printf ("redirect going away\n"); // delete the current view without calling finish - if (plugin == _pre_redirect) { + if (plugin == _pre_redirect.get()) { cleanup_pre_view (false); - _pre_redirect = 0; + _pre_redirect.reset ((Redirect*) 0); } - else if (plugin == _post_redirect) { + else if (plugin == _post_redirect.get()) { cleanup_post_view (false); - _post_redirect = 0; + _post_redirect.reset ((Redirect*) 0); } } diff --git a/gtk2_ardour/route_params_ui.h b/gtk2_ardour/route_params_ui.h index 29f5b9112a..5f487d6e5c 100644 --- a/gtk2_ardour/route_params_ui.h +++ b/gtk2_ardour/route_params_ui.h @@ -121,14 +121,14 @@ class RouteParams_UI : public ArdourDialog PluginSelector *_plugin_selector; RouteRedirectSelection _rr_selection; - ARDOUR::Route *_route; + boost::shared_ptr<ARDOUR::Route> _route; sigc::connection _route_conn; sigc::connection _route_ds_conn; - ARDOUR::Redirect * _pre_redirect; + boost::shared_ptr<ARDOUR::Redirect> _pre_redirect; sigc::connection _pre_plugin_conn; - ARDOUR::Redirect * _post_redirect; + boost::shared_ptr<ARDOUR::Redirect> _post_redirect; sigc::connection _post_plugin_conn; @@ -151,7 +151,7 @@ class RouteParams_UI : public ArdourDialog add(route); } Gtk::TreeModelColumn<Glib::ustring> text; - Gtk::TreeModelColumn<ARDOUR::Route*> route; + Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Route> > route; }; RouteDisplayModelColumns route_display_columns ; @@ -159,10 +159,10 @@ class RouteParams_UI : public ArdourDialog Glib::RefPtr<Gtk::ListStore> route_display_model; - void add_route (ARDOUR::Route*); + void add_route (boost::shared_ptr<ARDOUR::Route>); - void route_name_changed (void *src, ARDOUR::Route *route); - void route_removed (ARDOUR::Route *route); + void route_name_changed (void *src, boost::shared_ptr<ARDOUR::Route> route); + void route_removed (boost::shared_ptr<ARDOUR::Route> route); void route_selected(); @@ -180,8 +180,7 @@ class RouteParams_UI : public ArdourDialog void setup_redirect_boxes(); void cleanup_redirect_boxes(); - void redirect_selected (ARDOUR::Redirect *, ARDOUR::Placement); - void redirect_unselected (ARDOUR::Redirect *); + void redirect_selected (boost::shared_ptr<ARDOUR::Redirect>, ARDOUR::Placement); void plugin_going_away (ARDOUR::Plugin *foo, ARDOUR::Placement); void redirect_going_away (ARDOUR::Redirect *foo); diff --git a/gtk2_ardour/route_redirect_selection.cc b/gtk2_ardour/route_redirect_selection.cc index 6d315e0aae..76f202dd92 100644 --- a/gtk2_ardour/route_redirect_selection.cc +++ b/gtk2_ardour/route_redirect_selection.cc @@ -61,17 +61,6 @@ RouteRedirectSelection::clear () void RouteRedirectSelection::clear_redirects () { - for (RedirectSelection::iterator i = redirects.begin(); i != redirects.end(); ) { - RedirectSelection::iterator tmp; - - tmp = i; - ++tmp; - - delete *i; - - i = tmp; - } - redirects.clear (); RedirectsChanged (); } @@ -84,29 +73,32 @@ RouteRedirectSelection::clear_routes () } void -RouteRedirectSelection::add (Redirect* r) +RouteRedirectSelection::add (boost::shared_ptr<Redirect> r) { if (find (redirects.begin(), redirects.end(), r) == redirects.end()) { redirects.push_back (r); - - void (RouteRedirectSelection::*pmf)(Redirect*) = &RouteRedirectSelection::remove; - r->GoingAway.connect (mem_fun(*this, pmf)); + + // XXX SHAREDPTR FIXME + // void (RouteRedirectSelection::*pmf)(Redirect*) = &RouteRedirectSelection::remove; + // r->GoingAway.connect (mem_fun(*this, pmf)); RedirectsChanged(); } } void -RouteRedirectSelection::add (const vector<Redirect*>& rlist) +RouteRedirectSelection::add (const vector<boost::shared_ptr<Redirect> >& rlist) { bool changed = false; - for (vector<Redirect*>::const_iterator i = rlist.begin(); i != rlist.end(); ++i) { + for (vector<boost::shared_ptr<Redirect> >::const_iterator i = rlist.begin(); i != rlist.end(); ++i) { if (find (redirects.begin(), redirects.end(), *i) == redirects.end()) { redirects.push_back (*i); - void (RouteRedirectSelection::*pmf)(Redirect*) = &RouteRedirectSelection::remove; - (*i)->GoingAway.connect (mem_fun(*this, pmf)); + // XXX SHAREDPTR FIXME + + //void (RouteRedirectSelection::*pmf)(Redirect*) = &RouteRedirectSelection::remove; + // (*i)->GoingAway.connect (mem_fun(*this, pmf)); changed = true; } } @@ -117,9 +109,9 @@ RouteRedirectSelection::add (const vector<Redirect*>& rlist) } void -RouteRedirectSelection::remove (Redirect* r) +RouteRedirectSelection::remove (boost::shared_ptr<Redirect> r) { - list<Redirect*>::iterator i; + list<boost::shared_ptr<Redirect> >::iterator i; if ((i = find (redirects.begin(), redirects.end(), r)) != redirects.end()) { redirects.erase (i); RedirectsChanged (); @@ -127,36 +119,37 @@ RouteRedirectSelection::remove (Redirect* r) } void -RouteRedirectSelection::set (Redirect *r) +RouteRedirectSelection::set (boost::shared_ptr<Redirect> r) { clear_redirects (); add (r); } void -RouteRedirectSelection::set (const vector<Redirect*>& rlist) +RouteRedirectSelection::set (const vector<boost::shared_ptr<Redirect> >& rlist) { clear_redirects (); add (rlist); } void -RouteRedirectSelection::add (Route* r) +RouteRedirectSelection::add (boost::shared_ptr<Route> r) { if (find (routes.begin(), routes.end(), r) == routes.end()) { routes.push_back (r); - void (RouteRedirectSelection::*pmf)(Route*) = &RouteRedirectSelection::remove; - r->GoingAway.connect (bind (mem_fun(*this, pmf), r)); + // XXX SHAREDPTR FIXME + // void (RouteRedirectSelection::*pmf)(Route*) = &RouteRedirectSelection::remove; + // r->GoingAway.connect (bind (mem_fun(*this, pmf), r)); RoutesChanged(); } } void -RouteRedirectSelection::remove (Route* r) +RouteRedirectSelection::remove (boost::shared_ptr<Route> r) { - list<Route*>::iterator i; + list<boost::shared_ptr<Route> >::iterator i; if ((i = find (routes.begin(), routes.end(), r)) != routes.end()) { routes.erase (i); RoutesChanged (); @@ -164,16 +157,16 @@ RouteRedirectSelection::remove (Route* r) } void -RouteRedirectSelection::set (Route *r) +RouteRedirectSelection::set (boost::shared_ptr<Route> r) { clear_routes (); add (r); } bool -RouteRedirectSelection::selected (Route* ms) +RouteRedirectSelection::selected (boost::shared_ptr<Route> r) { - return find (routes.begin(), routes.end(), ms) != routes.end(); + return find (routes.begin(), routes.end(), r) != routes.end(); } bool diff --git a/gtk2_ardour/route_redirect_selection.h b/gtk2_ardour/route_redirect_selection.h index 9e2b866171..60d301e762 100644 --- a/gtk2_ardour/route_redirect_selection.h +++ b/gtk2_ardour/route_redirect_selection.h @@ -43,20 +43,20 @@ class RouteRedirectSelection : public sigc::trackable void clear (); bool empty(); - void set (ARDOUR::Redirect*); - void set (const std::vector<ARDOUR::Redirect*>&); - void add (ARDOUR::Redirect*); - void add (const std::vector<ARDOUR::Redirect*>&); - void remove (ARDOUR::Redirect*); + void set (boost::shared_ptr<ARDOUR::Redirect>); + void set (const std::vector<boost::shared_ptr<ARDOUR::Redirect> >&); + void add (boost::shared_ptr<ARDOUR::Redirect>); + void add (const std::vector<boost::shared_ptr<ARDOUR::Redirect> >&); + void remove (boost::shared_ptr<ARDOUR::Redirect>); - void set (ARDOUR::Route*); - void add (ARDOUR::Route*); - void remove (ARDOUR::Route*); + void set (boost::shared_ptr<ARDOUR::Route>); + void add (boost::shared_ptr<ARDOUR::Route>); + void remove (boost::shared_ptr<ARDOUR::Route>); void clear_redirects (); void clear_routes (); - bool selected (ARDOUR::Route*); + bool selected (boost::shared_ptr<ARDOUR::Route>); }; bool operator==(const RouteRedirectSelection& a, const RouteRedirectSelection& b); diff --git a/gtk2_ardour/route_selection.h b/gtk2_ardour/route_selection.h index 50797deed3..8d5673a2ef 100644 --- a/gtk2_ardour/route_selection.h +++ b/gtk2_ardour/route_selection.h @@ -1,12 +1,14 @@ #ifndef __ardour_gtk_route_selection_h__ #define __ardour_gtk_route_selection_h__ + +#include <boost/shared_ptr.hpp> #include <list> namespace ARDOUR { class Route; } -struct RouteSelection : list<ARDOUR::Route*> {}; +struct RouteSelection : std::list<boost::shared_ptr<ARDOUR::Route> > {}; #endif /* __ardour_gtk_route_selection_h__ */ diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc index a02814839a..eb20eeac08 100644 --- a/gtk2_ardour/route_ui.cc +++ b/gtk2_ardour/route_ui.cc @@ -44,9 +44,9 @@ using namespace ARDOUR; using namespace PBD; -RouteUI::RouteUI (ARDOUR::Route& rt, ARDOUR::Session& sess, const char* m_name, +RouteUI::RouteUI (boost::shared_ptr<ARDOUR::Route> rt, ARDOUR::Session& sess, const char* m_name, const char* s_name, const char* r_name) - : AxisView(sess), + : AxisView(sess), _route(rt), mute_button(0), solo_button(0), @@ -64,16 +64,16 @@ RouteUI::RouteUI (ARDOUR::Route& rt, ARDOUR::Session& sess, const char* m_name, set_color (unique_random_color()); } - _route.GoingAway.connect (mem_fun (*this, &RouteUI::route_removed)); - _route.active_changed.connect (mem_fun (*this, &RouteUI::route_active_changed)); + _route->GoingAway.connect (mem_fun (*this, &RouteUI::route_removed)); + _route->active_changed.connect (mem_fun (*this, &RouteUI::route_active_changed)); - mute_button = manage (new BindableToggleButton (_route.mute_control(), m_name )); - solo_button = manage (new BindableToggleButton (_route.solo_control(), s_name )); + mute_button = manage (new BindableToggleButton (_route->mute_control(), m_name )); + solo_button = manage (new BindableToggleButton (_route->solo_control(), s_name )); if (is_audio_track()) { - AudioTrack* at = dynamic_cast<AudioTrack*>(&_route); + boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack>(_route); - get_diskstream()->record_enable_changed.connect (mem_fun (*this, &RouteUI::route_rec_enable_changed)); + at->disk_stream().record_enable_changed.connect (mem_fun (*this, &RouteUI::route_rec_enable_changed)); _session.RecordStateChanged.connect (mem_fun (*this, &RouteUI::session_rec_enable_changed)); @@ -129,7 +129,7 @@ RouteUI::mute_press(GdkEventButton* ev) _session.begin_reversible_command (_("mute change")); _session.add_undo (_session.global_mute_memento(this)); - _session.set_all_mute (!_route.muted()); + _session.set_all_mute (!_route->muted()); _session.add_redo_no_execute (_session.global_mute_memento(this)); _session.commit_reversible_command (); @@ -140,14 +140,14 @@ RouteUI::mute_press(GdkEventButton* ev) */ if (ev->button == 1) { - set_mix_group_mute (_route, !_route.muted()); + set_mix_group_mute (_route, !_route->muted()); } } else { /* plain click applies change to this route */ - reversibly_apply_route_boolean ("mute change", &Route::set_mute, !_route.muted(), this); + reversibly_apply_route_boolean ("mute change", &Route::set_mute, !_route->muted(), this); } } } @@ -204,7 +204,7 @@ RouteUI::solo_press(GdkEventButton* ev) _session.begin_reversible_command (_("solo change")); _session.add_undo (_session.global_solo_memento(this)); - _session.set_all_solo (!_route.soloed()); + _session.set_all_solo (!_route->soloed()); _session.add_redo_no_execute (_session.global_solo_memento(this)); _session.commit_reversible_command (); @@ -215,7 +215,7 @@ RouteUI::solo_press(GdkEventButton* ev) _session.begin_reversible_command (_("solo change")); _session.add_undo (_session.global_solo_memento(this)); _session.set_all_solo (false); - _route.set_solo (true, this); + _route->set_solo (true, this); _session.add_redo_no_execute (_session.global_solo_memento(this)); _session.commit_reversible_command (); @@ -223,7 +223,7 @@ RouteUI::solo_press(GdkEventButton* ev) // shift-click: set this route to solo safe - _route.set_solo_safe (!_route.solo_safe(), this); + _route->set_solo_safe (!_route->solo_safe(), this); wait_for_release = false; } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::Control)) { @@ -233,14 +233,14 @@ RouteUI::solo_press(GdkEventButton* ev) */ if (ev->button == 1) { - set_mix_group_solo (_route, !_route.soloed()); + set_mix_group_solo (_route, !_route->soloed()); } } else { /* click: solo this route */ - reversibly_apply_route_boolean ("solo change", &Route::set_solo, !_route.soloed(), this); + reversibly_apply_route_boolean ("solo change", &Route::set_solo, !_route->soloed(), this); } } } @@ -289,7 +289,7 @@ RouteUI::rec_enable_press(GdkEventButton* ev) } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::Control)) { - set_mix_group_rec_enable (_route, !_route.record_enabled()); + set_mix_group_rec_enable (_route, !_route->record_enabled()); } else { @@ -317,7 +317,7 @@ RouteUI::update_solo_display () { bool x; - if (solo_button->get_active() != (x = _route.soloed())){ + if (solo_button->get_active() != (x = _route->soloed())){ ignore_toggle = true; solo_button->set_active(x); ignore_toggle = false; @@ -325,7 +325,7 @@ RouteUI::update_solo_display () /* show solo safe */ - if (_route.solo_safe()){ + if (_route->solo_safe()){ solo_button->set_name(safe_solo_button_name()); } else { solo_button->set_name(solo_button_name()); @@ -343,7 +343,7 @@ RouteUI::update_mute_display () { bool x; - if (mute_button->get_active() != (x = _route.muted())){ + if (mute_button->get_active() != (x = _route->muted())){ ignore_toggle = true; mute_button->set_active(x); ignore_toggle = false; @@ -365,7 +365,7 @@ RouteUI::session_rec_enable_changed () void RouteUI::update_rec_display () { - bool model = _route.record_enabled(); + bool model = _route->record_enabled(); bool view = rec_enable_button->get_active(); /* first make sure the button's "depressed" visual @@ -431,7 +431,7 @@ RouteUI::refresh_remote_control_menu () limit += 4; /* leave some breathing room */ rc_items.push_back (RadioMenuElem (rc_group, _("None"))); - if (_route.remote_control_id() == 0) { + if (_route->remote_control_id() == 0) { rc_active = dynamic_cast<CheckMenuItem*> (&rc_items.back()); rc_active->set_active (); } @@ -440,7 +440,7 @@ RouteUI::refresh_remote_control_menu () snprintf (buf, sizeof (buf), "%u", i); rc_items.push_back (RadioMenuElem (rc_group, buf)); rc_active = dynamic_cast<RadioMenuItem*>(&rc_items.back()); - if (_route.remote_control_id() == i) { + if (_route->remote_control_id() == i) { rc_active = dynamic_cast<CheckMenuItem*> (&rc_items.back()); rc_active->set_active (); } @@ -458,7 +458,7 @@ RouteUI::set_remote_control_id (uint32_t id, CheckMenuItem* item) */ if (item->get_active()) { - _route.set_remote_control_id (id); + _route->set_remote_control_id (id); } } @@ -473,9 +473,9 @@ RouteUI::build_solo_menu (void) CheckMenuItem* check; check = new CheckMenuItem(_("Solo-safe")); - check->set_active (_route.solo_safe()); + check->set_active (_route->solo_safe()); check->signal_toggled().connect (bind (mem_fun (*this, &RouteUI::toggle_solo_safe), check)); - _route.solo_safe_changed.connect(bind (mem_fun (*this, &RouteUI::solo_safe_toggle), check)); + _route->solo_safe_changed.connect(bind (mem_fun (*this, &RouteUI::solo_safe_toggle), check)); items.push_back (CheckMenuElem(*check)); check->show_all(); @@ -497,28 +497,28 @@ RouteUI::build_mute_menu(void) check = new CheckMenuItem(_("Pre Fader")); init_mute_menu(PRE_FADER, check); check->signal_toggled().connect(bind (mem_fun (*this, &RouteUI::toggle_mute_menu), PRE_FADER, check)); - _route.pre_fader_changed.connect(bind (mem_fun (*this, &RouteUI::pre_fader_toggle), check)); + _route->pre_fader_changed.connect(bind (mem_fun (*this, &RouteUI::pre_fader_toggle), check)); items.push_back (CheckMenuElem(*check)); check->show_all(); check = new CheckMenuItem(_("Post Fader")); init_mute_menu(POST_FADER, check); check->signal_toggled().connect(bind (mem_fun (*this, &RouteUI::toggle_mute_menu), POST_FADER, check)); - _route.post_fader_changed.connect(bind (mem_fun (*this, &RouteUI::post_fader_toggle), check)); + _route->post_fader_changed.connect(bind (mem_fun (*this, &RouteUI::post_fader_toggle), check)); items.push_back (CheckMenuElem(*check)); check->show_all(); check = new CheckMenuItem(_("Control Outs")); init_mute_menu(CONTROL_OUTS, check); check->signal_toggled().connect(bind (mem_fun (*this, &RouteUI::toggle_mute_menu), CONTROL_OUTS, check)); - _route.control_outs_changed.connect(bind (mem_fun (*this, &RouteUI::control_outs_toggle), check)); + _route->control_outs_changed.connect(bind (mem_fun (*this, &RouteUI::control_outs_toggle), check)); items.push_back (CheckMenuElem(*check)); check->show_all(); check = new CheckMenuItem(_("Main Outs")); init_mute_menu(MAIN_OUTS, check); check->signal_toggled().connect(bind (mem_fun (*this, &RouteUI::toggle_mute_menu), MAIN_OUTS, check)); - _route.main_outs_changed.connect(bind (mem_fun (*this, &RouteUI::main_outs_toggle), check)); + _route->main_outs_changed.connect(bind (mem_fun (*this, &RouteUI::main_outs_toggle), check)); items.push_back (CheckMenuElem(*check)); check->show_all(); @@ -529,7 +529,7 @@ RouteUI::build_mute_menu(void) void RouteUI::init_mute_menu(mute_type type, CheckMenuItem* check) { - if (_route.get_mute_config (type)) { + if (_route->get_mute_config (type)) { check->set_active (true); } } @@ -537,28 +537,28 @@ RouteUI::init_mute_menu(mute_type type, CheckMenuItem* check) void RouteUI::toggle_mute_menu(mute_type type, Gtk::CheckMenuItem* check) { - _route.set_mute_config(type, check->get_active(), this); + _route->set_mute_config(type, check->get_active(), this); } void RouteUI::toggle_solo_safe (Gtk::CheckMenuItem* check) { - _route.set_solo_safe (check->get_active(), this); + _route->set_solo_safe (check->get_active(), this); } void -RouteUI::set_mix_group_solo(Route& route, bool yn) +RouteUI::set_mix_group_solo(boost::shared_ptr<Route> route, bool yn) { RouteGroup* mix_group; - if((mix_group = route.mix_group()) != 0){ + if((mix_group = route->mix_group()) != 0){ _session.begin_reversible_command (_("mix group solo change")); _session.add_undo (_session.global_solo_memento (this)); mix_group->apply(&Route::set_solo, yn, this); _session.add_redo_no_execute (_session.global_solo_memento(this)); _session.commit_reversible_command (); } else { - reversibly_apply_route_boolean ("solo change", &Route::set_solo, !route.soloed(), this); + reversibly_apply_route_boolean ("solo change", &Route::set_solo, !route->soloed(), this); } } @@ -566,8 +566,8 @@ void RouteUI::reversibly_apply_route_boolean (string name, void (Route::*func)(bool, void *), bool yn, void *arg) { _session.begin_reversible_command (name); - _session.add_undo (bind (mem_fun (_route, func), !yn, (void *) arg)); - _session.add_redo (bind (mem_fun (_route, func), yn, (void *) arg)); + _session.add_undo (bind (mem_fun (*_route, func), !yn, (void *) arg)); + _session.add_redo (bind (mem_fun (*_route, func), yn, (void *) arg)); _session.commit_reversible_command (); } @@ -581,34 +581,34 @@ RouteUI::reversibly_apply_audio_track_boolean (string name, void (AudioTrack::*f } void -RouteUI::set_mix_group_mute(Route& route, bool yn) +RouteUI::set_mix_group_mute(boost::shared_ptr<Route> route, bool yn) { RouteGroup* mix_group; - if((mix_group = route.mix_group()) != 0){ + if((mix_group = route->mix_group()) != 0){ _session.begin_reversible_command (_("mix group mute change")); _session.add_undo (_session.global_mute_memento (this)); mix_group->apply(&Route::set_mute, yn, this); _session.add_redo_no_execute (_session.global_mute_memento(this)); _session.commit_reversible_command (); } else { - reversibly_apply_route_boolean ("mute change", &Route::set_mute, !route.muted(), this); + reversibly_apply_route_boolean ("mute change", &Route::set_mute, !route->muted(), this); } } void -RouteUI::set_mix_group_rec_enable(Route& route, bool yn) +RouteUI::set_mix_group_rec_enable(boost::shared_ptr<Route> route, bool yn) { RouteGroup* mix_group; - if((mix_group = route.mix_group()) != 0){ + if((mix_group = route->mix_group()) != 0){ _session.begin_reversible_command (_("mix group rec-enable change")); _session.add_undo (_session.global_record_enable_memento (this)); mix_group->apply (&Route::set_record_enable, yn, this); _session.add_redo_no_execute (_session.global_record_enable_memento(this)); _session.commit_reversible_command (); } else { - reversibly_apply_route_boolean ("rec-enable change", &Route::set_record_enable, !_route.record_enabled(), this); + reversibly_apply_route_boolean ("rec-enable change", &Route::set_record_enable, !_route->record_enabled(), this); } } @@ -639,7 +639,7 @@ RouteUI::set_color (const Gdk::Color & c) snprintf (buf, sizeof (buf), "%d:%d:%d", c.get_red(), c.get_green(), c.get_blue()); xml_node->add_property ("color", buf); - _route.gui_changed ("color", (void *) 0); /* EMIT_SIGNAL */ + _route->gui_changed ("color", (void *) 0); /* EMIT_SIGNAL */ } @@ -647,9 +647,9 @@ void RouteUI::ensure_xml_node () { if (xml_node == 0) { - if ((xml_node = _route.extra_xml ("GUI")) == 0) { + if ((xml_node = _route->extra_xml ("GUI")) == 0) { xml_node = new XMLNode ("GUI"); - _route.add_extra_xml (*xml_node); + _route->add_extra_xml (*xml_node); } } } @@ -695,9 +695,9 @@ RouteUI::remove_this_route () string prompt; if (is_audio_track()) { - prompt = string_compose (_("Do you really want to remove track \"%1\" ?\n\nYou may also lose the playlist used by this track.\n(cannot be undone)"), _route.name()); + prompt = string_compose (_("Do you really want to remove track \"%1\" ?\n\nYou may also lose the playlist used by this track.\n(cannot be undone)"), _route->name()); } else { - prompt = string_compose (_("Do you really want to remove bus \"%1\" ?\n(cannot be undone)"), _route.name()); + prompt = string_compose (_("Do you really want to remove bus \"%1\" ?\n(cannot be undone)"), _route->name()); } choices.push_back (_("No, do nothing.")); @@ -731,7 +731,7 @@ RouteUI::route_rename () ArdourPrompter name_prompter (true); string result; name_prompter.set_prompt (_("New Name: ")); - name_prompter.set_initial_text (_route.name()); + name_prompter.set_initial_text (_route->name()); name_prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT); name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false); name_prompter.show_all (); @@ -741,7 +741,7 @@ RouteUI::route_rename () case Gtk::RESPONSE_ACCEPT: name_prompter.get_result (result); if (result.length()) { - _route.set_name (result, this); + _route->set_name (result, this); } break; } @@ -755,7 +755,7 @@ RouteUI::name_changed (void *src) { ENSURE_GUI_THREAD(bind (mem_fun (*this, &RouteUI::name_changed), src)); - name_label.set_text (_route.name()); + name_label.set_text (_route->name()); } void @@ -764,8 +764,8 @@ RouteUI::toggle_route_active () bool yn; if (route_active_menu_item) { - if (route_active_menu_item->get_active() != (yn = _route.active())) { - _route.set_active (!yn); + if (route_active_menu_item->get_active() != (yn = _route->active())) { + _route->set_active (!yn); } } } @@ -774,7 +774,7 @@ void RouteUI::route_active_changed () { if (route_active_menu_item) { - Gtkmm2ext::UI::instance()->call_slot (bind (mem_fun (*route_active_menu_item, &CheckMenuItem::set_active), _route.active())); + Gtkmm2ext::UI::instance()->call_slot (bind (mem_fun (*route_active_menu_item, &CheckMenuItem::set_active), _route->active())); } } @@ -787,12 +787,12 @@ RouteUI::toggle_polarity () ENSURE_GUI_THREAD(mem_fun (*this, &RouteUI::toggle_polarity)); - if ((x = polarity_menu_item->get_active()) != _route.phase_invert()) { - _route.set_phase_invert (x, this); + if ((x = polarity_menu_item->get_active()) != _route->phase_invert()) { + _route->set_phase_invert (x, this); if (x) { name_label.set_text (X_("Ø ") + name_label.get_text()); } else { - name_label.set_text (_route.name()); + name_label.set_text (_route->name()); } } } @@ -807,7 +807,7 @@ RouteUI::polarity_changed () void RouteUI::solo_safe_toggle(void* src, Gtk::CheckMenuItem* check) { - bool yn = _route.solo_safe (); + bool yn = _route->solo_safe (); if (check->get_active() != yn) { check->set_active (yn); @@ -818,7 +818,7 @@ RouteUI::pre_fader_toggle(void* src, Gtk::CheckMenuItem* check) { ENSURE_GUI_THREAD(bind (mem_fun (*this, &RouteUI::pre_fader_toggle), src, check)); - bool yn = _route.get_mute_config(PRE_FADER); + bool yn = _route->get_mute_config(PRE_FADER); if (check->get_active() != yn) { check->set_active (yn); } @@ -829,7 +829,7 @@ RouteUI::post_fader_toggle(void* src, Gtk::CheckMenuItem* check) { ENSURE_GUI_THREAD(bind (mem_fun (*this, &RouteUI::post_fader_toggle), src, check)); - bool yn = _route.get_mute_config(POST_FADER); + bool yn = _route->get_mute_config(POST_FADER); if (check->get_active() != yn) { check->set_active (yn); } @@ -840,7 +840,7 @@ RouteUI::control_outs_toggle(void* src, Gtk::CheckMenuItem* check) { ENSURE_GUI_THREAD(bind (mem_fun (*this, &RouteUI::control_outs_toggle), src, check)); - bool yn = _route.get_mute_config(CONTROL_OUTS); + bool yn = _route->get_mute_config(CONTROL_OUTS); if (check->get_active() != yn) { check->set_active (yn); } @@ -851,7 +851,7 @@ RouteUI::main_outs_toggle(void* src, Gtk::CheckMenuItem* check) { ENSURE_GUI_THREAD(bind (mem_fun (*this, &RouteUI::main_outs_toggle), src, check)); - bool yn = _route.get_mute_config(MAIN_OUTS); + bool yn = _route->get_mute_config(MAIN_OUTS); if (check->get_active() != yn) { check->set_active (yn); } @@ -860,27 +860,27 @@ RouteUI::main_outs_toggle(void* src, Gtk::CheckMenuItem* check) void RouteUI::disconnect_input () { - _route.disconnect_inputs (this); + _route->disconnect_inputs (this); } void RouteUI::disconnect_output () { - _route.disconnect_outputs (this); + _route->disconnect_outputs (this); } bool RouteUI::is_audio_track () const { - return dynamic_cast<AudioTrack*>(&_route) != 0; + return dynamic_cast<AudioTrack*>(_route.get()) != 0; } AudioDiskstream* RouteUI::get_diskstream () const { - AudioTrack *at; + boost::shared_ptr<AudioTrack> at; - if ((at = dynamic_cast<AudioTrack*>(&_route)) != 0) { + if ((at = boost::dynamic_pointer_cast<AudioTrack>(_route)) != 0) { return &at->disk_stream(); } else { return 0; @@ -890,12 +890,13 @@ RouteUI::get_diskstream () const AudioTrack* RouteUI::audio_track() const { - return dynamic_cast<AudioTrack*>(&_route); + return dynamic_cast<AudioTrack*>(_route.get()); } + string RouteUI::name() const { - return _route.name(); + return _route->name(); } void @@ -903,7 +904,7 @@ RouteUI::map_frozen () { ENSURE_GUI_THREAD (mem_fun (*this, &RouteUI::map_frozen)); - AudioTrack* at = dynamic_cast<AudioTrack*>(&_route); + AudioTrack* at = dynamic_cast<AudioTrack*>(_route.get()); if (at) { switch (at->freeze_state()) { diff --git a/gtk2_ardour/route_ui.h b/gtk2_ardour/route_ui.h index df2e3aa319..48f7d47b97 100644 --- a/gtk2_ardour/route_ui.h +++ b/gtk2_ardour/route_ui.h @@ -44,18 +44,20 @@ class BindableToggleButton; class RouteUI : public virtual AxisView { public: - RouteUI(ARDOUR::Route&, ARDOUR::Session&, const char*, const char*, const char*); + RouteUI(boost::shared_ptr<ARDOUR::Route>, ARDOUR::Session&, const char*, const char*, const char*); virtual ~RouteUI(); bool is_audio_track() const; ARDOUR::AudioDiskstream* get_diskstream() const; - ARDOUR::Route& route() const { return _route; } + boost::shared_ptr<ARDOUR::Route> route() const { return _route; } ARDOUR::AudioTrack* audio_track() const; string name() const; - - ARDOUR::Route& _route; + + // protected: XXX sigh this should be here + + boost::shared_ptr<ARDOUR::Route> _route; void set_color (const Gdk::Color & c); bool choose_color (); @@ -106,9 +108,9 @@ class RouteUI : public virtual AxisView void build_mute_menu(void); void init_mute_menu(ARDOUR::mute_type, Gtk::CheckMenuItem*); - void set_mix_group_solo(ARDOUR::Route&, bool); - void set_mix_group_mute(ARDOUR::Route&, bool); - void set_mix_group_rec_enable(ARDOUR::Route&, bool); + void set_mix_group_solo(boost::shared_ptr<ARDOUR::Route>, bool); + void set_mix_group_mute(boost::shared_ptr<ARDOUR::Route>, bool); + void set_mix_group_rec_enable(boost::shared_ptr<ARDOUR::Route>, bool); int set_color_from_route (); diff --git a/gtk2_ardour/selection.cc b/gtk2_ardour/selection.cc index 2e4ed8a117..6dae5b0bcd 100644 --- a/gtk2_ardour/selection.cc +++ b/gtk2_ardour/selection.cc @@ -151,7 +151,7 @@ Selection::clear_lines () } void -Selection::toggle (Redirect* r) +Selection::toggle (boost::shared_ptr<Redirect> r) { RedirectSelection::iterator i; @@ -243,7 +243,7 @@ Selection::toggle (jack_nframes_t start, jack_nframes_t end) void -Selection::add (Redirect* r) +Selection::add (boost::shared_ptr<Redirect> r) { if (find (redirects.begin(), redirects.end(), r) == redirects.end()) { redirects.push_back (r); @@ -381,9 +381,9 @@ Selection::add (AutomationList* ac) } void -Selection::remove (Redirect* r) +Selection::remove (boost::shared_ptr<Redirect> r) { - list<Redirect*>::iterator i; + RedirectSelection::iterator i; if ((i = find (redirects.begin(), redirects.end(), r)) != redirects.end()) { redirects.erase (i); RedirectsChanged (); @@ -491,7 +491,7 @@ Selection::remove (AutomationList *ac) } void -Selection::set (Redirect *r) +Selection::set (boost::shared_ptr<Redirect> r) { clear_redirects (); add (r); diff --git a/gtk2_ardour/selection.h b/gtk2_ardour/selection.h index ebeda1aea7..102e6e9410 100644 --- a/gtk2_ardour/selection.h +++ b/gtk2_ardour/selection.h @@ -22,6 +22,7 @@ #define __ardour_gtk_selection_h__ #include <vector> +#include <boost/shared_ptr.hpp> #include <sigc++/signal.h> @@ -101,7 +102,7 @@ class Selection : public sigc::trackable void set (ARDOUR::AutomationList*); void set (ARDOUR::Playlist*); void set (const list<ARDOUR::Playlist*>&); - void set (ARDOUR::Redirect*); + void set (boost::shared_ptr<ARDOUR::Redirect>); void set (AutomationSelectable*); void toggle (TimeAxisView*); @@ -112,7 +113,7 @@ class Selection : public sigc::trackable void toggle (ARDOUR::AutomationList*); void toggle (ARDOUR::Playlist*); void toggle (const list<ARDOUR::Playlist*>&); - void toggle (ARDOUR::Redirect*); + void toggle (boost::shared_ptr<ARDOUR::Redirect>); void add (TimeAxisView*); void add (const list<TimeAxisView*>&); @@ -122,7 +123,7 @@ class Selection : public sigc::trackable void add (ARDOUR::AutomationList*); void add (ARDOUR::Playlist*); void add (const list<ARDOUR::Playlist*>&); - void add (ARDOUR::Redirect*); + void add (boost::shared_ptr<ARDOUR::Redirect>); void remove (TimeAxisView*); void remove (const list<TimeAxisView*>&); @@ -132,7 +133,7 @@ class Selection : public sigc::trackable void remove (ARDOUR::AutomationList*); void remove (ARDOUR::Playlist*); void remove (const list<ARDOUR::Playlist*>&); - void remove (ARDOUR::Redirect*); + void remove (boost::shared_ptr<ARDOUR::Redirect>); void replace (uint32_t time_index, jack_nframes_t start, jack_nframes_t end); diff --git a/gtk2_ardour/send_ui.cc b/gtk2_ardour/send_ui.cc index be95f753e7..9925ff51d4 100644 --- a/gtk2_ardour/send_ui.cc +++ b/gtk2_ardour/send_ui.cc @@ -30,7 +30,7 @@ using namespace ARDOUR; using namespace PBD; -SendUI::SendUI (Send& s, Session& se) +SendUI::SendUI (boost::shared_ptr<Send> s, Session& se) : _send (s), _session (se), gpm (s, se), @@ -53,10 +53,10 @@ SendUI::SendUI (Send& s, Session& se) show_all (); - _send.set_metering (true); + _send->set_metering (true); - _send.output_changed.connect (mem_fun (*this, &SendUI::ins_changed)); - _send.output_changed.connect (mem_fun (*this, &SendUI::outs_changed)); + _send->output_changed.connect (mem_fun (*this, &SendUI::ins_changed)); + _send->output_changed.connect (mem_fun (*this, &SendUI::outs_changed)); panners.set_width (Wide); panners.setup_pan (); @@ -70,7 +70,7 @@ SendUI::SendUI (Send& s, Session& se) SendUI::~SendUI () { - _send.set_metering (false); + _send->set_metering (false); /* XXX not clear that we need to do this */ @@ -118,7 +118,7 @@ SendUI::fast_update () } } -SendUIWindow::SendUIWindow (Send& s, Session& ss) +SendUIWindow::SendUIWindow (boost::shared_ptr<Send> s, Session& ss) { ui = new SendUI (s, ss); @@ -131,7 +131,7 @@ SendUIWindow::SendUIWindow (Send& s, Session& ss) add (vpacker); set_name ("SendUIWindow"); - s.GoingAway.connect (mem_fun (*this, &SendUIWindow::send_going_away)); + s->GoingAway.connect (mem_fun (*this, &SendUIWindow::send_going_away)); signal_delete_event().connect (bind (ptr_fun (just_hide_it), reinterpret_cast<Window *> (this))); diff --git a/gtk2_ardour/send_ui.h b/gtk2_ardour/send_ui.h index d1a49930ea..1d5a74e102 100644 --- a/gtk2_ardour/send_ui.h +++ b/gtk2_ardour/send_ui.h @@ -35,7 +35,7 @@ class IOSelector; class SendUI : public Gtk::HBox { public: - SendUI (ARDOUR::Send&, ARDOUR::Session&); + SendUI (boost::shared_ptr<ARDOUR::Send>, ARDOUR::Session&); ~SendUI(); void update (); @@ -44,7 +44,7 @@ class SendUI : public Gtk::HBox IOSelector* io; private: - ARDOUR::Send& _send; + boost::shared_ptr<ARDOUR::Send> _send; ARDOUR::Session& _session; GainMeter gpm; PannerUI panners; @@ -62,7 +62,7 @@ class SendUI : public Gtk::HBox class SendUIWindow : public Gtk::Window { public: - SendUIWindow(ARDOUR::Send&, ARDOUR::Session&); + SendUIWindow(boost::shared_ptr<ARDOUR::Send>, ARDOUR::Session&); ~SendUIWindow(); SendUI* ui; diff --git a/gtk2_ardour/sfdb_ui.cc b/gtk2_ardour/sfdb_ui.cc index 5cca008dc0..4948525b15 100644 --- a/gtk2_ardour/sfdb_ui.cc +++ b/gtk2_ardour/sfdb_ui.cc @@ -404,6 +404,9 @@ SoundFileOmega::set_mode (Editing::ImportMode mode) case Editing::ImportToTrack: split_check.set_sensitive (false); break; + case Editing::ImportAsTapeTrack: + split_check.set_sensitive (true); + break; } } @@ -443,5 +446,8 @@ SoundFileOmega::mode_changed () case Editing::ImportToTrack: split_check.set_sensitive (false); break; + case Editing::ImportAsTapeTrack: + split_check.set_sensitive (true); + break; } } diff --git a/libs/ardour/ardour/audio_track.h b/libs/ardour/ardour/audio_track.h index 6cfb3ff3e3..5f65e2591d 100644 --- a/libs/ardour/ardour/audio_track.h +++ b/libs/ardour/ardour/audio_track.h @@ -110,11 +110,11 @@ class AudioTrack : public Route private: struct FreezeRecordInsertInfo { - FreezeRecordInsertInfo(XMLNode& st) - : state (st), insert (0) {} + FreezeRecordInsertInfo(XMLNode& st, boost::shared_ptr<Insert> ins) + : state (st), insert (ins) {} XMLNode state; - Insert* insert; + boost::shared_ptr<Insert> insert; PBD::ID id; UndoAction memento; }; diff --git a/libs/ardour/ardour/audiofilesource.h b/libs/ardour/ardour/audiofilesource.h index eca2a3a0bc..eb3fd750d4 100644 --- a/libs/ardour/ardour/audiofilesource.h +++ b/libs/ardour/ardour/audiofilesource.h @@ -42,7 +42,8 @@ class AudioFileSource : public AudioSource { Removable = 0x8, RemovableIfEmpty = 0x10, RemoveAtDestroy = 0x20, - NoPeakFile = 0x40 + NoPeakFile = 0x40, + Destructive = 0x80 }; virtual ~AudioFileSource (); diff --git a/libs/ardour/ardour/destructive_filesource.h b/libs/ardour/ardour/destructive_filesource.h index 947367f754..5b773898c3 100644 --- a/libs/ardour/ardour/destructive_filesource.h +++ b/libs/ardour/ardour/destructive_filesource.h @@ -34,6 +34,8 @@ class DestructiveFileSource : public SndFileSource { DestructiveFileSource (std::string path, SampleFormat samp_format, HeaderFormat hdr_format, jack_nframes_t rate, Flag flags = AudioFileSource::Flag (AudioFileSource::Writable)); + DestructiveFileSource (std::string path, Flag flags); + DestructiveFileSource (const XMLNode&); ~DestructiveFileSource (); @@ -62,6 +64,7 @@ class DestructiveFileSource : public SndFileSource { jack_nframes_t file_pos; // unit is frames Sample* xfade_buf; + void init (); jack_nframes_t crossfade (Sample* data, jack_nframes_t cnt, int dir, char * workbuf); void set_timeline_position (jack_nframes_t); }; diff --git a/libs/ardour/ardour/insert.h b/libs/ardour/ardour/insert.h index c8ae6d46b0..a4c4439942 100644 --- a/libs/ardour/ardour/insert.h +++ b/libs/ardour/ardour/insert.h @@ -98,7 +98,7 @@ struct PluginInsertState : public RedirectState class PluginInsert : public Insert { public: - PluginInsert (Session&, Plugin&, Placement); + PluginInsert (Session&, boost::shared_ptr<Plugin>, Placement); PluginInsert (Session&, const XMLNode&); PluginInsert (const PluginInsert&); ~PluginInsert (); @@ -141,11 +141,11 @@ class PluginInsert : public Insert float default_parameter_value (uint32_t which); - Plugin& plugin(uint32_t num=0) const { + boost::shared_ptr<Plugin> plugin(uint32_t num=0) const { if (num < _plugins.size()) { - return *_plugins[num]; + return _plugins[num]; } else { - return *_plugins[0]; // we always have one + return _plugins[0]; // we always have one } } @@ -163,7 +163,7 @@ class PluginInsert : public Insert void parameter_changed (uint32_t, float); - vector<Plugin*> _plugins; + vector<boost::shared_ptr<Plugin> > _plugins; void automation_run (vector<Sample *>& bufs, uint32_t nbufs, jack_nframes_t nframes, jack_nframes_t offset); void connect_and_run (vector<Sample *>& bufs, uint32_t nbufs, jack_nframes_t nframes, jack_nframes_t offset, bool with_auto, jack_nframes_t now = 0); @@ -172,7 +172,7 @@ class PluginInsert : public Insert void auto_state_changed (uint32_t which); void automation_list_creation_callback (uint32_t, AutomationList&); - Plugin* plugin_factory (Plugin&); + boost::shared_ptr<Plugin> plugin_factory (boost::shared_ptr<Plugin>); }; } // namespace ARDOUR diff --git a/libs/ardour/ardour/plugin.h b/libs/ardour/ardour/plugin.h index e7d05aa352..97708065e4 100644 --- a/libs/ardour/ardour/plugin.h +++ b/libs/ardour/ardour/plugin.h @@ -21,6 +21,7 @@ #ifndef __ardour_ladspa_h__ #define __ardour_ladspa_h__ +#include <boost/shared_ptr.hpp> #include <sigc++/signal.h> #include <pbd/stateful.h> @@ -179,7 +180,7 @@ class Plugin : public Stateful, public sigc::trackable /* this is actually defined in plugin_manager.cc */ -Plugin * find_plugin(ARDOUR::Session&, string name, long unique_id, PluginInfo::Type); +boost::shared_ptr<Plugin> find_plugin(ARDOUR::Session&, string name, long unique_id, PluginInfo::Type); } // namespace ARDOUR diff --git a/libs/ardour/ardour/plugin_manager.h b/libs/ardour/ardour/plugin_manager.h index 1a07c67c8d..cc9a04738e 100644 --- a/libs/ardour/ardour/plugin_manager.h +++ b/libs/ardour/ardour/plugin_manager.h @@ -5,6 +5,8 @@ #include <map> #include <string> +#include <boost/shared_ptr.hpp> + #include <ardour/types.h> namespace ARDOUR { @@ -26,7 +28,7 @@ class PluginManager { int add_ladspa_directory (std::string dirpath); int add_vst_directory (std::string dirpath); - Plugin *load (ARDOUR::Session& s, PluginInfo* info); + boost::shared_ptr<Plugin> load (ARDOUR::Session& s, PluginInfo* info); static PluginManager* the_manager() { return _manager; } diff --git a/libs/ardour/ardour/redirect.h b/libs/ardour/ardour/redirect.h index 8b08a41ce3..658cab5d3b 100644 --- a/libs/ardour/ardour/redirect.h +++ b/libs/ardour/ardour/redirect.h @@ -25,6 +25,7 @@ #include <vector> #include <set> #include <map> +#include <boost/shared_ptr.hpp> #include <sigc++/signal.h> #include <glibmm/thread.h> @@ -64,7 +65,7 @@ class Redirect : public IO Redirect (const Redirect&); virtual ~Redirect (); - static Redirect *clone (const Redirect&); + static boost::shared_ptr<Redirect> clone (boost::shared_ptr<const Redirect>); bool active () const { return _active; } void set_active (bool yn, void *src); diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h index 8e4a094082..b8a11301ca 100644 --- a/libs/ardour/ardour/route.h +++ b/libs/ardour/ardour/route.h @@ -27,6 +27,8 @@ #include <map> #include <string> +#include <boost/shared_ptr.hpp> + #include <pbd/fastlog.h> #include <glibmm/thread.h> #include <pbd/xml++.h> @@ -56,7 +58,7 @@ class Route : public IO { protected: - typedef list<Redirect *> RedirectList; + typedef list<boost::shared_ptr<Redirect> > RedirectList; public: enum Flag { @@ -138,19 +140,19 @@ class Route : public IO void flush_redirects (); - template<class T> void foreach_redirect (T *obj, void (T::*func)(Redirect *)) { + template<class T> void foreach_redirect (T *obj, void (T::*func)(boost::shared_ptr<Redirect>)) { Glib::RWLock::ReaderLock lm (redirect_lock); for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) { (obj->*func) (*i); } } - Redirect *nth_redirect (uint32_t n) { + boost::shared_ptr<Redirect> nth_redirect (uint32_t n) { Glib::RWLock::ReaderLock lm (redirect_lock); RedirectList::iterator i; for (i = _redirects.begin(); i != _redirects.end() && n; ++i, --n); if (i == _redirects.end()) { - return 0; + return boost::shared_ptr<Redirect> (); } else { return *i; } @@ -158,9 +160,9 @@ class Route : public IO uint32_t max_redirect_outs () const { return redirect_max_outs; } - int add_redirect (Redirect *, void *src, uint32_t* err_streams = 0); + int add_redirect (boost::shared_ptr<Redirect>, void *src, uint32_t* err_streams = 0); int add_redirects (const RedirectList&, void *src, uint32_t* err_streams = 0); - int remove_redirect (Redirect *, void *src, uint32_t* err_streams = 0); + int remove_redirect (boost::shared_ptr<Redirect>, void *src, uint32_t* err_streams = 0); int copy_redirects (const Route&, Placement, uint32_t* err_streams = 0); int sort_redirects (uint32_t* err_streams = 0); @@ -209,8 +211,8 @@ class Route : public IO int set_control_outs (const vector<std::string>& ports); IO* control_outs() { return _control_outs; } - bool feeds (Route *); - set<Route *> fed_by; + bool feeds (boost::shared_ptr<Route>); + set<boost::shared_ptr<Route> > fed_by; struct ToggleControllable : public PBD::Controllable { enum ToggleType { @@ -336,12 +338,12 @@ class Route : public IO /* plugin count handling */ struct InsertCount { - ARDOUR::Insert& insert; + boost::shared_ptr<ARDOUR::Insert> insert; int32_t cnt; int32_t in; int32_t out; - InsertCount (ARDOUR::Insert& ins) : insert (ins), cnt (-1) {} + InsertCount (boost::shared_ptr<ARDOUR::Insert> ins) : insert (ins), cnt (-1) {} }; int32_t apply_some_plugin_counts (std::list<InsertCount>& iclist); diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 8b49af19d6..dbcd830a04 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -36,6 +36,7 @@ #include <pbd/error.h> #include <pbd/undo.h> #include <pbd/pool.h> +#include <pbd/rcu.h> #include <midi++/types.h> #include <midi++/mmc.h> @@ -100,9 +101,9 @@ class Session : public sigc::trackable, public Stateful { private: - typedef std::pair<Route*,bool> RouteBooleanState; + typedef std::pair<boost::shared_ptr<Route>,bool> RouteBooleanState; typedef vector<RouteBooleanState> GlobalRouteBooleanState; - typedef std::pair<Route*,MeterPoint> RouteMeterState; + typedef std::pair<boost::shared_ptr<Route>,MeterPoint> RouteMeterState; typedef vector<RouteMeterState> GlobalRouteMeterState; public: @@ -166,6 +167,7 @@ class Session : public sigc::trackable, public Stateful void* ptr; bool yes_or_no; Session::SlaveSource slave; + Route* route; }; list<AudioRange> audio_range; @@ -292,27 +294,26 @@ class Session : public sigc::trackable, public Stateful void foreach_audio_diskstream (void (AudioDiskstream::*func)(void)); template<class T> void foreach_audio_diskstream (T *obj, void (T::*func)(AudioDiskstream&)); - typedef list<Route *> RouteList; + typedef std::list<boost::shared_ptr<Route> > RouteList; - RouteList get_routes() const { - Glib::RWLock::ReaderLock rlock (route_lock); - return routes; /* XXX yes, force a copy */ + boost::shared_ptr<RouteList> get_routes() const { + return routes.reader (); } - uint32_t nroutes() const { return routes.size(); } + uint32_t nroutes() const { return routes.reader()->size(); } uint32_t ntracks () const; uint32_t nbusses () const; struct RoutePublicOrderSorter { - bool operator() (Route *, Route *b); + bool operator() (boost::shared_ptr<Route>, boost::shared_ptr<Route> b); }; template<class T> void foreach_route (T *obj, void (T::*func)(Route&)); - template<class T> void foreach_route (T *obj, void (T::*func)(Route*)); + template<class T> void foreach_route (T *obj, void (T::*func)(boost::shared_ptr<Route>)); template<class T, class A> void foreach_route (T *obj, void (T::*func)(Route&, A), A arg); - Route *route_by_name (string); - Route *route_by_remote_id (uint32_t id); + boost::shared_ptr<Route> route_by_name (string); + boost::shared_ptr<Route> route_by_remote_id (uint32_t id); bool route_name_unique (string) const; @@ -354,7 +355,7 @@ class Session : public sigc::trackable, public Stateful sigc::signal<void> DurationChanged; sigc::signal<void> HaltOnXrun; - sigc::signal<void,Route*> RouteAdded; + sigc::signal<void,boost::shared_ptr<Route> > RouteAdded; sigc::signal<void,AudioDiskstream*> AudioDiskstreamAdded; void request_roll (); @@ -505,9 +506,6 @@ class Session : public sigc::trackable, public Stateful void add_instant_xml (XMLNode&, const std::string& dir); - void swap_configuration(Configuration** new_config); - void copy_configuration(Configuration* new_config); - enum StateOfTheState { Clean = 0x0, Dirty = 0x1, @@ -548,13 +546,16 @@ class Session : public sigc::trackable, public Stateful /* fundamental operations. duh. */ + boost::shared_ptr<AudioTrack> new_audio_track (int input_channels, int output_channels, TrackMode mode = Normal); + boost::shared_ptr<Route> new_audio_route (int input_channels, int output_channels); - AudioTrack *new_audio_track (int input_channels, int output_channels, TrackMode mode = Normal); - - Route *new_audio_route (int input_channels, int output_channels); + void remove_route (boost::shared_ptr<Route>); - void remove_route (Route&); - void resort_routes (void *src); + void resort_routes (); + void resort_routes_using (boost::shared_ptr<RouteList>); + void resort_routes_proxy (void* src) { + resort_routes (); + } AudioEngine &engine() { return _engine; }; @@ -736,7 +737,7 @@ class Session : public sigc::trackable, public Stateful /* auditioning */ - Auditioner& the_auditioner() { return *auditioner; } + boost::shared_ptr<Auditioner> the_auditioner() { return auditioner; } void audition_playlist (); void audition_region (AudioRegion&); void cancel_audition (); @@ -775,8 +776,8 @@ class Session : public sigc::trackable, public Stateful /* control/master out */ - IO* control_out() const { return _control_out; } - IO* master_out() const { return _master_out; } + boost::shared_ptr<IO> control_out() const { return _control_out; } + boost::shared_ptr<IO> master_out() const { return _master_out; } /* insert/send management */ @@ -871,7 +872,7 @@ class Session : public sigc::trackable, public Stateful /* clicking */ - IO& click_io() { return *_click_io; } + boost::shared_ptr<IO> click_io() { return _click_io; } void set_clicking (bool yn); bool get_clicking() const; @@ -1041,9 +1042,9 @@ class Session : public sigc::trackable, public Stateful float _meter_falloff; bool _end_location_is_free; - void set_worst_io_latencies (bool take_lock); + void set_worst_io_latencies (); void set_worst_io_latencies_x (IOChange asifwecare, void *ignored) { - set_worst_io_latencies (true); + set_worst_io_latencies (); } void update_latency_compensation_proxy (void* ignored); @@ -1485,13 +1486,13 @@ class Session : public sigc::trackable, public Stateful /* routes stuff */ - RouteList routes; - mutable Glib::RWLock route_lock; - void add_route (Route*); + SerializedRCUManager<RouteList> routes; + + void add_route (boost::shared_ptr<Route>); uint32_t destructive_index; int load_routes (const XMLNode&); - Route* XMLRouteFactory (const XMLNode&); + boost::shared_ptr<Route> XMLRouteFactory (const XMLNode&); /* mixer stuff */ @@ -1501,7 +1502,7 @@ class Session : public sigc::trackable, public Stateful bool currently_soloing; void route_mute_changed (void *src); - void route_solo_changed (void *src, Route *); + void route_solo_changed (void *src, boost::shared_ptr<Route>); void catch_up_on_solo (); void update_route_solo_state (); void modify_solo_mute (bool, bool); @@ -1568,7 +1569,7 @@ class Session : public sigc::trackable, public Stateful /* AUDITIONING */ - Auditioner *auditioner; + boost::shared_ptr<Auditioner> auditioner; void set_audition (AudioRegion*); void non_realtime_set_audition (); AudioRegion *pending_audition_region; @@ -1685,7 +1686,7 @@ class Session : public sigc::trackable, public Stateful Clicks clicks; bool _clicking; - IO* _click_io; + boost::shared_ptr<IO> _click_io; Sample* click_data; Sample* click_emphasis_data; jack_nframes_t click_length; @@ -1717,8 +1718,8 @@ class Session : public sigc::trackable, public Stateful /* main outs */ uint32_t main_outs; - IO* _master_out; - IO* _control_out; + boost::shared_ptr<IO> _master_out; + boost::shared_ptr<IO> _control_out; AutoConnectOption input_auto_connect; AutoConnectOption output_auto_connect; diff --git a/libs/ardour/ardour/session_route.h b/libs/ardour/ardour/session_route.h index afe78b394e..feacc14775 100644 --- a/libs/ardour/ardour/session_route.h +++ b/libs/ardour/ardour/session_route.h @@ -33,14 +33,10 @@ namespace ARDOUR { template<class T> void Session::foreach_route (T *obj, void (T::*func)(Route&)) { - RouteList public_order; - - { - Glib::RWLock::ReaderLock lm (route_lock); - public_order = routes; - } - + boost::shared_ptr<RouteList> r = routes.reader(); + RouteList public_order (*r); RoutePublicOrderSorter cmp; + public_order.sort (cmp); for (RouteList::iterator i = public_order.begin(); i != public_order.end(); i++) { @@ -49,16 +45,12 @@ Session::foreach_route (T *obj, void (T::*func)(Route&)) } template<class T> void -Session::foreach_route (T *obj, void (T::*func)(Route*)) +Session::foreach_route (T *obj, void (T::*func)(boost::shared_ptr<Route>)) { - RouteList public_order; - - { - Glib::RWLock::ReaderLock lm (route_lock); - public_order = routes; - } - + boost::shared_ptr<RouteList> r = routes.reader(); + RouteList public_order (*r); RoutePublicOrderSorter cmp; + public_order.sort (cmp); for (RouteList::iterator i = public_order.begin(); i != public_order.end(); i++) { @@ -66,18 +58,13 @@ Session::foreach_route (T *obj, void (T::*func)(Route*)) } } - template<class T, class A> void Session::foreach_route (T *obj, void (T::*func)(Route&, A), A arg1) { - RouteList public_order; - - { - Glib::RWLock::ReaderLock lm (route_lock); - public_order = routes; - } - + boost::shared_ptr<RouteList> r = routes.reader(); + RouteList public_order (*r); RoutePublicOrderSorter cmp; + public_order.sort (cmp); for (RouteList::iterator i = public_order.begin(); i != public_order.end(); i++) { diff --git a/libs/ardour/audio_track.cc b/libs/ardour/audio_track.cc index 29496584f6..f425f0172e 100644 --- a/libs/ardour/audio_track.cc +++ b/libs/ardour/audio_track.cc @@ -438,8 +438,8 @@ AudioTrack::set_state_part_two () continue; } - FreezeRecordInsertInfo* frii = new FreezeRecordInsertInfo (*((*citer)->children().front())); - frii->insert = 0; + FreezeRecordInsertInfo* frii = new FreezeRecordInsertInfo (*((*citer)->children().front()), + boost::shared_ptr<Insert>()); frii->id = prop->value (); _freeze_record.insert_info.push_back (frii); } @@ -756,9 +756,9 @@ AudioTrack::export_stuff (vector<Sample*>& buffers, char * workbuf, uint32_t nbu */ for (i = _redirects.begin(); i != _redirects.end(); ++i) { - Insert *insert; + boost::shared_ptr<Insert> insert; - if ((insert = dynamic_cast<Insert*>(*i)) != 0) { + if ((insert = boost::dynamic_pointer_cast<Insert>(*i)) != 0) { switch (insert->placement()) { case PreFader: insert->run (buffers, nbufs, nframes, 0); @@ -794,9 +794,9 @@ AudioTrack::export_stuff (vector<Sample*>& buffers, char * workbuf, uint32_t nbu if (post_fader_work) { for (i = _redirects.begin(); i != _redirects.end(); ++i) { - PluginInsert *insert; + boost::shared_ptr<PluginInsert> insert; - if ((insert = dynamic_cast<PluginInsert*>(*i)) != 0) { + if ((insert = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) { switch ((*i)->placement()) { case PreFader: break; @@ -852,7 +852,6 @@ AudioTrack::bounce_range (jack_nframes_t start, jack_nframes_t end, InterThreadI void AudioTrack::freeze (InterThreadInfo& itt) { - Insert* insert; vector<AudioSource*> srcs; string new_playlist_name; Playlist* new_playlist; @@ -900,11 +899,12 @@ AudioTrack::freeze (InterThreadInfo& itt) for (RedirectList::iterator r = _redirects.begin(); r != _redirects.end(); ++r) { - if ((insert = dynamic_cast<Insert*>(*r)) != 0) { + boost::shared_ptr<Insert> insert; + + if ((insert = boost::dynamic_pointer_cast<Insert>(*r)) != 0) { - FreezeRecordInsertInfo* frii = new FreezeRecordInsertInfo ((*r)->get_state()); + FreezeRecordInsertInfo* frii = new FreezeRecordInsertInfo ((*r)->get_state(), insert); - frii->insert = insert; frii->id = insert->id(); frii->memento = (*r)->get_memento(); diff --git a/libs/ardour/audiofilesource.cc b/libs/ardour/audiofilesource.cc index 034b61860a..29736a8677 100644 --- a/libs/ardour/audiofilesource.cc +++ b/libs/ardour/audiofilesource.cc @@ -213,6 +213,10 @@ AudioFileSource::create (const string& idstr, Flag flags) { AudioFileSource* es = 0; + if (flags & Destructive) { + return new DestructiveFileSource (idstr, flags); + } + try { es = new CoreAudioSource (idstr, flags); } diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc index add9364cad..bf7a32c885 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -640,7 +640,7 @@ AudioSource::read_peaks (PeakData *peaks, jack_nframes_t npeaks, jack_nframes_t to_read = min (chunksize, (_length - current_frame)); - if ((frames_read = read_unlocked (raw_staging, current_frame, to_read, workbuf)) < 0) { + if ((frames_read = read_unlocked (raw_staging, current_frame, to_read, workbuf)) == 0) { error << string_compose(_("AudioSource[%1]: peak read - cannot read %2 samples at offset %3") , _name, to_read, current_frame) << endmsg; diff --git a/libs/ardour/destructive_filesource.cc b/libs/ardour/destructive_filesource.cc index 68eeded9b2..43fafff30a 100644 --- a/libs/ardour/destructive_filesource.cc +++ b/libs/ardour/destructive_filesource.cc @@ -70,19 +70,25 @@ jack_nframes_t DestructiveFileSource::xfade_frames = 64; DestructiveFileSource::DestructiveFileSource (string path, SampleFormat samp_format, HeaderFormat hdr_format, jack_nframes_t rate, Flag flags) : SndFileSource (path, samp_format, hdr_format, rate, flags) { - xfade_buf = new Sample[xfade_frames]; + init (); +} - _capture_start = false; - _capture_end = false; - file_pos = 0; - timeline_position = header_position_offset; - AudioFileSource::HeaderPositionOffsetChanged.connect (mem_fun (*this, &DestructiveFileSource::handle_header_position_change)); +DestructiveFileSource::DestructiveFileSource (string path, Flag flags) + : SndFileSource (path, flags) +{ + init (); } DestructiveFileSource::DestructiveFileSource (const XMLNode& node) : SndFileSource (node) { + init (); +} + +void +DestructiveFileSource::init () +{ xfade_buf = new Sample[xfade_frames]; _capture_start = false; diff --git a/libs/ardour/insert.cc b/libs/ardour/insert.cc index a2b03ad38d..11b1e25a74 100644 --- a/libs/ardour/insert.cc +++ b/libs/ardour/insert.cc @@ -62,12 +62,12 @@ Insert::Insert(Session& s, string name, Placement p) const string PluginInsert::port_automation_node_name = "PortAutomation"; -PluginInsert::PluginInsert (Session& s, Plugin& plug, Placement placement) - : Insert (s, plug.name(), placement) +PluginInsert::PluginInsert (Session& s, boost::shared_ptr<Plugin> plug, Placement placement) + : Insert (s, plug->name(), placement) { /* the first is the master */ - _plugins.push_back(&plug); + _plugins.push_back (plug); _plugins[0]->ParameterChanged.connect (mem_fun (*this, &PluginInsert::parameter_changed)); @@ -103,13 +103,13 @@ PluginInsert::PluginInsert (Session& s, const XMLNode& node) } PluginInsert::PluginInsert (const PluginInsert& other) - : Insert (other._session, other.plugin().name(), other.placement()) + : Insert (other._session, other.plugin()->name(), other.placement()) { uint32_t count = other._plugins.size(); /* make as many copies as requested */ for (uint32_t n = 0; n < count; ++n) { - _plugins.push_back (plugin_factory (other.plugin())); + _plugins.push_back (plugin_factory (other.plugin (n))); } @@ -137,7 +137,7 @@ PluginInsert::set_count (uint32_t num) uint32_t diff = num - _plugins.size(); for (uint32_t n = 0; n < diff; ++n) { - _plugins.push_back (plugin_factory (*_plugins[0])); + _plugins.push_back (plugin_factory (_plugins[0])); if (require_state) { /* XXX do something */ @@ -147,9 +147,7 @@ PluginInsert::set_count (uint32_t num) } else if (num < _plugins.size()) { uint32_t diff = _plugins.size() - num; for (uint32_t n= 0; n < diff; ++n) { - Plugin * plug = _plugins.back(); _plugins.pop_back(); - delete plug; } } @@ -167,12 +165,6 @@ PluginInsert::init () PluginInsert::~PluginInsert () { GoingAway (this); /* EMIT SIGNAL */ - - while (!_plugins.empty()) { - Plugin* p = _plugins.back(); - _plugins.pop_back(); - delete p; - } } void @@ -240,7 +232,7 @@ PluginInsert::set_automatable () void PluginInsert::parameter_changed (uint32_t which, float val) { - vector<Plugin*>::iterator i = _plugins.begin(); + vector<boost::shared_ptr<Plugin> >::iterator i = _plugins.begin(); /* don't set the first plugin, just all the slaves */ @@ -255,7 +247,7 @@ PluginInsert::parameter_changed (uint32_t which, float val) void PluginInsert::set_block_size (jack_nframes_t nframes) { - for (vector<Plugin*>::iterator i = _plugins.begin(); i != _plugins.end(); ++i) { + for (vector<boost::shared_ptr<Plugin> >::iterator i = _plugins.begin(); i != _plugins.end(); ++i) { (*i)->set_block_size (nframes); } } @@ -263,7 +255,7 @@ PluginInsert::set_block_size (jack_nframes_t nframes) void PluginInsert::activate () { - for (vector<Plugin*>::iterator i = _plugins.begin(); i != _plugins.end(); ++i) { + for (vector<boost::shared_ptr<Plugin> >::iterator i = _plugins.begin(); i != _plugins.end(); ++i) { (*i)->activate (); } } @@ -271,7 +263,7 @@ PluginInsert::activate () void PluginInsert::deactivate () { - for (vector<Plugin*>::iterator i = _plugins.begin(); i != _plugins.end(); ++i) { + for (vector<boost::shared_ptr<Plugin> >::iterator i = _plugins.begin(); i != _plugins.end(); ++i) { (*i)->deactivate (); } } @@ -309,7 +301,7 @@ PluginInsert::connect_and_run (vector<Sample*>& bufs, uint32_t nbufs, jack_nfram } } - for (vector<Plugin*>::iterator i = _plugins.begin(); i != _plugins.end(); ++i) { + for (vector<boost::shared_ptr<Plugin> >::iterator i = _plugins.begin(); i != _plugins.end(); ++i) { (*i)->connect_and_run (bufs, nbufs, in_index, out_index, nframes, offset); } @@ -357,7 +349,7 @@ PluginInsert::silence (jack_nframes_t nframes, jack_nframes_t offset) uint32_t n; if (active()) { - for (vector<Plugin*>::iterator i = _plugins.begin(); i != _plugins.end(); ++i) { + for (vector<boost::shared_ptr<Plugin> >::iterator i = _plugins.begin(); i != _plugins.end(); ++i) { n = (*i) -> get_info().n_inputs; (*i)->connect_and_run (_session.get_silent_buffers (n), n, in_index, out_index, nframes, offset); } @@ -506,19 +498,19 @@ PluginInsert::protect_automation () } } -Plugin* -PluginInsert::plugin_factory (Plugin& other) +boost::shared_ptr<Plugin> +PluginInsert::plugin_factory (boost::shared_ptr<Plugin> other) { - LadspaPlugin* lp; + boost::shared_ptr<LadspaPlugin> lp; #ifdef VST_SUPPORT - VSTPlugin* vp; + boost::shared_ptr<VSTPlugin> vp; #endif - if ((lp = dynamic_cast<LadspaPlugin*> (&other)) != 0) { - return new LadspaPlugin (*lp); + if ((lp = boost::dynamic_pointer_cast<LadspaPlugin> (other)) != 0) { + return boost::shared_ptr<Plugin> (new LadspaPlugin (*lp)); #ifdef VST_SUPPORT - } else if ((vp = dynamic_cast<VSTPlugin*> (&other)) != 0) { - return new VSTPlugin (*vp); + } else if ((vp = boost::dynamic_pointer_cast<VSTPlugin> (other)) != 0) { + return boost::shared_ptr<Plugin> (new VSTPlugin (*vp)); #endif } @@ -526,7 +518,7 @@ PluginInsert::plugin_factory (Plugin& other) X_("unknown plugin type in PluginInsert::plugin_factory")) << endmsg; /*NOTREACHED*/ - return 0; + return boost::shared_ptr<Plugin> ((Plugin*) 0); } int32_t @@ -666,7 +658,7 @@ PluginInsert::set_state(const XMLNode& node) return -1; } - Plugin* plugin; + boost::shared_ptr<Plugin> plugin; if (unique != 0) { plugin = find_plugin (_session, "", unique, type); @@ -692,13 +684,13 @@ PluginInsert::set_state(const XMLNode& node) _plugins.push_back (plugin); for (uint32_t n=1; n < count; ++n) { - _plugins.push_back (plugin_factory (*plugin)); + _plugins.push_back (plugin_factory (plugin)); } } for (niter = nlist.begin(); niter != nlist.end(); ++niter) { if ((*niter)->name() == plugin->state_node_name()) { - for (vector<Plugin*>::iterator i = _plugins.begin(); i != _plugins.end(); ++i) { + for (vector<boost::shared_ptr<Plugin> >::iterator i = _plugins.begin(); i != _plugins.end(); ++i) { (*i)->set_state (**niter); } break; diff --git a/libs/ardour/plugin_manager.cc b/libs/ardour/plugin_manager.cc index b096e81785..c8787a7d34 100644 --- a/libs/ardour/plugin_manager.cc +++ b/libs/ardour/plugin_manager.cc @@ -280,13 +280,14 @@ PluginManager::ladspa_discover (string path) return 0; } -Plugin * +boost::shared_ptr<Plugin> PluginManager::load (Session& session, PluginInfo *info) { void *module; - Plugin *plugin = 0; try { + boost::shared_ptr<Plugin> plugin; + if (info->type == PluginInfo::VST) { #ifdef VST_SUPPORT @@ -296,14 +297,14 @@ PluginManager::load (Session& session, PluginInfo *info) if ((handle = fst_load (info->path.c_str())) == 0) { error << string_compose(_("VST: cannot load module from \"%1\""), info->path) << endmsg; } else { - plugin = new VSTPlugin (_engine, session, handle); + plugin.reset (new VSTPlugin (_engine, session, handle)); } } else { error << _("You asked ardour to not use any VST plugins") << endmsg; } #else error << _("This version of ardour has no support for VST plugins") << endmsg; - return 0; + return boost::shared_ptr<Plugin> ((Plugin*) 0); #endif } else { @@ -312,21 +313,20 @@ PluginManager::load (Session& session, PluginInfo *info) error << string_compose(_("LADSPA: cannot load module from \"%1\""), info->path) << endmsg; error << dlerror() << endmsg; } else { - plugin = new LadspaPlugin (module, _engine, session, info->index, session.frame_rate()); + plugin.reset (new LadspaPlugin (module, _engine, session, info->index, session.frame_rate())); } } plugin->set_info(*info); + return plugin; } catch (failed_constructor &err) { - plugin = 0; + return boost::shared_ptr<Plugin> ((Plugin*) 0); } - - return plugin; } -Plugin * +boost::shared_ptr<Plugin> ARDOUR::find_plugin(Session& session, string name, long unique_id, PluginInfo::Type type) { PluginManager *mgr = PluginManager::the_manager(); @@ -343,7 +343,7 @@ ARDOUR::find_plugin(Session& session, string name, long unique_id, PluginInfo::T break; case PluginInfo::AudioUnit: default: - return 0; + return boost::shared_ptr<Plugin> ((Plugin *) 0); } for (i = plugs->begin(); i != plugs->end(); ++i) { @@ -353,7 +353,7 @@ ARDOUR::find_plugin(Session& session, string name, long unique_id, PluginInfo::T } } - return 0; + return boost::shared_ptr<Plugin> ((Plugin*) 0); } string diff --git a/libs/ardour/redirect.cc b/libs/ardour/redirect.cc index 9800c5b1a2..1ab2f91cf0 100644 --- a/libs/ardour/redirect.cc +++ b/libs/ardour/redirect.cc @@ -60,25 +60,25 @@ Redirect::~Redirect () { } -Redirect* -Redirect::clone (const Redirect& other) +boost::shared_ptr<Redirect> +Redirect::clone (boost::shared_ptr<const Redirect> other) { - const Send *send; - const PortInsert *port_insert; - const PluginInsert *plugin_insert; - - if ((send = dynamic_cast<const Send*>(&other)) != 0) { - return new Send (*send); - } else if ((port_insert = dynamic_cast<const PortInsert*>(&other)) != 0) { - return new PortInsert (*port_insert); - } else if ((plugin_insert = dynamic_cast<const PluginInsert*>(&other)) != 0) { - return new PluginInsert (*plugin_insert); + boost::shared_ptr<const Send> send; + boost::shared_ptr<const PortInsert> port_insert; + boost::shared_ptr<const PluginInsert> plugin_insert; + + if ((send = boost::dynamic_pointer_cast<const Send>(other)) != 0) { + return boost::shared_ptr<Redirect> (new Send (*send)); + } else if ((port_insert = boost::dynamic_pointer_cast<const PortInsert>(other)) != 0) { + return boost::shared_ptr<Redirect> (new PortInsert (*port_insert)); + } else if ((plugin_insert = boost::dynamic_pointer_cast<const PluginInsert>(other)) != 0) { + return boost::shared_ptr<Redirect> (new PluginInsert (*plugin_insert)); } else { fatal << _("programming error: unknown Redirect type in Redirect::Clone!\n") << endmsg; /*NOTREACHED*/ } - return 0; + return boost::shared_ptr<Redirect>(); } void diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 8d6ecf7eb5..f3162f9131 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -756,7 +756,7 @@ Route::set_mute (bool yn, void *src) } int -Route::add_redirect (Redirect *redirect, void *src, uint32_t* err_streams) +Route::add_redirect (boost::shared_ptr<Redirect> redirect, void *src, uint32_t* err_streams) { uint32_t old_rmo = redirect_max_outs; @@ -767,12 +767,12 @@ Route::add_redirect (Redirect *redirect, void *src, uint32_t* err_streams) { Glib::RWLock::WriterLock lm (redirect_lock); - PluginInsert* pi; - PortInsert* porti; + boost::shared_ptr<PluginInsert> pi; + boost::shared_ptr<PortInsert> porti; uint32_t potential_max_streams = 0; - if ((pi = dynamic_cast<PluginInsert*>(redirect)) != 0) { + if ((pi = boost::dynamic_pointer_cast<PluginInsert>(redirect)) != 0) { pi->set_count (1); if (pi->input_streams() == 0) { @@ -781,8 +781,8 @@ Route::add_redirect (Redirect *redirect, void *src, uint32_t* err_streams) } potential_max_streams = max(pi->input_streams(), pi->output_streams()); - - } else if ((porti = dynamic_cast<PortInsert*>(redirect)) != 0) { + + } else if ((porti = boost::dynamic_pointer_cast<PortInsert>(redirect)) != 0) { /* force new port inserts to start out with an i/o configuration that matches this route's i/o configuration. @@ -847,9 +847,9 @@ Route::add_redirects (const RedirectList& others, void *src, uint32_t* err_strea for (RedirectList::const_iterator i = others.begin(); i != others.end(); ++i) { - PluginInsert* pi; + boost::shared_ptr<PluginInsert> pi; - if ((pi = dynamic_cast<PluginInsert*>(*i)) != 0) { + if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) { pi->set_count (1); uint32_t m = max(pi->input_streams(), pi->output_streams()); @@ -898,11 +898,6 @@ Route::clear_redirects (void *src) { Glib::RWLock::WriterLock lm (redirect_lock); - - for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) { - delete *i; - } - _redirects.clear (); } @@ -916,7 +911,7 @@ Route::clear_redirects (void *src) } int -Route::remove_redirect (Redirect *redirect, void *src, uint32_t* err_streams) +Route::remove_redirect (boost::shared_ptr<Redirect> redirect, void *src, uint32_t* err_streams) { uint32_t old_rmo = redirect_max_outs; @@ -948,13 +943,13 @@ Route::remove_redirect (Redirect *redirect, void *src, uint32_t* err_streams) run. */ - Send* send; - PortInsert* port_insert; + boost::shared_ptr<Send> send; + boost::shared_ptr<PortInsert> port_insert; - if ((send = dynamic_cast<Send*> (*i)) != 0) { + if ((send = boost::dynamic_pointer_cast<Send> (*i)) != 0) { send->disconnect_inputs (this); send->disconnect_outputs (this); - } else if ((port_insert = dynamic_cast<PortInsert*> (*i)) != 0) { + } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (*i)) != 0) { port_insert->disconnect_inputs (this); port_insert->disconnect_outputs (this); } @@ -983,9 +978,9 @@ Route::remove_redirect (Redirect *redirect, void *src, uint32_t* err_streams) bool foo = false; for (i = _redirects.begin(); i != _redirects.end(); ++i) { - PluginInsert* pi; - - if ((pi = dynamic_cast<PluginInsert*>(*i)) != 0) { + boost::shared_ptr<PluginInsert> pi; + + if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) { if (pi->is_generator()) { foo = true; } @@ -1032,7 +1027,7 @@ Route::_reset_plugin_counts (uint32_t* err_streams) for (r = _redirects.begin(); r != _redirects.end(); ++r) { - Insert *insert; + boost::shared_ptr<Insert> insert; /* do this here in case we bomb out before we get to the end of this function. @@ -1040,22 +1035,22 @@ Route::_reset_plugin_counts (uint32_t* err_streams) redirect_max_outs = max ((*r)->output_streams (), redirect_max_outs); - if ((insert = dynamic_cast<Insert*>(*r)) != 0) { + if ((insert = boost::dynamic_pointer_cast<Insert>(*r)) != 0) { ++i_cnt; - insert_map[insert->placement()].push_back (InsertCount (*insert)); + insert_map[insert->placement()].push_back (InsertCount (insert)); /* reset plugin counts back to one for now so that we have a predictable, controlled state to try to configure. */ - PluginInsert* pi; + boost::shared_ptr<PluginInsert> pi; - if ((pi = dynamic_cast<PluginInsert*>(insert)) != 0) { + if ((pi = boost::dynamic_pointer_cast<PluginInsert>(insert)) != 0) { pi->set_count (1); } - } else if (dynamic_cast<Send*> (*r) != 0) { + } else if (boost::dynamic_pointer_cast<Send> (*r) != 0) { ++s_cnt; } } @@ -1082,7 +1077,7 @@ Route::_reset_plugin_counts (uint32_t* err_streams) if (!insert_map[PreFader].empty()) { InsertCount& ic (insert_map[PreFader].back()); - initial_streams = ic.insert.compute_output_streams (ic.cnt); + initial_streams = ic.insert->compute_output_streams (ic.cnt); } else { initial_streams = n_inputs (); } @@ -1106,9 +1101,9 @@ Route::_reset_plugin_counts (uint32_t* err_streams) RedirectList::iterator prev = _redirects.end(); for (r = _redirects.begin(); r != _redirects.end(); prev = r, ++r) { - Send* s; + boost::shared_ptr<Send> s; - if ((s = dynamic_cast<Send*> (*r)) != 0) { + if ((s = boost::dynamic_pointer_cast<Send> (*r)) != 0) { if (r == _redirects.begin()) { s->expect_inputs (n_inputs()); } else { @@ -1131,11 +1126,11 @@ Route::apply_some_plugin_counts (list<InsertCount>& iclist) for (i = iclist.begin(); i != iclist.end(); ++i) { - if ((*i).insert.configure_io ((*i).cnt, (*i).in, (*i).out)) { + if ((*i).insert->configure_io ((*i).cnt, (*i).in, (*i).out)) { return -1; } /* make sure that however many we have, they are all active */ - (*i).insert.activate (); + (*i).insert->activate (); } return 0; @@ -1148,7 +1143,7 @@ Route::check_some_plugin_counts (list<InsertCount>& iclist, int32_t required_inp for (i = iclist.begin(); i != iclist.end(); ++i) { - if (((*i).cnt = (*i).insert.can_support_input_configuration (required_inputs)) < 0) { + if (((*i).cnt = (*i).insert->can_support_input_configuration (required_inputs)) < 0) { if (err_streams) { *err_streams = required_inputs; } @@ -1156,7 +1151,7 @@ Route::check_some_plugin_counts (list<InsertCount>& iclist, int32_t required_inp } (*i).in = required_inputs; - (*i).out = (*i).insert.compute_output_streams ((*i).cnt); + (*i).out = (*i).insert->compute_output_streams ((*i).cnt); required_inputs = (*i).out; } @@ -1200,7 +1195,7 @@ Route::copy_redirects (const Route& other, Placement placement, uint32_t* err_st for (RedirectList::const_iterator i = other._redirects.begin(); i != other._redirects.end(); ++i) { if ((*i)->placement() == placement) { - _redirects.push_back (Redirect::clone (**i)); + _redirects.push_back (Redirect::clone (*i)); } } @@ -1218,7 +1213,6 @@ Route::copy_redirects (const Route& other, Placement placement, uint32_t* err_st ++tmp; if ((*i)->placement() == placement) { - delete *i; _redirects.erase (i); } @@ -1237,10 +1231,7 @@ Route::copy_redirects (const Route& other, Placement placement, uint32_t* err_st } else { /* SUCCESSFUL COPY ATTEMPT: delete the redirects we removed pre-copy */ - - for (RedirectList::iterator i = to_be_deleted.begin(); i != to_be_deleted.end(); ++i) { - delete *i; - } + to_be_deleted.clear (); } } @@ -1283,7 +1274,7 @@ Route::all_redirects_active (bool state) } struct RedirectSorter { - bool operator() (const Redirect *a, const Redirect *b) { + bool operator() (boost::shared_ptr<const Redirect> a, boost::shared_ptr<const Redirect> b) { return a->sort_key() < b->sort_key(); } }; @@ -1442,13 +1433,13 @@ void Route::add_redirect_from_xml (const XMLNode& node) { const XMLProperty *prop; - Insert *insert = 0; - Send *send = 0; if (node.name() == "Send") { + try { - send = new Send (_session, node); + boost::shared_ptr<Send> send (new Send (_session, node)); + add_redirect (send, this); } catch (failed_constructor &err) { @@ -1456,21 +1447,21 @@ Route::add_redirect_from_xml (const XMLNode& node) return; } - add_redirect (send, this); - } else if (node.name() == "Insert") { try { if ((prop = node.property ("type")) != 0) { + boost::shared_ptr<Insert> insert; + if (prop->value() == "ladspa" || prop->value() == "Ladspa" || prop->value() == "vst") { - insert = new PluginInsert(_session, node); + insert.reset (new PluginInsert(_session, node)); } else if (prop->value() == "port") { - insert = new PortInsert (_session, node); + insert.reset (new PortInsert (_session, node)); } else { @@ -1715,8 +1706,8 @@ Route::silence (jack_nframes_t nframes, jack_nframes_t offset) if (lm.locked()) { for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) { - PluginInsert* pi; - if (!_active && (pi = dynamic_cast<PluginInsert*> (*i)) != 0) { + boost::shared_ptr<PluginInsert> pi; + if (!_active && (pi = boost::dynamic_pointer_cast<PluginInsert> (*i)) != 0) { // skip plugins, they don't need anything when we're not active continue; } @@ -1827,18 +1818,17 @@ Route::set_comment (string cmt, void *src) } bool -Route::feeds (Route *o) +Route::feeds (boost::shared_ptr<Route> other) { uint32_t i, j; - IO& other = *o; IO& self = *this; uint32_t no = self.n_outputs(); - uint32_t ni = other.n_inputs (); + uint32_t ni = other->n_inputs (); for (i = 0; i < no; ++i) { for (j = 0; j < ni; ++j) { - if (self.output(i)->connected_to (other.input(j)->name())) { + if (self.output(i)->connected_to (other->input(j)->name())) { return true; } } @@ -1852,7 +1842,7 @@ Route::feeds (Route *o) for (i = 0; i < no; ++i) { for (j = 0; j < ni; ++j) { - if ((*r)->output(i)->connected_to (other.input (j)->name())) { + if ((*r)->output(i)->connected_to (other->input (j)->name())) { return true; } } @@ -1867,7 +1857,7 @@ Route::feeds (Route *o) for (i = 0; i < no; ++i) { for (j = 0; j < ni; ++j) { - if (_control_outs->output(i)->connected_to (other.input (j)->name())) { + if (_control_outs->output(i)->connected_to (other->input (j)->name())) { return true; } } @@ -2118,10 +2108,10 @@ Route::toggle_monitor_input () bool Route::has_external_redirects () const { - const PortInsert* pi; + boost::shared_ptr<const PortInsert> pi; for (RedirectList::const_iterator i = _redirects.begin(); i != _redirects.end(); ++i) { - if ((pi = dynamic_cast<const PortInsert*>(*i)) != 0) { + if ((pi = boost::dynamic_pointer_cast<const PortInsert>(*i)) != 0) { uint32_t no = pi->n_outputs(); @@ -2290,8 +2280,8 @@ Route::protect_automation () } for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) { - PluginInsert* pi; - if ((pi = dynamic_cast<PluginInsert*> (*i)) != 0) { + boost::shared_ptr<PluginInsert> pi; + if ((pi = boost::dynamic_pointer_cast<PluginInsert> (*i)) != 0) { pi->protect_automation (); } } diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 34807e798b..ae879ed083 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -74,6 +74,7 @@ using namespace std; using namespace ARDOUR; using namespace PBD; +using boost::shared_ptr; const char* Session::_template_suffix = X_(".template"); const char* Session::_statefile_suffix = X_(".ardour"); @@ -254,6 +255,9 @@ Session::Session (AudioEngine &eng, _midi_port (default_midi_port), pending_events (2048), midi_requests (128), // the size of this should match the midi request pool size + routes (new RouteList), + auditioner ((Auditioner*) 0), + _click_io ((IO*) 0), main_outs (0) { bool new_session; @@ -301,6 +305,7 @@ Session::Session (AudioEngine &eng, _midi_port (default_midi_port), pending_events (2048), midi_requests (16), + routes (new RouteList), main_outs (0) { @@ -318,15 +323,13 @@ Session::Session (AudioEngine &eng, } if (control_out_channels) { - Route* r; - r = new Route (*this, _("monitor"), -1, control_out_channels, -1, control_out_channels, Route::ControlOut); + shared_ptr<Route> r (new Route (*this, _("monitor"), -1, control_out_channels, -1, control_out_channels, Route::ControlOut)); add_route (r); _control_out = r; } if (master_out_channels) { - Route* r; - r = new Route (*this, _("master"), -1, master_out_channels, -1, master_out_channels, Route::MasterOut); + shared_ptr<Route> r (new Route (*this, _("master"), -1, master_out_channels, -1, master_out_channels, Route::MasterOut)); add_route (r); _master_out = r; } else { @@ -378,15 +381,6 @@ Session::~Session () clear_clicks (); - if (_click_io) { - delete _click_io; - } - - - if (auditioner) { - delete auditioner; - } - for (vector<Sample*>::iterator i = _passthru_buffers.begin(); i != _passthru_buffers.end(); ++i) { free(*i); } @@ -446,17 +440,6 @@ Session::~Session () } #ifdef TRACK_DESTRUCTION - cerr << "delete routes\n"; -#endif /* TRACK_DESTRUCTION */ - for (RouteList::iterator i = routes.begin(); i != routes.end(); ) { - RouteList::iterator tmp; - tmp = i; - ++tmp; - delete *i; - i = tmp; - } - -#ifdef TRACK_DESTRUCTION cerr << "delete audio_diskstreams\n"; #endif /* TRACK_DESTRUCTION */ for (AudioDiskstreamList::iterator i = audio_diskstreams.begin(); i != audio_diskstreams.end(); ) { @@ -546,7 +529,7 @@ Session::~Session () } void -Session::set_worst_io_latencies (bool take_lock) +Session::set_worst_io_latencies () { _worst_output_latency = 0; _worst_input_latency = 0; @@ -555,18 +538,12 @@ Session::set_worst_io_latencies (bool take_lock) return; } - if (take_lock) { - route_lock.reader_lock (); - } + boost::shared_ptr<RouteList> r = routes.reader (); - for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) { + for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { _worst_output_latency = max (_worst_output_latency, (*i)->output_latency()); _worst_input_latency = max (_worst_input_latency, (*i)->input_latency()); } - - if (take_lock) { - route_lock.reader_unlock (); - } } void @@ -583,7 +560,7 @@ Session::when_engine_running () /* every time we reconnect, recompute worst case output latencies */ - _engine.Running.connect (sigc::bind (mem_fun (*this, &Session::set_worst_io_latencies), true)); + _engine.Running.connect (mem_fun (*this, &Session::set_worst_io_latencies)); if (synced_to_jack()) { _engine.transport_stop (); @@ -598,7 +575,7 @@ Session::when_engine_running () try { XMLNode* child = 0; - _click_io = new ClickIO (*this, "click", 0, 0, -1, -1); + _click_io.reset (new ClickIO (*this, "click", 0, 0, -1, -1)); if (state_tree && (child = find_named_node (*state_tree->root(), "Click")) != 0) { @@ -634,7 +611,7 @@ Session::when_engine_running () error << _("cannot setup Click I/O") << endmsg; } - set_worst_io_latencies (true); + set_worst_io_latencies (); if (_clicking) { ControlChanged (Clicking); /* EMIT SIGNAL */ @@ -649,7 +626,7 @@ Session::when_engine_running () */ try { - auditioner = new Auditioner (*this); + auditioner.reset (new Auditioner (*this)); } catch (failed_constructor& err) { @@ -1452,7 +1429,6 @@ Session::set_block_size (jack_nframes_t nframes) */ { - Glib::RWLock::ReaderLock lm (route_lock); Glib::RWLock::ReaderLock dsm (diskstream_lock); vector<Sample*>::iterator i; uint32_t np; @@ -1494,7 +1470,9 @@ Session::set_block_size (jack_nframes_t nframes) allocate_pan_automation_buffers (nframes, _npan_buffers, true); - for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) { + boost::shared_ptr<RouteList> r = routes.reader (); + + for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { (*i)->set_block_size (nframes); } @@ -1502,7 +1480,7 @@ Session::set_block_size (jack_nframes_t nframes) (*i)->set_block_size (nframes); } - set_worst_io_latencies (false); + set_worst_io_latencies (); } } @@ -1544,7 +1522,7 @@ Session::set_default_fade (float steepness, float fade_msecs) } struct RouteSorter { - bool operator() (Route* r1, Route* r2) { + bool operator() (boost::shared_ptr<Route> r1, boost::shared_ptr<Route> r2) { if (r1->fed_by.find (r2) != r1->fed_by.end()) { return false; } else if (r2->fed_by.find (r1) != r2->fed_by.end()) { @@ -1566,9 +1544,9 @@ struct RouteSorter { }; static void -trace_terminal (Route* r1, Route* rbase) +trace_terminal (shared_ptr<Route> r1, shared_ptr<Route> rbase) { - Route* r2; + shared_ptr<Route> r2; if ((r1->fed_by.find (rbase) != r1->fed_by.end()) && (rbase->fed_by.find (r1) != rbase->fed_by.end())) { info << string_compose(_("feedback loop setup between %1 and %2"), r1->name(), rbase->name()) << endmsg; @@ -1577,13 +1555,13 @@ trace_terminal (Route* r1, Route* rbase) /* make a copy of the existing list of routes that feed r1 */ - set<Route *> existing = r1->fed_by; + set<shared_ptr<Route> > existing = r1->fed_by; /* for each route that feeds r1, recurse, marking it as feeding rbase as well. */ - for (set<Route *>::iterator i = existing.begin(); i != existing.end(); ++i) { + for (set<shared_ptr<Route> >::iterator i = existing.begin(); i != existing.end(); ++i) { r2 =* i; /* r2 is a route that feeds r1 which somehow feeds base. mark @@ -1613,7 +1591,7 @@ trace_terminal (Route* r1, Route* rbase) } void -Session::resort_routes (void* src) +Session::resort_routes () { /* don't do anything here with signals emitted by Routes while we are being destroyed. @@ -1623,54 +1601,64 @@ Session::resort_routes (void* src) return; } - /* Caller MUST hold the route_lock */ - RouteList::iterator i, j; + { - for (i = routes.begin(); i != routes.end(); ++i) { + RCUWriter<RouteList> writer (routes); + shared_ptr<RouteList> r = writer.get_copy (); + resort_routes_using (r); + /* writer goes out of scope and forces update */ + } +} +void +Session::resort_routes_using (shared_ptr<RouteList> r) +{ + RouteList::iterator i, j; + + for (i = r->begin(); i != r->end(); ++i) { + (*i)->fed_by.clear (); - for (j = routes.begin(); j != routes.end(); ++j) { - + for (j = r->begin(); j != r->end(); ++j) { + /* although routes can feed themselves, it will cause an endless recursive descent if we detect it. so don't bother checking for self-feeding. */ - + if (*j == *i) { continue; } - + if ((*j)->feeds (*i)) { (*i)->fed_by.insert (*j); } } } - for (i = routes.begin(); i != routes.end(); ++i) { + for (i = r->begin(); i != r->end(); ++i) { trace_terminal (*i, *i); } - + RouteSorter cmp; - routes.sort (cmp); - + r->sort (cmp); + #if 0 cerr << "finished route resort\n"; - for (i = routes.begin(); i != routes.end(); ++i) { + for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { cerr << " " << (*i)->name() << " signal order = " << (*i)->order_key ("signal") << endl; } cerr << endl; #endif - + } -AudioTrack* +shared_ptr<AudioTrack> Session::new_audio_track (int input_channels, int output_channels, TrackMode mode) { - AudioTrack *track; char track_name[32]; uint32_t n = 0; uint32_t channels_used = 0; @@ -1681,9 +1669,10 @@ Session::new_audio_track (int input_channels, int output_channels, TrackMode mod /* count existing audio tracks */ { - Glib::RWLock::ReaderLock lm (route_lock); - for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) { - if (dynamic_cast<AudioTrack*>(*i) != 0) { + shared_ptr<RouteList> r = routes.reader (); + + for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { + if (dynamic_cast<AudioTrack*>((*i).get()) != 0) { if (!(*i)->hidden()) { n++; channels_used += (*i)->n_inputs(); @@ -1720,7 +1709,7 @@ Session::new_audio_track (int input_channels, int output_channels, TrackMode mod } try { - track = new AudioTrack (*this, track_name, Route::Flag (0), mode); + shared_ptr<AudioTrack> track (new AudioTrack (*this, track_name, Route::Flag (0), mode)); if (track->ensure_io (input_channels, output_channels, false, this)) { error << string_compose (_("cannot configure %1 in/%2 out configuration for new audio track"), @@ -1771,25 +1760,23 @@ Session::new_audio_track (int input_channels, int output_channels, TrackMode mod track->set_control_outs (cports); } - track->diskstream_changed.connect (mem_fun (this, &Session::resort_routes)); + track->diskstream_changed.connect (mem_fun (this, &Session::resort_routes_proxy)); add_route (track); track->set_remote_control_id (ntracks()); + return track; } catch (failed_constructor &err) { error << _("Session: could not create new audio track.") << endmsg; - return 0; + return shared_ptr<AudioTrack> ((AudioTrack*) 0); } - - return track; } -Route* +shared_ptr<Route> Session::new_audio_route (int input_channels, int output_channels) { - Route *bus; char bus_name[32]; uint32_t n = 0; string port; @@ -1797,9 +1784,10 @@ Session::new_audio_route (int input_channels, int output_channels) /* count existing audio busses */ { - Glib::RWLock::ReaderLock lm (route_lock); - for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) { - if (dynamic_cast<AudioTrack*>(*i) == 0) { + shared_ptr<RouteList> r = routes.reader (); + + for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { + if (dynamic_cast<AudioTrack*>((*i).get()) == 0) { if (!(*i)->hidden()) { n++; } @@ -1817,7 +1805,7 @@ Session::new_audio_route (int input_channels, int output_channels) } while (n < (UINT_MAX-1)); try { - bus = new Route (*this, bus_name, -1, -1, -1, -1); + shared_ptr<Route> bus (new Route (*this, bus_name, -1, -1, -1, -1)); if (bus->ensure_io (input_channels, output_channels, false, this)) { error << string_compose (_("cannot configure %1 in/%2 out configuration for new audio track"), @@ -1866,23 +1854,23 @@ Session::new_audio_route (int input_channels, int output_channels) } add_route (bus); + return bus; } catch (failed_constructor &err) { error << _("Session: could not create new route.") << endmsg; - return 0; + return shared_ptr<Route> ((Route*) 0); } - - return bus; } void -Session::add_route (Route* route) +Session::add_route (shared_ptr<Route> route) { { - Glib::RWLock::WriterLock lm (route_lock); - routes.push_front (route); - resort_routes(0); + RCUWriter<RouteList> writer (routes); + shared_ptr<RouteList> r = writer.get_copy (); + r->push_front (route); + resort_routes_using (r); } route->solo_changed.connect (sigc::bind (mem_fun (*this, &Session::route_solo_changed), route)); @@ -1936,40 +1924,43 @@ Session::add_diskstream (AudioDiskstream* dstream) } void -Session::remove_route (Route& route) +Session::remove_route (shared_ptr<Route> route) { { - Glib::RWLock::WriterLock lm (route_lock); - routes.remove (&route); + RCUWriter<RouteList> writer (routes); + shared_ptr<RouteList> rs = writer.get_copy (); + rs->remove (route); /* deleting the master out seems like a dumb idea, but its more of a UI policy issue than our concern. */ - if (&route == _master_out) { - _master_out = 0; + if (route == _master_out) { + _master_out = shared_ptr<Route> ((Route*) 0); } - if (&route == _control_out) { - _control_out = 0; + if (route == _control_out) { + _control_out = shared_ptr<Route> ((Route*) 0); /* cancel control outs for all routes */ vector<string> empty; - for (RouteList::iterator r = routes.begin(); r != routes.end(); ++r) { + for (RouteList::iterator r = rs->begin(); r != rs->end(); ++r) { (*r)->set_control_outs (empty); } } update_route_solo_state (); + + /* writer goes out of scope, forces route list update */ } AudioTrack* at; AudioDiskstream* ds = 0; - if ((at = dynamic_cast<AudioTrack*>(&route)) != 0) { + if ((at = dynamic_cast<AudioTrack*>(route.get())) != 0) { ds = &at->disk_stream(); } @@ -1992,7 +1983,7 @@ Session::remove_route (Route& route) save_state (_current_snapshot_name); - delete &route; + /* all shared ptrs to route should go out of scope here */ } void @@ -2002,19 +1993,20 @@ Session::route_mute_changed (void* src) } void -Session::route_solo_changed (void* src, Route* route) +Session::route_solo_changed (void* src, shared_ptr<Route> route) { if (solo_update_disabled) { // We know already return; } - Glib::RWLock::ReaderLock lm (route_lock); bool is_track; - is_track = (dynamic_cast<AudioTrack*>(route) != 0); + is_track = (dynamic_cast<AudioTrack*>(route.get()) != 0); - for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) { + shared_ptr<RouteList> r = routes.reader (); + + for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { /* soloing a track mutes all other tracks, soloing a bus mutes all other busses */ @@ -2022,7 +2014,7 @@ Session::route_solo_changed (void* src, Route* route) /* don't mess with busses */ - if (dynamic_cast<AudioTrack*>(*i) == 0) { + if (dynamic_cast<AudioTrack*>((*i).get()) == 0) { continue; } @@ -2030,7 +2022,7 @@ Session::route_solo_changed (void* src, Route* route) /* don't mess with tracks */ - if (dynamic_cast<AudioTrack*>(*i) != 0) { + if (dynamic_cast<AudioTrack*>((*i).get()) != 0) { continue; } } @@ -2063,10 +2055,10 @@ Session::route_solo_changed (void* src, Route* route) bool same_thing_soloed = false; bool signal = false; - for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) { + for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { if ((*i)->soloed()) { something_soloed = true; - if (dynamic_cast<AudioTrack*>(*i)) { + if (dynamic_cast<AudioTrack*>((*i).get())) { if (is_track) { same_thing_soloed = true; break; @@ -2117,11 +2109,13 @@ Session::update_route_solo_state () /* this is where we actually implement solo by changing the solo mute setting of each track. */ - - for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) { + + shared_ptr<RouteList> r = routes.reader (); + + for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { if ((*i)->soloed()) { mute = true; - if (dynamic_cast<AudioTrack*>(*i)) { + if (dynamic_cast<AudioTrack*>((*i).get())) { is_track = true; } break; @@ -2137,7 +2131,7 @@ Session::update_route_solo_state () /* nothing is soloed */ - for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) { + for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { (*i)->set_solo_mute (false); } @@ -2158,13 +2152,15 @@ Session::update_route_solo_state () void Session::modify_solo_mute (bool is_track, bool mute) { - for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) { + shared_ptr<RouteList> r = routes.reader (); + + for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { if (is_track) { /* only alter track solo mute */ - if (dynamic_cast<AudioTrack*>(*i)) { + if (dynamic_cast<AudioTrack*>((*i).get())) { if ((*i)->soloed()) { (*i)->set_solo_mute (!mute); } else { @@ -2176,7 +2172,7 @@ Session::modify_solo_mute (bool is_track, bool mute) /* only alter bus solo mute */ - if (!dynamic_cast<AudioTrack*>(*i)) { + if (!dynamic_cast<AudioTrack*>((*i).get())) { if ((*i)->soloed()) { @@ -2208,36 +2204,35 @@ Session::catch_up_on_solo () basis, but needs the global overview that only the session has. */ - Glib::RWLock::ReaderLock lm (route_lock); update_route_solo_state(); } -Route * +shared_ptr<Route> Session::route_by_name (string name) { - Glib::RWLock::ReaderLock lm (route_lock); + shared_ptr<RouteList> r = routes.reader (); - for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) { + for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { if ((*i)->name() == name) { - return* i; + return *i; } } - return 0; + return shared_ptr<Route> ((Route*) 0); } -Route * +shared_ptr<Route> Session::route_by_remote_id (uint32_t id) { - Glib::RWLock::ReaderLock lm (route_lock); + shared_ptr<RouteList> r = routes.reader (); - for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) { + for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { if ((*i)->remote_control_id() == id) { - return* i; + return *i; } } - return 0; + return shared_ptr<Route> ((Route*) 0); } void @@ -3088,7 +3083,7 @@ Session::cancel_audition () } bool -Session::RoutePublicOrderSorter::operator() (Route* a, Route* b) +Session::RoutePublicOrderSorter::operator() (boost::shared_ptr<Route> a, boost::shared_ptr<Route> b) { return a->order_key(N_("signal")) < b->order_key(N_("signal")); } @@ -3134,13 +3129,11 @@ Session::is_auditioning () const void Session::set_all_solo (bool yn) { - { - Glib::RWLock::ReaderLock lm (route_lock); - - for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) { - if (!(*i)->hidden()) { - (*i)->set_solo (yn, this); - } + shared_ptr<RouteList> r = routes.reader (); + + for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { + if (!(*i)->hidden()) { + (*i)->set_solo (yn, this); } } @@ -3150,13 +3143,11 @@ Session::set_all_solo (bool yn) void Session::set_all_mute (bool yn) { - { - Glib::RWLock::ReaderLock lm (route_lock); - - for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) { - if (!(*i)->hidden()) { - (*i)->set_mute (yn, this); - } + shared_ptr<RouteList> r = routes.reader (); + + for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { + if (!(*i)->hidden()) { + (*i)->set_mute (yn, this); } } @@ -3199,10 +3190,9 @@ Session::graph_reordered () return; } - Glib::RWLock::WriterLock lm1 (route_lock); Glib::RWLock::ReaderLock lm2 (diskstream_lock); - resort_routes (0); + resort_routes (); /* force all diskstreams to update their capture offset values to reflect any changes in latencies within the graph. @@ -3228,12 +3218,12 @@ Session::record_enable_all () void Session::record_enable_change_all (bool yn) { - Glib::RWLock::ReaderLock lm1 (route_lock); + shared_ptr<RouteList> r = routes.reader (); - for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) { + for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { AudioTrack* at; - if ((at = dynamic_cast<AudioTrack*>(*i)) != 0) { + if ((at = dynamic_cast<AudioTrack*>((*i).get())) != 0) { at->set_record_enable (yn, this); } } @@ -3499,9 +3489,9 @@ Session::reset_native_file_format () bool Session::route_name_unique (string n) const { - Glib::RWLock::ReaderLock lm (route_lock); + shared_ptr<RouteList> r = routes.reader (); - for (RouteList::const_iterator i = routes.begin(); i != routes.end(); ++i) { + for (RouteList::const_iterator i = r->begin(); i != r->end(); ++i) { if ((*i)->name() == n) { return false; } @@ -3561,13 +3551,13 @@ Session::allocate_pan_automation_buffers (jack_nframes_t nframes, uint32_t howma int Session::freeze (InterThreadInfo& itt) { - Glib::RWLock::ReaderLock lm (route_lock); + shared_ptr<RouteList> r = routes.reader (); - for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) { + for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { AudioTrack *at; - if ((at = dynamic_cast<AudioTrack*>(*i)) != 0) { + if ((at = dynamic_cast<AudioTrack*>((*i).get())) != 0) { /* XXX this is wrong because itt.progress will keep returning to zero at the start of every track. */ @@ -3756,10 +3746,10 @@ uint32_t Session::ntracks () const { uint32_t n = 0; - Glib::RWLock::ReaderLock lm (route_lock); + shared_ptr<RouteList> r = routes.reader (); - for (RouteList::const_iterator i = routes.begin(); i != routes.end(); ++i) { - if (dynamic_cast<AudioTrack*> (*i)) { + for (RouteList::const_iterator i = r->begin(); i != r->end(); ++i) { + if (dynamic_cast<AudioTrack*> ((*i).get())) { ++n; } } @@ -3771,10 +3761,10 @@ uint32_t Session::nbusses () const { uint32_t n = 0; - Glib::RWLock::ReaderLock lm (route_lock); + shared_ptr<RouteList> r = routes.reader (); - for (RouteList::const_iterator i = routes.begin(); i != routes.end(); ++i) { - if (dynamic_cast<AudioTrack*> (*i) == 0) { + for (RouteList::const_iterator i = r->begin(); i != r->end(); ++i) { + if (dynamic_cast<AudioTrack*> ((*i).get()) == 0) { ++n; } } diff --git a/libs/ardour/session_export.cc b/libs/ardour/session_export.cc index ddced9cc5f..ad8ce7c407 100644 --- a/libs/ardour/session_export.cc +++ b/libs/ardour/session_export.cc @@ -485,8 +485,9 @@ Session::prepare_to_export (AudioExportSpecification& spec) /* take everyone out of awrite to avoid disasters */ { - Glib::RWLock::ReaderLock lm (route_lock); - for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) { + boost::shared_ptr<RouteList> r = routes.reader (); + + for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { (*i)->protect_automation (); } } diff --git a/libs/ardour/session_midi.cc b/libs/ardour/session_midi.cc index 5d513de2fc..821f894eeb 100644 --- a/libs/ardour/session_midi.cc +++ b/libs/ardour/session_midi.cc @@ -776,12 +776,12 @@ Session::mmc_record_enable (MIDI::MachineControl &mmc, size_t trk, bool enabled) if (mmc_control) { RouteList::iterator i; - Glib::RWLock::ReaderLock guard (route_lock); + boost::shared_ptr<RouteList> r = routes.reader(); - for (i = routes.begin(); i != routes.end(); ++i) { + for (i = r->begin(); i != r->end(); ++i) { AudioTrack *at; - if ((at = dynamic_cast<AudioTrack*>(*i)) != 0) { + if ((at = dynamic_cast<AudioTrack*>((*i).get())) != 0) { if (trk == at->remote_control_id()) { at->set_record_enable (enabled, &mmc); break; diff --git a/libs/ardour/session_process.cc b/libs/ardour/session_process.cc index 5568b2a16c..2024730292 100644 --- a/libs/ardour/session_process.cc +++ b/libs/ardour/session_process.cc @@ -77,23 +77,20 @@ Session::no_roll (jack_nframes_t nframes, jack_nframes_t offset) jack_nframes_t end_frame = _transport_frame + nframes; int ret = 0; bool declick = get_transport_declick_required(); + boost::shared_ptr<RouteList> r = routes.reader (); if (_click_io) { _click_io->silence (nframes, offset); } - /* XXX we're supposed to have the route_lock while doing this. - this is really bad ... - */ - if (g_atomic_int_get (&processing_prohibited)) { - for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) { + for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { (*i)->silence (nframes, offset); } return 0; } - for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) { + for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { if ((*i)->hidden()) { continue; @@ -118,6 +115,7 @@ Session::process_routes (jack_nframes_t nframes, jack_nframes_t offset) bool record_active; int declick = get_transport_declick_required(); bool rec_monitors = get_rec_monitors_input(); + boost::shared_ptr<RouteList> r = routes.reader (); if (transport_sub_state & StopPendingCapture) { /* force a declick out */ @@ -126,7 +124,7 @@ Session::process_routes (jack_nframes_t nframes, jack_nframes_t offset) record_active = actively_recording(); // || (get_record_enabled() && get_punch_in()); - for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) { + for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { int ret; @@ -161,13 +159,14 @@ Session::silent_process_routes (jack_nframes_t nframes, jack_nframes_t offset) bool record_active = actively_recording(); int declick = get_transport_declick_required(); bool rec_monitors = get_rec_monitors_input(); + boost::shared_ptr<RouteList> r = routes.reader (); if (transport_sub_state & StopPendingCapture) { /* force a declick out */ declick = -1; } - for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) { + for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { int ret; @@ -249,10 +248,14 @@ Session::process_with_events (jack_nframes_t nframes) jack_nframes_t stop_limit; long frames_moved; + /* make sure the auditioner is silent */ + if (auditioner) { auditioner->silence (nframes, 0); } + /* handle any pending events */ + while (pending_events.read (&ev, 1) == 1) { merge_event (ev); } @@ -281,13 +284,12 @@ Session::process_with_events (jack_nframes_t nframes) end_frame = _transport_frame + nframes; { - Glib::RWLock::ReaderLock rm (route_lock, Glib::TRY_LOCK); Glib::RWLock::ReaderLock dsm (diskstream_lock, Glib::TRY_LOCK); Event* this_event; Events::iterator the_next_one; - - if (!rm.locked() || !dsm.locked() || (post_transport_work & (PostTransportLocate|PostTransportStop))) { + + if (!dsm.locked() || (post_transport_work & (PostTransportLocate|PostTransportStop))) { no_roll (nframes, 0); return; } @@ -694,7 +696,7 @@ Session::follow_slave (jack_nframes_t nframes, jack_nframes_t offset) summon_butler (); } - jack_nframes_t frames_moved = (long) floor (_transport_speed * nframes); + int32_t frames_moved = (int32_t) floor (_transport_speed * nframes); if (frames_moved < 0) { decrement_transport_position (-frames_moved); @@ -731,10 +733,9 @@ Session::process_without_events (jack_nframes_t nframes) long frames_moved; { - Glib::RWLock::ReaderLock rm (route_lock, Glib::TRY_LOCK); Glib::RWLock::ReaderLock dsm (diskstream_lock, Glib::TRY_LOCK); - if (!rm.locked() || !dsm.locked() || (post_transport_work & (PostTransportLocate|PostTransportStop))) { + if (!dsm.locked() || (post_transport_work & (PostTransportLocate|PostTransportStop))) { no_roll (nframes, 0); return; } @@ -803,21 +804,23 @@ Session::process_without_events (jack_nframes_t nframes) void Session::process_audition (jack_nframes_t nframes) { - Glib::RWLock::ReaderLock rm (route_lock, Glib::TRY_LOCK); Event* ev; + boost::shared_ptr<RouteList> r = routes.reader (); - if (rm.locked()) { - for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) { - if (!(*i)->hidden()) { - (*i)->silence (nframes, 0); - } + for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { + if (!(*i)->hidden()) { + (*i)->silence (nframes, 0); } } + + /* run the auditioner, and if it says we need butler service, ask for it */ if (auditioner->play_audition (nframes) > 0) { summon_butler (); } + /* handle pending events */ + while (pending_events.read (&ev, 1) == 1) { merge_event (ev); } diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 6fb60ebcab..2f6f57e2d8 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -165,7 +165,6 @@ Session::first_stage_init (string fullpath, string snapshot_name) _slave_type = None; butler_mixdown_buffer = 0; butler_gain_buffer = 0; - auditioner = 0; mmc_control = false; midi_control = true; mmc = 0; @@ -180,8 +179,6 @@ Session::first_stage_init (string fullpath, string snapshot_name) _edit_mode = Slide; pending_edit_mode = _edit_mode; _play_range = false; - _control_out = 0; - _master_out = 0; input_auto_connect = AutoConnectOption (0); output_auto_connect = AutoConnectOption (0); waiting_to_start = false; @@ -216,7 +213,6 @@ Session::first_stage_init (string fullpath, string snapshot_name) waveforms for clicks. */ - _click_io = 0; _clicking = false; click_requested = false; click_data = 0; @@ -1411,10 +1407,10 @@ Session::state(bool full_state) child = node->add_child ("Routes"); { - Glib::RWLock::ReaderLock lm (route_lock); + boost::shared_ptr<RouteList> r = routes.reader (); RoutePublicOrderSorter cmp; - RouteList public_order(routes); + RouteList public_order (*r); public_order.sort (cmp); for (RouteList::iterator i = public_order.begin(); i != public_order.end(); ++i) { @@ -1710,7 +1706,6 @@ Session::load_routes (const XMLNode& node) { XMLNodeList nlist; XMLNodeConstIterator niter; - Route *route; nlist = node.children(); @@ -1718,7 +1713,9 @@ Session::load_routes (const XMLNode& node) for (niter = nlist.begin(); niter != nlist.end(); ++niter) { - if ((route = XMLRouteFactory (**niter)) == 0) { + boost::shared_ptr<Route> route (XMLRouteFactory (**niter)); + + if (route == 0) { error << _("Session: cannot create Route from XML description.") << endmsg; return -1; } @@ -1729,17 +1726,19 @@ Session::load_routes (const XMLNode& node) return 0; } -Route * +boost::shared_ptr<Route> Session::XMLRouteFactory (const XMLNode& node) { if (node.name() != "Route") { - return 0; + return boost::shared_ptr<Route> ((Route*) 0); } if (node.property ("diskstream") != 0 || node.property ("diskstream-id") != 0) { - return new AudioTrack (*this, node); + boost::shared_ptr<Route> x (new AudioTrack (*this, node)); + return x; } else { - return new Route (*this, node); + boost::shared_ptr<Route> x (new Route (*this, node)); + return x; } } @@ -2423,23 +2422,6 @@ Session::load_route_groups (const XMLNode& node, bool edit) return 0; } -void -Session::swap_configuration(Configuration** new_config) -{ - Glib::RWLock::WriterLock lm (route_lock); // jlc - WHY? - Configuration* tmp = *new_config; - *new_config = Config; - Config = tmp; - set_dirty(); -} - -void -Session::copy_configuration(Configuration* new_config) -{ - Glib::RWLock::WriterLock lm (route_lock); - new_config = new Configuration(*Config); -} - static bool state_file_filter (const string &str, void *arg) { @@ -2615,14 +2597,15 @@ Session::GlobalRouteBooleanState Session::get_global_route_boolean (bool (Route::*method)(void) const) { GlobalRouteBooleanState s; - Glib::RWLock::ReaderLock lm (route_lock); + boost::shared_ptr<RouteList> r = routes.reader (); - for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) { + for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { if (!(*i)->hidden()) { RouteBooleanState v; v.first =* i; - v.second = ((*i)->*method)(); + Route* r = (*i).get(); + v.second = (r->*method)(); s.push_back (v); } @@ -2635,9 +2618,9 @@ Session::GlobalRouteMeterState Session::get_global_route_metering () { GlobalRouteMeterState s; - Glib::RWLock::ReaderLock lm (route_lock); + boost::shared_ptr<RouteList> r = routes.reader (); - for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) { + for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { if (!(*i)->hidden()) { RouteMeterState v; @@ -2663,7 +2646,8 @@ void Session::set_global_route_boolean (GlobalRouteBooleanState s, void (Route::*method)(bool, void*), void* arg) { for (GlobalRouteBooleanState::iterator i = s.begin(); i != s.end(); ++i) { - (i->first->*method) (i->second, arg); + Route* r = i->first.get(); + (r->*method) (i->second, arg); } } @@ -3267,6 +3251,10 @@ Session::add_controllable (Controllable* c) void Session::remove_controllable (Controllable* c) { + if (_state_of_the_state | Deletion) { + return; + } + Glib::Mutex::Lock lm (controllables_lock); controllables.remove (c); } diff --git a/libs/ardour/session_transport.cc b/libs/ardour/session_transport.cc index 376dee11a2..03e078ecde 100644 --- a/libs/ardour/session_transport.cc +++ b/libs/ardour/session_transport.cc @@ -191,11 +191,11 @@ Session::realtime_stop (bool abort) void Session::butler_transport_work () { - Glib::RWLock::ReaderLock rm (route_lock); Glib::RWLock::ReaderLock dsm (diskstream_lock); - + boost::shared_ptr<RouteList> r = routes.reader (); + if (post_transport_work & PostTransportCurveRealloc) { - for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) { + for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { (*i)->curve_reallocate(); } } @@ -332,7 +332,9 @@ Session::non_realtime_stop (bool abort) (*i)->transport_stopped (*now, xnow, abort); } - for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) { + boost::shared_ptr<RouteList> r = routes.reader (); + + for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { if (!(*i)->hidden()) { (*i)->set_pending_declick (0); } @@ -544,7 +546,9 @@ Session::set_auto_loop (bool yn) void Session::flush_all_redirects () { - for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) { + boost::shared_ptr<RouteList> r = routes.reader (); + + for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { (*i)->flush_redirects (); } } @@ -1193,11 +1197,12 @@ Session::update_latency_compensation (bool with_stop, bool abort) return; } - Glib::RWLock::ReaderLock lm (route_lock); Glib::RWLock::ReaderLock lm2 (diskstream_lock); _worst_track_latency = 0; - for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) { + boost::shared_ptr<RouteList> r = routes.reader (); + + for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { if (with_stop) { (*i)->handle_transport_stopped (abort, (post_transport_work & PostTransportLocate), (!(post_transport_work & PostTransportLocate) || pending_locate_flush)); @@ -1215,7 +1220,7 @@ Session::update_latency_compensation (bool with_stop, bool abort) } } - for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) { + for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { (*i)->set_latency_delay (_worst_track_latency); } @@ -1225,7 +1230,7 @@ Session::update_latency_compensation (bool with_stop, bool abort) _engine.update_total_latencies (); } - set_worst_io_latencies (false); + set_worst_io_latencies (); /* reflect any changes in latencies into capture offsets */ diff --git a/libs/pbd/whitespace.cc b/libs/pbd/whitespace.cc index 7f74940457..e35a8a8c0e 100644 --- a/libs/pbd/whitespace.cc +++ b/libs/pbd/whitespace.cc @@ -7,9 +7,11 @@ strip_whitespace_edges (string& str) { string::size_type i; string::size_type len; - string::size_type s; + string::size_type s; len = str.length(); + + /* strip front */ for (i = 0; i < len; ++i) { if (isgraph (str[i])) { @@ -17,14 +19,26 @@ strip_whitespace_edges (string& str) } } - s = i; + /* strip back */ + + if (len > 1) { + + s = i; + i = len - 1; + + do { + if (isgraph (str[i]) || i == 0) { + break; + } - for (i = len - 1; i >= 0; --i) { - if (isgraph (str[i])) { - break; - } - } + --i; + + } while (true); + + str = str.substr (s, (i - s) + 1); - str = str.substr (s, (i - s) + 1); + } else { + str = str.substr (s); + } } diff --git a/libs/surfaces/control_protocol/control_protocol.cc b/libs/surfaces/control_protocol/control_protocol.cc index 10295bc698..dd9adc206e 100644 --- a/libs/surfaces/control_protocol/control_protocol.cc +++ b/libs/surfaces/control_protocol/control_protocol.cc @@ -49,7 +49,7 @@ void ControlProtocol::next_track (uint32_t initial_id) { uint32_t limit = session->nroutes(); - Route* cr = route_table[0]; + boost::shared_ptr<Route> cr = route_table[0]; uint32_t id; if (cr) { @@ -88,7 +88,7 @@ void ControlProtocol::prev_track (uint32_t initial_id) { uint32_t limit = session->nroutes() - 1; - Route* cr = route_table[0]; + boost::shared_ptr<Route> cr = route_table[0]; uint32_t id; if (cr) { @@ -128,29 +128,32 @@ void ControlProtocol::set_route_table_size (uint32_t size) { while (route_table.size() < size) { - route_table.push_back (0); + route_table.push_back (boost::shared_ptr<Route> ((Route*) 0)); } } void -ControlProtocol::set_route_table (uint32_t table_index, ARDOUR::Route*) +ControlProtocol::set_route_table (uint32_t table_index, boost::shared_ptr<ARDOUR::Route> r) { + if (table_index >= route_table.size()) { + return; + } + + route_table[table_index] = r; + + // XXX SHAREDPTR need to handle r->GoingAway } bool ControlProtocol::set_route_table (uint32_t table_index, uint32_t remote_control_id) { - if (table_index >= route_table.size()) { - return false; - } - - Route* r = session->route_by_remote_id (remote_control_id); + boost::shared_ptr<Route> r = session->route_by_remote_id (remote_control_id); if (!r) { return false; } - - route_table[table_index] = r; + + set_route_table (table_index, r); return true; } @@ -162,9 +165,9 @@ ControlProtocol::route_set_rec_enable (uint32_t table_index, bool yn) return; } - Route* r = route_table[table_index]; + boost::shared_ptr<Route> r = route_table[table_index]; - AudioTrack* at = dynamic_cast<AudioTrack*>(r); + boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack>(r); if (at) { at->set_record_enable (yn, this); @@ -178,9 +181,9 @@ ControlProtocol::route_get_rec_enable (uint32_t table_index) return false; } - Route* r = route_table[table_index]; + boost::shared_ptr<Route> r = route_table[table_index]; - AudioTrack* at = dynamic_cast<AudioTrack*>(r); + boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack>(r); if (at) { return at->record_enabled (); @@ -197,7 +200,7 @@ ControlProtocol::route_get_gain (uint32_t table_index) return 0.0f; } - Route* r = route_table[table_index]; + boost::shared_ptr<Route> r = route_table[table_index]; if (r == 0) { return 0.0f; @@ -213,7 +216,7 @@ ControlProtocol::route_set_gain (uint32_t table_index, float gain) return; } - Route* r = route_table[table_index]; + boost::shared_ptr<Route> r = route_table[table_index]; if (r != 0) { r->set_gain (gain, this); @@ -227,7 +230,7 @@ ControlProtocol::route_get_effective_gain (uint32_t table_index) return 0.0f; } - Route* r = route_table[table_index]; + boost::shared_ptr<Route> r = route_table[table_index]; if (r == 0) { return 0.0f; @@ -244,7 +247,7 @@ ControlProtocol::route_get_peak_input_power (uint32_t table_index, uint32_t whic return 0.0f; } - Route* r = route_table[table_index]; + boost::shared_ptr<Route> r = route_table[table_index]; if (r == 0) { return 0.0f; @@ -261,7 +264,7 @@ ControlProtocol::route_get_muted (uint32_t table_index) return false; } - Route* r = route_table[table_index]; + boost::shared_ptr<Route> r = route_table[table_index]; if (r == 0) { return false; @@ -277,7 +280,7 @@ ControlProtocol::route_set_muted (uint32_t table_index, bool yn) return; } - Route* r = route_table[table_index]; + boost::shared_ptr<Route> r = route_table[table_index]; if (r != 0) { r->set_mute (yn, this); @@ -292,7 +295,7 @@ ControlProtocol::route_get_soloed (uint32_t table_index) return false; } - Route* r = route_table[table_index]; + boost::shared_ptr<Route> r = route_table[table_index]; if (r == 0) { return false; @@ -308,7 +311,7 @@ ControlProtocol::route_set_soloed (uint32_t table_index, bool yn) return; } - Route* r = route_table[table_index]; + boost::shared_ptr<Route> r = route_table[table_index]; if (r != 0) { r->set_solo (yn, this); @@ -322,7 +325,7 @@ ControlProtocol:: route_get_name (uint32_t table_index) return ""; } - Route* r = route_table[table_index]; + boost::shared_ptr<Route> r = route_table[table_index]; if (r == 0) { return ""; diff --git a/libs/surfaces/control_protocol/control_protocol/control_protocol.h b/libs/surfaces/control_protocol/control_protocol/control_protocol.h index 2bd23f5b48..8be652b9df 100644 --- a/libs/surfaces/control_protocol/control_protocol/control_protocol.h +++ b/libs/surfaces/control_protocol/control_protocol/control_protocol.h @@ -25,6 +25,7 @@ #include <string> #include <vector> #include <list> +#include <boost/shared_ptr.hpp> #include <sigc++/sigc++.h> #include <pbd/stateful.h> #include <control_protocol/basic_ui.h> @@ -73,7 +74,7 @@ class ControlProtocol : public sigc::trackable, public Stateful, public BasicUI */ void set_route_table_size (uint32_t size); - void set_route_table (uint32_t table_index, ARDOUR::Route*); + void set_route_table (uint32_t table_index, boost::shared_ptr<ARDOUR::Route>); bool set_route_table (uint32_t table_index, uint32_t remote_control_id); void route_set_rec_enable (uint32_t table_index, bool yn); @@ -94,7 +95,7 @@ class ControlProtocol : public sigc::trackable, public Stateful, public BasicUI std::string route_get_name (uint32_t table_index); protected: - std::vector<ARDOUR::Route*> route_table; + std::vector<boost::shared_ptr<ARDOUR::Route> > route_table; std::string _name; bool _active; |