2009-01-23 16:24:11 -05:00
|
|
|
/*
|
2009-10-14 12:10:01 -04:00
|
|
|
Copyright (C) 2009 Paul Davis
|
2009-01-23 16:24:11 -05:00
|
|
|
|
|
|
|
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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2009-02-10 10:45:06 -05:00
|
|
|
#include <gtkmm/image.h>
|
|
|
|
#include <gtkmm/stock.h>
|
2009-01-23 16:24:11 -05:00
|
|
|
#include "global_port_matrix.h"
|
2009-08-29 16:48:11 -04:00
|
|
|
#include "utils.h"
|
2009-05-13 12:04:41 -04:00
|
|
|
|
2009-01-23 16:24:11 -05:00
|
|
|
#include "ardour/bundle.h"
|
|
|
|
#include "ardour/session.h"
|
|
|
|
#include "ardour/audioengine.h"
|
|
|
|
#include "ardour/port.h"
|
|
|
|
|
2009-05-13 12:04:41 -04:00
|
|
|
#include "i18n.h"
|
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
using namespace std;
|
|
|
|
|
2009-12-04 22:04:54 -05:00
|
|
|
GlobalPortMatrix::GlobalPortMatrix (Gtk::Window* p, ARDOUR::Session* s, ARDOUR::DataType t)
|
2009-07-21 21:28:31 -04:00
|
|
|
: PortMatrix (p, s, t)
|
2009-01-23 16:24:11 -05:00
|
|
|
{
|
2009-02-08 22:18:10 -05:00
|
|
|
setup_all_ports ();
|
2009-11-18 08:35:31 -05:00
|
|
|
init ();
|
2009-01-23 16:24:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-02-08 22:18:10 -05:00
|
|
|
GlobalPortMatrix::setup_ports (int dim)
|
2009-01-23 16:24:11 -05:00
|
|
|
{
|
2009-02-08 22:18:10 -05:00
|
|
|
_ports[dim].suspend_signals ();
|
2010-06-29 22:59:13 -04:00
|
|
|
_ports[dim].gather (_session, type(), dim == IN, false);
|
2009-02-08 22:18:10 -05:00
|
|
|
_ports[dim].resume_signals ();
|
2009-01-23 16:24:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-01-30 10:08:09 -05:00
|
|
|
GlobalPortMatrix::set_state (ARDOUR::BundleChannel c[2], bool s)
|
2009-01-23 16:24:11 -05:00
|
|
|
{
|
2009-01-30 10:08:09 -05:00
|
|
|
ARDOUR::Bundle::PortList const & in_ports = c[IN].bundle->channel_ports (c[IN].channel);
|
|
|
|
ARDOUR::Bundle::PortList const & out_ports = c[OUT].bundle->channel_ports (c[OUT].channel);
|
2009-01-23 16:24:11 -05:00
|
|
|
|
2009-01-30 10:08:09 -05:00
|
|
|
for (ARDOUR::Bundle::PortList::const_iterator i = in_ports.begin(); i != in_ports.end(); ++i) {
|
|
|
|
for (ARDOUR::Bundle::PortList::const_iterator j = out_ports.begin(); j != out_ports.end(); ++j) {
|
2009-01-23 16:24:11 -05:00
|
|
|
|
2009-12-04 22:04:54 -05:00
|
|
|
ARDOUR::Port* p = _session->engine().get_port_by_name (*i);
|
|
|
|
ARDOUR::Port* q = _session->engine().get_port_by_name (*j);
|
2009-01-23 16:24:11 -05:00
|
|
|
|
|
|
|
if (p) {
|
|
|
|
if (s) {
|
|
|
|
p->connect (*j);
|
|
|
|
} else {
|
|
|
|
p->disconnect (*j);
|
|
|
|
}
|
|
|
|
} else if (q) {
|
|
|
|
if (s) {
|
|
|
|
q->connect (*i);
|
|
|
|
} else {
|
2009-01-30 10:08:09 -05:00
|
|
|
q->disconnect (*i);
|
2009-01-23 16:24:11 -05:00
|
|
|
}
|
2009-11-16 17:32:58 -05:00
|
|
|
} else {
|
|
|
|
/* two non-Ardour ports */
|
|
|
|
if (s) {
|
2009-12-04 22:04:54 -05:00
|
|
|
jack_connect (_session->engine().jack (), j->c_str(), i->c_str());
|
2009-11-16 17:32:58 -05:00
|
|
|
} else {
|
2009-12-04 22:04:54 -05:00
|
|
|
jack_disconnect (_session->engine().jack (), j->c_str(), i->c_str());
|
2009-11-16 17:32:58 -05:00
|
|
|
}
|
2009-01-23 16:24:11 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-03 10:31:42 -04:00
|
|
|
PortMatrixNode::State
|
2009-01-30 10:08:09 -05:00
|
|
|
GlobalPortMatrix::get_state (ARDOUR::BundleChannel c[2]) const
|
2009-01-23 16:24:11 -05:00
|
|
|
{
|
2009-12-04 22:04:54 -05:00
|
|
|
if (_session == 0) {
|
|
|
|
return PortMatrixNode::NOT_ASSOCIATED;
|
|
|
|
}
|
|
|
|
|
2009-01-30 10:08:09 -05:00
|
|
|
ARDOUR::Bundle::PortList const & in_ports = c[IN].bundle->channel_ports (c[IN].channel);
|
|
|
|
ARDOUR::Bundle::PortList const & out_ports = c[OUT].bundle->channel_ports (c[OUT].channel);
|
2009-02-08 22:18:10 -05:00
|
|
|
if (in_ports.empty() || out_ports.empty()) {
|
2009-02-14 15:17:45 -05:00
|
|
|
/* we're looking at a bundle with no parts associated with this channel,
|
|
|
|
so nothing to connect */
|
2009-11-16 17:32:58 -05:00
|
|
|
return PortMatrixNode::NOT_ASSOCIATED;
|
2009-02-08 22:18:10 -05:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-01-30 10:08:09 -05:00
|
|
|
for (ARDOUR::Bundle::PortList::const_iterator i = in_ports.begin(); i != in_ports.end(); ++i) {
|
|
|
|
for (ARDOUR::Bundle::PortList::const_iterator j = out_ports.begin(); j != out_ports.end(); ++j) {
|
2009-01-23 16:24:11 -05:00
|
|
|
|
2009-12-04 22:04:54 -05:00
|
|
|
ARDOUR::Port* p = _session->engine().get_port_by_name (*i);
|
|
|
|
ARDOUR::Port* q = _session->engine().get_port_by_name (*j);
|
2009-01-23 16:24:11 -05:00
|
|
|
|
|
|
|
if (!p && !q) {
|
2009-11-16 17:32:58 -05:00
|
|
|
/* two non-Ardour ports; things are slightly more involved */
|
|
|
|
/* XXX: is this the easiest way to do this? */
|
|
|
|
/* XXX: isn't this very inefficient? */
|
|
|
|
|
2009-12-04 22:04:54 -05:00
|
|
|
jack_client_t* jack = _session->engine().jack ();
|
2009-11-16 17:32:58 -05:00
|
|
|
jack_port_t* jp = jack_port_by_name (jack, i->c_str());
|
|
|
|
if (jp == 0) {
|
|
|
|
return PortMatrixNode::NOT_ASSOCIATED;
|
|
|
|
}
|
|
|
|
|
|
|
|
char const ** c = jack_port_get_all_connections (jack, jp);
|
|
|
|
|
|
|
|
char const ** p = c;
|
|
|
|
|
|
|
|
while (p && *p != 0) {
|
|
|
|
if (strcmp (*p, j->c_str()) == 0) {
|
|
|
|
free (c);
|
|
|
|
return PortMatrixNode::ASSOCIATED;
|
|
|
|
}
|
|
|
|
++p;
|
|
|
|
}
|
|
|
|
|
|
|
|
free (c);
|
|
|
|
return PortMatrixNode::NOT_ASSOCIATED;
|
2009-01-23 16:24:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (p && p->connected_to (*j) == false) {
|
2009-05-03 10:31:42 -04:00
|
|
|
return PortMatrixNode::NOT_ASSOCIATED;
|
2009-01-23 16:24:11 -05:00
|
|
|
} else if (q && q->connected_to (*i) == false) {
|
2009-05-03 10:31:42 -04:00
|
|
|
return PortMatrixNode::NOT_ASSOCIATED;
|
2009-01-23 16:24:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-03 10:31:42 -04:00
|
|
|
return PortMatrixNode::ASSOCIATED;
|
2009-01-23 16:24:11 -05:00
|
|
|
}
|
|
|
|
|
2009-12-04 22:04:54 -05:00
|
|
|
GlobalPortMatrixWindow::GlobalPortMatrixWindow (ARDOUR::Session* s, ARDOUR::DataType t)
|
2009-07-21 21:28:31 -04:00
|
|
|
: _port_matrix (this, s, t)
|
2009-01-23 16:24:11 -05:00
|
|
|
{
|
2009-01-26 15:41:22 -05:00
|
|
|
switch (t) {
|
|
|
|
case ARDOUR::DataType::AUDIO:
|
2009-10-19 13:25:37 -04:00
|
|
|
set_title (_("Audio Connection Manager"));
|
2009-01-26 15:41:22 -05:00
|
|
|
break;
|
|
|
|
case ARDOUR::DataType::MIDI:
|
2009-10-19 13:25:37 -04:00
|
|
|
set_title (_("MIDI Connection Manager"));
|
2009-01-26 15:41:22 -05:00
|
|
|
break;
|
|
|
|
}
|
2009-02-10 10:45:06 -05:00
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
add (_port_matrix);
|
2009-12-07 13:35:42 -05:00
|
|
|
_port_matrix.show ();
|
2009-07-18 09:10:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-07-21 21:28:31 -04:00
|
|
|
GlobalPortMatrixWindow::on_show ()
|
2009-07-18 09:10:08 -04:00
|
|
|
{
|
2009-07-21 21:28:31 -04:00
|
|
|
Gtk::Window::on_show ();
|
2009-08-29 16:48:11 -04:00
|
|
|
pair<uint32_t, uint32_t> const pm_max = _port_matrix.max_size ();
|
|
|
|
resize_window_to_proportion_of_monitor (this, pm_max.first, pm_max.second);
|
2009-05-03 10:31:42 -04:00
|
|
|
}
|
2010-05-07 21:20:33 -04:00
|
|
|
|
2010-07-20 13:56:02 -04:00
|
|
|
void
|
|
|
|
GlobalPortMatrixWindow::set_session (ARDOUR::Session* s)
|
|
|
|
{
|
|
|
|
_port_matrix.set_session (s);
|
|
|
|
}
|
|
|
|
|
2010-05-07 21:20:33 -04:00
|
|
|
string
|
|
|
|
GlobalPortMatrix::disassociation_verb () const
|
|
|
|
{
|
|
|
|
return _("Disconnect");
|
|
|
|
}
|
|
|
|
|
|
|
|
string
|
|
|
|
GlobalPortMatrix::channel_noun () const
|
|
|
|
{
|
|
|
|
return _("port");
|
|
|
|
}
|
|
|
|
|