}
void
-IO::silence (nframes_t nframes)
+IO::silence (framecnt_t nframes)
{
/* io_lock, not taken: function must be called from Session::process() calltree */
return 0;
}
- {
- BLOCK_PROCESS_CALLBACK ();
-
- {
- Glib::Mutex::Lock lm (io_lock);
-
- /* check that our_port is really one of ours */
-
- if ( ! _ports.contains(our_port)) {
- return -1;
- }
-
- /* disconnect it from the source */
-
- if (our_port->disconnect (other_port)) {
- error << string_compose(_("IO: cannot disconnect port %1 from %2"), our_port->name(), other_port) << endmsg;
- return -1;
- }
-
- check_bundles_connected ();
- }
- }
+ {
+ Glib::Mutex::Lock lm (io_lock);
+
+ /* check that our_port is really one of ours */
+
+ if ( ! _ports.contains(our_port)) {
+ return -1;
+ }
+
+ /* disconnect it from the source */
+
+ if (our_port->disconnect (other_port)) {
+ error << string_compose(_("IO: cannot disconnect port %1 from %2"), our_port->name(), other_port) << endmsg;
+ return -1;
+ }
+
+ check_bundles_connected ();
+ }
+
+ changed (IOChange (IOChange::ConnectionsChanged), src); /* EMIT SIGNAL */
- changed (IOChange (IOChange::ConnectionsChanged), src); /* EMIT SIGNAL */
_session.set_dirty ();
return 0;
}
{
- BLOCK_PROCESS_CALLBACK ();
-
- {
- Glib::Mutex::Lock lm (io_lock);
-
- /* check that our_port is really one of ours */
-
- if ( ! _ports.contains(our_port) ) {
- return -1;
- }
-
- /* connect it to the source */
-
- if (our_port->connect (other_port)) {
- return -1;
- }
+ Glib::Mutex::Lock lm (io_lock);
+
+ /* check that our_port is really one of ours */
+
+ if ( ! _ports.contains(our_port) ) {
+ return -1;
+ }
+
+ /* connect it to the source */
+
+ if (our_port->connect (other_port)) {
+ return -1;
}
}
int
IO::remove_port (Port* port, void* src)
{
+ ChanCount before = _ports.count ();
+ ChanCount after = before;
+ after.set (port->type(), after.get (port->type()) - 1);
+
+ bool const r = PortCountChanging (after); /* EMIT SIGNAL */
+ if (r) {
+ return -1;
+ }
+
IOChange change;
{
{
Glib::Mutex::Lock lm (io_lock);
- ChanCount before = _ports.count ();
-
if (_ports.remove(port)) {
change.type = IOChange::Type (change.type | IOChange::ConfigurationChanged);
change.before = before;
}
PortCountChanged (n_ports()); /* EMIT SIGNAL */
+
+ if (change.type != IOChange::NoChange) {
+ changed (change, src);
+ _session.set_dirty ();
+ }
}
if (change.type & IOChange::ConfigurationChanged) {
setup_bundle ();
}
- if (change.type != IOChange::NoChange) {
- changed (change, src);
- _session.set_dirty ();
- return 0;
+ if (change.type == IOChange::NoChange) {
+ return -1;
}
- return -1;
+ return 0;
}
/** Add a port.
}
PortCountChanged (n_ports()); /* EMIT SIGNAL */
+
+ // pan_changed (src); /* EMIT SIGNAL */
+ change.type = IOChange::ConfigurationChanged;
+ change.after = _ports.count ();
+ changed (change, src); /* EMIT SIGNAL */
}
if (destination.length()) {
}
}
- // pan_changed (src); /* EMIT SIGNAL */
- change.type = IOChange::ConfigurationChanged;
- change.after = _ports.count ();
- changed (change, src); /* EMIT SIGNAL */
setup_bundle ();
_session.set_dirty ();
IO::disconnect (void* src)
{
{
- BLOCK_PROCESS_CALLBACK ();
-
- {
- Glib::Mutex::Lock lm (io_lock);
-
- for (PortSet::iterator i = _ports.begin(); i != _ports.end(); ++i) {
- i->disconnect_all ();
- }
-
- check_bundles_connected ();
+ Glib::Mutex::Lock lm (io_lock);
+
+ for (PortSet::iterator i = _ports.begin(); i != _ports.end(); ++i) {
+ i->disconnect_all ();
}
+
+ check_bundles_connected ();
}
-
+
changed (IOChange (IOChange::ConnectionsChanged), src); /* EMIT SIGNAL */
return 0;
}
+/** Caller must hold process lock */
bool
IO::ensure_ports_locked (ChanCount count, bool clear, void* /*src*/)
{
+ assert (!AudioEngine::instance()->process_lock().trylock());
+
Port* port = 0;
bool changed = false;
return changed;
}
-
+/** Caller must hold process lock */
int
-IO::ensure_ports (ChanCount count, bool clear, bool lockit, void* src)
+IO::ensure_ports (ChanCount count, bool clear, void* src)
{
+ assert (!AudioEngine::instance()->process_lock().trylock());
+
bool changed = false;
if (count == n_ports() && !clear) {
change.before = _ports.count ();
- if (lockit) {
- BLOCK_PROCESS_CALLBACK ();
+ {
Glib::Mutex::Lock im (io_lock);
changed = ensure_ports_locked (count, clear, src);
- } else {
- changed = ensure_ports_locked (count, clear, src);
}
if (changed) {
change.after = _ports.count ();
change.type = IOChange::ConfigurationChanged;
this->changed (change, src); /* EMIT SIGNAL */
+ _buffers.attach_buffers (_ports);
setup_bundle ();
_session.set_dirty ();
}
return 0;
}
+/** Caller must hold process lock */
int
IO::ensure_io (ChanCount count, bool clear, void* src)
{
- return ensure_ports (count, clear, true, src);
+ assert (!AudioEngine::instance()->process_lock().trylock());
+
+ return ensure_ports (count, clear, src);
}
XMLNode&
get_port_counts (node, version, n, c);
- if (ensure_ports (n, true, true, this)) {
- error << string_compose(_("%1: cannot create I/O ports"), _name) << endmsg;
- return -1;
+ {
+ Glib::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
+
+ if (ensure_ports (n, true, this)) {
+ error << string_compose(_("%1: cannot create I/O ports"), _name) << endmsg;
+ return -1;
+ }
}
/* XXX use c */
return 0;
}
- // FIXME: audio-only
- if (ensure_ports (ChanCount(DataType::AUDIO, nports), true, true, this)) {
- return -1;
+ {
+ Glib::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
+
+ // FIXME: audio-only
+ if (ensure_ports (ChanCount(DataType::AUDIO, nports), true, this)) {
+ return -1;
+ }
}
string::size_type start, end, ostart;
}
void
-IO::set_port_latency (nframes_t nframes)
+IO::set_port_latency (framecnt_t nframes)
{
Glib::Mutex::Lock lm (io_lock);
}
}
-nframes_t
+framecnt_t
IO::latency () const
{
- nframes_t max_latency;
- nframes_t latency;
+ framecnt_t max_latency;
+ framecnt_t latency;
max_latency = 0;
int
IO::connect_ports_to_bundle (boost::shared_ptr<Bundle> c, void* src)
{
+ BLOCK_PROCESS_CALLBACK ();
+
{
- BLOCK_PROCESS_CALLBACK ();
Glib::Mutex::Lock lm2 (io_lock);
c->connect (_bundle, _session.engine());
int
IO::disconnect_ports_from_bundle (boost::shared_ptr<Bundle> c, void* src)
{
+ BLOCK_PROCESS_CALLBACK ();
+
{
- BLOCK_PROCESS_CALLBACK ();
Glib::Mutex::Lock lm2 (io_lock);
c->disconnect (_bundle, _session.engine());
}
void
-IO::process_input (boost::shared_ptr<Processor> proc, sframes_t start_frame, sframes_t end_frame, nframes_t nframes)
+IO::process_input (boost::shared_ptr<Processor> proc, framepos_t start_frame, framepos_t end_frame, pframes_t nframes)
{
- BufferSet bufs;
-
/* don't read the data into new buffers - just use the port buffers directly */
- bufs.attach_buffers (_ports, nframes, 0);
- proc->run (bufs, start_frame, end_frame, nframes, true);
+ _buffers.get_jack_port_addresses (_ports, nframes, 0);
+ proc->run (_buffers, start_frame, end_frame, nframes, true);
}
void
-IO::collect_input (BufferSet& bufs, nframes_t nframes, ChanCount offset)
+IO::collect_input (BufferSet& bufs, pframes_t nframes, ChanCount offset)
{
assert(bufs.available() >= _ports.count());
}
void
-IO::copy_to_outputs (BufferSet& bufs, DataType type, nframes_t nframes, nframes_t offset)
+IO::copy_to_outputs (BufferSet& bufs, DataType type, pframes_t nframes, framecnt_t offset)
{
// Copy any buffers 1:1 to outputs
return false;
}
+
+bool
+IO::has_port (Port* p) const
+{
+ Glib::Mutex::Lock lm (io_lock);
+ return _ports.contains (p);
+}