diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2015-01-16 12:17:09 -0500 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2015-06-29 14:18:13 -0400 |
commit | ba981a14c4fb7e6bfe1a7434e81cdecac422c838 (patch) | |
tree | ef80088a3f00d27475d48023975cc6cba7794575 /libs | |
parent | 2a5dbff87ba42d84e86285c92b9afc69f1edf07b (diff) |
initial version of playback priority design. No GUI control over options yet
Conflicts:
libs/ardour/ardour/session.h
libs/ardour/ardour/types.h
libs/ardour/enums.cc
libs/ardour/session_transport.cc
system_config
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/ardour/rc_configuration_vars.h | 1 | ||||
-rw-r--r-- | libs/ardour/ardour/session.h | 16 | ||||
-rw-r--r-- | libs/ardour/ardour/types.h | 10 | ||||
-rw-r--r-- | libs/ardour/enums.cc | 25 | ||||
-rw-r--r-- | libs/ardour/session.cc | 31 | ||||
-rw-r--r-- | libs/ardour/session_transport.cc | 96 |
6 files changed, 143 insertions, 36 deletions
diff --git a/libs/ardour/ardour/rc_configuration_vars.h b/libs/ardour/ardour/rc_configuration_vars.h index 10587aba2e..1defe3d54a 100644 --- a/libs/ardour/ardour/rc_configuration_vars.h +++ b/libs/ardour/ardour/rc_configuration_vars.h @@ -163,6 +163,7 @@ CONFIG_VARIABLE (ShuttleUnits, shuttle_units, "shuttle-units", Percentage) CONFIG_VARIABLE (float, shuttle_max_speed, "shuttle-max-speed", 8.0f) CONFIG_VARIABLE (bool, locate_while_waiting_for_sync, "locate-while-waiting-for-sync", false) CONFIG_VARIABLE (bool, disable_disarm_during_roll, "disable-disarm-during-roll", false) +CONFIG_VARIABLE (AutoReturnTarget, auto_return_target_list, "auto-return-target-list", AutoReturnTarget(LastLocate|RangeSelectionStart|Loop|RegionSelectionStart)) /* metering */ diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 48243179f8..0714077302 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -847,6 +847,14 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop void maybe_update_session_range (framepos_t, framepos_t); + /* temporary hacks to allow selection to be pushed from GUI into backend. + Whenever we move the selection object into libardour, these will go away. + */ + void set_range_selection (framepos_t start, framepos_t end); + void set_object_selection (framepos_t start, framepos_t end); + void clear_range_selection (); + void clear_object_selection (); + /* buffers for gain and pan */ gain_t* gain_automation_buffer () const; @@ -1445,6 +1453,8 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop void engine_halted (); void xrun_recovery (); void set_track_loop (bool); + bool select_playhead_priority_target (framepos_t&); + void follow_playhead_priority (); /* These are synchronous and so can only be called from within the process * cycle @@ -1669,6 +1679,12 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop void set_play_range (std::list<AudioRange>&, bool leave_rolling); void unset_play_range (); + /* temporary hacks to allow selection to be pushed from GUI into backend + Whenever we move the selection object into libardour, these will go away. + */ + Evoral::Range<framepos_t> _range_selection; + Evoral::Range<framepos_t> _object_selection; + /* main outs */ uint32_t main_outs; diff --git a/libs/ardour/ardour/types.h b/libs/ardour/ardour/types.h index 8d7fb125a1..ba521f3b71 100644 --- a/libs/ardour/ardour/types.h +++ b/libs/ardour/ardour/types.h @@ -635,6 +635,13 @@ namespace ARDOUR { Custom, }; + enum AutoReturnTarget { + LastLocate = 0x1, + RangeSelectionStart = 0x2, + Loop = 0x4, + RegionSelectionStart = 0x8, + }; + } // namespace ARDOUR @@ -662,6 +669,7 @@ std::istream& operator>>(std::istream& o, ARDOUR::PositionLockStyle& sf); std::istream& operator>>(std::istream& o, ARDOUR::FadeShape& sf); std::istream& operator>>(std::istream& o, ARDOUR::RegionSelectionAfterSplit& sf); std::istream& operator>>(std::istream& o, ARDOUR::BufferingPreset& var); +std::istream& operator>>(std::istream& o, ARDOUR::AutoReturnTarget& sf); std::ostream& operator<<(std::ostream& o, const ARDOUR::SampleFormat& sf); std::ostream& operator<<(std::ostream& o, const ARDOUR::HeaderFormat& sf); @@ -684,7 +692,7 @@ std::ostream& operator<<(std::ostream& o, const ARDOUR::PositionLockStyle& sf); std::ostream& operator<<(std::ostream& o, const ARDOUR::FadeShape& sf); std::ostream& operator<<(std::ostream& o, const ARDOUR::RegionSelectionAfterSplit& sf); std::ostream& operator<<(std::ostream& o, const ARDOUR::BufferingPreset& var); - +std::ostream& operator<<(std::ostream& o, const ARDOUR::AutoReturnTarget& sf); /* because these operators work on types which can be used when making a UI_CONFIG_VARIABLE (in gtk2_ardour) we need them to be exported. diff --git a/libs/ardour/enums.cc b/libs/ardour/enums.cc index 6bad252516..24b060ec28 100644 --- a/libs/ardour/enums.cc +++ b/libs/ardour/enums.cc @@ -131,7 +131,8 @@ setup_enum_writer () MTC_Status _MIDI_MTC_Status; Evoral::OverlapType _OverlapType; BufferingPreset _BufferingPreset; - + AutoReturnTarget _AutoReturnTarget; + #define REGISTER(e) enum_writer.register_distinct (typeid(e).name(), i, s); i.clear(); s.clear() #define REGISTER_BITS(e) enum_writer.register_bits (typeid(e).name(), i, s); i.clear(); s.clear() #define REGISTER_ENUM(e) i.push_back (e); s.push_back (#e) @@ -666,6 +667,12 @@ setup_enum_writer () REGISTER_ENUM (Large); REGISTER_ENUM (Custom); REGISTER(_BufferingPreset); + + REGISTER_ENUM (LastLocate); + REGISTER_ENUM (RangeSelectionStart); + REGISTER_ENUM (Loop); + REGISTER_ENUM (RegionSelectionStart); + REGISTER_BITS (_AutoReturnTarget); } } /* namespace ARDOUR */ @@ -1025,3 +1032,19 @@ std::ostream& operator<<(std::ostream& o, const ARDOUR::BufferingPreset& var) std::string s = enum_2_string (var); return o << s; } + +std::istream& operator>>(std::istream& o, AutoReturnTarget& var) +{ + std::string s; + o >> s; + var = (AutoReturnTarget) string_2_enum (s, var); + return o; +} + +std::ostream& operator<<(std::ostream& o, const AutoReturnTarget& var) +{ + std::string s = enum_2_string (var); + return o << s; +} + + diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index b02bcb8dec..27b1aa461f 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -271,6 +271,8 @@ Session::Session (AudioEngine &eng, , click_emphasis_length (0) , _clicks_cleared (0) , _play_range (false) + , _range_selection (-1,-1) + , _object_selection (-1,-1) , main_outs (0) , first_file_data_format_reset (true) , first_file_header_format_reset (true) @@ -6109,3 +6111,32 @@ Session::reconnect_ltc_output () #endif } } + +void +Session::set_range_selection (framepos_t start, framepos_t end) +{ + cerr << "set range selection " << start << " .. " << end << endl; + _range_selection = Evoral::Range<framepos_t> (start, end); + follow_playhead_priority (); +} + +void +Session::set_object_selection (framepos_t start, framepos_t end) +{ + _object_selection = Evoral::Range<framepos_t> (start, end); + follow_playhead_priority (); +} + +void +Session::clear_range_selection () +{ + _range_selection = Evoral::Range<framepos_t> (-1,-1); + follow_playhead_priority (); +} + +void +Session::clear_object_selection () +{ + _object_selection = Evoral::Range<framepos_t> (-1,-1); + follow_playhead_priority (); +} diff --git a/libs/ardour/session_transport.cc b/libs/ardour/session_transport.cc index 2656fd0d83..994a4b89a1 100644 --- a/libs/ardour/session_transport.cc +++ b/libs/ardour/session_transport.cc @@ -494,6 +494,62 @@ Session::non_realtime_locate () clear_clicks (); } +bool +Session::select_playhead_priority_target (framepos_t& jump_to) +{ + jump_to = -1; + + AutoReturnTarget autoreturn = Config->get_auto_return_target_list (); + + if (!autoreturn) { + return false; + } + + /* Note that the order of checking each AutoReturnTarget flag defines + the priority each flag. + */ + + if (autoreturn & LastLocate) { + jump_to = _last_roll_location; + } + + if (jump_to < 0 && (autoreturn & RangeSelectionStart)) { + if (!_range_selection.empty()) { + jump_to = _range_selection.from; + } + } + + if (jump_to < 0 && (autoreturn & Loop)) { + /* don't try to handle loop play when synced to JACK */ + + if (!synced_to_engine()) { + Location *location = _locations->auto_loop_location(); + + if (location) { + jump_to = location->start(); + } + } + } + + if (jump_to < 0 && (autoreturn & RegionSelectionStart)) { + if (!_object_selection.empty()) { + jump_to = _object_selection.from; + } + } + + return jump_to >= 0; +} + +void +Session::follow_playhead_priority () +{ + framepos_t target; + + if (select_playhead_priority_target (target)) { + request_locate (target); + } +} + void Session::non_realtime_stop (bool abort, int on_entry, bool& finished) { @@ -576,8 +632,7 @@ Session::non_realtime_stop (bool abort, int on_entry, bool& finished) update_latency_compensation (); } - bool const auto_return_enabled = - (!config.get_external_sync() && (config.get_auto_return() || abort)); + bool const auto_return_enabled = (!config.get_external_sync() && (Config->get_auto_return_target_list() || abort)); if (auto_return_enabled || (ptw & PostTransportLocate) || @@ -603,40 +658,13 @@ Session::non_realtime_stop (bool abort, int on_entry, bool& finished) do_locate = true; } else { - if (config.get_auto_return()) { - - if (play_loop) { - - /* don't try to handle loop play when synced to JACK */ + framepos_t jump_to; - if (!synced_to_engine()) { + if (select_playhead_priority_target (jump_to)) { - Location *location = _locations->auto_loop_location(); - - if (location != 0) { - _transport_frame = location->start(); - } else { - _transport_frame = _last_roll_location; - } - do_locate = true; - } - - } else if (_play_range) { - - /* return to start of range */ - - if (!current_audio_range.empty()) { - _transport_frame = current_audio_range.front().start; - do_locate = true; - } - - } else { - - /* regular auto-return */ + _transport_frame = jump_to; + do_locate = true; - _transport_frame = _last_roll_location; - do_locate = true; - } } else if (abort) { _transport_frame = _last_roll_location; @@ -1218,7 +1246,7 @@ Session::set_transport_speed (double speed, framepos_t destination_frame, bool a } _engine.transport_stop (); } else { - bool const auto_return_enabled = (!config.get_external_sync() && (config.get_auto_return() || abort)); + bool const auto_return_enabled = (!config.get_external_sync() && (Config->get_auto_return_target_list() || abort)); if (!auto_return_enabled) { _requested_return_frame = destination_frame; |