use dynamic bitsets for send + port insert naming; fix up ardev, arval etc more gener...
authorPaul Davis <paul@linuxaudiosystems.com>
Fri, 5 Jan 2007 16:31:15 +0000 (16:31 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Fri, 5 Jan 2007 16:31:15 +0000 (16:31 +0000)
git-svn-id: svn://localhost/ardour2/trunk@1274 d708f5d6-7413-0410-9779-e7cbd77b26cf

17 files changed:
gtk2_ardour/SConscript
gtk2_ardour/ardbg
gtk2_ardour/ardev
gtk2_ardour/ardev.in [deleted file]
gtk2_ardour/ardev_common.sh
gtk2_ardour/ardev_common.sh.in [new file with mode: 0644]
gtk2_ardour/arprof
gtk2_ardour/arval
gtk2_ardour/redirect_box.cc
libs/ardour/ardour/insert.h
libs/ardour/ardour/route.h
libs/ardour/ardour/send.h
libs/ardour/ardour/session.h
libs/ardour/insert.cc
libs/ardour/route.cc
libs/ardour/send.cc
libs/ardour/session.cc

index 375dba278ba34c695137c5dabfc080ef26ecce58..94e558bbe620b09e5ffdec075a3e313ef87734ba 100644 (file)
@@ -278,7 +278,7 @@ my_subst_dict['%VERSION%'] = ardour_version
 ardoursh = env.SubstInFile ('ardour.sh','ardour.sh.in', SUBST_DICT = my_subst_dict);
 env.AddPostAction (ardoursh, Chmod ('$TARGET', 0755))
 
-ardourdev = env.SubstInFile ('ardev','ardev.in', SUBST_DICT = my_subst_dict);
+ardourdev = env.SubstInFile ('ardev_common.sh','ardev_common.sh.in', SUBST_DICT = my_subst_dict);
 env.AddPostAction (ardourdev, Chmod ('$TARGET', 0755))
 
 Default(ardourdev)
index 933b5ba720c44c1fa45a746e7c9cdbca763c9e40..95466a42b8b314ec5cf32ed45ebeec922aecaeac 100755 (executable)
@@ -1,4 +1,4 @@
 #!/bin/sh
 dir=`dirname "$0"`
 . $dir/ardev_common.sh
-exec gdb gtk2_ardour/ardour.bin $*
+exec gdb $EXECUTABLE $*
index 73f657322874087f6bef670c496df8bc97f7a442..ff68e11fbe1713f42e710163e2f644018b3857ca 100755 (executable)
@@ -1,3 +1,3 @@
 #!/bin/sh
 . `dirname "$0"`/ardev_common.sh
-exec gtk2_ardour/ardour-2.0beta10 $*
+exec $EXECUTABLE $*
diff --git a/gtk2_ardour/ardev.in b/gtk2_ardour/ardev.in
deleted file mode 100644 (file)
index d9ba833..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-. `dirname "$0"`/ardev_common.sh
-exec gtk2_ardour/ardour-%VERSION% $*
index d4109de8bb7c2cdda92a0568175f7fcd72311a8f..3cef2254d2a45784740e3fba37a80c98f5a7ec4c 100755 (executable)
@@ -13,3 +13,4 @@ export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH
 # For the internal clearlooks engine
 export GTK_PATH=$PWD/libs/clearlooks:~/.ardour2
 
+EXECUTABLE=gtk2_ardour/ardour-2.0beta10
diff --git a/gtk2_ardour/ardev_common.sh.in b/gtk2_ardour/ardev_common.sh.in
new file mode 100644 (file)
index 0000000..6017dcd
--- /dev/null
@@ -0,0 +1,16 @@
+cd `dirname "$0"`/..
+
+#export G_DEBUG=fatal_criticals
+
+export ARDOUR_PATH=gtk2_ardour/icons:gtk2_ardour/pixmaps:gtk2_ardour
+export GTK_PATH=libs/clearlooks
+
+
+export LD_LIBRARY_PATH=libs/surfaces/control_protocol:libs/ardour:libs/midi++2:libs/pbd:libs/soundtouch:libs/gtkmm2ext:libs/sigc++2:libs/glibmm2:libs/gtkmm2/atk:libs/gtkmm2/pango:libs/gtkmm2/gdk:libs/gtkmm2/gtk:libs/libgnomecanvasmm:libs/libsndfile:libs/appleutility:$LD_LIBRARY_PATH
+
+# DYLD_LIBRARY_PATH is for darwin.
+export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH
+# For the internal clearlooks engine
+export GTK_PATH=$PWD/libs/clearlooks:~/.ardour2
+
+EXECUTABLE=gtk2_ardour/ardour-%VERSION%
index 984866a99b2952e53458498cc642547205e687c4..05a469cb1763d38a773af6bf3f8dd1bed6ec2a36 100755 (executable)
@@ -5,5 +5,5 @@ if [ gprofhelper.c -nt gprofhelper.so ] ; then
     gcc -shared -nostdlib -fPIC gprofhelper.c -o gprofhelper.so -lpthread -ldl || exit 1
 fi
 
-export LD_LIBRARY_PATH=../libs/ardour/.libs
-LDPRELOAD=./gprofhelper.so ./ardour $*
+. ardev_common.sh
+LDPRELOAD=./gprofhelper.so $EXECUTABLE $*
index a1dc501d3fbd554792791808f7ea24070a119bc4..920e7cb1a897efe5a09927dfdc24e0325b6fa3b7 100755 (executable)
@@ -1,4 +1,4 @@
 #!/bin/sh
 . ardev_common.sh
 export ARDOUR_RUNNING_UNDER_VALGRIND=TRUE
-exec valgrind  --num-callers=50 --tool=memcheck gtk2_ardour/ardour.bin --novst $*
+exec valgrind  --num-callers=50 --tool=memcheck $EXECUTABLE --novst $*
index 48dd82923731f9691d07a9675d0569dda7003336..d9a7eb1aec0ff3266529e78bddc68e55deb27c84 100644 (file)
@@ -835,7 +835,6 @@ RedirectBox::rename_redirect (boost::shared_ptr<Redirect> redirect)
        }
 
        return;
