display results of a bounce in the region list
[ardour.git] / libs / ardour / automation_event.cc
index 88932009bf85c8abdc623848450d361558ada485..f286b11607319cd7b10931088176d8871aca2a83 100644 (file)
@@ -31,6 +31,9 @@
 using namespace std;
 using namespace ARDOUR;
 using namespace sigc;
+using namespace PBD;
+
+sigc::signal<void,AutomationList *> AutomationList::AutomationListCreated;
 
 #if 0
 static void dumpit (const AutomationList& al, string prefix = "")
@@ -63,6 +66,8 @@ AutomationList::AutomationList (double defval, bool with_state)
        if (!no_state) {
                save_state (_("initial"));
        }
+
+        AutomationListCreated(this);
 }
 
 AutomationList::AutomationList (const AutomationList& other)
@@ -90,6 +95,7 @@ AutomationList::AutomationList (const AutomationList& other)
        }
 
        mark_dirty ();
+        AutomationListCreated(this);
 }
 
 AutomationList::AutomationList (const AutomationList& other, double start, double end)
@@ -122,6 +128,7 @@ AutomationList::AutomationList (const AutomationList& other, double start, doubl
        delete section;
 
        mark_dirty ();
+        AutomationListCreated(this);
 }
 
 AutomationList::~AutomationList()
@@ -129,6 +136,8 @@ AutomationList::~AutomationList()
        std::set<ControlEvent*> all_events;
        AutomationList::State* asp;
 
+       GoingAway ();
+
        for (AutomationEventList::iterator x = events.begin(); x != events.end(); ++x) {
                all_events.insert (*x);
        }
