fix (no)use of offset in AudioEngine::get_sync_offset()
[ardour.git] / libs / ardour / location.cc
index 3654e03a9dcd7ab8081b272390c412e1fe8d7483..b66d0f3942606ad52982f717e34644bdb0de7878 100644 (file)
 #include <ctime>
 #include <sigc++/bind.h>
 
-#include <pbd/stl_delete.h>
-#include <pbd/xml++.h>
-#include <pbd/enumwriter.h>
+#include "pbd/stl_delete.h"
+#include "pbd/xml++.h"
+#include "pbd/enumwriter.h"
 
-#include <ardour/location.h>
-#include <ardour/session.h>
-#include <ardour/audiofilesource.h>
+#include "ardour/location.h"
+#include "ardour/session.h"
+#include "ardour/audiofilesource.h"
 
 #include "i18n.h"
 
@@ -43,7 +43,8 @@ using namespace sigc;
 using namespace PBD;
 
 Location::Location (const Location& other)
-       : _name (other._name),
+       : StatefulDestructible(),
+         _name (other._name),
          _start (other._start),
          _end (other._end),
          _flags (other._flags)
@@ -87,7 +88,7 @@ Location::operator= (const Location& other)
 }
 
 int
-Location::set_start (nframes_t s)
+Location::set_start (nframes64_t s)
 {
        if (_locked) {
                return -1;
@@ -128,7 +129,7 @@ Location::set_start (nframes_t s)
 }
 
 int
-Location::set_end (nframes_t e)
+Location::set_end (nframes64_t e)
 {
        if (_locked) {
                return -1;
@@ -165,7 +166,7 @@ Location::set_end (nframes_t e)
 }
 
 int
-Location::set (nframes_t start, nframes_t end)
+Location::set (nframes64_t start, nframes64_t end)
 {
        if (_locked) {
                return -1;
@@ -190,7 +191,7 @@ Location::set (nframes_t start, nframes_t end)
 }
 
 int
-Location::move_to (nframes_t pos) 
+Location::move_to (nframes64_t pos) 
 {
        if (_locked) {
                return -1;
@@ -246,6 +247,14 @@ Location::set_is_start (bool yn, void *src)
        }
 }
 
+void
+Location::set_is_range_marker (bool yn, void *src)
+{
+       if (set_flag_internal (yn, IsRangeMarker)) {
+                FlagsChanged (this, src); /* EMIT SIGNAL */
+       }
+}
+
 void
 Location::set_auto_punch (bool yn, void *src) 
 {
@@ -327,9 +336,9 @@ Location::get_state (void)
        id().print (buf, sizeof (buf));
        node->add_property("id", buf);
        node->add_property ("name", name());
-       snprintf (buf, sizeof (buf), "%u", start());
+       snprintf (buf, sizeof (buf), "%" PRId64, start());
        node->add_property ("start", buf);
-       snprintf (buf, sizeof (buf), "%u", end());
+       snprintf (buf, sizeof (buf), "%" PRId64, end());
        node->add_property ("end", buf);
        node->add_property ("flags", enum_2_string (_flags));
        node->add_property ("locked", (_locked ? "yes" : "no"));
@@ -376,14 +385,14 @@ Location::set_state (const XMLNode& node)
                   may make the value of _start illegal.
                */
                
-       _start = atoi (prop->value().c_str());
-               
+       sscanf (prop->value().c_str(), "%" PRId64, &_start);
+       
        if ((prop = node.property ("end")) == 0) {
                  error << _("XML node for Location has no end information") << endmsg; 
                  return -1;
        }
                
-       _end = atoi (prop->value().c_str());
+       sscanf (prop->value().c_str(), "%" PRId64, &_end);
                
        if ((prop = node.property ("flags")) == 0) {
                  error << _("XML node for Location has no flags information") << endmsg; 
@@ -645,7 +654,7 @@ Locations::remove (Location *loc)
 }
 
 void
-Locations::location_changed (Location* loc)
+Locations::location_changed (Location* /*loc*/)
 {
        changed (); /* EMIT SIGNAL */
 }
@@ -724,7 +733,7 @@ struct LocationStartLaterComparison
 };
 
 Location *
-Locations::first_location_before (nframes_t frame, bool include_special_ranges)
+Locations::first_location_before (nframes64_t frame, bool include_special_ranges)
 {
        LocationList locs;
 
@@ -751,7 +760,7 @@ Locations::first_location_before (nframes_t frame, bool include_special_ranges)
 }
 
 Location *
-Locations::first_location_after (nframes_t frame, bool include_special_ranges)
+Locations::first_location_after (nframes64_t frame, bool include_special_ranges)
 {
        LocationList locs;
 
@@ -777,8 +786,8 @@ Locations::first_location_after (nframes_t frame, bool include_special_ranges)
        return 0;
 }
 
-nframes_t
-Locations::first_mark_before (nframes_t frame, bool include_special_ranges)
+nframes64_t
+Locations::first_mark_before (nframes64_t frame, bool include_special_ranges)
 {
        LocationList locs;
 
@@ -817,8 +826,8 @@ Locations::first_mark_before (nframes_t frame, bool include_special_ranges)
        return 0;
 }
 
-nframes_t
-Locations::first_mark_after (nframes_t frame, bool include_special_ranges)
+nframes64_t
+Locations::first_mark_after (nframes64_t frame, bool include_special_ranges)
 {
        LocationList locs;
 
@@ -924,3 +933,16 @@ Locations::get_location_by_id(PBD::ID id)
 
     return 0;
 }
+
+void
+Locations::find_all_between (nframes64_t start, nframes64_t end, LocationList& ll, Location::Flags flags)
+{
+       Glib::Mutex::Lock lm (lock);
+
+       for (LocationList::const_iterator i = locations.begin(); i != locations.end(); ++i) {
+               if ((flags == 0 || (*i)->matches (flags)) && 
+                   ((*i)->start() >= start && (*i)->end() < end)) {
+                       ll.push_back (*i);
+               }
+       }
+}