2008-06-02 21:41:35 +00:00
|
|
|
/*
|
2019-08-03 04:01:25 +02:00
|
|
|
* Copyright (C) 2000-2017 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
|
* Copyright (C) 2006-2014 David Robillard <d@drobilla.net>
|
|
|
|
|
* Copyright (C) 2006 Jesse Chappell <jesse@essej.net>
|
|
|
|
|
* Copyright (C) 2007-2011 Carl Hetherington <carl@carlh.net>
|
|
|
|
|
* Copyright (C) 2013-2015 John Emmas <john@creativepost.co.uk>
|
|
|
|
|
* Copyright (C) 2013-2016 Tim Mayberry <mojofunk@gmail.com>
|
|
|
|
|
* Copyright (C) 2013-2019 Robin Gareus <robin@gareus.org>
|
|
|
|
|
* Copyright (C) 2015 GZharun <grygoriiz@wavesglobal.com>
|
|
|
|
|
* Copyright (C) 2016-2017 Julien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
*/
|
2008-06-02 21:41:35 +00:00
|
|
|
|
|
|
|
|
#include <algorithm>
|
2010-04-03 16:11:56 +00:00
|
|
|
#include <cmath>
|
2013-08-04 15:17:19 +01:00
|
|
|
#include <vector>
|
2010-04-03 16:11:56 +00:00
|
|
|
|
2008-06-02 21:41:35 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <locale.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
2008-09-10 15:03:30 +00:00
|
|
|
#include <glibmm.h>
|
2012-07-25 17:48:55 +00:00
|
|
|
#include <glibmm/threads.h>
|
2008-06-02 21:41:35 +00:00
|
|
|
|
2009-02-25 18:26:51 +00:00
|
|
|
#include "pbd/xml++.h"
|
|
|
|
|
#include "pbd/replace_all.h"
|
|
|
|
|
#include "pbd/unknown_type.h"
|
2009-06-09 20:21:19 +00:00
|
|
|
#include "pbd/enumwriter.h"
|
2016-09-05 10:22:39 +10:00
|
|
|
#include "pbd/locale_guard.h"
|
2016-08-25 12:59:02 +10:00
|
|
|
#include "pbd/types_convert.h"
|
2009-02-25 18:26:51 +00:00
|
|
|
|
|
|
|
|
#include "ardour/audioengine.h"
|
2009-06-09 20:21:19 +00:00
|
|
|
#include "ardour/buffer.h"
|
2012-05-24 06:09:29 +00:00
|
|
|
#include "ardour/buffer_set.h"
|
2011-03-08 20:12:40 +00:00
|
|
|
#include "ardour/debug.h"
|
2009-02-25 18:26:51 +00:00
|
|
|
#include "ardour/io.h"
|
|
|
|
|
#include "ardour/port.h"
|
2015-03-23 13:51:45 +02:00
|
|
|
#include "ardour/profile.h"
|
2012-05-24 06:09:29 +00:00
|
|
|
#include "ardour/route.h"
|
2009-02-25 18:26:51 +00:00
|
|
|
#include "ardour/session.h"
|
2016-08-25 12:59:02 +10:00
|
|
|
#include "ardour/types_convert.h"
|
2009-02-25 18:26:51 +00:00
|
|
|
#include "ardour/user_bundle.h"
|
2008-06-02 21:41:35 +00:00
|
|
|
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2008-06-02 21:41:35 +00:00
|
|
|
|
2012-07-25 17:48:55 +00:00
|
|
|
#define BLOCK_PROCESS_CALLBACK() Glib::Threads::Mutex::Lock em (AudioEngine::instance()->process_lock())
|
2008-06-02 21:41:35 +00:00
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
using namespace ARDOUR;
|
|
|
|
|
using namespace PBD;
|
|
|
|
|
|
|
|
|
|
const string IO::state_node_name = "IO";
|
2009-12-19 20:26:31 +00:00
|
|
|
PBD::Signal1<void,ChanCount> IO::PortCountChanged;
|
2008-06-02 21:41:35 +00:00
|
|
|
|
|
|
|
|
/** @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).
|
|
|
|
|
*/
|
2012-07-17 13:59:46 +00:00
|
|
|
IO::IO (Session& s, const string& name, Direction dir, DataType default_type, bool sendish)
|
The great audio processing overhaul.
The vast majority of Route signal processing is now simply in the list of
processors. There are definitely regressions here, but there's also
a lot of things fixed. It's far too much work to let diverge anymore
regardless, so here it is.
The basic model is: A route has a fixed set of input channels (matching
its JACK input ports and diskstream). The first processor takes this
as input. The next processor is configured using the first processor's
output as input, and is allowed to choose whatever output it wants
given that input... and so on, and so on. Finally, the last processor's
requested output is used to set up the panner and create whatever Jack
ports are needed to output the data.
All 'special' internal processors (meter, fader, amp, insert, send) are
currently transparent: they read any input, and return the same set
of channels back (unmodified, except for amp).
User visible changes:
* LV2 Instrument support (tracks with both MIDI and audio channels)
* MIDI in/out plugin support
* Generic plugin replication (for MIDI plugins, MIDI/audio plugins)
* Movable meter point
Known Bugs:
* Things seem to get weird on loaded sessions
* Output delivery is sketchy
* 2.0 session loading was probably already broken...
but it's definitely broken now :)
Please test this and file bugs if you have any time...
git-svn-id: svn://localhost/ardour2/branches/3.0@5055 d708f5d6-7413-0410-9779-e7cbd77b26cf
2009-05-07 06:30:50 +00:00
|
|
|
: SessionObject (s, name)
|
2009-06-09 20:21:19 +00:00
|
|
|
, _direction (dir)
|
The great audio processing overhaul.
The vast majority of Route signal processing is now simply in the list of
processors. There are definitely regressions here, but there's also
a lot of things fixed. It's far too much work to let diverge anymore
regardless, so here it is.
The basic model is: A route has a fixed set of input channels (matching
its JACK input ports and diskstream). The first processor takes this
as input. The next processor is configured using the first processor's
output as input, and is allowed to choose whatever output it wants
given that input... and so on, and so on. Finally, the last processor's
requested output is used to set up the panner and create whatever Jack
ports are needed to output the data.
All 'special' internal processors (meter, fader, amp, insert, send) are
currently transparent: they read any input, and return the same set
of channels back (unmodified, except for amp).
User visible changes:
* LV2 Instrument support (tracks with both MIDI and audio channels)
* MIDI in/out plugin support
* Generic plugin replication (for MIDI plugins, MIDI/audio plugins)
* Movable meter point
Known Bugs:
* Things seem to get weird on loaded sessions
* Output delivery is sketchy
* 2.0 session loading was probably already broken...
but it's definitely broken now :)
Please test this and file bugs if you have any time...
git-svn-id: svn://localhost/ardour2/branches/3.0@5055 d708f5d6-7413-0410-9779-e7cbd77b26cf
2009-05-07 06:30:50 +00:00
|
|
|
, _default_type (default_type)
|
2012-07-17 13:59:46 +00:00
|
|
|
, _sendish (sendish)
|
The great audio processing overhaul.
The vast majority of Route signal processing is now simply in the list of
processors. There are definitely regressions here, but there's also
a lot of things fixed. It's far too much work to let diverge anymore
regardless, so here it is.
The basic model is: A route has a fixed set of input channels (matching
its JACK input ports and diskstream). The first processor takes this
as input. The next processor is configured using the first processor's
output as input, and is allowed to choose whatever output it wants
given that input... and so on, and so on. Finally, the last processor's
requested output is used to set up the panner and create whatever Jack
ports are needed to output the data.
All 'special' internal processors (meter, fader, amp, insert, send) are
currently transparent: they read any input, and return the same set
of channels back (unmodified, except for amp).
User visible changes:
* LV2 Instrument support (tracks with both MIDI and audio channels)
* MIDI in/out plugin support
* Generic plugin replication (for MIDI plugins, MIDI/audio plugins)
* Movable meter point
Known Bugs:
* Things seem to get weird on loaded sessions
* Output delivery is sketchy
* 2.0 session loading was probably already broken...
but it's definitely broken now :)
Please test this and file bugs if you have any time...
git-svn-id: svn://localhost/ardour2/branches/3.0@5055 d708f5d6-7413-0410-9779-e7cbd77b26cf
2009-05-07 06:30:50 +00:00
|
|
|
{
|
2009-06-09 20:21:19 +00:00
|
|
|
_active = true;
|
2009-11-25 23:24:02 +00:00
|
|
|
setup_bundle ();
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
|
2012-07-17 13:59:46 +00:00
|
|
|
IO::IO (Session& s, const XMLNode& node, DataType dt, bool sendish)
|
The great audio processing overhaul.
The vast majority of Route signal processing is now simply in the list of
processors. There are definitely regressions here, but there's also
a lot of things fixed. It's far too much work to let diverge anymore
regardless, so here it is.
The basic model is: A route has a fixed set of input channels (matching
its JACK input ports and diskstream). The first processor takes this
as input. The next processor is configured using the first processor's
output as input, and is allowed to choose whatever output it wants
given that input... and so on, and so on. Finally, the last processor's
requested output is used to set up the panner and create whatever Jack
ports are needed to output the data.
All 'special' internal processors (meter, fader, amp, insert, send) are
currently transparent: they read any input, and return the same set
of channels back (unmodified, except for amp).
User visible changes:
* LV2 Instrument support (tracks with both MIDI and audio channels)
* MIDI in/out plugin support
* Generic plugin replication (for MIDI plugins, MIDI/audio plugins)
* Movable meter point
Known Bugs:
* Things seem to get weird on loaded sessions
* Output delivery is sketchy
* 2.0 session loading was probably already broken...
but it's definitely broken now :)
Please test this and file bugs if you have any time...
git-svn-id: svn://localhost/ardour2/branches/3.0@5055 d708f5d6-7413-0410-9779-e7cbd77b26cf
2009-05-07 06:30:50 +00:00
|
|
|
: SessionObject(s, "unnamed io")
|
2009-06-09 20:21:19 +00:00
|
|
|
, _direction (Input)
|
The great audio processing overhaul.
The vast majority of Route signal processing is now simply in the list of
processors. There are definitely regressions here, but there's also
a lot of things fixed. It's far too much work to let diverge anymore
regardless, so here it is.
The basic model is: A route has a fixed set of input channels (matching
its JACK input ports and diskstream). The first processor takes this
as input. The next processor is configured using the first processor's
output as input, and is allowed to choose whatever output it wants
given that input... and so on, and so on. Finally, the last processor's
requested output is used to set up the panner and create whatever Jack
ports are needed to output the data.
All 'special' internal processors (meter, fader, amp, insert, send) are
currently transparent: they read any input, and return the same set
of channels back (unmodified, except for amp).
User visible changes:
* LV2 Instrument support (tracks with both MIDI and audio channels)
* MIDI in/out plugin support
* Generic plugin replication (for MIDI plugins, MIDI/audio plugins)
* Movable meter point
Known Bugs:
* Things seem to get weird on loaded sessions
* Output delivery is sketchy
* 2.0 session loading was probably already broken...
but it's definitely broken now :)
Please test this and file bugs if you have any time...
git-svn-id: svn://localhost/ardour2/branches/3.0@5055 d708f5d6-7413-0410-9779-e7cbd77b26cf
2009-05-07 06:30:50 +00:00
|
|
|
, _default_type (dt)
|
2012-07-17 13:59:46 +00:00
|
|
|
, _sendish (sendish)
|
The great audio processing overhaul.
The vast majority of Route signal processing is now simply in the list of
processors. There are definitely regressions here, but there's also
a lot of things fixed. It's far too much work to let diverge anymore
regardless, so here it is.
The basic model is: A route has a fixed set of input channels (matching
its JACK input ports and diskstream). The first processor takes this
as input. The next processor is configured using the first processor's
output as input, and is allowed to choose whatever output it wants
given that input... and so on, and so on. Finally, the last processor's
requested output is used to set up the panner and create whatever Jack
ports are needed to output the data.
All 'special' internal processors (meter, fader, amp, insert, send) are
currently transparent: they read any input, and return the same set
of channels back (unmodified, except for amp).
User visible changes:
* LV2 Instrument support (tracks with both MIDI and audio channels)
* MIDI in/out plugin support
* Generic plugin replication (for MIDI plugins, MIDI/audio plugins)
* Movable meter point
Known Bugs:
* Things seem to get weird on loaded sessions
* Output delivery is sketchy
* 2.0 session loading was probably already broken...
but it's definitely broken now :)
Please test this and file bugs if you have any time...
git-svn-id: svn://localhost/ardour2/branches/3.0@5055 d708f5d6-7413-0410-9779-e7cbd77b26cf
2009-05-07 06:30:50 +00:00
|
|
|
{
|
2009-06-09 20:21:19 +00:00
|
|
|
_active = true;
|
2008-06-02 21:41:35 +00:00
|
|
|
|
2009-10-15 18:56:11 +00:00
|
|
|
set_state (node, Stateful::loading_state_version);
|
2009-11-25 23:24:02 +00:00
|
|
|
setup_bundle ();
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IO::~IO ()
|
|
|
|
|
{
|
2012-07-25 17:48:55 +00:00
|
|
|
Glib::Threads::Mutex::Lock lm (io_lock);
|
2008-06-02 21:41:35 +00:00
|
|
|
|
2016-10-14 12:30:16 -04:00
|
|
|
DEBUG_TRACE (DEBUG::Ports, string_compose ("IO %1 unregisters %2 ports\n", name(), _ports.num_ports()));
|
|
|
|
|
|
2008-06-02 21:41:35 +00:00
|
|
|
BLOCK_PROCESS_CALLBACK ();
|
|
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
for (PortSet::iterator i = _ports.begin(); i != _ports.end(); ++i) {
|
2008-06-02 21:41:35 +00:00
|
|
|
_session.engine().unregister_port (*i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-26 19:00:27 +00:00
|
|
|
void
|
2021-06-11 20:01:22 +02:00
|
|
|
IO::connection_change (boost::shared_ptr<Port> a, boost::shared_ptr<Port> b)
|
2012-01-26 19:00:27 +00:00
|
|
|
{
|
2019-03-18 15:33:05 +01:00
|
|
|
if (_session.deletion_in_progress ()) {
|
2016-04-18 21:55:50 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2012-01-26 19:00:27 +00:00
|
|
|
/* this could be called from within our own ::disconnect() method(s)
|
|
|
|
|
or from somewhere that operates directly on a port. so, we don't
|
|
|
|
|
know for sure if we can take this lock or not. if we fail,
|
|
|
|
|
we assume that its safely locked by our own ::disconnect().
|
|
|
|
|
*/
|
|
|
|
|
|
2012-07-25 17:48:55 +00:00
|
|
|
Glib::Threads::Mutex::Lock tm (io_lock, Glib::Threads::TRY_LOCK);
|
2012-01-26 19:00:27 +00:00
|
|
|
|
|
|
|
|
if (tm.locked()) {
|
|
|
|
|
/* we took the lock, so we cannot be here from inside
|
|
|
|
|
* ::disconnect()
|
|
|
|
|
*/
|
|
|
|
|
if (_ports.contains (a) || _ports.contains (b)) {
|
2015-10-05 16:17:49 +02:00
|
|
|
changed (IOChange (IOChange::ConnectionsChanged), this); /* EMIT SIGNAL */
|
2012-01-26 19:00:27 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
/* we didn't get the lock, so assume that we're inside
|
|
|
|
|
* ::disconnect(), and it will call changed() appropriately.
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-02 21:41:35 +00:00
|
|
|
void
|
2017-09-18 12:39:17 -04:00
|
|
|
IO::silence (samplecnt_t nframes)
|
2008-06-02 21:41:35 +00:00
|
|
|
{
|
|
|
|
|
/* io_lock, not taken: function must be called from Session::process() calltree */
|
|
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
for (PortSet::iterator i = _ports.begin(); i != _ports.end(); ++i) {
|
2017-08-03 23:54:26 +02:00
|
|
|
if (i->port_handle ()) {
|
|
|
|
|
i->get_buffer(nframes).silence (nframes);
|
|
|
|
|
}
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2011-10-28 17:04:09 +00:00
|
|
|
IO::disconnect (boost::shared_ptr<Port> our_port, string other_port, void* src)
|
2008-06-02 21:41:35 +00:00
|
|
|
{
|
|
|
|
|
if (other_port.length() == 0 || our_port == 0) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2010-12-29 17:52:32 +00:00
|
|
|
|
2017-09-18 06:47:01 +02:00
|
|
|
{
|
|
|
|
|
Glib::Threads::Mutex::Lock lm (io_lock);
|
2011-06-01 16:50:12 +00:00
|
|
|
|
2017-09-18 06:47:01 +02:00
|
|
|
/* check that our_port is really one of ours */
|
2011-06-01 16:50:12 +00:00
|
|
|
|
2017-09-18 06:47:01 +02:00
|
|
|
if ( ! _ports.contains(our_port)) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2011-06-01 16:50:12 +00:00
|
|
|
|
2017-09-18 06:47:01 +02:00
|
|
|
/* disconnect it from the source */
|
2011-06-01 16:50:12 +00:00
|
|
|
|
2020-07-18 20:09:14 +02:00
|
|
|
DEBUG_TRACE (DEBUG::PortConnectIO,
|
|
|
|
|
string_compose("IO::disconnect %1 from %2\n", our_port->name(), other_port));
|
|
|
|
|
|
2017-09-18 06:47:01 +02:00
|
|
|
if (our_port->disconnect (other_port)) {
|
|
|
|
|
error << string_compose(_("IO: cannot disconnect port %1 from %2"), our_port->name(), other_port) << endmsg;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-06-01 16:50:12 +00:00
|
|
|
|
2017-09-18 06:47:01 +02:00
|
|
|
changed (IOChange (IOChange::ConnectionsChanged), src); /* EMIT SIGNAL */
|
2008-06-02 21:41:35 +00:00
|
|
|
|
|
|
|
|
_session.set_dirty ();
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2011-10-28 17:04:09 +00:00
|
|
|
IO::connect (boost::shared_ptr<Port> our_port, string other_port, void* src)
|
2008-06-02 21:41:35 +00:00
|
|
|
{
|
|
|
|
|
if (other_port.length() == 0 || our_port == 0) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
2012-07-25 17:48:55 +00:00
|
|
|
Glib::Threads::Mutex::Lock lm (io_lock);
|
2011-06-01 16:50:12 +00:00
|
|
|
|
2010-11-25 23:46:24 +00:00
|
|
|
/* check that our_port is really one of ours */
|
2011-06-01 16:50:12 +00:00
|
|
|
|
2010-11-25 23:46:24 +00:00
|
|
|
if ( ! _ports.contains(our_port) ) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2011-06-01 16:50:12 +00:00
|
|
|
|
2010-11-25 23:46:24 +00:00
|
|
|
/* connect it to the source */
|
2011-06-01 16:50:12 +00:00
|
|
|
|
2020-07-18 20:09:14 +02:00
|
|
|
DEBUG_TRACE (DEBUG::PortConnectIO,
|
|
|
|
|
string_compose("IO::connect %1 to %2\n", our_port->name(), other_port));
|
|
|
|
|
|
2010-11-25 23:46:24 +00:00
|
|
|
if (our_port->connect (other_port)) {
|
|
|
|
|
return -1;
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-08-30 22:34:21 +00:00
|
|
|
changed (IOChange (IOChange::ConnectionsChanged), src); /* EMIT SIGNAL */
|
2008-06-02 21:41:35 +00:00
|
|
|
_session.set_dirty ();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-11 22:57:34 +02:00
|
|
|
bool
|
|
|
|
|
IO::can_add_port (DataType type) const
|
|
|
|
|
{
|
|
|
|
|
switch (type) {
|
|
|
|
|
case DataType::NIL:
|
|
|
|
|
return false;
|
|
|
|
|
case DataType::AUDIO:
|
|
|
|
|
return true;
|
|
|
|
|
case DataType::MIDI:
|
|
|
|
|
return _ports.count ().n_midi() < 1;
|
|
|
|
|
}
|
2019-08-07 17:27:56 +02:00
|
|
|
abort(); /*NOTREACHED*/
|
|
|
|
|
return false;
|
2019-07-11 22:57:34 +02:00
|
|
|
}
|
|
|
|
|
|
2008-06-02 21:41:35 +00:00
|
|
|
int
|
2011-10-28 17:04:09 +00:00
|
|
|
IO::remove_port (boost::shared_ptr<Port> port, void* src)
|
2008-06-02 21:41:35 +00:00
|
|
|
{
|
2010-11-25 23:46:24 +00:00
|
|
|
ChanCount before = _ports.count ();
|
|
|
|
|
ChanCount after = before;
|
|
|
|
|
after.set (port->type(), after.get (port->type()) - 1);
|
|
|
|
|
|
2012-05-14 17:18:48 +00:00
|
|
|
boost::optional<bool> const r = PortCountChanging (after); /* EMIT SIGNAL */
|
2019-11-21 17:48:56 +01:00
|
|
|
if (r.value_or (false)) {
|
2010-11-25 23:46:24 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-30 22:34:21 +00:00
|
|
|
IOChange change;
|
2008-06-02 21:41:35 +00:00
|
|
|
|
|
|
|
|
{
|
|
|
|
|
BLOCK_PROCESS_CALLBACK ();
|
|
|
|
|
|
|
|
|
|
{
|
2012-07-25 17:48:55 +00:00
|
|
|
Glib::Threads::Mutex::Lock lm (io_lock);
|
2008-06-02 21:41:35 +00:00
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
if (_ports.remove(port)) {
|
2010-08-30 22:34:21 +00:00
|
|
|
change.type = IOChange::Type (change.type | IOChange::ConfigurationChanged);
|
|
|
|
|
change.before = before;
|
|
|
|
|
change.after = _ports.count ();
|
2008-06-02 21:41:35 +00:00
|
|
|
|
|
|
|
|
if (port->connected()) {
|
2010-08-30 22:34:21 +00:00
|
|
|
change.type = IOChange::Type (change.type | IOChange::ConnectionsChanged);
|
2009-10-14 16:10:01 +00:00
|
|
|
}
|
2008-06-02 21:41:35 +00:00
|
|
|
|
2011-10-28 17:04:09 +00:00
|
|
|
_session.engine().unregister_port (port);
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
PortCountChanged (n_ports()); /* EMIT SIGNAL */
|
2010-11-25 23:46:24 +00:00
|
|
|
|
|
|
|
|
if (change.type != IOChange::NoChange) {
|
|
|
|
|
changed (change, src);
|
2011-07-13 01:00:53 +00:00
|
|
|
_buffers.attach_buffers (_ports);
|
2010-11-25 23:46:24 +00:00
|
|
|
}
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
|
2010-08-30 22:34:21 +00:00
|
|
|
if (change.type & IOChange::ConfigurationChanged) {
|
2009-11-25 23:24:02 +00:00
|
|
|
setup_bundle ();
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
|
2010-11-25 23:46:24 +00:00
|
|
|
if (change.type == IOChange::NoChange) {
|
|
|
|
|
return -1;
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
|
2011-07-13 01:00:53 +00:00
|
|
|
_session.set_dirty ();
|
2015-10-05 16:17:49 +02:00
|
|
|
|
2010-11-25 23:46:24 +00:00
|
|
|
return 0;
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
|
2010-09-06 21:00:31 +00:00
|
|
|
/** Add a port.
|
2008-06-02 21:41:35 +00:00
|
|
|
*
|
2010-09-06 21:00:31 +00:00
|
|
|
* @param destination Name of port to connect new port to.
|
2008-06-02 21:41:35 +00:00
|
|
|
* @param src Source for emitted ConfigurationChanged signal.
|
|
|
|
|
* @param type Data type of port. Default value (NIL) will use this IO's default type.
|
|
|
|
|
*/
|
|
|
|
|
int
|
2009-06-09 20:21:19 +00:00
|
|
|
IO::add_port (string destination, void* src, DataType type)
|
2008-06-02 21:41:35 +00:00
|
|
|
{
|
2011-10-28 17:04:09 +00:00
|
|
|
boost::shared_ptr<Port> our_port;
|
2008-06-02 21:41:35 +00:00
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
if (type == DataType::NIL) {
|
2008-06-02 21:41:35 +00:00
|
|
|
type = _default_type;
|
2009-06-09 20:21:19 +00:00
|
|
|
}
|
2008-06-02 21:41:35 +00:00
|
|
|
|
2019-07-11 22:57:34 +02:00
|
|
|
if (!can_add_port (type)) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-07 17:50:56 +00:00
|
|
|
ChanCount before = _ports.count ();
|
|
|
|
|
ChanCount after = before;
|
|
|
|
|
after.set (type, after.get (type) + 1);
|
2015-10-05 16:17:49 +02:00
|
|
|
|
2011-12-07 17:50:56 +00:00
|
|
|
bool const r = PortCountChanging (after); /* EMIT SIGNAL */
|
|
|
|
|
if (r) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2015-10-05 16:17:49 +02:00
|
|
|
|
2010-08-30 22:34:21 +00:00
|
|
|
IOChange change;
|
|
|
|
|
|
2008-06-02 21:41:35 +00:00
|
|
|
{
|
|
|
|
|
BLOCK_PROCESS_CALLBACK ();
|
|
|
|
|
|
2009-10-14 16:10:01 +00:00
|
|
|
|
|
|
|
|
{
|
2012-07-25 17:48:55 +00:00
|
|
|
Glib::Threads::Mutex::Lock lm (io_lock);
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2010-09-06 21:00:31 +00:00
|
|
|
/* Create a new port */
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
string portname = build_legal_port_name (type);
|
2015-10-05 16:17:49 +02:00
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
if (_direction == Input) {
|
|
|
|
|
if ((our_port = _session.engine().register_input_port (type, portname)) == 0) {
|
|
|
|
|
error << string_compose(_("IO: cannot register input port %1"), portname) << endmsg;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if ((our_port = _session.engine().register_output_port (type, portname)) == 0) {
|
|
|
|
|
error << string_compose(_("IO: cannot register output port %1"), portname) << endmsg;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
2009-06-09 20:21:19 +00:00
|
|
|
|
2010-08-30 22:34:21 +00:00
|
|
|
change.before = _ports.count ();
|
2009-06-09 20:21:19 +00:00
|
|
|
_ports.add (our_port);
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
2015-10-05 16:17:49 +02:00
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
PortCountChanged (n_ports()); /* EMIT SIGNAL */
|
2010-11-25 23:46:24 +00:00
|
|
|
change.type = IOChange::ConfigurationChanged;
|
|
|
|
|
change.after = _ports.count ();
|
|
|
|
|
changed (change, src); /* EMIT SIGNAL */
|
2011-07-13 01:00:53 +00:00
|
|
|
_buffers.attach_buffers (_ports);
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
|
2011-07-22 15:44:13 +00:00
|
|
|
if (!destination.empty()) {
|
2009-02-10 00:49:19 +00:00
|
|
|
if (our_port->connect (destination)) {
|
2008-06-02 21:41:35 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2016-04-17 21:50:13 +02:00
|
|
|
apply_pretty_name ();
|
2009-11-25 23:24:02 +00:00
|
|
|
setup_bundle ();
|
2008-06-02 21:41:35 +00:00
|
|
|
_session.set_dirty ();
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2009-06-09 20:21:19 +00:00
|
|
|
IO::disconnect (void* src)
|
2008-06-02 21:41:35 +00:00
|
|
|
{
|
2009-10-14 16:10:01 +00:00
|
|
|
{
|
2012-07-25 17:48:55 +00:00
|
|
|
Glib::Threads::Mutex::Lock lm (io_lock);
|
2011-06-01 16:50:12 +00:00
|
|
|
|
2010-11-25 23:46:24 +00:00
|
|
|
for (PortSet::iterator i = _ports.begin(); i != _ports.end(); ++i) {
|
|
|
|
|
i->disconnect_all ();
|
2009-06-09 20:21:19 +00:00
|
|
|
}
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
2011-06-01 16:50:12 +00:00
|
|
|
|
2010-08-30 22:34:21 +00:00
|
|
|
changed (IOChange (IOChange::ConnectionsChanged), src); /* EMIT SIGNAL */
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
return 0;
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
|
2010-11-25 23:46:24 +00:00
|
|
|
/** Caller must hold process lock */
|
2011-07-25 16:11:00 +00:00
|
|
|
int
|
|
|
|
|
IO::ensure_ports_locked (ChanCount count, bool clear, bool& changed)
|
2008-06-02 21:41:35 +00:00
|
|
|
{
|
2013-08-04 19:03:32 +01:00
|
|
|
#ifndef PLATFORM_WINDOWS
|
2010-11-25 23:46:24 +00:00
|
|
|
assert (!AudioEngine::instance()->process_lock().trylock());
|
2013-07-13 16:57:04 -04:00
|
|
|
#endif
|
2011-06-01 16:50:12 +00:00
|
|
|
|
2011-10-28 17:04:09 +00:00
|
|
|
boost::shared_ptr<Port> port;
|
2016-08-08 09:26:50 -04:00
|
|
|
vector<boost::shared_ptr<Port> > deleted_ports;
|
2011-07-25 16:11:00 +00:00
|
|
|
|
|
|
|
|
changed = false;
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
const size_t n = count.get(*t);
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
/* remove unused ports */
|
|
|
|
|
for (size_t i = n_ports().get(*t); i > n; --i) {
|
|
|
|
|
port = _ports.port(*t, i-1);
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
assert(port);
|
|
|
|
|
_ports.remove(port);
|
2016-08-08 09:26:50 -04:00
|
|
|
|
|
|
|
|
/* hold a reference to the port so that we can ensure
|
|
|
|
|
* that this thread, and not a JACK notification thread,
|
|
|
|
|
* holds the final reference.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
deleted_ports.push_back (port);
|
2011-10-28 17:04:09 +00:00
|
|
|
_session.engine().unregister_port (port);
|
2008-06-02 21:41:35 +00:00
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
changed = true;
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
|
2016-08-08 09:26:50 -04:00
|
|
|
/* this will drop the final reference to the deleted ports,
|
|
|
|
|
* which will in turn call their destructors, which will in
|
|
|
|
|
* turn call the backend to unregister them.
|
|
|
|
|
*
|
|
|
|
|
* There will no connect/disconnect or register/unregister
|
|
|
|
|
* callbacks from the backend until we get here, because
|
|
|
|
|
* they are driven by the Port destructor. The destructor
|
|
|
|
|
* will not execute until we drop the final reference,
|
|
|
|
|
* which all happens right .... here.
|
|
|
|
|
*/
|
|
|
|
|
deleted_ports.clear ();
|
|
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
/* create any necessary new ports */
|
|
|
|
|
while (n_ports().get(*t) < n) {
|
2008-06-02 21:41:35 +00:00
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
string portname = build_legal_port_name (*t);
|
2008-06-02 21:41:35 +00:00
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
try {
|
2008-06-02 21:41:35 +00:00
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
if (_direction == Input) {
|
2009-02-11 00:58:24 +00:00
|
|
|
if ((port = _session.engine().register_input_port (*t, portname)) == 0) {
|
2008-06-02 21:41:35 +00:00
|
|
|
error << string_compose(_("IO: cannot register input port %1"), portname) << endmsg;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2009-06-09 20:21:19 +00:00
|
|
|
} else {
|
2009-02-11 00:58:24 +00:00
|
|
|
if ((port = _session.engine().register_output_port (*t, portname)) == 0) {
|
2008-06-02 21:41:35 +00:00
|
|
|
error << string_compose(_("IO: cannot register output port %1"), portname) << endmsg;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
catch (AudioEngine::PortRegistrationFailure& err) {
|
|
|
|
|
/* pass it on */
|
2010-05-09 00:46:54 +00:00
|
|
|
throw;
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
_ports.add (port);
|
2008-06-02 21:41:35 +00:00
|
|
|
changed = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2008-06-02 21:41:35 +00:00
|
|
|
if (changed) {
|
2009-06-09 20:21:19 +00:00
|
|
|
PortCountChanged (n_ports()); /* EMIT SIGNAL */
|
2008-06-02 21:41:35 +00:00
|
|
|
_session.set_dirty ();
|
|
|
|
|
}
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2008-06-02 21:41:35 +00:00
|
|
|
if (clear) {
|
|
|
|
|
/* disconnect all existing ports so that we get a fresh start */
|
2009-06-09 20:21:19 +00:00
|
|
|
for (PortSet::iterator i = _ports.begin(); i != _ports.end(); ++i) {
|
2009-02-10 00:49:19 +00:00
|
|
|
i->disconnect_all ();
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-25 16:11:00 +00:00
|
|
|
return 0;
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
|
2010-11-25 23:46:24 +00:00
|
|
|
/** Caller must hold process lock */
|
2008-06-02 21:41:35 +00:00
|
|
|
int
|
2010-11-25 00:03:14 +00:00
|
|
|
IO::ensure_ports (ChanCount count, bool clear, void* src)
|
2008-06-02 21:41:35 +00:00
|
|
|
{
|
2013-08-04 19:03:32 +01:00
|
|
|
#ifndef PLATFORM_WINDOWS
|
2010-11-25 23:46:24 +00:00
|
|
|
assert (!AudioEngine::instance()->process_lock().trylock());
|
2013-07-13 16:57:04 -04:00
|
|
|
#endif
|
2011-06-01 16:50:12 +00:00
|
|
|
|
2008-06-02 21:41:35 +00:00
|
|
|
bool changed = false;
|
|
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
if (count == n_ports() && !clear) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2008-06-02 21:41:35 +00:00
|
|
|
|
2010-08-30 22:34:21 +00:00
|
|
|
IOChange change;
|
|
|
|
|
|
|
|
|
|
change.before = _ports.count ();
|
2011-06-01 16:50:12 +00:00
|
|
|
|
2010-11-25 00:03:14 +00:00
|
|
|
{
|
2012-07-25 17:48:55 +00:00
|
|
|
Glib::Threads::Mutex::Lock im (io_lock);
|
2011-07-25 16:11:00 +00:00
|
|
|
if (ensure_ports_locked (count, clear, changed)) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (changed) {
|
2010-08-30 22:34:21 +00:00
|
|
|
change.after = _ports.count ();
|
|
|
|
|
change.type = IOChange::ConfigurationChanged;
|
|
|
|
|
this->changed (change, src); /* EMIT SIGNAL */
|
2011-01-10 16:23:54 +00:00
|
|
|
_buffers.attach_buffers (_ports);
|
2009-11-25 23:24:02 +00:00
|
|
|
setup_bundle ();
|
2009-06-09 20:21:19 +00:00
|
|
|
_session.set_dirty ();
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-11 20:01:22 +02:00
|
|
|
void
|
|
|
|
|
IO::reestablish_port_subscriptions ()
|
|
|
|
|
{
|
|
|
|
|
_port_connections.drop_connections ();
|
|
|
|
|
for (PortSet::iterator i = _ports.begin(); i != _ports.end(); ++i) {
|
|
|
|
|
i->ConnectedOrDisconnected.connect_same_thread (*this, boost::bind (&IO::connection_change, this, _1, _2));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-25 23:46:24 +00:00
|
|
|
/** Caller must hold process lock */
|
2008-06-02 21:41:35 +00:00
|
|
|
int
|
2009-06-09 20:21:19 +00:00
|
|
|
IO::ensure_io (ChanCount count, bool clear, void* src)
|
2008-06-02 21:41:35 +00:00
|
|
|
{
|
2013-08-04 19:03:32 +01:00
|
|
|
#ifndef PLATFORM_WINDOWS
|
2010-11-25 23:46:24 +00:00
|
|
|
assert (!AudioEngine::instance()->process_lock().trylock());
|
2013-07-13 16:57:04 -04:00
|
|
|
#endif
|
2011-06-01 16:50:12 +00:00
|
|
|
|
2010-11-25 00:03:14 +00:00
|
|
|
return ensure_ports (count, clear, src);
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
XMLNode&
|
2011-10-27 23:36:42 +00:00
|
|
|
IO::get_state ()
|
2008-06-02 21:41:35 +00:00
|
|
|
{
|
2017-10-04 00:35:29 +02:00
|
|
|
return state ();
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
XMLNode&
|
2017-10-04 00:35:29 +02:00
|
|
|
IO::state ()
|
2008-06-02 21:41:35 +00:00
|
|
|
{
|
|
|
|
|
XMLNode* node = new XMLNode (state_node_name);
|
|
|
|
|
int n;
|
2012-07-25 17:48:55 +00:00
|
|
|
Glib::Threads::Mutex::Lock lm (io_lock);
|
2008-06-02 21:41:35 +00:00
|
|
|
|
2016-08-25 12:59:02 +10:00
|
|
|
node->set_property ("name", name());
|
|
|
|
|
node->set_property ("id", id ());
|
|
|
|
|
node->set_property ("direction", _direction);
|
|
|
|
|
node->set_property ("default-type", _default_type);
|
2008-06-02 21:41:35 +00:00
|
|
|
|
2016-04-17 21:50:13 +02:00
|
|
|
if (!_pretty_name_prefix.empty ()) {
|
2016-08-25 12:59:02 +10:00
|
|
|
node->set_property("pretty-name", _pretty_name_prefix);
|
2016-04-17 21:50:13 +02:00
|
|
|
}
|
|
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
for (PortSet::iterator i = _ports.begin(); i != _ports.end(); ++i) {
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2008-06-02 21:41:35 +00:00
|
|
|
vector<string> connections;
|
|
|
|
|
|
2009-06-09 21:30:32 +00:00
|
|
|
XMLNode* pnode = new XMLNode (X_("Port"));
|
2016-08-25 12:59:02 +10:00
|
|
|
pnode->set_property (X_("type"), i->type());
|
|
|
|
|
pnode->set_property (X_("name"), i->name());
|
2009-06-09 20:21:19 +00:00
|
|
|
|
2008-06-02 21:41:35 +00:00
|
|
|
if (i->get_connections (connections)) {
|
2015-09-27 16:10:10 +02:00
|
|
|
vector<string>::const_iterator ci;
|
|
|
|
|
std::sort (connections.begin(), connections.end());
|
2008-06-02 21:41:35 +00:00
|
|
|
|
|
|
|
|
for (n = 0, ci = connections.begin(); ci != connections.end(); ++ci, ++n) {
|
2009-06-09 20:21:19 +00:00
|
|
|
|
2008-06-02 21:41:35 +00:00
|
|
|
/* if its a connection to our own port,
|
|
|
|
|
return only the port name, not the
|
|
|
|
|
whole thing. this allows connections
|
|
|
|
|
to be re-established even when our
|
|
|
|
|
client name is different.
|
|
|
|
|
*/
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2009-06-23 02:43:35 +00:00
|
|
|
XMLNode* cnode = new XMLNode (X_("Connection"));
|
|
|
|
|
|
2016-08-25 12:59:02 +10:00
|
|
|
cnode->set_property (X_("other"), _session.engine().make_port_name_relative (*ci));
|
2009-06-23 02:43:35 +00:00
|
|
|
pnode->add_child_nocopy (*cnode);
|
2009-10-14 16:10:01 +00:00
|
|
|
}
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
node->add_child_nocopy (*pnode);
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return *node;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2009-10-15 00:57:55 +00:00
|
|
|
IO::set_state (const XMLNode& node, int version)
|
2008-06-02 21:41:35 +00:00
|
|
|
{
|
2009-10-15 00:57:55 +00:00
|
|
|
/* callers for version < 3000 need to call set_state_2X directly, as A3 IOs
|
|
|
|
|
* are input OR output, not both, so the direction needs to be specified
|
|
|
|
|
* by the caller.
|
|
|
|
|
*/
|
|
|
|
|
assert (version >= 3000);
|
2009-10-20 00:50:43 +00:00
|
|
|
|
2008-06-02 21:41:35 +00:00
|
|
|
/* force use of non-localized representation of decimal point,
|
|
|
|
|
since we use it a lot in XML files and so forth.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if (node.name() != state_node_name) {
|
|
|
|
|
error << string_compose(_("incorrect XML node \"%1\" passed to IO object"), node.name()) << endmsg;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2017-03-31 19:53:14 +02:00
|
|
|
bool ignore_name = node.property ("ignore-name");
|
2016-08-25 12:59:02 +10:00
|
|
|
std::string name;
|
|
|
|
|
if (node.get_property ("name", name) && !ignore_name) {
|
|
|
|
|
set_name (name);
|
2009-02-14 17:28:01 +00:00
|
|
|
}
|
2008-06-02 21:41:35 +00:00
|
|
|
|
2016-08-25 12:59:02 +10:00
|
|
|
if (node.get_property (X_("default-type"), _default_type)) {
|
2009-06-09 20:21:19 +00:00
|
|
|
assert(_default_type != DataType::NIL);
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
|
2011-10-18 13:18:47 +00:00
|
|
|
set_id (node);
|
2008-06-02 21:41:35 +00:00
|
|
|
|
2016-08-25 12:59:02 +10:00
|
|
|
node.get_property ("direction", _direction);
|
2008-06-02 21:41:35 +00:00
|
|
|
|
2009-10-15 00:57:55 +00:00
|
|
|
if (create_ports (node, version)) {
|
2009-06-09 20:21:19 +00:00
|
|
|
return -1;
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
2021-11-03 15:06:16 -06:00
|
|
|
|
2019-03-28 03:01:53 +01:00
|
|
|
if (_sendish && _direction == Output) {
|
|
|
|
|
/* ignore <Port name="..."> from XML for sends, but use the names
|
|
|
|
|
* ::ensure_ports_locked() creates port using ::build_legal_port_name()
|
|
|
|
|
* This is needed to properly restore connections when creating
|
|
|
|
|
* external sends from templates because the IO name changes.
|
|
|
|
|
*/
|
|
|
|
|
PortSet::iterator i = _ports.begin();
|
|
|
|
|
XMLNodeConstIterator x = node.children().begin();
|
2021-03-17 17:59:36 +01:00
|
|
|
for (; i != _ports.end() && x != node.children().end(); ++i, ++x) {
|
2019-03-28 03:01:53 +01:00
|
|
|
if ((*x)->name() == "Port") {
|
|
|
|
|
(*x)->remove_property (X_("name"));
|
|
|
|
|
(*x)->set_property (X_("name"), i->name());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-06-02 21:41:35 +00:00
|
|
|
|
2016-04-17 21:50:13 +02:00
|
|
|
// after create_ports, updates names
|
2021-11-03 15:06:16 -06:00
|
|
|
|
2016-08-25 12:59:02 +10:00
|
|
|
if (node.get_property ("pretty-name", name)) {
|
|
|
|
|
set_pretty_name (name);
|
2016-04-17 21:50:13 +02:00
|
|
|
}
|
|
|
|
|
|
2021-11-03 15:06:16 -06:00
|
|
|
/* now set port state (this will *not* connect them, but will store
|
|
|
|
|
the names of connected ports).
|
|
|
|
|
*/
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2021-11-03 15:06:16 -06:00
|
|
|
if (version < 3000) {
|
|
|
|
|
return set_port_state_2X (node, version, false);
|
|
|
|
|
}
|
2008-06-02 21:41:35 +00:00
|
|
|
|
2021-11-03 15:06:16 -06:00
|
|
|
XMLProperty const * prop;
|
|
|
|
|
|
|
|
|
|
for (XMLNodeConstIterator i = node.children().begin(); i != node.children().end(); ++i) {
|
2009-06-23 02:43:35 +00:00
|
|
|
|
2021-11-03 15:06:16 -06:00
|
|
|
if ((*i)->name() == "Port") {
|
|
|
|
|
|
|
|
|
|
prop = (*i)->property (X_("name"));
|
|
|
|
|
|
|
|
|
|
if (!prop) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
boost::shared_ptr<Port> p = port_by_name (prop->value());
|
|
|
|
|
|
|
|
|
|
if (p) {
|
|
|
|
|
p->set_state (**i, version);
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-15 00:57:55 +00:00
|
|
|
int
|
|
|
|
|
IO::set_state_2X (const XMLNode& node, int version, bool in)
|
|
|
|
|
{
|
2016-05-04 23:09:37 -04:00
|
|
|
XMLProperty const * prop;
|
2016-05-07 12:19:41 +02:00
|
|
|
LocaleGuard lg;
|
2009-10-15 00:57:55 +00:00
|
|
|
|
|
|
|
|
/* force use of non-localized representation of decimal point,
|
|
|
|
|
since we use it a lot in XML files and so forth.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if (node.name() != state_node_name) {
|
|
|
|
|
error << string_compose(_("incorrect XML node \"%1\" passed to IO object"), node.name()) << endmsg;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2009-10-20 00:50:43 +00:00
|
|
|
|
2009-10-15 00:57:55 +00:00
|
|
|
if ((prop = node.property ("name")) != 0) {
|
|
|
|
|
set_name (prop->value());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((prop = node.property (X_("default-type"))) != 0) {
|
|
|
|
|
_default_type = DataType(prop->value());
|
|
|
|
|
assert(_default_type != DataType::NIL);
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-18 13:18:47 +00:00
|
|
|
set_id (node);
|
2009-10-15 00:57:55 +00:00
|
|
|
|
|
|
|
|
_direction = in ? Input : Output;
|
|
|
|
|
|
|
|
|
|
if (create_ports (node, version)) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-03 15:06:16 -06:00
|
|
|
if (set_port_state_2X (node, version, in)) {
|
|
|
|
|
return -1;
|
2009-10-15 00:57:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2008-09-10 15:03:30 +00:00
|
|
|
boost::shared_ptr<Bundle>
|
2009-06-09 20:21:19 +00:00
|
|
|
IO::find_possible_bundle (const string &desired_name)
|
2008-09-10 15:03:30 +00:00
|
|
|
{
|
|
|
|
|
static const string digits = "0123456789";
|
2009-06-09 20:21:19 +00:00
|
|
|
const string &default_name = (_direction == Input ? _("in") : _("out"));
|
|
|
|
|
const string &bundle_type_name = (_direction == Input ? _("input") : _("output"));
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2008-09-10 15:03:30 +00:00
|
|
|
boost::shared_ptr<Bundle> c = _session.bundle_by_name (desired_name);
|
|
|
|
|
|
|
|
|
|
if (!c) {
|
|
|
|
|
int bundle_number, mask;
|
|
|
|
|
string possible_name;
|
|
|
|
|
bool stereo = false;
|
|
|
|
|
string::size_type last_non_digit_pos;
|
2016-09-07 23:07:36 +10:00
|
|
|
std::string bundle_number_str;
|
2008-09-10 15:03:30 +00:00
|
|
|
|
|
|
|
|
error << string_compose(_("Unknown bundle \"%1\" listed for %2 of %3"), desired_name, bundle_type_name, _name)
|
|
|
|
|
<< endmsg;
|
|
|
|
|
|
|
|
|
|
// find numeric suffix of desired name
|
|
|
|
|
bundle_number = 0;
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2008-09-10 15:03:30 +00:00
|
|
|
last_non_digit_pos = desired_name.find_last_not_of(digits);
|
|
|
|
|
|
|
|
|
|
if (last_non_digit_pos != string::npos) {
|
2016-09-07 23:07:36 +10:00
|
|
|
bundle_number_str = desired_name.substr(last_non_digit_pos);
|
|
|
|
|
bundle_number = string_to<int32_t>(bundle_number_str);
|
2008-09-10 15:03:30 +00:00
|
|
|
}
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2008-09-10 15:03:30 +00:00
|
|
|
// see if it's a stereo connection e.g. "in 3+4"
|
|
|
|
|
|
|
|
|
|
if (last_non_digit_pos > 1 && desired_name[last_non_digit_pos] == '+') {
|
|
|
|
|
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) {
|
2010-02-23 20:25:53 +00:00
|
|
|
int left_bundle_number = 0;
|
2016-09-07 23:07:36 +10:00
|
|
|
bundle_number_str = desired_name.substr(left_last_non_digit_pos, last_non_digit_pos-1);
|
|
|
|
|
left_bundle_number = string_to<int32_t>(bundle_number_str);
|
2008-09-10 15:03:30 +00:00
|
|
|
|
|
|
|
|
if (left_bundle_number > 0 && left_bundle_number + 1 == bundle_number) {
|
|
|
|
|
bundle_number--;
|
|
|
|
|
stereo = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// make 0-based
|
|
|
|
|
if (bundle_number)
|
|
|
|
|
bundle_number--;
|
|
|
|
|
|
|
|
|
|
// find highest set bit
|
|
|
|
|
mask = 1;
|
2009-02-26 00:58:35 +00:00
|
|
|
while ((mask <= bundle_number) && (mask <<= 1)) {}
|
2009-10-14 16:10:01 +00:00
|
|
|
|
|
|
|
|
// "wrap" bundle number into largest possible power of 2
|
2008-09-10 15:03:30 +00:00
|
|
|
// that works...
|
|
|
|
|
|
|
|
|
|
while (mask) {
|
|
|
|
|
|
|
|
|
|
if (bundle_number & mask) {
|
|
|
|
|
bundle_number &= ~mask;
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2016-09-07 23:07:36 +10:00
|
|
|
std::string possible_name = default_name + " " + to_string(bundle_number + 1);
|
2008-09-10 15:03:30 +00:00
|
|
|
|
|
|
|
|
if (stereo) {
|
2016-09-07 23:07:36 +10:00
|
|
|
possible_name += "+" + to_string(bundle_number + 2);
|
2008-09-10 15:03:30 +00:00
|
|
|
}
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2008-09-10 15:03:30 +00:00
|
|
|
if ((c = _session.bundle_by_name (possible_name)) != 0) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
mask >>= 1;
|
|
|
|
|
}
|
|
|
|
|
if (c) {
|
|
|
|
|
info << string_compose (_("Bundle %1 was not available - \"%2\" used instead"), desired_name, possible_name)
|
|
|
|
|
<< endmsg;
|
|
|
|
|
} else {
|
|
|
|
|
error << string_compose(_("No %1 bundles available as a replacement"), bundle_type_name)
|
|
|
|
|
<< endmsg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return c;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-02 21:41:35 +00:00
|
|
|
int
|
2009-10-21 00:15:42 +00:00
|
|
|
IO::get_port_counts_2X (XMLNode const & node, int /*version*/, ChanCount& n, boost::shared_ptr<Bundle>& /*c*/)
|
2008-06-02 21:41:35 +00:00
|
|
|
{
|
2009-10-15 00:57:55 +00:00
|
|
|
XMLProperty const * prop;
|
|
|
|
|
XMLNodeList children = node.children ();
|
|
|
|
|
|
|
|
|
|
uint32_t n_audio = 0;
|
2009-10-19 14:13:03 +00:00
|
|
|
|
2009-10-15 00:57:55 +00:00
|
|
|
for (XMLNodeIterator i = children.begin(); i != children.end(); ++i) {
|
|
|
|
|
|
|
|
|
|
if ((prop = node.property ("inputs")) != 0 && _direction == Input) {
|
|
|
|
|
n_audio = count (prop->value().begin(), prop->value().end(), '{');
|
2010-03-28 19:07:23 +00:00
|
|
|
} else if ((prop = node.property ("input-connection")) != 0 && _direction == Input) {
|
|
|
|
|
n_audio = 1;
|
2009-10-15 00:57:55 +00:00
|
|
|
} else if ((prop = node.property ("outputs")) != 0 && _direction == Output) {
|
|
|
|
|
n_audio = count (prop->value().begin(), prop->value().end(), '{');
|
2010-03-28 19:07:23 +00:00
|
|
|
} else if ((prop = node.property ("output-connection")) != 0 && _direction == Output) {
|
|
|
|
|
n_audio = 2;
|
2009-10-15 00:57:55 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ChanCount cnt;
|
|
|
|
|
cnt.set_audio (n_audio);
|
|
|
|
|
n = ChanCount::max (n, cnt);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
IO::get_port_counts (const XMLNode& node, int version, ChanCount& n, boost::shared_ptr<Bundle>& c)
|
|
|
|
|
{
|
|
|
|
|
if (version < 3000) {
|
|
|
|
|
return get_port_counts_2X (node, version, n, c);
|
|
|
|
|
}
|
2009-10-20 00:50:43 +00:00
|
|
|
|
2008-06-02 21:41:35 +00:00
|
|
|
XMLProperty const * prop;
|
The great audio processing overhaul.
The vast majority of Route signal processing is now simply in the list of
processors. There are definitely regressions here, but there's also
a lot of things fixed. It's far too much work to let diverge anymore
regardless, so here it is.
The basic model is: A route has a fixed set of input channels (matching
its JACK input ports and diskstream). The first processor takes this
as input. The next processor is configured using the first processor's
output as input, and is allowed to choose whatever output it wants
given that input... and so on, and so on. Finally, the last processor's
requested output is used to set up the panner and create whatever Jack
ports are needed to output the data.
All 'special' internal processors (meter, fader, amp, insert, send) are
currently transparent: they read any input, and return the same set
of channels back (unmodified, except for amp).
User visible changes:
* LV2 Instrument support (tracks with both MIDI and audio channels)
* MIDI in/out plugin support
* Generic plugin replication (for MIDI plugins, MIDI/audio plugins)
* Movable meter point
Known Bugs:
* Things seem to get weird on loaded sessions
* Output delivery is sketchy
* 2.0 session loading was probably already broken...
but it's definitely broken now :)
Please test this and file bugs if you have any time...
git-svn-id: svn://localhost/ardour2/branches/3.0@5055 d708f5d6-7413-0410-9779-e7cbd77b26cf
2009-05-07 06:30:50 +00:00
|
|
|
XMLNodeConstIterator iter;
|
2009-06-09 20:21:19 +00:00
|
|
|
uint32_t n_audio = 0;
|
|
|
|
|
uint32_t n_midi = 0;
|
|
|
|
|
ChanCount cnt;
|
2009-05-16 02:51:17 +00:00
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
n = n_ports();
|
The great audio processing overhaul.
The vast majority of Route signal processing is now simply in the list of
processors. There are definitely regressions here, but there's also
a lot of things fixed. It's far too much work to let diverge anymore
regardless, so here it is.
The basic model is: A route has a fixed set of input channels (matching
its JACK input ports and diskstream). The first processor takes this
as input. The next processor is configured using the first processor's
output as input, and is allowed to choose whatever output it wants
given that input... and so on, and so on. Finally, the last processor's
requested output is used to set up the panner and create whatever Jack
ports are needed to output the data.
All 'special' internal processors (meter, fader, amp, insert, send) are
currently transparent: they read any input, and return the same set
of channels back (unmodified, except for amp).
User visible changes:
* LV2 Instrument support (tracks with both MIDI and audio channels)
* MIDI in/out plugin support
* Generic plugin replication (for MIDI plugins, MIDI/audio plugins)
* Movable meter point
Known Bugs:
* Things seem to get weird on loaded sessions
* Output delivery is sketchy
* 2.0 session loading was probably already broken...
but it's definitely broken now :)
Please test this and file bugs if you have any time...
git-svn-id: svn://localhost/ardour2/branches/3.0@5055 d708f5d6-7413-0410-9779-e7cbd77b26cf
2009-05-07 06:30:50 +00:00
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
if ((prop = node.property ("connection")) != 0) {
|
|
|
|
|
|
|
|
|
|
if ((c = find_possible_bundle (prop->value())) != 0) {
|
2010-06-30 02:59:13 +00:00
|
|
|
n = ChanCount::max (n, c->nchannels());
|
The great audio processing overhaul.
The vast majority of Route signal processing is now simply in the list of
processors. There are definitely regressions here, but there's also
a lot of things fixed. It's far too much work to let diverge anymore
regardless, so here it is.
The basic model is: A route has a fixed set of input channels (matching
its JACK input ports and diskstream). The first processor takes this
as input. The next processor is configured using the first processor's
output as input, and is allowed to choose whatever output it wants
given that input... and so on, and so on. Finally, the last processor's
requested output is used to set up the panner and create whatever Jack
ports are needed to output the data.
All 'special' internal processors (meter, fader, amp, insert, send) are
currently transparent: they read any input, and return the same set
of channels back (unmodified, except for amp).
User visible changes:
* LV2 Instrument support (tracks with both MIDI and audio channels)
* MIDI in/out plugin support
* Generic plugin replication (for MIDI plugins, MIDI/audio plugins)
* Movable meter point
Known Bugs:
* Things seem to get weird on loaded sessions
* Output delivery is sketchy
* 2.0 session loading was probably already broken...
but it's definitely broken now :)
Please test this and file bugs if you have any time...
git-svn-id: svn://localhost/ardour2/branches/3.0@5055 d708f5d6-7413-0410-9779-e7cbd77b26cf
2009-05-07 06:30:50 +00:00
|
|
|
}
|
2009-06-09 20:21:19 +00:00
|
|
|
return 0;
|
The great audio processing overhaul.
The vast majority of Route signal processing is now simply in the list of
processors. There are definitely regressions here, but there's also
a lot of things fixed. It's far too much work to let diverge anymore
regardless, so here it is.
The basic model is: A route has a fixed set of input channels (matching
its JACK input ports and diskstream). The first processor takes this
as input. The next processor is configured using the first processor's
output as input, and is allowed to choose whatever output it wants
given that input... and so on, and so on. Finally, the last processor's
requested output is used to set up the panner and create whatever Jack
ports are needed to output the data.
All 'special' internal processors (meter, fader, amp, insert, send) are
currently transparent: they read any input, and return the same set
of channels back (unmodified, except for amp).
User visible changes:
* LV2 Instrument support (tracks with both MIDI and audio channels)
* MIDI in/out plugin support
* Generic plugin replication (for MIDI plugins, MIDI/audio plugins)
* Movable meter point
Known Bugs:
* Things seem to get weird on loaded sessions
* Output delivery is sketchy
* 2.0 session loading was probably already broken...
but it's definitely broken now :)
Please test this and file bugs if you have any time...
git-svn-id: svn://localhost/ardour2/branches/3.0@5055 d708f5d6-7413-0410-9779-e7cbd77b26cf
2009-05-07 06:30:50 +00:00
|
|
|
}
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
for (iter = node.children().begin(); iter != node.children().end(); ++iter) {
|
2008-09-10 15:03:30 +00:00
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
if ((*iter)->name() == X_("Bundle")) {
|
2014-11-18 02:25:02 -05:00
|
|
|
prop = (*iter)->property ("name");
|
2009-06-09 20:21:19 +00:00
|
|
|
if ((c = find_possible_bundle (prop->value())) != 0) {
|
2010-06-30 02:59:13 +00:00
|
|
|
n = ChanCount::max (n, c->nchannels());
|
2009-06-09 20:21:19 +00:00
|
|
|
return 0;
|
|
|
|
|
} else {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2009-03-01 19:45:35 +00:00
|
|
|
}
|
2008-09-10 15:03:30 +00:00
|
|
|
|
2009-06-09 21:30:32 +00:00
|
|
|
if ((*iter)->name() == X_("Port")) {
|
2009-06-09 20:21:19 +00:00
|
|
|
prop = (*iter)->property (X_("type"));
|
2008-09-10 15:03:30 +00:00
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
if (!prop) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (prop->value() == X_("audio")) {
|
|
|
|
|
cnt.set_audio (++n_audio);
|
|
|
|
|
} else if (prop->value() == X_("midi")) {
|
|
|
|
|
cnt.set_midi (++n_midi);
|
|
|
|
|
}
|
2009-03-01 19:45:35 +00:00
|
|
|
}
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
n = ChanCount::max (n, cnt);
|
The great audio processing overhaul.
The vast majority of Route signal processing is now simply in the list of
processors. There are definitely regressions here, but there's also
a lot of things fixed. It's far too much work to let diverge anymore
regardless, so here it is.
The basic model is: A route has a fixed set of input channels (matching
its JACK input ports and diskstream). The first processor takes this
as input. The next processor is configured using the first processor's
output as input, and is allowed to choose whatever output it wants
given that input... and so on, and so on. Finally, the last processor's
requested output is used to set up the panner and create whatever Jack
ports are needed to output the data.
All 'special' internal processors (meter, fader, amp, insert, send) are
currently transparent: they read any input, and return the same set
of channels back (unmodified, except for amp).
User visible changes:
* LV2 Instrument support (tracks with both MIDI and audio channels)
* MIDI in/out plugin support
* Generic plugin replication (for MIDI plugins, MIDI/audio plugins)
* Movable meter point
Known Bugs:
* Things seem to get weird on loaded sessions
* Output delivery is sketchy
* 2.0 session loading was probably already broken...
but it's definitely broken now :)
Please test this and file bugs if you have any time...
git-svn-id: svn://localhost/ardour2/branches/3.0@5055 d708f5d6-7413-0410-9779-e7cbd77b26cf
2009-05-07 06:30:50 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2009-10-15 00:57:55 +00:00
|
|
|
IO::create_ports (const XMLNode& node, int version)
|
The great audio processing overhaul.
The vast majority of Route signal processing is now simply in the list of
processors. There are definitely regressions here, but there's also
a lot of things fixed. It's far too much work to let diverge anymore
regardless, so here it is.
The basic model is: A route has a fixed set of input channels (matching
its JACK input ports and diskstream). The first processor takes this
as input. The next processor is configured using the first processor's
output as input, and is allowed to choose whatever output it wants
given that input... and so on, and so on. Finally, the last processor's
requested output is used to set up the panner and create whatever Jack
ports are needed to output the data.
All 'special' internal processors (meter, fader, amp, insert, send) are
currently transparent: they read any input, and return the same set
of channels back (unmodified, except for amp).
User visible changes:
* LV2 Instrument support (tracks with both MIDI and audio channels)
* MIDI in/out plugin support
* Generic plugin replication (for MIDI plugins, MIDI/audio plugins)
* Movable meter point
Known Bugs:
* Things seem to get weird on loaded sessions
* Output delivery is sketchy
* 2.0 session loading was probably already broken...
but it's definitely broken now :)
Please test this and file bugs if you have any time...
git-svn-id: svn://localhost/ardour2/branches/3.0@5055 d708f5d6-7413-0410-9779-e7cbd77b26cf
2009-05-07 06:30:50 +00:00
|
|
|
{
|
2009-06-09 20:21:19 +00:00
|
|
|
ChanCount n;
|
|
|
|
|
boost::shared_ptr<Bundle> c;
|
2009-10-20 00:50:43 +00:00
|
|
|
|
2009-10-15 00:57:55 +00:00
|
|
|
get_port_counts (node, version, n, c);
|
2009-10-20 00:50:43 +00:00
|
|
|
|
2010-11-25 23:46:24 +00:00
|
|
|
{
|
2012-07-25 17:48:55 +00:00
|
|
|
Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
|
2011-06-01 16:50:12 +00:00
|
|
|
|
2010-11-25 23:46:24 +00:00
|
|
|
if (ensure_ports (n, true, this)) {
|
|
|
|
|
error << string_compose(_("%1: cannot create I/O ports"), _name) << endmsg;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
/* XXX use c */
|
|
|
|
|
|
2008-06-02 21:41:35 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2021-11-03 15:06:16 -06:00
|
|
|
IO::set_port_state_2X (const XMLNode& node, int /*version*/, bool in)
|
2009-10-15 00:57:55 +00:00
|
|
|
{
|
2016-05-04 23:09:37 -04:00
|
|
|
XMLProperty const * prop;
|
2009-10-15 00:57:55 +00:00
|
|
|
|
|
|
|
|
/* XXX: bundles ("connections" as was) */
|
2009-10-20 00:50:43 +00:00
|
|
|
|
2009-10-15 00:57:55 +00:00
|
|
|
if ((prop = node.property ("inputs")) != 0 && in) {
|
|
|
|
|
|
|
|
|
|
string::size_type ostart = 0;
|
|
|
|
|
string::size_type start = 0;
|
|
|
|
|
string::size_type end = 0;
|
|
|
|
|
int i = 0;
|
|
|
|
|
int n;
|
|
|
|
|
vector<string> ports;
|
|
|
|
|
|
|
|
|
|
string const str = prop->value ();
|
2009-10-20 00:50:43 +00:00
|
|
|
|
2009-10-15 00:57:55 +00:00
|
|
|
while ((start = str.find_first_of ('{', ostart)) != string::npos) {
|
|
|
|
|
start += 1;
|
2009-10-20 00:50:43 +00:00
|
|
|
|
2009-10-15 00:57:55 +00:00
|
|
|
if ((end = str.find_first_of ('}', start)) == string::npos) {
|
|
|
|
|
error << string_compose(_("IO: badly formed string in XML node for inputs \"%1\""), str) << endmsg;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2009-10-20 00:50:43 +00:00
|
|
|
|
2009-10-15 00:57:55 +00:00
|
|
|
if ((n = parse_io_string (str.substr (start, end - start), ports)) < 0) {
|
|
|
|
|
error << string_compose(_("bad input string in XML node \"%1\""), str) << endmsg;
|
2009-10-20 00:50:43 +00:00
|
|
|
|
2009-10-15 00:57:55 +00:00
|
|
|
return -1;
|
2009-10-20 00:50:43 +00:00
|
|
|
|
2009-10-15 00:57:55 +00:00
|
|
|
} else if (n > 0) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int x = 0; x < n; ++x) {
|
|
|
|
|
/* XXX: this is a bit of a hack; need to check if it's always valid */
|
2009-10-20 00:50:43 +00:00
|
|
|
string::size_type const p = ports[x].find ("/out");
|
2009-10-15 00:57:55 +00:00
|
|
|
if (p != string::npos) {
|
|
|
|
|
ports[x].replace (p, 4, "/audio_out");
|
|
|
|
|
}
|
2015-01-27 11:59:23 +00:00
|
|
|
if (NULL != nth(i).get())
|
|
|
|
|
nth(i)->connect (ports[x]);
|
2009-10-15 00:57:55 +00:00
|
|
|
}
|
|
|
|
|
}
|
2009-10-20 00:50:43 +00:00
|
|
|
|
2009-10-15 00:57:55 +00:00
|
|
|
ostart = end+1;
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((prop = node.property ("outputs")) != 0 && !in) {
|
|
|
|
|
|
|
|
|
|
string::size_type ostart = 0;
|
|
|
|
|
string::size_type start = 0;
|
|
|
|
|
string::size_type end = 0;
|
|
|
|
|
int i = 0;
|
|
|
|
|
int n;
|
|
|
|
|
vector<string> ports;
|
2009-10-20 00:50:43 +00:00
|
|
|
|
2009-10-15 00:57:55 +00:00
|
|
|
string const str = prop->value ();
|
2009-10-20 00:50:43 +00:00
|
|
|
|
2009-10-15 00:57:55 +00:00
|
|
|
while ((start = str.find_first_of ('{', ostart)) != string::npos) {
|
|
|
|
|
start += 1;
|
2009-10-20 00:50:43 +00:00
|
|
|
|
2009-10-15 00:57:55 +00:00
|
|
|
if ((end = str.find_first_of ('}', start)) == string::npos) {
|
|
|
|
|
error << string_compose(_("IO: badly formed string in XML node for outputs \"%1\""), str) << endmsg;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2009-10-20 00:50:43 +00:00
|
|
|
|
2009-10-15 00:57:55 +00:00
|
|
|
if ((n = parse_io_string (str.substr (start, end - start), ports)) < 0) {
|
|
|
|
|
error << string_compose(_("IO: bad output string in XML node \"%1\""), str) << endmsg;
|
2009-10-20 00:50:43 +00:00
|
|
|
|
2009-10-15 00:57:55 +00:00
|
|
|
return -1;
|
2009-10-20 00:50:43 +00:00
|
|
|
|
2009-10-15 00:57:55 +00:00
|
|
|
} else if (n > 0) {
|
2009-10-20 00:50:43 +00:00
|
|
|
|
2009-10-15 00:57:55 +00:00
|
|
|
for (int x = 0; x < n; ++x) {
|
|
|
|
|
/* XXX: this is a bit of a hack; need to check if it's always valid */
|
2009-10-20 00:50:43 +00:00
|
|
|
string::size_type const p = ports[x].find ("/in");
|
2009-10-15 00:57:55 +00:00
|
|
|
if (p != string::npos) {
|
|
|
|
|
ports[x].replace (p, 3, "/audio_in");
|
|
|
|
|
}
|
2015-01-27 11:59:23 +00:00
|
|
|
if (NULL != nth(i).get())
|
|
|
|
|
nth(i)->connect (ports[x]);
|
2009-10-15 00:57:55 +00:00
|
|
|
}
|
|
|
|
|
}
|
2009-10-20 00:50:43 +00:00
|
|
|
|
2009-10-15 00:57:55 +00:00
|
|
|
ostart = end+1;
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-03 15:06:16 -06:00
|
|
|
void
|
|
|
|
|
IO::prepare_for_reset (XMLNode& node, const std::string& name)
|
|
|
|
|
{
|
|
|
|
|
/* reset name */
|
|
|
|
|
node.set_property ("name", name);
|
|
|
|
|
|
|
|
|
|
/* now find connections and reset the name of the port
|
|
|
|
|
in one so that when we re-use it it will match
|
|
|
|
|
the name of the thing we're applying it to.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
XMLProperty * prop;
|
|
|
|
|
XMLNodeList children = node.children();
|
|
|
|
|
|
|
|
|
|
for (XMLNodeIterator i = children.begin(); i != children.end(); ++i) {
|
|
|
|
|
|
|
|
|
|
if ((*i)->name() == "Port") {
|
|
|
|
|
|
|
|
|
|
prop = (*i)->property (X_("name"));
|
|
|
|
|
|
|
|
|
|
if (prop) {
|
|
|
|
|
string new_name;
|
|
|
|
|
string old = prop->value();
|
|
|
|
|
string::size_type slash = old.find ('/');
|
|
|
|
|
|
|
|
|
|
if (slash != string::npos) {
|
|
|
|
|
/* port name is of form: <IO-name>/<port-name> */
|
|
|
|
|
|
|
|
|
|
new_name = name;
|
|
|
|
|
new_name += old.substr (old.find ('/'));
|
|
|
|
|
|
|
|
|
|
prop->set_value (new_name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-06-02 21:41:35 +00:00
|
|
|
int
|
2009-06-09 20:21:19 +00:00
|
|
|
IO::set_ports (const string& str)
|
2008-06-02 21:41:35 +00:00
|
|
|
{
|
|
|
|
|
vector<string> ports;
|
|
|
|
|
int n;
|
|
|
|
|
uint32_t nports;
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2008-06-02 21:41:35 +00:00
|
|
|
if ((nports = count (str.begin(), str.end(), '{')) == 0) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-25 23:46:24 +00:00
|
|
|
{
|
2012-07-25 17:48:55 +00:00
|
|
|
Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
|
2011-06-01 16:50:12 +00:00
|
|
|
|
2010-11-25 23:46:24 +00:00
|
|
|
// FIXME: audio-only
|
|
|
|
|
if (ensure_ports (ChanCount(DataType::AUDIO, nports), true, this)) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
|
2014-11-18 02:35:35 -05:00
|
|
|
string::size_type start = 0;
|
|
|
|
|
string::size_type end = 0;
|
|
|
|
|
string::size_type ostart = 0;
|
|
|
|
|
for (int i = 0; (start = str.find_first_of ('{', ostart)) != string::npos; ++i) {
|
2008-06-02 21:41:35 +00:00
|
|
|
start += 1;
|
|
|
|
|
|
|
|
|
|
if ((end = str.find_first_of ('}', start)) == string::npos) {
|
|
|
|
|
error << string_compose(_("IO: badly formed string in XML node for inputs \"%1\""), str) << endmsg;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((n = parse_io_string (str.substr (start, end - start), ports)) < 0) {
|
|
|
|
|
error << string_compose(_("bad input string in XML node \"%1\""), str) << endmsg;
|
|
|
|
|
|
|
|
|
|
return -1;
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2008-06-02 21:41:35 +00:00
|
|
|
} else if (n > 0) {
|
|
|
|
|
|
|
|
|
|
for (int x = 0; x < n; ++x) {
|
2009-06-09 20:21:19 +00:00
|
|
|
connect (nth (i), ports[x], this);
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ostart = end+1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
IO::parse_io_string (const string& str, vector<string>& ports)
|
|
|
|
|
{
|
|
|
|
|
string::size_type pos, opos;
|
|
|
|
|
|
|
|
|
|
if (str.length() == 0) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
opos = 0;
|
|
|
|
|
|
|
|
|
|
ports.clear ();
|
|
|
|
|
|
|
|
|
|
while ((pos = str.find_first_of (',', opos)) != string::npos) {
|
|
|
|
|
ports.push_back (str.substr (opos, pos - opos));
|
|
|
|
|
opos = pos + 1;
|
|
|
|
|
}
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2008-06-02 21:41:35 +00:00
|
|
|
if (opos < str.length()) {
|
|
|
|
|
ports.push_back (str.substr(opos));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ports.size();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
IO::parse_gain_string (const string& str, vector<string>& ports)
|
|
|
|
|
{
|
|
|
|
|
string::size_type pos, opos;
|
|
|
|
|
|
|
|
|
|
opos = 0;
|
|
|
|
|
ports.clear ();
|
|
|
|
|
|
|
|
|
|
while ((pos = str.find_first_of (',', opos)) != string::npos) {
|
|
|
|
|
ports.push_back (str.substr (opos, pos - opos));
|
|
|
|
|
opos = pos + 1;
|
|
|
|
|
}
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2008-06-02 21:41:35 +00:00
|
|
|
if (opos < str.length()) {
|
|
|
|
|
ports.push_back (str.substr(opos));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ports.size();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
IO::set_name (const string& requested_name)
|
|
|
|
|
{
|
2009-06-25 20:46:39 +00:00
|
|
|
string name = requested_name;
|
|
|
|
|
|
2010-02-11 17:08:34 +00:00
|
|
|
if (_name == name) {
|
2008-06-02 21:41:35 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2008-06-02 21:41:35 +00:00
|
|
|
/* replace all colons in the name. i wish we didn't have to do this */
|
|
|
|
|
|
2011-06-01 16:50:12 +00:00
|
|
|
replace_all (name, ":", "-");
|
2008-06-02 21:41:35 +00:00
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
for (PortSet::iterator i = _ports.begin(); i != _ports.end(); ++i) {
|
2009-01-21 02:27:21 +00:00
|
|
|
string current_name = i->name();
|
2022-01-24 21:21:07 +01:00
|
|
|
assert (current_name.find (_name) != std::string::npos);
|
2010-02-11 23:10:29 +00:00
|
|
|
current_name.replace (current_name.find (_name), _name.val().length(), name);
|
2008-06-02 21:41:35 +00:00
|
|
|
i->set_name (current_name);
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-25 20:46:39 +00:00
|
|
|
bool const r = SessionObject::set_name (name);
|
2008-06-02 21:41:35 +00:00
|
|
|
|
2009-11-25 23:24:02 +00:00
|
|
|
setup_bundle ();
|
2008-06-02 21:41:35 +00:00
|
|
|
|
|
|
|
|
return r;
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-17 21:50:13 +02:00
|
|
|
void
|
|
|
|
|
IO::set_pretty_name (const std::string& str)
|
|
|
|
|
{
|
|
|
|
|
if (_pretty_name_prefix == str) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
_pretty_name_prefix = str;
|
|
|
|
|
apply_pretty_name ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
IO::apply_pretty_name ()
|
|
|
|
|
{
|
|
|
|
|
uint32_t pn = 1;
|
|
|
|
|
if (_pretty_name_prefix.empty ()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
for (PortSet::iterator i = _ports.begin (); i != _ports.end(); ++i, ++pn) {
|
|
|
|
|
(*i)->set_pretty_name (string_compose (("%1/%2 %3"),
|
|
|
|
|
_pretty_name_prefix,
|
|
|
|
|
_direction == Output ? _("Out") : _("In"),
|
|
|
|
|
pn));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-26 09:38:32 +01:00
|
|
|
void
|
|
|
|
|
IO::set_private_port_latencies (samplecnt_t value, bool playback)
|
|
|
|
|
{
|
|
|
|
|
LatencyRange lat;
|
|
|
|
|
lat.min = lat.max = value;
|
|
|
|
|
for (PortSet::iterator i = _ports.begin (); i != _ports.end(); ++i) {
|
|
|
|
|
i->set_private_latency_range (lat, playback);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-14 21:33:08 +02:00
|
|
|
void
|
|
|
|
|
IO::set_public_port_latency_from_connections () const
|
|
|
|
|
{
|
|
|
|
|
/* get min/max of connected up/downstream ports */
|
|
|
|
|
bool connected = false;
|
|
|
|
|
bool playback = _direction == Output;
|
|
|
|
|
LatencyRange lr;
|
|
|
|
|
lr.min = ~((pframes_t) 0);
|
|
|
|
|
lr.max = 0;
|
|
|
|
|
|
|
|
|
|
for (PortSet::const_iterator i = _ports.begin(); i != _ports.end(); ++i) {
|
|
|
|
|
if (i->connected()) {
|
|
|
|
|
connected = true;
|
|
|
|
|
}
|
|
|
|
|
i->collect_latency_from_backend (lr, playback);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!connected) {
|
|
|
|
|
/* if output is not connected to anything, use private latency */
|
|
|
|
|
lr.min = lr.max = latency ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (PortSet::const_iterator i = _ports.begin (); i != _ports.end(); ++i) {
|
|
|
|
|
i->set_public_latency_range (lr, playback);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-26 09:38:32 +01:00
|
|
|
void
|
|
|
|
|
IO::set_public_port_latencies (samplecnt_t value, bool playback) const
|
|
|
|
|
{
|
|
|
|
|
LatencyRange lat;
|
|
|
|
|
lat.min = lat.max = value;
|
|
|
|
|
for (PortSet::const_iterator i = _ports.begin (); i != _ports.end(); ++i) {
|
|
|
|
|
i->set_public_latency_range (lat, playback);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-18 12:39:17 -04:00
|
|
|
samplecnt_t
|
2009-06-09 20:21:19 +00:00
|
|
|
IO::latency () const
|
2008-06-02 21:41:35 +00:00
|
|
|
{
|
2017-09-28 06:08:30 +02:00
|
|
|
samplecnt_t max_latency = 0;
|
2008-06-02 21:41:35 +00:00
|
|
|
|
|
|
|
|
/* io lock not taken - must be protected by other means */
|
|
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
for (PortSet::const_iterator i = _ports.begin(); i != _ports.end(); ++i) {
|
2017-09-28 06:08:30 +02:00
|
|
|
samplecnt_t latency;
|
2011-03-12 20:25:09 +00:00
|
|
|
if ((latency = i->private_latency_range (_direction == Output).max) > max_latency) {
|
2020-04-26 20:47:43 +02:00
|
|
|
DEBUG_TRACE (DEBUG::LatencyIO, string_compose ("port %1 has %2 latency of %3 - use\n",
|
|
|
|
|
name(),
|
|
|
|
|
((_direction == Output) ? "PLAYBACK" : "CAPTURE"),
|
|
|
|
|
latency));
|
2008-06-02 21:41:35 +00:00
|
|
|
max_latency = latency;
|
2009-10-14 16:10:01 +00:00
|
|
|
}
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
|
2020-04-26 20:47:43 +02:00
|
|
|
DEBUG_TRACE (DEBUG::LatencyIO, string_compose ("%1: max %4 latency from %2 ports = %3\n",
|
|
|
|
|
name(), _ports.num_ports(), max_latency,
|
|
|
|
|
((_direction == Output) ? "PLAYBACK" : "CAPTURE")));
|
2008-06-02 21:41:35 +00:00
|
|
|
return max_latency;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-19 13:56:47 +01:00
|
|
|
#if 0 // not used, but may some day be handy for debugging
|
2017-09-28 06:08:30 +02:00
|
|
|
samplecnt_t
|
|
|
|
|
IO::public_latency () const
|
|
|
|
|
{
|
|
|
|
|
samplecnt_t max_latency = 0;
|
|
|
|
|
|
|
|
|
|
/* io lock not taken - must be protected by other means */
|
|
|
|
|
|
|
|
|
|
for (PortSet::const_iterator i = _ports.begin(); i != _ports.end(); ++i) {
|
|
|
|
|
samplecnt_t latency;
|
|
|
|
|
if ((latency = i->public_latency_range (_direction == Output).max) > max_latency) {
|
2020-04-26 20:47:43 +02:00
|
|
|
DEBUG_TRACE (DEBUG::LatencyIO, string_compose ("port %1 has %2 latency of %3 - use\n",
|
|
|
|
|
name(),
|
|
|
|
|
((_direction == Output) ? "PLAYBACK" : "CAPTURE"),
|
|
|
|
|
latency));
|
2017-09-28 06:08:30 +02:00
|
|
|
max_latency = latency;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-26 20:47:43 +02:00
|
|
|
DEBUG_TRACE (DEBUG::LatencyIO, string_compose ("%1: max %4 public latency from %2 ports = %3\n",
|
|
|
|
|
name(), _ports.num_ports(), max_latency,
|
|
|
|
|
((_direction == Output) ? "PLAYBACK" : "CAPTURE")));
|
2017-09-28 06:08:30 +02:00
|
|
|
return max_latency;
|
|
|
|
|
}
|
2021-02-19 13:56:47 +01:00
|
|
|
#endif
|
2017-09-28 06:08:30 +02:00
|
|
|
|
|
|
|
|
samplecnt_t
|
|
|
|
|
IO::connected_latency (bool for_playback) const
|
|
|
|
|
{
|
|
|
|
|
/* io lock not taken - must be protected by other means */
|
|
|
|
|
samplecnt_t max_latency = 0;
|
|
|
|
|
bool connected = false;
|
|
|
|
|
|
|
|
|
|
/* if output is not connected to anything, use private latency */
|
|
|
|
|
for (PortSet::const_iterator i = _ports.begin(); i != _ports.end(); ++i) {
|
|
|
|
|
if (i->connected()) {
|
|
|
|
|
connected = true;
|
|
|
|
|
max_latency = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
samplecnt_t latency;
|
|
|
|
|
if ((latency = i->private_latency_range (for_playback).max) > max_latency) {
|
|
|
|
|
max_latency = latency;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (connected) {
|
|
|
|
|
for (PortSet::const_iterator i = _ports.begin(); i != _ports.end(); ++i) {
|
|
|
|
|
LatencyRange lr;
|
|
|
|
|
i->get_connected_latency_range (lr, for_playback);
|
|
|
|
|
if (lr.max > max_latency) {
|
|
|
|
|
max_latency = lr.max;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return max_latency;
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
int
|
2017-08-23 22:03:20 +02:00
|
|
|
IO::connect_ports_to_bundle (boost::shared_ptr<Bundle> c, bool exclusive, void* src) {
|
|
|
|
|
return connect_ports_to_bundle(c, exclusive, false, src);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
IO::connect_ports_to_bundle (boost::shared_ptr<Bundle> c, bool exclusive,
|
|
|
|
|
bool allow_partial, void* src)
|
2009-06-09 20:21:19 +00:00
|
|
|
{
|
2010-11-25 23:46:24 +00:00
|
|
|
BLOCK_PROCESS_CALLBACK ();
|
|
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
{
|
2012-07-25 17:48:55 +00:00
|
|
|
Glib::Threads::Mutex::Lock lm2 (io_lock);
|
2008-06-02 21:41:35 +00:00
|
|
|
|
2012-10-18 16:15:11 +00:00
|
|
|
if (exclusive) {
|
|
|
|
|
for (PortSet::iterator i = _ports.begin(); i != _ports.end(); ++i) {
|
|
|
|
|
i->disconnect_all ();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-23 22:03:20 +02:00
|
|
|
c->connect (_bundle, _session.engine(), allow_partial);
|
2008-06-02 21:41:35 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-30 22:34:21 +00:00
|
|
|
changed (IOChange (IOChange::ConnectionsChanged), src); /* EMIT SIGNAL */
|
2009-06-09 20:21:19 +00:00
|
|
|
return 0;
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
int
|
|
|
|
|
IO::disconnect_ports_from_bundle (boost::shared_ptr<Bundle> c, void* src)
|
2008-06-02 21:41:35 +00:00
|
|
|
{
|
2010-11-25 23:46:24 +00:00
|
|
|
BLOCK_PROCESS_CALLBACK ();
|
|
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
{
|
2012-07-25 17:48:55 +00:00
|
|
|
Glib::Threads::Mutex::Lock lm2 (io_lock);
|
2008-06-02 21:41:35 +00:00
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
c->disconnect (_bundle, _session.engine());
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
/* If this is a UserBundle, make a note of what we've done */
|
2009-01-30 07:40:13 +00:00
|
|
|
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
|
2010-08-30 22:34:21 +00:00
|
|
|
changed (IOChange (IOChange::ConnectionsChanged), src); /* EMIT SIGNAL */
|
2009-06-09 20:21:19 +00:00
|
|
|
return 0;
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2009-07-21 15:55:17 +00:00
|
|
|
IO::bundle_changed (Bundle::Change /*c*/)
|
2008-06-02 21:41:35 +00:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
|
2008-06-02 21:41:35 +00:00
|
|
|
string
|
2009-06-09 20:21:19 +00:00
|
|
|
IO::build_legal_port_name (DataType type)
|
2008-06-02 21:41:35 +00:00
|
|
|
{
|
2013-08-01 18:49:40 -04:00
|
|
|
const int name_size = AudioEngine::instance()->port_name_size();
|
2008-06-02 21:41:35 +00:00
|
|
|
int limit;
|
|
|
|
|
string suffix;
|
|
|
|
|
|
|
|
|
|
if (type == DataType::AUDIO) {
|
2013-01-28 21:34:17 +00:00
|
|
|
suffix = X_("audio");
|
2008-06-02 21:41:35 +00:00
|
|
|
} else if (type == DataType::MIDI) {
|
2013-01-28 21:34:17 +00:00
|
|
|
suffix = X_("midi");
|
2008-06-02 21:41:35 +00:00
|
|
|
} else {
|
|
|
|
|
throw unknown_type();
|
|
|
|
|
}
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2009-08-10 19:29:29 +00:00
|
|
|
/* note that if "in" or "out" are translated it will break a session
|
|
|
|
|
across locale switches because a port's connection list will
|
|
|
|
|
show (old) translated names, but the current port name will
|
|
|
|
|
use the (new) translated name.
|
|
|
|
|
*/
|
|
|
|
|
|
2012-07-17 13:59:46 +00:00
|
|
|
if (_sendish) {
|
|
|
|
|
if (_direction == Input) {
|
|
|
|
|
suffix += X_("_return");
|
|
|
|
|
} else {
|
|
|
|
|
suffix += X_("_send");
|
|
|
|
|
}
|
2008-06-02 21:41:35 +00:00
|
|
|
} else {
|
2012-07-17 13:59:46 +00:00
|
|
|
if (_direction == Input) {
|
|
|
|
|
suffix += X_("_in");
|
|
|
|
|
} else {
|
|
|
|
|
suffix += X_("_out");
|
|
|
|
|
}
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
2009-05-16 02:51:17 +00:00
|
|
|
|
2008-06-02 21:41:35 +00:00
|
|
|
// allow up to 4 digits for the output port number, plus the slash, suffix and extra space
|
|
|
|
|
|
2013-08-01 18:49:40 -04:00
|
|
|
limit = name_size - AudioEngine::instance()->my_name().length() - (suffix.length() + 5);
|
2008-06-02 21:41:35 +00:00
|
|
|
|
2013-08-04 15:17:19 +01:00
|
|
|
std::vector<char> buf1(name_size+1);
|
|
|
|
|
std::vector<char> buf2(name_size+1);
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2011-07-26 02:07:59 +00:00
|
|
|
/* colons are illegal in port names, so fix that */
|
|
|
|
|
|
|
|
|
|
string nom = _name.val();
|
|
|
|
|
replace_all (nom, ":", ";");
|
|
|
|
|
|
2013-08-04 15:17:19 +01:00
|
|
|
snprintf (&buf1[0], name_size+1, ("%.*s/%s"), limit, nom.c_str(), suffix.c_str());
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2013-08-04 15:17:19 +01:00
|
|
|
int port_number = find_port_hole (&buf1[0]);
|
2013-08-09 17:48:15 +01:00
|
|
|
snprintf (&buf2[0], name_size+1, "%s %d", &buf1[0], port_number);
|
The great audio processing overhaul.
The vast majority of Route signal processing is now simply in the list of
processors. There are definitely regressions here, but there's also
a lot of things fixed. It's far too much work to let diverge anymore
regardless, so here it is.
The basic model is: A route has a fixed set of input channels (matching
its JACK input ports and diskstream). The first processor takes this
as input. The next processor is configured using the first processor's
output as input, and is allowed to choose whatever output it wants
given that input... and so on, and so on. Finally, the last processor's
requested output is used to set up the panner and create whatever Jack
ports are needed to output the data.
All 'special' internal processors (meter, fader, amp, insert, send) are
currently transparent: they read any input, and return the same set
of channels back (unmodified, except for amp).
User visible changes:
* LV2 Instrument support (tracks with both MIDI and audio channels)
* MIDI in/out plugin support
* Generic plugin replication (for MIDI plugins, MIDI/audio plugins)
* Movable meter point
Known Bugs:
* Things seem to get weird on loaded sessions
* Output delivery is sketchy
* 2.0 session loading was probably already broken...
but it's definitely broken now :)
Please test this and file bugs if you have any time...
git-svn-id: svn://localhost/ardour2/branches/3.0@5055 d708f5d6-7413-0410-9779-e7cbd77b26cf
2009-05-07 06:30:50 +00:00
|
|
|
|
2013-08-04 15:17:19 +01:00
|
|
|
return string (&buf2[0]);
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32_t
|
2009-06-09 20:21:19 +00:00
|
|
|
IO::find_port_hole (const char* base)
|
2008-06-02 21:41:35 +00:00
|
|
|
{
|
|
|
|
|
/* CALLER MUST HOLD IO LOCK */
|
|
|
|
|
|
|
|
|
|
uint32_t n;
|
|
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
if (_ports.empty()) {
|
2008-06-02 21:41:35 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* we only allow up to 4 characters for the port number
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
for (n = 1; n < 9999; ++n) {
|
2013-09-12 11:28:50 -04:00
|
|
|
std::vector<char> buf (AudioEngine::instance()->port_name_size());
|
2009-06-09 20:21:19 +00:00
|
|
|
PortSet::iterator i = _ports.begin();
|
2008-06-02 21:41:35 +00:00
|
|
|
|
2013-12-02 21:10:08 +10:00
|
|
|
snprintf (&buf[0], buf.size()+1, _("%s %u"), base, n);
|
2008-06-02 21:41:35 +00:00
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
for ( ; i != _ports.end(); ++i) {
|
2013-08-04 15:17:19 +01:00
|
|
|
if (string(i->name()) == string(&buf[0])) {
|
2008-06-02 21:41:35 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
if (i == _ports.end()) {
|
2008-06-02 21:41:35 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return n;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-10-28 17:04:09 +00:00
|
|
|
boost::shared_ptr<AudioPort>
|
2009-06-09 20:21:19 +00:00
|
|
|
IO::audio(uint32_t n) const
|
2008-06-02 21:41:35 +00:00
|
|
|
{
|
2009-06-09 20:21:19 +00:00
|
|
|
return _ports.nth_audio_port (n);
|
2008-06-02 21:41:35 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-28 17:04:09 +00:00
|
|
|
boost::shared_ptr<MidiPort>
|
2009-06-09 20:21:19 +00:00
|
|
|
IO::midi(uint32_t n) const
|
2008-06-02 21:41:35 +00:00
|
|
|
{
|
2009-06-09 20:21:19 +00:00
|
|
|
return _ports.nth_midi_port (n);
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2009-11-25 23:24:02 +00:00
|
|
|
* Setup a bundle that describe our inputs or outputs. Also creates the bundle if necessary.
|
2008-06-02 21:41:35 +00:00
|
|
|
*/
|
|
|
|
|
void
|
2009-11-25 23:24:02 +00:00
|
|
|
IO::setup_bundle ()
|
2008-06-02 21:41:35 +00:00
|
|
|
{
|
2017-09-18 06:47:01 +02:00
|
|
|
char buf[32];
|
2008-06-02 21:41:35 +00:00
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
if (!_bundle) {
|
2009-08-02 00:33:50 +00:00
|
|
|
_bundle.reset (new Bundle (_direction == Input));
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
_bundle->suspend_signals ();
|
2009-02-09 03:18:10 +00:00
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
_bundle->remove_channels ();
|
2009-02-09 03:18:10 +00:00
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
if (_direction == Input) {
|
2010-02-11 23:10:29 +00:00
|
|
|
snprintf(buf, sizeof (buf), _("%s in"), _name.val().c_str());
|
2009-06-09 20:21:19 +00:00
|
|
|
} else {
|
2010-02-11 23:10:29 +00:00
|
|
|
snprintf(buf, sizeof (buf), _("%s out"), _name.val().c_str());
|
2009-02-09 03:18:10 +00:00
|
|
|
}
|
2017-09-18 06:47:01 +02:00
|
|
|
_bundle->set_name (buf);
|
2010-07-01 01:14:14 +00:00
|
|
|
|
|
|
|
|
int c = 0;
|
|
|
|
|
for (DataType::iterator i = DataType::begin(); i != DataType::end(); ++i) {
|
|
|
|
|
|
|
|
|
|
uint32_t const N = _ports.count().get (*i);
|
|
|
|
|
for (uint32_t j = 0; j < N; ++j) {
|
|
|
|
|
_bundle->add_channel (bundle_channel_name (j, N, *i), *i);
|
|
|
|
|
_bundle->set_port (c, _session.engine().make_port_name_non_relative (_ports.port(*i, j)->name()));
|
|
|
|
|
++c;
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
2009-02-09 03:18:10 +00:00
|
|
|
|
2021-06-11 20:01:22 +02:00
|
|
|
reestablish_port_subscriptions ();
|
|
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
_bundle->resume_signals ();
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
/** @return Bundles connected to our ports */
|
2009-01-25 06:47:11 +00:00
|
|
|
BundleList
|
2009-06-09 20:21:19 +00:00
|
|
|
IO::bundles_connected ()
|
2008-06-02 21:41:35 +00:00
|
|
|
{
|
2009-01-25 06:47:11 +00:00
|
|
|
BundleList bundles;
|
2009-08-02 00:33:50 +00:00
|
|
|
|
2009-02-11 02:14:01 +00:00
|
|
|
/* Session bundles */
|
2009-01-25 06:47:11 +00:00
|
|
|
boost::shared_ptr<ARDOUR::BundleList> b = _session.bundles ();
|
|
|
|
|
for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
|
2009-06-09 20:21:19 +00:00
|
|
|
if ((*i)->connected_to (_bundle, _session.engine())) {
|
2009-02-11 02:14:01 +00:00
|
|
|
bundles.push_back (*i);
|
2009-01-25 06:47:11 +00:00
|
|
|
}
|
2009-02-11 02:14:01 +00:00
|
|
|
}
|
2008-06-02 21:41:35 +00:00
|
|
|
|
2009-02-11 02:14:01 +00:00
|
|
|
/* Route bundles */
|
2008-06-02 21:41:35 +00:00
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
boost::shared_ptr<ARDOUR::RouteList> r = _session.get_routes ();
|
2008-06-02 21:41:35 +00:00
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
if (_direction == Input) {
|
|
|
|
|
for (ARDOUR::RouteList::iterator i = r->begin(); i != r->end(); ++i) {
|
|
|
|
|
if ((*i)->output()->bundle()->connected_to (_bundle, _session.engine())) {
|
|
|
|
|
bundles.push_back ((*i)->output()->bundle());
|
|
|
|
|
}
|
2009-01-25 06:47:11 +00:00
|
|
|
}
|
2009-06-09 20:21:19 +00:00
|
|
|
} else {
|
|
|
|
|
for (ARDOUR::RouteList::iterator i = r->begin(); i != r->end(); ++i) {
|
|
|
|
|
if ((*i)->input()->bundle()->connected_to (_bundle, _session.engine())) {
|
|
|
|
|
bundles.push_back ((*i)->input()->bundle());
|
|
|
|
|
}
|
2009-01-25 06:47:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
return bundles;
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IO::UserBundleInfo::UserBundleInfo (IO* io, boost::shared_ptr<UserBundle> b)
|
|
|
|
|
{
|
|
|
|
|
bundle = b;
|
2009-12-21 18:23:07 +00:00
|
|
|
b->Changed.connect_same_thread (changed, boost::bind (&IO::bundle_changed, io, _1));
|
2008-06-02 21:41:35 +00:00
|
|
|
}
|
|
|
|
|
|
2009-01-27 18:36:40 +00:00
|
|
|
std::string
|
2010-07-01 01:14:14 +00:00
|
|
|
IO::bundle_channel_name (uint32_t c, uint32_t n, DataType t) const
|
2009-01-27 18:36:40 +00:00
|
|
|
{
|
|
|
|
|
char buf[32];
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2010-07-01 01:14:14 +00:00
|
|
|
if (t == DataType::AUDIO) {
|
|
|
|
|
|
|
|
|
|
switch (n) {
|
|
|
|
|
case 1:
|
|
|
|
|
return _("mono");
|
|
|
|
|
case 2:
|
|
|
|
|
return c == 0 ? _("L") : _("R");
|
|
|
|
|
default:
|
2016-07-13 18:27:53 -04:00
|
|
|
snprintf (buf, sizeof(buf), "%d", (c + 1));
|
2010-07-01 01:14:14 +00:00
|
|
|
return buf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
2016-07-13 18:27:53 -04:00
|
|
|
snprintf (buf, sizeof(buf), "%d", (c + 1));
|
2009-01-27 18:36:40 +00:00
|
|
|
return buf;
|
2010-07-01 01:14:14 +00:00
|
|
|
|
2009-01-27 18:36:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return "";
|
|
|
|
|
}
|
2009-01-30 07:40:13 +00:00
|
|
|
|
2009-03-02 16:52:40 +00:00
|
|
|
string
|
|
|
|
|
IO::name_from_state (const XMLNode& node)
|
|
|
|
|
{
|
2016-05-04 23:09:37 -04:00
|
|
|
XMLProperty const * prop;
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2009-03-02 16:52:40 +00:00
|
|
|
if ((prop = node.property ("name")) != 0) {
|
|
|
|
|
return prop->value();
|
2009-10-14 16:10:01 +00:00
|
|
|
}
|
|
|
|
|
|
2009-03-02 16:52:40 +00:00
|
|
|
return string();
|
|
|
|
|
}
|
2009-01-30 07:40:13 +00:00
|
|
|
|
2009-03-02 16:52:40 +00:00
|
|
|
void
|
|
|
|
|
IO::set_name_in_state (XMLNode& node, const string& new_name)
|
|
|
|
|
{
|
2016-08-25 12:59:02 +10:00
|
|
|
node.set_property (X_("name"), new_name);
|
2011-11-16 23:03:59 +00:00
|
|
|
XMLNodeList children = node.children ();
|
|
|
|
|
for (XMLNodeIterator i = children.begin(); i != children.end(); ++i) {
|
|
|
|
|
if ((*i)->name() == X_("Port")) {
|
|
|
|
|
string const old_name = (*i)->property(X_("name"))->value();
|
|
|
|
|
string const old_name_second_part = old_name.substr (old_name.find_first_of ("/") + 1);
|
2016-08-25 12:59:02 +10:00
|
|
|
(*i)->set_property (X_("name"), string_compose ("%1/%2", new_name, old_name_second_part));
|
2011-11-16 23:03:59 +00:00
|
|
|
}
|
2009-10-14 16:10:01 +00:00
|
|
|
}
|
2009-03-02 16:52:40 +00:00
|
|
|
}
|
2009-04-23 17:48:37 +00:00
|
|
|
|
2010-03-21 17:02:30 +00:00
|
|
|
bool
|
|
|
|
|
IO::connected () const
|
|
|
|
|
{
|
2017-09-18 06:47:01 +02:00
|
|
|
/* do we have any connections at all? */
|
2011-06-01 16:50:12 +00:00
|
|
|
|
2017-09-18 06:47:01 +02:00
|
|
|
for (PortSet::const_iterator p = _ports.begin(); p != _ports.end(); ++p) {
|
|
|
|
|
if (p->connected()) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-06-01 16:50:12 +00:00
|
|
|
|
2017-09-18 06:47:01 +02:00
|
|
|
return false;
|
2010-03-21 17:02:30 +00:00
|
|
|
}
|
|
|
|
|
|
2009-05-17 02:08:13 +00:00
|
|
|
bool
|
|
|
|
|
IO::connected_to (boost::shared_ptr<const IO> other) const
|
|
|
|
|
{
|
2009-07-01 23:14:27 +00:00
|
|
|
if (!other) {
|
2017-09-18 06:47:01 +02:00
|
|
|
return connected ();
|
2009-07-01 23:14:27 +00:00
|
|
|
}
|
|
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
assert (_direction != other->direction());
|
|
|
|
|
|
2009-05-17 02:08:13 +00:00
|
|
|
uint32_t i, j;
|
2009-06-09 20:21:19 +00:00
|
|
|
uint32_t no = n_ports().n_total();
|
|
|
|
|
uint32_t ni = other->n_ports ().n_total();
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2009-05-17 02:08:13 +00:00
|
|
|
for (i = 0; i < no; ++i) {
|
|
|
|
|
for (j = 0; j < ni; ++j) {
|
2015-01-27 11:59:23 +00:00
|
|
|
if ((NULL != nth(i).get()) && (NULL != other->nth(j).get())) {
|
|
|
|
|
if (nth(i)->connected_to (other->nth(j)->name())) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2009-05-17 02:08:13 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-03 15:01:21 +00:00
|
|
|
bool
|
|
|
|
|
IO::connected_to (const string& str) const
|
|
|
|
|
{
|
|
|
|
|
for (PortSet::const_iterator i = _ports.begin(); i != _ports.end(); ++i) {
|
|
|
|
|
if (i->connected_to (str)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
void
|
2010-12-03 22:26:29 +00:00
|
|
|
IO::collect_input (BufferSet& bufs, pframes_t nframes, ChanCount offset)
|
2009-06-09 20:21:19 +00:00
|
|
|
{
|
|
|
|
|
assert(bufs.available() >= _ports.count());
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
if (_ports.count() == ChanCount::ZERO) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bufs.set_count (_ports.count());
|
|
|
|
|
|
|
|
|
|
for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
|
|
|
|
|
PortSet::iterator i = _ports.begin(*t);
|
|
|
|
|
BufferSet::iterator b = bufs.begin(*t);
|
|
|
|
|
|
|
|
|
|
for (uint32_t off = 0; off < offset.get(*t); ++off, ++b) {
|
|
|
|
|
if (b == bufs.end(*t)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for ( ; i != _ports.end(*t); ++i, ++b) {
|
2016-04-03 03:12:55 +02:00
|
|
|
const Buffer& bb (i->get_buffer (nframes));
|
2009-06-09 20:21:19 +00:00
|
|
|
b->read_from (bb, nframes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2017-09-18 12:39:17 -04:00
|
|
|
IO::copy_to_outputs (BufferSet& bufs, DataType type, pframes_t nframes, samplecnt_t offset)
|
2009-06-09 20:21:19 +00:00
|
|
|
{
|
|
|
|
|
PortSet::iterator o = _ports.begin(type);
|
|
|
|
|
BufferSet::iterator i = bufs.begin(type);
|
|
|
|
|
BufferSet::iterator prev = i;
|
|
|
|
|
|
2016-07-09 00:19:44 +02:00
|
|
|
assert(i != bufs.end(type)); // or second loop will crash
|
|
|
|
|
|
|
|
|
|
// Copy any buffers 1:1 to outputs
|
|
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
while (i != bufs.end(type) && o != _ports.end (type)) {
|
|
|
|
|
Buffer& port_buffer (o->get_buffer (nframes));
|
|
|
|
|
port_buffer.read_from (*i, nframes, offset);
|
|
|
|
|
prev = i;
|
|
|
|
|
++i;
|
|
|
|
|
++o;
|
|
|
|
|
}
|
2009-10-14 16:10:01 +00:00
|
|
|
|
2009-06-09 20:21:19 +00:00
|
|
|
// Copy last buffer to any extra outputs
|
|
|
|
|
|
|
|
|
|
while (o != _ports.end(type)) {
|
|
|
|
|
Buffer& port_buffer (o->get_buffer (nframes));
|
|
|
|
|
port_buffer.read_from (*prev, nframes, offset);
|
|
|
|
|
++o;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-06-23 02:43:35 +00:00
|
|
|
|
2011-10-28 17:04:09 +00:00
|
|
|
boost::shared_ptr<Port>
|
2009-06-23 02:43:35 +00:00
|
|
|
IO::port_by_name (const std::string& str) const
|
|
|
|
|
{
|
|
|
|
|
/* to be called only from ::set_state() - no locking */
|
|
|
|
|
|
|
|
|
|
for (PortSet::const_iterator i = _ports.begin(); i != _ports.end(); ++i) {
|
|
|
|
|
|
2011-10-28 17:04:09 +00:00
|
|
|
if (i->name() == str) {
|
|
|
|
|
return boost::const_pointer_cast<Port> (*i);
|
2009-06-23 02:43:35 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-28 17:04:09 +00:00
|
|
|
return boost::shared_ptr<Port> ();
|
2009-06-23 02:43:35 +00:00
|
|
|
}
|
2010-05-01 15:09:19 +00:00
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
IO::physically_connected () const
|
|
|
|
|
{
|
|
|
|
|
for (PortSet::const_iterator i = _ports.begin(); i != _ports.end(); ++i) {
|
2017-09-18 06:47:01 +02:00
|
|
|
if (i->physically_connected()) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-05-01 15:09:19 +00:00
|
|
|
|
2017-09-18 06:47:01 +02:00
|
|
|
return false;
|
2010-05-01 15:09:19 +00:00
|
|
|
}
|
2010-12-29 17:52:32 +00:00
|
|
|
|
|
|
|
|
bool
|
2011-10-28 17:04:09 +00:00
|
|
|
IO::has_port (boost::shared_ptr<Port> p) const
|
2010-12-29 17:52:32 +00:00
|
|
|
{
|
2012-07-25 17:48:55 +00:00
|
|
|
Glib::Threads::Mutex::Lock lm (io_lock);
|
2010-12-29 17:52:32 +00:00
|
|
|
return _ports.contains (p);
|
|
|
|
|
}
|