id_t becomes a fully-fledged object, UUID's used for IDs, generic MIDI now owns bindi...
[ardour.git] / libs / ardour / audioregion.cc
index 95201ab6f76ab84712abe973b244f20212e6279f..6665b8d962f658a52c7f08182251acf9b8050e0b 100644 (file)
@@ -27,8 +27,9 @@
 #include <sigc++/bind.h>
 #include <sigc++/class_slot.h>
 
+#include <glibmm/thread.h>
+
 #include <pbd/basename.h>
-#include <pbd/lockmonitor.h>
 #include <pbd/xml++.h>
 
 #include <ardour/audioregion.h>
@@ -37,6 +38,7 @@
 #include <ardour/dB.h>
 #include <ardour/playlist.h>
 #include <ardour/audiofilter.h>
+#include <ardour/audiosource.h>
 
 #include "i18n.h"
 #include <locale.h>
@@ -62,7 +64,7 @@ AudioRegionState::AudioRegionState (string why)
 {
 }
 
-AudioRegion::AudioRegion (Source& src, jack_nframes_t start, jack_nframes_t length, bool announce)
+AudioRegion::AudioRegion (AudioSource& src, jack_nframes_t start, jack_nframes_t length, bool announce)
        : Region (start, length, PBD::basename_nosuffix(src.name()), 0,  Region::Flag(Region::DefaultFlags|Region::External)),
          _fade_in (0.0, 2.0, 1.0, false),
          _fade_out (0.0, 2.0, 1.0, false),
@@ -88,7 +90,7 @@ AudioRegion::AudioRegion (Source& src, jack_nframes_t start, jack_nframes_t leng
        }
 }
 
-AudioRegion::AudioRegion (Source& src, jack_nframes_t start, jack_nframes_t length, const string& name, layer_t layer, Flag flags, bool announce)
+AudioRegion::AudioRegion (AudioSource& src, jack_nframes_t start, jack_nframes_t length, const string& name, layer_t layer, Flag flags, bool announce)
        : Region (start, length, name, layer, flags),
          _fade_in (0.0, 2.0, 1.0, false),
          _fade_out (0.0, 2.0, 1.0, false),
@@ -149,7 +151,7 @@ AudioRegion::AudioRegion (const AudioRegion& other, jack_nframes_t offset, jack_
 {
        /* create a new AudioRegion, that is part of an existing one */
        
-       set<Source*> unique_srcs;
+       set<AudioSource*> unique_srcs;
 
        for (SourceList::const_iterator i= other.sources.begin(); i != other.sources.end(); ++i) {
                sources.push_back (*i);
@@ -208,7 +210,7 @@ AudioRegion::AudioRegion (const AudioRegion &other)
 {
        /* Pure copy constructor */
 
-       set<Source*> unique_srcs;
+       set<AudioSource*> unique_srcs;
 
        for (SourceList::const_iterator i = other.sources.begin(); i != other.sources.end(); ++i) {
                sources.push_back (*i);
@@ -236,7 +238,7 @@ AudioRegion::AudioRegion (const AudioRegion &other)
        /* NOTE: no CheckNewRegion signal emitted here. This is the copy constructor */
 }
 
-AudioRegion::AudioRegion (Source& src, const XMLNode& node)
+AudioRegion::AudioRegion (AudioSource& src, const XMLNode& node)
        : Region (node),
          _fade_in (0.0, 2.0, 1.0, false),
          _fade_out (0.0, 2.0, 1.0, false),
@@ -265,9 +267,7 @@ AudioRegion::AudioRegion (SourceList& srcs, const XMLNode& node)
          _fade_out (0.0, 2.0, 1.0, false),
          _envelope (0.0, 2.0, 1.0, false)
 {
-       /* basic AudioRegion constructor */
-
-       set<Source*> unique_srcs;
+       set<AudioSource*> unique_srcs;
 
        for (SourceList::iterator i=srcs.begin(); i != srcs.end(); ++i) {
                sources.push_back (*i);
@@ -655,7 +655,7 @@ AudioRegion::state (bool full)
 
        for (uint32_t n=0; n < sources.size(); ++n) {
                snprintf (buf2, sizeof(buf2), "source-%d", n);
-               snprintf (buf, sizeof(buf), "%" PRIu64, sources[n]->id());
+               sources[n]->id().print (buf2);
                node.add_property (buf2, buf);
        }
 
@@ -1093,7 +1093,7 @@ void
 AudioRegion::lock_sources ()
 {
        SourceList::iterator i;
-       set<Source*> unique_srcs;
+       set<AudioSource*> unique_srcs;
 
        for (i = sources.begin(); i != sources.end(); ++i) {
                unique_srcs.insert (*i);
@@ -1111,7 +1111,7 @@ void
 AudioRegion::unlock_sources ()
 {
        SourceList::iterator i;
-       set<Source*> unique_srcs;
+       set<AudioSource*> unique_srcs;
 
        for (i = sources.begin(); i != sources.end(); ++i) {
                unique_srcs.insert (*i);
@@ -1139,15 +1139,15 @@ AudioRegion::master_source_names ()
 }
 
 bool
-AudioRegion::region_list_equivalent (const AudioRegion& other)
+AudioRegion::region_list_equivalent (const AudioRegion& other) const
 {
        return size_equivalent (other) && source_equivalent (other) && _name == other._name;
 }
 
 bool
-AudioRegion::source_equivalent (const AudioRegion& other)
+AudioRegion::source_equivalent (const AudioRegion& other) const
 {
-       SourceList::iterator i;
+       SourceList::const_iterator i;
        SourceList::const_iterator io;
 
        for (i = sources.begin(), io = other.sources.begin(); i != sources.end() && io != other.sources.end(); ++i, ++io) {
@@ -1166,7 +1166,13 @@ AudioRegion::source_equivalent (const AudioRegion& other)
 }
 
 bool
-AudioRegion::equivalent (const AudioRegion& other)
+AudioRegion::overlap_equivalent (const AudioRegion& other) const
+{
+       return coverage (other.first_frame(), other.last_frame()) != OverlapNone;
+}
+
+bool
+AudioRegion::equivalent (const AudioRegion& other) const
 {
        return _start == other._start &&
                _position == other._position &&
@@ -1174,7 +1180,7 @@ AudioRegion::equivalent (const AudioRegion& other)
 }
 
 bool
-AudioRegion::size_equivalent (const AudioRegion& other)
+AudioRegion::size_equivalent (const AudioRegion& other) const
 {
        return _start == other._start &&
                _length == other._length;