13
0

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
This commit is contained in:
Paul Davis 2007-01-05 16:31:15 +00:00
parent d631a8d89f
commit 4aac8ae0e5
17 changed files with 148 additions and 71 deletions

View 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)

View File

@ -1,4 +1,4 @@
#!/bin/sh
dir=`dirname "$0"`
. $dir/ardev_common.sh
exec gdb gtk2_ardour/ardour.bin $*
exec gdb $EXECUTABLE $*

View File

@ -1,3 +1,3 @@
#!/bin/sh
. `dirname "$0"`/ardev_common.sh
exec gtk2_ardour/ardour-2.0beta10 $*
exec $EXECUTABLE $*

View File

@ -1,3 +0,0 @@
#!/bin/sh
. `dirname "$0"`/ardev_common.sh
exec gtk2_ardour/ardour-%VERSION% $*

View File

@ -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

View File

@ -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%

View File

@ -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 $*

View File

@ -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 $*

View 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

View 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

View 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);

View File

@ -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

View 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 *);

View File

@ -49,21 +49,16 @@ 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, 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)
{
}
/***************************************************************
Plugin inserts: send data through a plugin
***************************************************************/
@ -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);

View 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)
{

View 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) */

View 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 */
return string_compose (_("send %1"), ++cnt);
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);
}
}
string
Session::next_insert_name ()
uint32_t
Session::next_send_id ()
{
char buf[32];
snprintf (buf, sizeof (buf), "insert %" PRIu32, ++insert_cnt);
return buf;
/* 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);
}
}
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;
}
void
Session::mark_insert_id (uint32_t id)
{
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 */