summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2007-01-05 16:31:15 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2007-01-05 16:31:15 +0000
commit4aac8ae0e51f848706750abd1a448fbabe55daab (patch)
treee0f38192e249a85e0d1d444290262898d9d51976
parentd631a8d89fd0a4b72a84c415ca2bdb4c2ca99bbc (diff)
use dynamic bitsets for send + port insert naming; fix up ardev, arval etc more generically
git-svn-id: svn://localhost/ardour2/trunk@1274 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--gtk2_ardour/SConscript2
-rwxr-xr-xgtk2_ardour/ardbg2
-rwxr-xr-xgtk2_ardour/ardev2
-rw-r--r--gtk2_ardour/ardev.in3
-rwxr-xr-xgtk2_ardour/ardev_common.sh1
-rw-r--r--gtk2_ardour/ardev_common.sh.in16
-rwxr-xr-xgtk2_ardour/arprof4
-rwxr-xr-xgtk2_ardour/arval2
-rw-r--r--gtk2_ardour/redirect_box.cc6
-rw-r--r--libs/ardour/ardour/insert.h11
-rw-r--r--libs/ardour/ardour/route.h2
-rw-r--r--libs/ardour/ardour/send.h6
-rw-r--r--libs/ardour/ardour/session.h12
-rw-r--r--libs/ardour/insert.cc30
-rw-r--r--libs/ardour/route.cc15
-rw-r--r--libs/ardour/send.cc15
-rw-r--r--libs/ardour/session.cc86
17 files changed, 146 insertions, 69 deletions
diff --git a/gtk2_ardour/SConscript b/gtk2_ardour/SConscript
index 375dba278b..94e558bbe6 100644
--- a/gtk2_ardour/SConscript
+++ b/gtk2_ardour/SConscript
@@ -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)
diff --git a/gtk2_ardour/ardbg b/gtk2_ardour/ardbg
index 933b5ba720..95466a42b8 100755
--- a/gtk2_ardour/ardbg
+++ b/gtk2_ardour/ardbg
@@ -1,4 +1,4 @@
#!/bin/sh
dir=`dirname "$0"`
. $dir/ardev_common.sh
-exec gdb gtk2_ardour/ardour.bin $*
+exec gdb $EXECUTABLE $*
diff --git a/gtk2_ardour/ardev b/gtk2_ardour/ardev
index 73f6573228..ff68e11fbe 100755
--- a/gtk2_ardour/ardev
+++ b/gtk2_ardour/ardev
@@ -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
index d9ba8330bb..0000000000
--- a/gtk2_ardour/ardev.in
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-. `dirname "$0"`/ardev_common.sh
-exec gtk2_ardour/ardour-%VERSION% $*
diff --git a/gtk2_ardour/ardev_common.sh b/gtk2_ardour/ardev_common.sh
index d4109de8bb..3cef2254d2 100755
--- a/gtk2_ardour/ardev_common.sh
+++ b/gtk2_ardour/ardev_common.sh
@@ -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
index 0000000000..6017dcdba4
--- /dev/null
+++ b/gtk2_ardour/ardev_common.sh.in
@@ -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%
diff --git a/gtk2_ardour/arprof b/gtk2_ardour/arprof
index 984866a99b..05a469cb17 100755
--- a/gtk2_ardour/arprof
+++ b/gtk2_ardour/arprof
@@ -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 $*
diff --git a/gtk2_ardour/arval b/gtk2_ardour/arval
index a1dc501d3f..920e7cb1a8 100755
--- a/gtk2_ardour/arval
+++ b/gtk2_ardour/arval
@@ -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 $*
diff --git a/gtk2_ardour/redirect_box.cc b/gtk2_ardour/redirect_box.cc
index 48dd829237..d9a7eb1aec 100644
--- a/gtk2_ardour/redirect_box.cc
+++ b/gtk2_ardour/redirect_box.cc
@@ -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
diff --git a/libs/ardour/ardour/insert.h b/libs/ardour/ardour/insert.h
index 61bee6c803..99b4e4b373 100644
--- a/libs/ardour/ardour/insert.h
+++ b/libs/ardour/ardour/insert.h
@@ -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
diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h
index 2067c31b9c..869d7eb239 100644
--- a/libs/ardour/ardour/route.h
+++ b/libs/ardour/ardour/route.h
@@ -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);
diff --git a/libs/ardour/ardour/send.h b/libs/ardour/ardour/send.h
index d22d483a8f..38c3d2a20a 100644
--- a/libs/ardour/ardour/send.h
+++ b/libs/ardour/ardour/send.h
@@ -33,12 +33,15 @@
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
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h
index 5aa53e274f..03e50d152d 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -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 *);
diff --git a/libs/ardour/insert.cc b/libs/ardour/insert.cc
index 0416d3e1e4..8231cbbbe6 100644
--- a/libs/ardour/insert.cc
+++ b/libs/ardour/insert.cc
@@ -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);
diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc
index 4e82e89b3e..a322c10068 100644
--- a/libs/ardour/route.cc
+++ b/libs/ardour/route.cc
@@ -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)
{
diff --git a/libs/ardour/send.cc b/libs/ardour/send.cc
index 21069e3899..7888f89d41 100644
--- a/libs/ardour/send.cc
+++ b/libs/ardour/send.cc
@@ -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) */
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index c6cd6528d3..4d8a77613c 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -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 */