framecnt_t check_initial_delay (framecnt_t nframes, framepos_t&);
virtual void monitoring_changed (bool, PBD::Controllable::GroupControlDisposition);
+ AlignChoice _alignment_choice;
+ void set_align_choice_from_io ();
+ void input_changed ();
+
private:
void parameter_changed (std::string const & p);
if ((a != _alignment_style) || force) {
_alignment_style = a;
+ cerr << name() << " using align style " << enum_2_string (_alignment_style) << endl;
set_capture_offset ();
AlignmentStyleChanged ();
}
}
-void
-DiskWriter::set_align_style_from_io ()
-{
- bool have_physical = false;
-
- if (_alignment_choice != Automatic) {
- return;
- }
-
- if (!_route) {
- return;
- }
-
- boost::shared_ptr<IO> input = _route->input ();
-
- if (input) {
- uint32_t n = 0;
- vector<string> connections;
- boost::shared_ptr<ChannelList> c = channels.reader();
-
- for (ChannelList::iterator chan = c->begin(); chan != c->end(); ++chan, ++n) {
-
- if ((input->nth (n).get()) && (input->nth (n)->get_connections (connections) == 0)) {
- if (AudioEngine::instance()->port_is_physical (connections[0])) {
- have_physical = true;
- break;
- }
- }
-
- connections.clear ();
- }
- }
-
-#ifdef MIXBUS
- // compensate for latency when bouncing from master or mixbus.
- // we need to use "ExistingMaterial" to pick up the master bus' latency
- // see also Route::direct_feeds_according_to_reality
- IOVector ios;
- ios.push_back (_io);
- if (_session.master_out() && ios.fed_by (_session.master_out()->output())) {
- have_physical = true;
- }
- for (uint32_t n = 0; n < NUM_MIXBUSES && !have_physical; ++n) {
- if (_session.get_mixbus (n) && ios.fed_by (_session.get_mixbus(n)->output())) {
- have_physical = true;
- }
- }
-#endif
-
- if (have_physical) {
- set_align_style (ExistingMaterial);
- } else {
- set_align_style (CaptureTime);
- }
-}
-
void
DiskWriter::set_align_choice (AlignChoice a, bool force)
{
_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;
+ case UseExistingMaterial:
+ set_align_style (ExistingMaterial);
+ break;
+ case UseCaptureTime:
+ set_align_style (CaptureTime);
+ break;
+ default:
+ error << string_compose (_("programming error: %1"), "DiskWriter: asked to use illegal alignment style") << endmsg;
+ break;
}
}
}
DiskWriter::state (bool full)
{
XMLNode& node (DiskIOProcessor::state (full));
- node.set_property(X_("type"), X_("diskwriter"));
+ node.set_property (X_("type"), X_("diskwriter"));
node.set_property (X_("capture-alignment"), enum_2_string (_alignment_choice));
node.set_property (X_("record-safe"), (_record_safe ? X_("yes" : "no")));
return node;
int
DiskWriter::set_state (const XMLNode& node, int version)
{
- XMLProperty const * prop;
-
if (DiskIOProcessor::set_state (node, version)) {
return -1;
}
-#if 0 // XXX DISK
- if (!node.property (X_("capture-alignment")) != 0) {
- set_align_choice (AlignChoice (string_2_enum (prop->value(), _alignment_choice)), true);
+ AlignChoice ac;
+
+ if (node.get_property (X_("capture-alignment"), ac)) {
+ set_align_choice (ac, true);
} else {
set_align_choice (Automatic, true);
}
-#endif
if (!node.get_property (X_("record-safe"), _record_safe)) {
_record_safe = false;
: Route (sess, name, flag, default_type)
, _saved_meter_point (_meter_point)
, _mode (mode)
+ , _alignment_choice (Automatic)
{
_freeze_record.state = NoFreeze;
_declickable = true;
_record_safe_control->Changed.connect_same_thread (*this, boost::bind (&Track::record_safe_changed, this, _1, _2));
_record_enable_control->Changed.connect_same_thread (*this, boost::bind (&Track::record_enable_changed, this, _1, _2));
+ _input->changed.connect_same_thread (*this, boost::bind (&Track::input_changed, this));
+
return 0;
}
+void
+Track::input_changed ()
+{
+ if (_disk_writer && _alignment_choice == Automatic) {
+ set_align_choice_from_io ();
+ }
+}
+
XMLNode&
Track::get_state ()
{
root.add_child_nocopy (_record_enable_control->get_state ());
root.set_property (X_("saved-meter-point"), _saved_meter_point);
+ root.set_property (X_("alignment-choice"), _alignment_choice);
return root;
}
}
XMLNode* child;
- XMLProperty const * prop;
if (version >= 3000 && version < 4000) {
if ((child = find_named_node (node, X_("Diskstream"))) != 0) {
_saved_meter_point = _meter_point;
}
+ AlignChoice ac;
+
+ if (node.get_property (X_("alignment-choice"), ac)) {
+ set_align_choice (ac, true);
+ }
+
return 0;
}
return use_playlist (data_type(), playlist);
}
+void
+Track::set_align_choice (AlignChoice ac, bool force)
+{
+ switch (ac) {
+ case Automatic:
+ _alignment_choice = Automatic;
+ set_align_choice_from_io ();
+ return;
+ default:
+ break;
+ }
+
+ _disk_writer->set_align_choice (ac, force);
+ _alignment_choice = ac;
+}
+
void
Track::set_align_style (AlignStyle s, bool force)
{
- // XXX DISK
+ _disk_writer->set_align_style (s, force);
}
void
-Track::set_align_choice (AlignChoice s, bool force)
+Track::set_align_choice_from_io ()
{
- // XXX DISK
+ bool have_physical = false;
+
+ if (_input) {
+ uint32_t n = 0;
+ vector<string> connections;
+ boost::shared_ptr<Port> p;
+
+ while (true) {
+
+ p = _input->nth (n++);
+
+ if (!p) {
+ break;
+ }
+
+ if (p->get_connections (connections) != 0) {
+ if (AudioEngine::instance()->port_is_physical (connections[0])) {
+ have_physical = true;
+ break;
+ }
+ }
+
+ connections.clear ();
+ }
+ }
+
+#ifdef MIXBUS
+ // compensate for latency when bouncing from master or mixbus.
+ // we need to use "ExistingMaterial" to pick up the master bus' latency
+ // see also Route::direct_feeds_according_to_reality
+ IOVector ios;
+ ios.push_back (_input);
+ if (_session.master_out() && ios.fed_by (_session.master_out()->output())) {
+ have_physical = true;
+ }
+ for (uint32_t n = 0; n < NUM_MIXBUSES && !have_physical; ++n) {
+ if (_session.get_mixbus (n) && ios.fed_by (_session.get_mixbus(n)->output())) {
+ have_physical = true;
+ }
+ }
+#endif
+
+ if (have_physical) {
+ _disk_writer->set_align_style (ExistingMaterial);
+ } else {
+ _disk_writer->set_align_style (CaptureTime);
+ }
}
void