From 8faf95b9bdf8985b25e839419acffc495c8107e3 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 7 Dec 2009 23:51:46 +0000 Subject: [PATCH] better, cleaner, more generic version of real-time ping pong, still just for one case of rec-enable but more coming soon git-svn-id: svn://localhost/ardour2/branches/3.0@6325 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/rc_option_editor.cc | 2 +- gtk2_ardour/route_ui.cc | 11 +++---- libs/ardour/ardour/session.h | 16 +++------- libs/ardour/ardour/session_event.h | 11 ++++--- libs/ardour/enums.cc | 1 - libs/ardour/session.cc | 47 +++--------------------------- libs/ardour/session_process.cc | 26 ----------------- 7 files changed, 18 insertions(+), 96 deletions(-) diff --git a/gtk2_ardour/rc_option_editor.cc b/gtk2_ardour/rc_option_editor.cc index 8773db5c48..8597995a88 100644 --- a/gtk2_ardour/rc_option_editor.cc +++ b/gtk2_ardour/rc_option_editor.cc @@ -1003,7 +1003,7 @@ RCOptionEditor::RCOptionEditor () add_option (_("Transport"), new BoolOption ( "disable-disarm-during-roll", - _("Disable record disarm when transport is rolling"), + _("Disable per-track record disarm while rolling"), mem_fun (*_rc_config, &RCConfiguration::get_disable_disarm_during_roll), mem_fun (*_rc_config, &RCConfiguration::set_disable_disarm_during_roll) )); diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc index a8e97f081f..ba706242fa 100644 --- a/gtk2_ardour/route_ui.cc +++ b/gtk2_ardour/route_ui.cc @@ -457,7 +457,6 @@ RouteUI::post_rec_cleanup (SessionEvent* ev, UndoTransaction* undo, Session::Glo { ENSURE_GUI_THREAD (bind (mem_fun (*this, &RouteUI::post_rec_cleanup), ev, undo, cmd)); - delete ev->routes; delete ev; check_rec_enable_sensitivity (); @@ -493,13 +492,11 @@ RouteUI::rec_enable_press(GdkEventButton* ev) UndoTransaction* undo = _session.start_reversible_command (_("rec-enable change")); Session::GlobalRecordEnableStateCommand *cmd = new Session::GlobalRecordEnableStateCommand(_session, this); - sigc::slot callback = bind (sigc::mem_fun (*this, &RouteUI::post_rec_cleanup), undo, cmd); + SessionEvent* ev = new SessionEvent (SessionEvent::RealTimeOperation, SessionEvent::Add, SessionEvent::Immediate, 0, 0.0); + ev->rt_slot = bind (sigc::mem_fun (_session, &Session::set_all_record_enable), _session.get_routes(), !rec_enable_button->get_active()); + ev->rt_return = bind (sigc::mem_fun (*this, &RouteUI::post_rec_cleanup), undo, cmd); - if (rec_enable_button->get_active()) { - _session.record_disenable_all (callback); - } else { - _session.record_enable_all (callback); - } + _session.queue_event (ev); } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 18af14a313..ed34c387e8 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -303,6 +303,8 @@ class Session : public PBD::StatefulDestructible, public SessionEventManager, pu sigc::signal RouteAdded; sigc::signal RouteGroupChanged; + void queue_event (SessionEvent*); + void request_roll_at_and_return (nframes_t start, nframes_t return_to); void request_bounded_roll (nframes_t start, nframes_t end); void request_stop (bool abort = false, bool clear_state = false); @@ -330,12 +332,6 @@ class Session : public PBD::StatefulDestructible, public SessionEventManager, pu int remove_region_from_region_list (boost::shared_ptr); - /* ask the session to do realtime things, in RT context, then get back to us via a callback (which must be - cross-thread or RT safe, since it too is called from RT context) - */ - - void request_real_time_operation (sigc::slot rt_op, sigc::slot callback); - nframes_t get_maximum_extent () const; nframes_t current_end_frame() const { return end_location->start(); } nframes_t current_start_frame() const { return start_location->start(); } @@ -626,9 +622,8 @@ class Session : public PBD::StatefulDestructible, public SessionEventManager, pu sigc::signal SoloActive; sigc::signal SoloChanged; - - void record_disenable_all (sigc::slot); - void record_enable_all (sigc::slot); + + void set_all_record_enable (boost::shared_ptr, bool); /* control/master out */ @@ -1188,7 +1183,6 @@ class Session : public PBD::StatefulDestructible, public SessionEventManager, pu /* SessionEventManager interface */ - void queue_event (SessionEvent*); void process_event (SessionEvent*); void set_next_event (); void cleanup_event (SessionEvent*,int); @@ -1475,8 +1469,6 @@ class Session : public PBD::StatefulDestructible, public SessionEventManager, pu void jack_timebase_callback (jack_transport_state_t, nframes_t, jack_position_t*, int); int jack_sync_callback (jack_transport_state_t, jack_position_t*); void reset_jack_connection (jack_client_t* jack); - void record_enable_change_all (bool yn, sigc::slot); - void do_record_enable_change_all (RouteList*, bool); void process_rtop (SessionEvent*); XMLNode& state(bool); diff --git a/libs/ardour/ardour/session_event.h b/libs/ardour/ardour/session_event.h index a903e3cd4f..7775f4b1ad 100644 --- a/libs/ardour/ardour/session_event.h +++ b/libs/ardour/ardour/session_event.h @@ -32,7 +32,6 @@ struct SessionEvent { Audition, InputConfigurationChange, SetPlayAudioRange, - SetRecordEnable, RealTimeOperation, /* only one of each of these events can be queued at any one time */ @@ -64,9 +63,9 @@ struct SessionEvent { union { bool second_yes_or_no; - RouteList* routes; }; + boost::shared_ptr routes; sigc::slot rt_slot; /* what to call in RT context */ sigc::slot rt_return; /* called after rt_slot, with this event as an argument */ @@ -118,10 +117,8 @@ class SessionEventManager { SessionEventManager () : pending_events (2048){} virtual ~SessionEventManager() {} - void add_event (nframes64_t action_frame, SessionEvent::Type type, nframes64_t target_frame = 0); - void remove_event (nframes64_t frame, SessionEvent::Type type); + virtual void queue_event (SessionEvent *ev) = 0; void clear_events (SessionEvent::Type type); - protected: RingBuffer pending_events; @@ -143,8 +140,10 @@ class SessionEventManager { bool _remove_event (SessionEvent *); void _clear_event_type (SessionEvent::Type); + void add_event (nframes64_t action_frame, SessionEvent::Type type, nframes64_t target_frame = 0); + void remove_event (nframes64_t frame, SessionEvent::Type type); + virtual void process_event(SessionEvent*) = 0; - virtual void queue_event (SessionEvent *ev) = 0; virtual void set_next_event () = 0; }; diff --git a/libs/ardour/enums.cc b/libs/ardour/enums.cc index 0676973e53..be61b2acb2 100644 --- a/libs/ardour/enums.cc +++ b/libs/ardour/enums.cc @@ -307,7 +307,6 @@ setup_enum_writer () REGISTER_CLASS_ENUM (SessionEvent, Audition); REGISTER_CLASS_ENUM (SessionEvent, InputConfigurationChange); REGISTER_CLASS_ENUM (SessionEvent, SetPlayAudioRange); - REGISTER_CLASS_ENUM (SessionEvent, SetRecordEnable); REGISTER_CLASS_ENUM (SessionEvent, StopOnce); REGISTER_CLASS_ENUM (SessionEvent, AutoLoop); REGISTER (_SessionEvent_Type); diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 5c8c2254f9..cdd5041856 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -3605,53 +3605,12 @@ Session::graph_reordered () } void -Session::record_disenable_all (sigc::slot callback) +Session::set_all_record_enable (boost::shared_ptr rl, bool yn) { if (!writable()) { return; } - record_enable_change_all (false, callback); -} - -void -Session::record_enable_all (sigc::slot callback) -{ - if (!writable()) { - return; - } - - record_enable_change_all (true, callback); -} - -void -Session::record_enable_change_all (bool yn, sigc::slot callback) -{ - shared_ptr r = routes.reader (); - RouteList* tracks = new RouteList; - - for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { - boost::shared_ptr t; - - if (boost::dynamic_pointer_cast(*i) != 0) { - tracks->push_back (*i); - } - } - - sigc::slot rt_op = bind (sigc::mem_fun (*this, &Session::do_record_enable_change_all), tracks, yn); - - SessionEvent* ev = new SessionEvent (SessionEvent::RealTimeOperation, SessionEvent::Add, SessionEvent::Immediate, 0, 0.0); - - ev->routes = tracks; // set here so that callback can delete it - ev->rt_slot = rt_op; - ev->rt_return = callback; - - queue_event (ev); -} - -void -Session::do_record_enable_change_all (RouteList* rl, bool yn) -{ for (RouteList::iterator i = rl->begin(); i != rl->end(); ) { boost::shared_ptr t; @@ -3663,7 +3622,9 @@ Session::do_record_enable_change_all (RouteList* rl, bool yn) } else { ++i; } - } + } else { + ++i; + } } set_dirty (); diff --git a/libs/ardour/session_process.cc b/libs/ardour/session_process.cc index 22c6abfc73..078ef260c6 100644 --- a/libs/ardour/session_process.cc +++ b/libs/ardour/session_process.cc @@ -983,18 +983,6 @@ Session::set_next_event () } } -void -Session::cleanup_event (SessionEvent* ev, int status) -{ - switch (ev->type) { - case SessionEvent::SetRecordEnable: - delete ev->routes; - break; - default: - break; - } -} - void Session::process_event (SessionEvent* ev) { @@ -1134,10 +1122,6 @@ Session::process_event (SessionEvent* ev) set_play_range (ev->audio_range, (ev->speed == 1.0f)); break; - case SessionEvent::SetRecordEnable: - do_record_enable_change_all (ev->routes, ev->yes_or_no); - break; - case SessionEvent::RealTimeOperation: process_rtop (ev); del = false; // other side of RT request needs to clean up @@ -1158,16 +1142,6 @@ Session::process_event (SessionEvent* ev) } } - -void -Session::request_real_time_operation (sigc::slot rt_op, sigc::slot callback) -{ - SessionEvent* ev = new SessionEvent (SessionEvent::RealTimeOperation, SessionEvent::Add, SessionEvent::Immediate, 0, 0.0); - ev->rt_slot = rt_op; - ev->rt_return = callback; - queue_event (ev); -} - void Session::process_rtop (SessionEvent* ev) { -- 2.30.2