-  
 }
 
 void
@@ -920,8 +919,9 @@ RedirectBox::get_selected_redirects (vector<boost::shared_ptr<Redirect> >& redir
 {
     vector<Gtk::TreeModel::Path> pathlist = redirect_display.get_selection()->get_selected_rows();
  
-       for (vector<Gtk::TreeModel::Path>::iterator iter = pathlist.begin(); iter != pathlist.end(); ++iter)
-               redirects.push_back ((*(model->get_iter(*iter)))[columns.redirect]);
+    for (vector<Gtk::TreeModel::Path>::iterator iter = pathlist.begin(); iter != pathlist.end(); ++iter) {
+           redirects.push_back ((*(model->get_iter(*iter)))[columns.redirect]);
+    }
 }
 
 void
index 61bee6c80397219d78624ebff2d9f9cae8754bc0..99b4e4b3734ddce5c1423a0a3ae242ced6328296 100644 (file)
@@ -45,10 +45,8 @@ class Plugin;
 class Insert : public Redirect
 {
   public:
-       Insert(Session& s, Placement p);
-       Insert(Session& s, string name, Placement p);
-
-       Insert(Session& s, Placement p, int imin, int imax, int omin, int omax);
+       Insert(Session& s, std::string name, Placement p);
+       Insert(Session& s, std::string name, Placement p, int imin, int imax, int omin, int omax);
        
        virtual ~Insert() { }
 
@@ -84,6 +82,11 @@ class PortInsert : public Insert
        int32_t can_support_input_configuration (int32_t) const;
        int32_t configure_io (int32_t magic, int32_t in, int32_t out);
        int32_t compute_output_streams (int32_t cnt) const;
+
+       uint32_t bit_slot() const { return bitslot; }
+
+  private:
+       uint32_t bitslot;
 };
 
 class PluginInsert : public Insert
index 2067c31b9c14b83e95b6f147c202271cf754c6d3..869d7eb23968f00f32c9173a5b6e789118bb4c9d 100644 (file)
@@ -173,8 +173,6 @@ class Route : public IO
        void all_redirects_flip();
        void all_redirects_active (bool state);
 
-       uint32_t count_sends ();
-
        virtual nframes_t update_total_latency();
        nframes_t signal_latency() const { return _own_latency; }
        virtual void set_latency_delay (nframes_t);
index d22d483a8f0218d45e5245271760be7bfc836c55..38c3d2a20ab2714776db7465f362fd6cea9fb714 100644 (file)
 
 namespace ARDOUR {
 
-class Send : public Redirect {
+class Send : public Redirect 
+{
   public:      
        Send (Session&, Placement);
        Send (Session&, const XMLNode&);
        Send (const Send&);
        ~Send ();
+
+       uint32_t bit_slot() const { return bitslot; }
        
        void run (vector<Sample *> &bufs, uint32_t nbufs, nframes_t nframes, nframes_t offset);
        void activate() {}
@@ -58,6 +61,7 @@ class Send : public Redirect {
   private:
        bool _metering;
        uint32_t expected_inputs;
+       uint32_t bitslot;
 };
 
 } // namespace ARDOUR
index 5aa53e274f88fc4dcf5ad0308283191ed6c56f14..03e50d152dc5810fec33b07217e40af343bc9fa1 100644 (file)
@@ -30,6 +30,7 @@
 #include <stack>
 
 #include <boost/weak_ptr.hpp>
+#include <boost/dynamic_bitset.hpp>
 
 #include <stdint.h>
 
@@ -677,9 +678,11 @@ class Session : public PBD::StatefulDestructible
        uint32_t n_plugin_inserts() const { return _plugin_inserts.size(); }
        uint32_t n_sends() const { return _sends.size(); }
 
-       string next_send_name();
-       string next_insert_name();
-       
+       uint32_t next_send_id();
+       uint32_t next_insert_id();
+       void mark_send_id (uint32_t);
+       void mark_insert_id (uint32_t);
+
        /* s/w "RAID" management */
        
        nframes_t available_capture_duration();
@@ -1520,9 +1523,12 @@ class Session : public PBD::StatefulDestructible
        list<PortInsert *>   _port_inserts;
        list<PluginInsert *> _plugin_inserts;
        list<Send *>         _sends;
+       boost::dynamic_bitset<uint32_t>  send_bitset;
+       boost::dynamic_bitset<uint32_t>  insert_bitset;
        uint32_t          send_cnt;
        uint32_t          insert_cnt;
 
+
        void add_redirect (Redirect *);
        void remove_redirect (Redirect *);
 
index 0416d3e1e41355b40e56681934e994d7561facef..8231cbbbe6c4d6621026f7475b913961ed47f9d8 100644 (file)
@@ -49,18 +49,13 @@ using namespace std;
 using namespace ARDOUR;
 using namespace PBD;
 
-Insert::Insert(Session& s, Placement p)
-       : Redirect (s, s.next_insert_name(), p)
+Insert::Insert(Session& s, string name, Placement p)
+       : Redirect (s, name, p)
 {
 }
 
-Insert::Insert(Session& s, Placement p, int imin, int imax, int omin, int omax)
-       : Redirect (s, s.next_insert_name(), p, imin, imax, omin, omax)
-{
-}
-
-Insert::Insert(Session& s, string name, Placement p)
-       : Redirect (s, name, p)
+Insert::Insert(Session& s, string name, Placement p, int imin, int imax, int omin, int omax)
+       : Redirect (s, name, p, imin, imax, omin, omax)
 {
 }
 
@@ -833,7 +828,7 @@ PluginInsert::type ()
  ***************************************************************/
 
 PortInsert::PortInsert (Session& s, Placement p)
-       : Insert (s, p, 1, -1, 1, -1)
+       : Insert (s, string_compose (_("insert %1"), (bitslot = s.next_insert_id()) + 1), p, 1, -1, 1, -1)
 {
        init ();
        RedirectCreated (this); /* EMIT SIGNAL */
@@ -841,7 +836,7 @@ PortInsert::PortInsert (Session& s, Placement p)
 }
 
 PortInsert::PortInsert (const PortInsert& other)
-       : Insert (other._session, other.placement(), 1, -1, 1, -1)
+       : Insert (other._session, string_compose (_("insert %1"), (bitslot = other._session.next_insert_id()) + 1), other.placement(), 1, -1, 1, -1)
 {
        init ();
        RedirectCreated (this); /* EMIT SIGNAL */
@@ -917,9 +912,11 @@ XMLNode&
 PortInsert::state (bool full)
 {
        XMLNode *node = new XMLNode("Insert");
-
+       char buf[32];
        node->add_child_nocopy (Redirect::state(full)); 
-       node->add_property("type", "port");
+       node->add_property ("type", "port");
+       snprintf (buf, sizeof (buf), "%" PRIu32, bitslot);
+       node->add_property ("bitslot", buf);
 
        return *node;
 }
@@ -942,6 +939,13 @@ PortInsert::set_state(const XMLNode& node)
                return -1;
        }
 
+       if ((prop = node.property ("bitslot")) == 0) {
+               bitslot = _session.next_insert_id();
+       } else {
+               sscanf (prop->value().c_str(), "%" PRIu32, &bitslot);
+               _session.mark_insert_id (bitslot);
+       }
+
        for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
                if ((*niter)->name() == Redirect::state_node_name) {
                        Redirect::set_state (**niter);
index 4e82e89b3e44deafc8626f5dabc0137cea36878c..a322c10068bf81fd9719441440baed3691e5dc1b 100644 (file)
@@ -781,21 +781,6 @@ Route::set_mute (bool yn, void *src)
        }
 }
 
-uint32_t
-Route::count_sends ()
-{
-       uint32_t cnt = 0;
-       Glib::RWLock::ReaderLock lm (redirect_lock);
-
-       for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
-               if (boost::dynamic_pointer_cast<Send> (*i)) {
-                       ++cnt;
-               }
-       }
-
-       return cnt;
-}
-
 int
 Route::add_redirect (boost::shared_ptr<Redirect> redirect, void *src, uint32_t* err_streams)
 {
index 21069e3899cd5d4c0b43e1925712093dcf6467b3..7888f89d412894b801196defc24762344aa4ea10 100644 (file)
@@ -32,7 +32,7 @@ using namespace ARDOUR;
 using namespace PBD;
 
 Send::Send (Session& s, Placement p)
-       : Redirect (s, s.next_send_name(), p)
+       : Redirect (s, string_compose (_("send %1"), (bitslot = s.next_send_id()) + 1), p)
 {
        _metering = false;
        expected_inputs = 0;
@@ -53,7 +53,7 @@ Send::Send (Session& s, const XMLNode& node)
 }
 
 Send::Send (const Send& other)
-       : Redirect (other._session, other._session.next_send_name(), other.placement())
+       : Redirect (other._session, string_compose (_("send %1"), (bitslot = other._session.next_send_id()) + 1), other.placement())
 {
        _metering = false;
        expected_inputs = 0;
@@ -76,7 +76,10 @@ XMLNode&
 Send::state(bool full)
 {
        XMLNode *node = new XMLNode("Send");
+       char buf[32];
        node->add_child_nocopy (Redirect::state (full));
+       snprintf (buf, sizeof (buf), "%" PRIu32, bitslot);
+       node->add_property ("bitslot", buf);
        return *node;
 }
 
@@ -85,6 +88,14 @@ Send::set_state(const XMLNode& node)
 {
        XMLNodeList nlist = node.children();
        XMLNodeIterator niter;
+       const XMLProperty* prop;
+
+       if ((prop = node.property ("bitslot")) == 0) {
+               bitslot = _session.next_send_id();
+       } else {
+               sscanf (prop->value().c_str(), "%" PRIu32, &bitslot);
+               _session.mark_send_id (bitslot);
+       }
 
        /* Send has regular IO automation (gain, pan) */
 
index c6cd6528d35802e294cfd0c2413b17898b1aeb0f..4d8a77613ca1d010a0624d3d34a9f4b12c23d9cd 100644 (file)
@@ -3347,10 +3347,14 @@ Session::remove_redirect (Redirect* redirect)
        Insert* insert;
        PortInsert* port_insert;
        PluginInsert* plugin_insert;
-
+       
        if ((insert = dynamic_cast<Insert *> (redirect)) != 0) {
                if ((port_insert = dynamic_cast<PortInsert *> (insert)) != 0) {
-                       _port_inserts.remove (port_insert);
+                       list<PortInsert*>::iterator x = find (_port_inserts.begin(), _port_inserts.end(), port_insert);
+                       if (x != _port_inserts.end()) {
+                               insert_bitset[port_insert->bit_slot()] = false;
+                               _port_inserts.erase (x);
+                       }
                } else if ((plugin_insert = dynamic_cast<PluginInsert *> (insert)) != 0) {
                        _plugin_inserts.remove (plugin_insert);
                } else {
@@ -3360,7 +3364,11 @@ Session::remove_redirect (Redirect* redirect)
                        /*NOTREACHED*/
                }
        } else if ((send = dynamic_cast<Send *> (redirect)) != 0) {
-               _sends.remove (send);
+               list<Send*>::iterator x = find (_sends.begin(), _sends.end(), send);
+               if (x != _sends.end()) {
+                       send_bitset[send->bit_slot()] = false;
+                       _sends.erase (x);
+               }
        } else {
                fatal << _("programming error: unknown type of Redirect deleted!") << endmsg;
                /*NOTREACHED*/
@@ -3492,26 +3500,70 @@ Session::ensure_passthru_buffers (uint32_t howmany)
        allocate_pan_automation_buffers (current_block_size, howmany, false);
 }
 
-string
-Session::next_send_name ()
+uint32_t
+Session::next_insert_id ()
 {
-       uint32_t cnt = 0;
-       
-       shared_ptr<RouteList> r = routes.reader ();
-       
-       for (RouteList::const_iterator i = r->begin(); i != r->end(); ++i) {
-               cnt += (*i)->count_sends ();
+       /* this doesn't really loop forever. just think about it */
+
+       while (true) {
+               for (boost::dynamic_bitset<uint32_t>::size_type n = 0; n < insert_bitset.size(); ++n) {
+                       if (!insert_bitset[n]) {
+                               insert_bitset[n] = true;
+                               cerr << "Returning " << n << " as insert ID\n";
+                               return n;
+                               
+                       }
+               }
+               
+               /* none available, so resize and try again */
+
+               insert_bitset.resize (insert_bitset.size() + 16, false);
+       }
+}
+
+uint32_t
+Session::next_send_id ()
+{
+       /* this doesn't really loop forever. just think about it */
+
+       while (true) {
+               for (boost::dynamic_bitset<uint32_t>::size_type n = 0; n < send_bitset.size(); ++n) {
+                       if (!send_bitset[n]) {
+                               send_bitset[n] = true;
+                               cerr << "Returning " << n << " as send ID\n";
+                               return n;
+                               
+                       }
+               }
+               
+               /* none available, so resize and try again */
+
+               send_bitset.resize (send_bitset.size() + 16, false);
        }
+}
 
-       return string_compose (_("send %1"), ++cnt);
+void
+Session::mark_send_id (uint32_t id)
+{
+       if (id >= send_bitset.size()) {
+               send_bitset.resize (id+16, false);
+       }
+       if (send_bitset[id]) {
+               warning << string_compose (_("send ID %1 appears to be in use already"), id) << endmsg;
+       }
+       send_bitset[id] = true;
 }
 
-string
-Session::next_insert_name ()
+void
+Session::mark_insert_id (uint32_t id)
 {
-       char buf[32];
-       snprintf (buf, sizeof (buf), "insert %" PRIu32, ++insert_cnt);
-       return buf;
+       if (id >= insert_bitset.size()) {
+               insert_bitset.resize (id+16, false);
+       }
+       if (insert_bitset[id]) {
+               warning << string_compose (_("insert ID %1 appears to be in use already"), id) << endmsg;
+       }
+       insert_bitset[id] = true;
 }
 
 /* Named Selection management */