Use ID::to_s() in libardour instead of ID::print()
[ardour.git] / libs / ardour / diskstream.cc
index f2da7982fe5e002e8748f1933e2e9c344f58eb1f..cf6db56af98fe4688cc54b329155a9c53dd8eab8 100644 (file)
@@ -17,7 +17,6 @@
 
 */
 
-#include <fstream>
 #include <cassert>
 #include <cstdio>
 #include <unistd.h>
@@ -47,7 +46,7 @@
 #include "ardour/session.h"
 #include "ardour/track.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 #include <locale.h>
 
 using namespace std;
@@ -149,6 +148,12 @@ Diskstream::~Diskstream ()
         delete deprecated_io_node;
 }
 
+bool
+Diskstream::non_layered () const
+{
+       return _session.config.get_layered_record_mode();
+}
+
 void
 Diskstream::set_track (Track* t)
 {
@@ -261,6 +266,16 @@ Diskstream::set_capture_offset ()
                _capture_offset = 0;
                break;
        }
+#ifdef MIXBUS
+       framecnt_t port_offset;
+       if (_track->mixbus_internal_bounce (port_offset)) {
+               /* _capture_offset may become negative, but the sum
+                * _capture_offset + existing_material_offset
+                * will be postive.
+                */
+               _capture_offset -= port_offset;
+       }
+#endif
 
         DEBUG_TRACE (DEBUG::CaptureAlignment, string_compose ("%1: using IO latency, capture offset set to %2 with style = %3\n", name(), _capture_offset, enum_2_string (_alignment_style)));
 }
@@ -381,7 +396,7 @@ Diskstream::use_playlist (boost::shared_ptr<Playlist> playlist)
                _playlist = playlist;
                _playlist->use();
 
-               if (!in_set_state && recordable()) {
+               if (!in_set_state && destructive() && recordable()) {
                        reset_write_sources (false);
                }
 
@@ -462,13 +477,12 @@ Diskstream::get_state ()
 {
        XMLNode* node = new XMLNode ("Diskstream");
         char buf[64];
-       LocaleGuard lg (X_("C"));
+       LocaleGuard lg;
 
        node->add_property ("flags", enum_2_string (_flags));
        node->add_property ("playlist", _playlist->name());
        node->add_property("name", _name);
-       id().print (buf, sizeof (buf));
-       node->add_property("id", buf);
+       node->add_property ("id", id ().to_s ());
        snprintf (buf, sizeof(buf), "%f", _visible_speed);
        node->add_property ("speed", buf);
         node->add_property ("capture-alignment", enum_2_string (_alignment_choice));
@@ -484,7 +498,7 @@ Diskstream::get_state ()
 int
 Diskstream::set_state (const XMLNode& node, int /*version*/)
 {
-       const XMLProperty* prop;
+       XMLProperty const * prop;
 
        if ((prop = node.property ("name")) != 0) {
                _name = prop->value();
@@ -504,7 +518,7 @@ Diskstream::set_state (const XMLNode& node, int /*version*/)
                error << string_compose (_("%1: this session uses destructive tracks, which are not supported"), PROGRAM_NAME) << endmsg;
                return -1;
        }
-       
+
         if ((prop = node.property (X_("capture-alignment"))) != 0) {
                 set_align_choice (AlignChoice (string_2_enum (prop->value(), _alignment_choice)), true);
         } else {
@@ -526,7 +540,7 @@ Diskstream::set_state (const XMLNode& node, int /*version*/)
                        non_realtime_set_speed ();
                }
        }
-       
+
        if ((prop = node.property ("record-safe")) != 0) {
            _record_safe = PBD::string_is_affirmative (prop->value()) ? 1 : 0;
        }
@@ -569,7 +583,9 @@ Diskstream::playlist_ranges_moved (list< Evoral::RangeMove<framepos_t> > const &
                         continue;
                 }
                 boost::shared_ptr<AutomationList> alist = ac->alist();
-
+               if (!alist->size()) {
+                       continue;
+               }
                 XMLNode & before = alist->get_state ();
                 bool const things_moved = alist->move_ranges (movements);
                 if (things_moved) {
@@ -599,6 +615,9 @@ Diskstream::move_processor_automation (boost::weak_ptr<Processor> p, list< Evora
 
        for (set<Evoral::Parameter>::const_iterator i = a.begin (); i != a.end (); ++i) {
                boost::shared_ptr<AutomationList> al = processor->automation_control(*i)->alist();
+               if (!al->size()) {
+                       continue;
+               }
                XMLNode & before = al->get_state ();
                bool const things_moved = al->move_ranges (movements);
                if (things_moved) {
@@ -799,7 +818,7 @@ framecnt_t
 Diskstream::default_disk_read_chunk_frames()
 {
        return 65536;
-}      
+}
 
 framecnt_t
 Diskstream::default_disk_write_chunk_frames ()
@@ -818,7 +837,7 @@ Diskstream::set_buffering_parameters (BufferingPreset bp)
        if (!get_buffering_presets (bp, read_chunk_size, read_buffer_size, write_chunk_size, write_buffer_size)) {
                return;
        }
-       
+
        disk_read_chunk_frames = read_chunk_size;
        disk_write_chunk_frames = write_chunk_size;
        Config->set_audio_capture_buffer_seconds (write_buffer_size);
@@ -865,4 +884,3 @@ Diskstream::get_buffering_presets (BufferingPreset bp,
 
        return true;
 }
-