#include <fstream>
#include <algorithm>
+#include <cmath>
+
#include <unistd.h>
#include <locale.h>
#include <errno.h>
-#include <sigc++/bind.h>
-
#include <glibmm.h>
#include <glibmm/thread.h>
#include "i18n.h"
-#include <cmath>
-
-/*
- A bug in OS X's cmath that causes isnan() and isinf() to be
- "undeclared". the following works around that
-*/
-
-#if defined(__APPLE__) && defined(__MACH__)
-extern "C" int isnan (double);
-extern "C" int isinf (double);
-#endif
-
-#define BLOCK_PROCESS_CALLBACK() Glib::Mutex::Lock em (_session.engine().process_lock())
+#define BLOCK_PROCESS_CALLBACK() Glib::Mutex::Lock em (AudioEngine::instance()->process_lock())
using namespace std;
using namespace ARDOUR;
const string IO::state_node_name = "IO";
bool IO::connecting_legal = false;
-sigc::signal<int> IO::ConnectingLegal;
-sigc::signal<void,ChanCount> IO::PortCountChanged;
+PBD::Signal0<int> IO::ConnectingLegal;
+PBD::Signal1<void,ChanCount> IO::PortCountChanged;
/** @param default_type The type of port that will be created by ensure_io
* and friends if no type is explicitly requested (to avoid breakage).
}
void
-IO::check_bundles (std::vector<UserBundleInfo>& list, const PortSet& ports)
+IO::check_bundles (std::vector<UserBundleInfo*>& list, const PortSet& ports)
{
- std::vector<UserBundleInfo> new_list;
+ std::vector<UserBundleInfo*> new_list;
- for (std::vector<UserBundleInfo>::iterator i = list.begin(); i != list.end(); ++i) {
+ for (std::vector<UserBundleInfo*>::iterator i = list.begin(); i != list.end(); ++i) {
- uint32_t const N = i->bundle->nchannels ();
+ uint32_t const N = (*i)->bundle->nchannels ();
if (_ports.num_ports (default_type()) < N) {
continue;
for (uint32_t j = 0; j < N; ++j) {
/* Every port on bundle channel j must be connected to our input j */
- Bundle::PortList const pl = i->bundle->channel_ports (j);
+ Bundle::PortList const pl = (*i)->bundle->channel_ports (j);
for (uint32_t k = 0; k < pl.size(); ++k) {
if (ports.port(j)->connected_to (pl[k]) == false) {
ok = false;
if (ok) {
new_list.push_back (*i);
} else {
- i->changed.disconnect ();
+ delete *i;
}
}
node->add_property ("direction", enum_2_string (_direction));
node->add_property ("default-type", _default_type.to_string());
- for (std::vector<UserBundleInfo>::iterator i = _bundles_connected.begin(); i != _bundles_connected.end(); ++i) {
+ for (std::vector<UserBundleInfo*>::iterator i = _bundles_connected.begin(); i != _bundles_connected.end(); ++i) {
XMLNode* n = new XMLNode ("Bundle");
- n->add_property ("name", i->bundle->name ());
+ n->add_property ("name", (*i)->bundle->name ());
node->add_child_nocopy (*n);
}
pending_state_node = new XMLNode (node);
pending_state_node_version = version;
pending_state_node_in = false;
- connection_legal_c = ConnectingLegal.connect (sigc::mem_fun (*this, &IO::connecting_became_legal));
+ ConnectingLegal.connect_same_thread (connection_legal_c, boost::bind (&IO::connecting_became_legal, this));
}
pending_state_node = new XMLNode (node);
pending_state_node_version = version;
pending_state_node_in = in;
- connection_legal_c = ConnectingLegal.connect (sigc::mem_fun (*this, &IO::connecting_became_legal));
+ ConnectingLegal.connect_same_thread (connection_legal_c, boost::bind (&IO::connecting_became_legal, this));
}
return 0;
// see if it's a stereo connection e.g. "in 3+4"
if (last_non_digit_pos > 1 && desired_name[last_non_digit_pos] == '+') {
- int left_bundle_number = 0;
string::size_type left_last_non_digit_pos;
left_last_non_digit_pos = desired_name.find_last_not_of(digits, last_non_digit_pos-1);
if (left_last_non_digit_pos != string::npos) {
+ int left_bundle_number = 0;
stringstream s;
s << desired_name.substr(left_last_non_digit_pos, last_non_digit_pos-1);
s >> left_bundle_number;
if ((prop = node.property ("inputs")) != 0 && _direction == Input) {
n_audio = count (prop->value().begin(), prop->value().end(), '{');
+ } else if ((prop = node.property ("input-connection")) != 0 && _direction == Input) {
+ n_audio = 1;
} else if ((prop = node.property ("outputs")) != 0 && _direction == Output) {
n_audio = count (prop->value().begin(), prop->value().end(), '{');
+ } else if ((prop = node.property ("output-connection")) != 0 && _direction == Output) {
+ n_audio = 2;
}
}
{
string name = requested_name;
- if (name == _name) {
+ if (_name == name) {
return true;
}
/* replace all colons in the name. i wish we didn't have to do this */
- if (replace_all (name, ":", "-")) {
- warning << _("you cannot use colons to name objects with I/O connections") << endmsg;
- }
+ replace_all (name, ":", "-");
for (PortSet::iterator i = _ports.begin(); i != _ports.end(); ++i) {
string current_name = i->name();
- current_name.replace (current_name.find (_name), _name.length(), name);
+ current_name.replace (current_name.find (_name), _name.val().length(), name);
i->set_name (current_name);
}
if (ub) {
/* See if we already know about this one */
- std::vector<UserBundleInfo>::iterator i = _bundles_connected.begin();
- while (i != _bundles_connected.end() && i->bundle != ub) {
+ std::vector<UserBundleInfo*>::iterator i = _bundles_connected.begin();
+ while (i != _bundles_connected.end() && (*i)->bundle != ub) {
++i;
}
if (i == _bundles_connected.end()) {
/* We don't, so make a note */
- _bundles_connected.push_back (UserBundleInfo (this, ub));
+ _bundles_connected.push_back (new UserBundleInfo (this, ub));
}
}
}
boost::shared_ptr<UserBundle> ub = boost::dynamic_pointer_cast<UserBundle> (c);
if (ub) {
- std::vector<UserBundleInfo>::iterator i = _bundles_connected.begin();
- while (i != _bundles_connected.end() && i->bundle != ub) {
+ std::vector<UserBundleInfo*>::iterator i = _bundles_connected.begin();
+ while (i != _bundles_connected.end() && (*i)->bundle != ub) {
++i;
}
if (i != _bundles_connected.end()) {
+ delete *i;
_bundles_connected.erase (i);
}
}
IO::enable_connecting ()
{
connecting_legal = true;
- return ConnectingLegal ();
+ boost::optional<int> r = ConnectingLegal ();
+ return r.get_value_or (0);
}
void
char buf1[name_size+1];
char buf2[name_size+1];
- snprintf (buf1, name_size+1, ("%.*s/%s"), limit, _name.c_str(), suffix.c_str());
+ snprintf (buf1, name_size+1, ("%.*s/%s"), limit, _name.val().c_str(), suffix.c_str());
int port_number = find_port_hole (buf1);
snprintf (buf2, name_size+1, "%s %d", buf1, port_number);
_bundle->remove_channels ();
if (_direction == Input) {
- snprintf(buf, sizeof (buf), _("%s in"), _name.c_str());
+ snprintf(buf, sizeof (buf), _("%s in"), _name.val().c_str());
} else {
- snprintf(buf, sizeof (buf), _("%s out"), _name.c_str());
+ snprintf(buf, sizeof (buf), _("%s out"), _name.val().c_str());
}
_bundle->set_name (buf);
uint32_t const ni = _ports.num_ports();
BundleList bundles;
/* User bundles */
- for (std::vector<UserBundleInfo>::iterator i = _bundles_connected.begin(); i != _bundles_connected.end(); ++i) {
- bundles.push_back (i->bundle);
+ for (std::vector<UserBundleInfo*>::iterator i = _bundles_connected.begin(); i != _bundles_connected.end(); ++i) {
+ bundles.push_back ((*i)->bundle);
}
/* Session bundles */
IO::UserBundleInfo::UserBundleInfo (IO* io, boost::shared_ptr<UserBundle> b)
{
bundle = b;
- changed = b->Changed.connect (
- sigc::mem_fun (*io, &IO::bundle_changed)
- );
+ b->Changed.connect_same_thread (changed, boost::bind (&IO::bundle_changed, io, _1));
}
std::string
}
}
+bool
+IO::connected () const
+{
+ /* do we have any connections at all? */
+
+ for (PortSet::const_iterator p = _ports.begin(); p != _ports.end(); ++p) {
+ if (p->connected()) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
bool
IO::connected_to (boost::shared_ptr<const IO> other) const
{
if (!other) {
- /* do we have any connections at all? */
-
- for (PortSet::const_iterator p = _ports.begin(); p != _ports.end(); ++p) {
- if (p->connected()) {
- return true;
- }
- }
-
- return false;
+ return connected ();
}
assert (_direction != other->direction());