diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2007-10-17 16:49:31 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2007-10-17 16:49:31 +0000 |
commit | 239ec39da6583e6e00cd03fa3bde8f1e27016b4d (patch) | |
tree | 8e46988053361eefbbcaa0291f5d0540cd0ab9c7 /libs/ardour/audioengine.cc | |
parent | df28e90c673b209b946463efa02f35c5a0f6bed5 (diff) |
new internal port type, round I, plus tiny fix for legalize_for_xml() (also for 2.0-ongoing)
git-svn-id: svn://localhost/ardour2/trunk@2559 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/audioengine.cc')
-rw-r--r-- | libs/ardour/audioengine.cc | 93 |
1 files changed, 78 insertions, 15 deletions
diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc index 63a51b76c4..4552de1186 100644 --- a/libs/ardour/audioengine.cc +++ b/libs/ardour/audioengine.cc @@ -32,6 +32,7 @@ #include <ardour/buffer.h> #include <ardour/port.h> #include <ardour/jack_audio_port.h> +#include <ardour/internal_audio_port.h> #include <ardour/jack_midi_port.h> #include <ardour/session.h> #include <ardour/cycle_timer.h> @@ -508,17 +509,33 @@ AudioEngine::remove_session () } Port * -AudioEngine::register_port (DataType type, const string& portname, bool input) +AudioEngine::register_port (PortType ptype, DataType dtype, const string& portname, bool input) { Port* newport = 0; try { - if (type == DataType::AUDIO) - newport = new JackAudioPort (portname, (input ? Port::IsInput : Port::IsOutput)); - else if (type == DataType::MIDI) - newport = new JackMidiPort (portname, (input ? Port::IsInput : Port::IsOutput)); - else - throw unknown_type(); + switch (ptype) { + case Jack: + if (dtype == DataType::AUDIO) { + newport = new JackAudioPort (portname, (input ? Port::IsInput : Port::IsOutput)); + } else if (dtype == DataType::MIDI) { + newport = new JackMidiPort (portname, (input ? Port::IsInput : Port::IsOutput)); + } else { + throw unknown_type(); + } + break; + + case Internal: + if (dtype == DataType::AUDIO) { + newport = new InternalAudioPort (portname, (input ? Port::IsInput : Port::IsOutput)); + } else if (dtype == DataType::MIDI) { + error << _("Internal MIDI ports are not implemented yet!") << endmsg; + throw unknown_type(); + } else { + throw unknown_type(); + } + break; + } if (newport != 0) { RCUWriter<Ports> writer (ports); @@ -535,16 +552,30 @@ AudioEngine::register_port (DataType type, const string& portname, bool input) } } +InternalPort* +AudioEngine::get_internal_port (const std::string& short_name) +{ + boost::shared_ptr<Ports> p = ports.reader(); + + for (Ports::iterator i = p->begin(); i != p->end(); ++i) { + if ((*i)->short_name() == short_name) { + return dynamic_cast<InternalPort*> (*i); + } + } + return 0; +} + + Port * -AudioEngine::register_input_port (DataType type, const string& portname) +AudioEngine::register_input_port (PortType ptype, DataType type, const string& portname) { - return register_port (type, portname, true); + return register_port (ptype, type, portname, true); } Port * -AudioEngine::register_output_port (DataType type, const string& portname) +AudioEngine::register_output_port (PortType ptype, DataType type, const string& portname) { - return register_port (type, portname, false); + return register_port (ptype, type, portname, false); } int @@ -565,7 +596,6 @@ AudioEngine::unregister_port (Port& port) for (Ports::iterator i = ps->begin(); i != ps->end(); ++i) { if ((*i) == &port) { remove_connections_for (port); - cerr << "eraseing " << (*i)->name() << endl; delete *i; ps->erase (i); break; @@ -581,6 +611,8 @@ AudioEngine::unregister_port (Port& port) int AudioEngine::connect (const string& source, const string& destination) { + int ret; + if (!_running) { if (!_has_run) { fatal << _("connect called before engine was started") << endmsg; @@ -589,11 +621,26 @@ AudioEngine::connect (const string& source, const string& destination) return -1; } } - + string s = make_port_name_non_relative (source); string d = make_port_name_non_relative (destination); + + if (source.substr (0, 9) == "internal:") { + if (destination.substr (0, 9) == "internal:") { + InternalPort* src = get_internal_port (source); + InternalPort* dst = get_internal_port (destination); + + InternalPort::connect (*src, *dst); + ret = 0; - int ret = jack_connect (_jack, s.c_str(), d.c_str()); + } else { + ret = -1; + } + + } else { + + ret = jack_connect (_jack, s.c_str(), d.c_str()); + } if (ret == 0) { pair<string,string> c (s, d); @@ -614,6 +661,8 @@ AudioEngine::connect (const string& source, const string& destination) int AudioEngine::disconnect (const string& source, const string& destination) { + int ret; + if (!_running) { if (!_has_run) { fatal << _("disconnect called before engine was started") << endmsg; @@ -626,7 +675,21 @@ AudioEngine::disconnect (const string& source, const string& destination) string s = make_port_name_non_relative (source); string d = make_port_name_non_relative (destination); - int ret = jack_disconnect (_jack, s.c_str(), d.c_str()); + if (source.substr (0, 9) == "internal:") { + if (destination.substr (0, 9) == "internal:") { + InternalPort* src = get_internal_port (source); + InternalPort* dst = get_internal_port (destination); + + InternalPort::disconnect (*src, *dst); + ret = 0; + } else { + ret = -1; + } + + } else { + + ret = jack_disconnect (_jack, s.c_str(), d.c_str()); + } if (ret == 0) { pair<string,string> c (s, d); |