@@ -225,7 +234,7 @@ void
 AutomationList::clear ()
 {
        {
-               LockMonitor lm (lock, __LINE__, __FILE__);
+               Glib::Mutex::Lock lm (lock);
                events.clear ();
                if (!no_state) {
                        save_state (_("cleared"));
@@ -239,14 +248,14 @@ AutomationList::clear ()
 void
 AutomationList::x_scale (double factor)
 {
-       LockMonitor lm (lock, __LINE__, __FILE__);
+       Glib::Mutex::Lock lm (lock);
        _x_scale (factor);
 }
 
 bool
 AutomationList::extend_to (double when)
 {
-       LockMonitor lm (lock, __LINE__, __FILE__);
+       Glib::Mutex::Lock lm (lock);
        if (events.empty() || events.back()->when == when) {
                return false;
        }
@@ -285,7 +294,7 @@ AutomationList::rt_add (double when, double value)
        // cerr << "RT: alist @ " << this << " add " << value << " @ " << when << endl;
 
        {
-               LockMonitor lm (lock, __LINE__, __FILE__);
+               Glib::Mutex::Lock lm (lock);
 
                iterator where;
                TimeComparator cmp;
@@ -369,7 +378,7 @@ AutomationList::add (double when, double value, bool for_loading)
        /* this is for graphical editing and loading data from storage */
 
        {
-               LockMonitor lm (lock, __LINE__, __FILE__);
+               Glib::Mutex::Lock lm (lock);
                TimeComparator cmp;
                ControlEvent cp (when, 0.0f);
                bool insert = true;
@@ -413,7 +422,7 @@ void
 AutomationList::erase (AutomationList::iterator i)
 {
        {
-               LockMonitor lm (lock, __LINE__, __FILE__);
+               Glib::Mutex::Lock lm (lock);
                events.erase (i);
                reposition_for_rt_add (0);
                if (!no_state) {
@@ -428,7 +437,7 @@ void
 AutomationList::erase (AutomationList::iterator start, AutomationList::iterator end)
 {
        {
-               LockMonitor lm (lock, __LINE__, __FILE__);
+               Glib::Mutex::Lock lm (lock);
                events.erase (start, end);
                reposition_for_rt_add (0);
                if (!no_state) {
@@ -445,7 +454,7 @@ AutomationList::reset_range (double start, double endt)
        bool reset = false;
 
        {
-               LockMonitor lm (lock, __LINE__, __FILE__);
+        Glib::Mutex::Lock lm (lock);
                TimeComparator cmp;
                ControlEvent cp (start, 0.0f);
                iterator s;
@@ -481,7 +490,7 @@ AutomationList::erase_range (double start, double endt)
        bool erased = false;
 
        {
-               LockMonitor lm (lock, __LINE__, __FILE__);
+               Glib::Mutex::Lock lm (lock);
                TimeComparator cmp;
                ControlEvent cp (start, 0.0f);
                iterator s;
@@ -515,7 +524,7 @@ AutomationList::move_range (iterator start, iterator end, double xdelta, double
        */
 
        {
-               LockMonitor lm (lock, __LINE__, __FILE__);
+               Glib::Mutex::Lock lm (lock);
 
                while (start != end) {
                        (*start)->when += xdelta;
@@ -542,7 +551,7 @@ AutomationList::modify (iterator iter, double when, double val)
        */
 
        {
-               LockMonitor lm (lock, __LINE__, __FILE__);
+               Glib::Mutex::Lock lm (lock);
                (*iter)->when = when;
                (*iter)->value = val;
                if (!no_state) {
@@ -558,7 +567,7 @@ AutomationList::modify (iterator iter, double when, double val)
 std::pair<AutomationList::iterator,AutomationList::iterator>
 AutomationList::control_points_adjacent (double xval)
 {
-       LockMonitor lm (lock, __LINE__, __FILE__);
+       Glib::Mutex::Lock lm (lock);
        iterator i;
        TimeComparator cmp;
        ControlEvent cp (xval, 0.0f);
@@ -620,7 +629,7 @@ Change
 AutomationList::restore_state (StateManager::State& state) 
 {
        {
-               LockMonitor lm (lock, __LINE__, __FILE__);
+               Glib::Mutex::Lock lm (lock);
                State* lstate = dynamic_cast<State*> (&state);
 
                events.clear ();
@@ -655,7 +664,7 @@ void
 AutomationList::truncate_end (double last_coordinate)
 {
        {
-               LockMonitor lm (lock, __LINE__, __FILE__);
+               Glib::Mutex::Lock lm (lock);
                ControlEvent cp (last_coordinate, 0);
                list<ControlEvent*>::reverse_iterator i;
                double last_val;
@@ -760,7 +769,7 @@ void
 AutomationList::truncate_start (double overall_length)
 {
        {
-               LockMonitor lm (lock, __LINE__, __FILE__);
+               Glib::Mutex::Lock lm (lock);
                AutomationList::iterator i;
                double first_legal_value;
                double first_legal_coordinate;
@@ -998,7 +1007,7 @@ AutomationList::cut (iterator start, iterator end)
        AutomationList* nal = new AutomationList (default_value);
 
        {
-               LockMonitor lm (lock, __LINE__, __FILE__);
+               Glib::Mutex::Lock lm (lock);
 
                for (iterator x = start; x != end; ) {
                        iterator tmp;
@@ -1032,7 +1041,7 @@ AutomationList::cut_copy_clear (double start, double end, int op)
        bool changed = false;
        
        {
-               LockMonitor lm (lock, __LINE__, __FILE__);
+               Glib::Mutex::Lock lm (lock);
 
                if ((s = lower_bound (events.begin(), events.end(), &cp, cmp)) == events.end()) {
                        return nal;
@@ -1094,7 +1103,7 @@ AutomationList::copy (iterator start, iterator end)
        AutomationList* nal = new AutomationList (default_value);
 
        {
-               LockMonitor lm (lock, __LINE__, __FILE__);
+               Glib::Mutex::Lock lm (lock);
                
                for (iterator x = start; x != end; ) {
                        iterator tmp;
@@ -1141,7 +1150,7 @@ AutomationList::paste (AutomationList& alist, double pos, float times)
        }
 
        {
-               LockMonitor lm (lock, __LINE__, __FILE__);
+               Glib::Mutex::Lock lm (lock);
                iterator where;
                iterator prev;
                double end = 0;
@@ -1208,9 +1217,9 @@ AutomationList::store_state (XMLNode& node) const
                
                XMLNode *pointnode = new XMLNode ("point");
                
-               snprintf (buf, sizeof (buf), "%" PRIu32, (jack_nframes_t) floor ((*i)->when));
+               snprintf (buf, sizeof (buf), "%" PRIu32, (nframes_t) floor ((*i)->when));
                pointnode->add_property ("x", buf);
-               snprintf (buf, sizeof (buf), "%f", (*i)->value);
+               snprintf (buf, sizeof (buf), "%.12g", (*i)->value);
                pointnode->add_property ("y", buf);
 
                node.add_child_nocopy (*pointnode);
@@ -1223,7 +1232,7 @@ AutomationList::load_state (const XMLNode& node)
        const XMLNodeList& elist = node.children();
        XMLNodeConstIterator i;
        XMLProperty* prop;
-       jack_nframes_t x;
+       nframes_t x;
        double y;
 
        clear ();
@@ -1245,3 +1254,17 @@ AutomationList::load_state (const XMLNode& node)
                add (x, y);
        }
 }
+
+XMLNode &AutomationList::get_state ()
+{
+    XMLNode *node = new XMLNode("AutomationList");
+    store_state(*node);
+    return *node;
+}
+
+int AutomationList::set_state(const XMLNode &s)
+{
+    load_state(s);
+    return 0;
+}
+