diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2011-03-09 05:19:44 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2011-03-09 05:19:44 +0000 |
commit | 8849cb428741d7d60261d1e44ceec665912281f5 (patch) | |
tree | 94649231bdf12dfb30cf2f43b8e9029ba2b0cb2b /libs/ardour/diskstream.cc | |
parent | 30ac00b92d420da94b3cd3d9dd7fbe200ee69667 (diff) |
add new concept for managing alignment style (AlignChoice); switch to using worst_playback_latency() just about everywhere we were using worst_output_latency() - the former includes plugin latency. answer appears to break earlier fixes to alignment, but is semantically right, so plan to investigate in another 8 hours or so
git-svn-id: svn://localhost/ardour2/branches/3.0@9112 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/diskstream.cc')
-rw-r--r-- | libs/ardour/diskstream.cc | 53 |
1 files changed, 42 insertions, 11 deletions
diff --git a/libs/ardour/diskstream.cc b/libs/ardour/diskstream.cc index 97780972f8..647d62e00f 100644 --- a/libs/ardour/diskstream.cc +++ b/libs/ardour/diskstream.cc @@ -32,11 +32,12 @@ #include <sys/mman.h> +#include <glibmm/thread.h> + #include "pbd/error.h" #include "pbd/basename.h" -#include <glibmm/thread.h> -#include "pbd/xml++.h" #include "pbd/memento_command.h" +#include "pbd/xml++.h" #include "ardour/ardour.h" #include "ardour/audioengine.h" @@ -93,6 +94,7 @@ Diskstream::Diskstream (Session &sess, const string &name, Flag flag) , last_recordable_frame (max_framepos) , last_possibly_recording (0) , _alignment_style (ExistingMaterial) + , _alignment_choice (Automatic) , _scrubbing (false) , _slaved (false) , loop_location (0) @@ -110,8 +112,6 @@ Diskstream::Diskstream (Session &sess, const string &name, Flag flag) , _read_data_count (0) , _write_data_count (0) , in_set_state (false) - , _persistent_alignment_style (ExistingMaterial) - , first_input_change (true) , _flags (flag) , deprecated_io_node (0) { @@ -137,6 +137,7 @@ Diskstream::Diskstream (Session& sess, const XMLNode& /*node*/) , last_recordable_frame (max_framepos) , last_possibly_recording (0) , _alignment_style (ExistingMaterial) + , _alignment_choice (Automatic) , _scrubbing (false) , _slaved (false) , loop_location (0) @@ -154,8 +155,6 @@ Diskstream::Diskstream (Session& sess, const XMLNode& /*node*/) , _read_data_count (0) , _write_data_count (0) , in_set_state (false) - , _persistent_alignment_style (ExistingMaterial) - , first_input_change (true) , _flags (Recordable) , deprecated_io_node (0) { @@ -270,6 +269,7 @@ Diskstream::set_capture_offset () DEBUG_TRACE (DEBUG::CaptureAlignment, string_compose ("%1: using IO latency, capture offset set to %2\n", name(), _capture_offset)); } + void Diskstream::set_align_style (AlignStyle a) { @@ -283,6 +283,30 @@ Diskstream::set_align_style (AlignStyle a) } } +void +Diskstream::set_align_choice (AlignChoice a) +{ + if (record_enabled() && _session.actively_recording()) { + return; + } + + if (a != _alignment_choice) { + _alignment_choice = a; + + switch (_alignment_choice) { + case Automatic: + set_align_style_from_io (); + break; + case UseExistingMaterial: + set_align_style (ExistingMaterial); + break; + case UseCaptureTime: + set_align_style (CaptureTime); + break; + } + } +} + int Diskstream::set_loop (Location *location) { @@ -452,6 +476,7 @@ Diskstream::get_state () node->add_property("id", buf); snprintf (buf, sizeof(buf), "%f", _visible_speed); node->add_property ("speed", buf); + node->add_property ("capture-alignment", enum_2_string (_alignment_choice)); if (_extra_xml) { node->add_child_copy (*_extra_xml); @@ -483,6 +508,12 @@ Diskstream::set_state (const XMLNode& node, int /*version*/) _flags = Flag (string_2_enum (prop->value(), _flags)); } + if ((prop = node.property (X_("capture-alignment"))) != 0) { + _alignment_choice = AlignChoice (string_2_enum (prop->value(), _alignment_choice)); + } else { + _alignment_choice = Automatic; + } + if ((prop = node.property ("playlist")) == 0) { return -1; } @@ -621,10 +652,10 @@ Diskstream::check_record_status (framepos_t transport_frame, bool can_record) last_recordable_frame = max_framepos; capture_start_frame = transport_frame; - DEBUG_TRACE (DEBUG::CaptureAlignment, string_compose ("%1: @ %7 basic FRF = %2 LRF = %3 CSF = %4 CO = %5, WLO = %6\n", + DEBUG_TRACE (DEBUG::CaptureAlignment, string_compose ("%1: @ %7 basic FRF = %2 LRF = %3 CSF = %4 CO = %5, WPL = %6\n", name(), first_recordable_frame, last_recordable_frame, capture_start_frame, _capture_offset, - _session.worst_output_latency(), + _session.worst_playback_latency(), transport_frame)); @@ -635,13 +666,13 @@ Diskstream::check_record_status (framepos_t transport_frame, bool can_record) if (_alignment_style == ExistingMaterial) { - /* audio played by ardour will take (up to) _session.worst_output_latency() ("WOL") to + /* audio played by ardour will take (up to) _session.worst_playback_latency() ("WOL") to appear at the speakers; audio played at the time when it does appear at the speakers will take _capture_offset to arrive back here. we've already added _capture_offset, so now add WOL. */ - first_recordable_frame += _session.worst_output_latency(); + first_recordable_frame += _session.worst_playback_latency(); DEBUG_TRACE (DEBUG::CaptureAlignment, string_compose ("\tROLL: shift FRF by delta between WOL %1\n", first_recordable_frame)); } else { @@ -657,7 +688,7 @@ Diskstream::check_record_status (framepos_t transport_frame, bool can_record) if (_alignment_style == ExistingMaterial) { /* see comment in ExistingMaterial block above */ - first_recordable_frame += _session.worst_output_latency(); + first_recordable_frame += _session.worst_playback_latency(); DEBUG_TRACE (DEBUG::CaptureAlignment, string_compose ("\tMANUAL PUNCH: shift FRF by delta between WOL and CO to %1\n", first_recordable_frame)); } else { |