2005-09-25 14:42:24 -04:00
|
|
|
/*
|
2007-10-12 20:58:03 -04:00
|
|
|
Copyright (C) 2002-2007 Paul Davis
|
2005-09-25 14:42:24 -04: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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2008-09-10 11:03:30 -04:00
|
|
|
#include <gtkmm/messagedialog.h>
|
2007-10-10 14:37:13 -04:00
|
|
|
#include <glibmm/objectbase.h>
|
2008-09-10 11:03:30 -04:00
|
|
|
|
2005-09-25 16:33:00 -04:00
|
|
|
#include <gtkmm2ext/doi.h>
|
2008-09-10 11:03:30 -04:00
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "ardour/port_insert.h"
|
2007-10-10 14:37:13 -04:00
|
|
|
#include "ardour/session.h"
|
|
|
|
#include "ardour/io.h"
|
|
|
|
#include "ardour/audioengine.h"
|
2007-10-12 08:13:11 -04:00
|
|
|
#include "ardour/track.h"
|
2007-10-12 10:49:07 -04:00
|
|
|
#include "ardour/audio_track.h"
|
|
|
|
#include "ardour/midi_track.h"
|
|
|
|
#include "ardour/data_type.h"
|
2009-01-20 21:27:21 -05:00
|
|
|
#include "ardour/port.h"
|
2009-01-20 09:46:00 -05:00
|
|
|
#include "ardour/bundle.h"
|
2008-09-10 11:03:30 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "io_selector.h"
|
2007-10-10 14:37:13 -04:00
|
|
|
#include "utils.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "gui_thread.h"
|
|
|
|
#include "i18n.h"
|
|
|
|
|
2008-09-10 11:03:30 -04:00
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace Gtk;
|
|
|
|
|
2009-06-09 16:21:19 -04:00
|
|
|
IOSelector::IOSelector (ARDOUR::Session& session, boost::shared_ptr<ARDOUR::IO> io)
|
2009-01-30 10:08:09 -05:00
|
|
|
: PortMatrix (session, io->default_type())
|
2008-12-14 04:35:23 -05:00
|
|
|
, _io (io)
|
2007-10-12 20:58:03 -04:00
|
|
|
{
|
2009-01-30 10:08:09 -05:00
|
|
|
/* signal flow from 0 to 1 */
|
2009-06-09 16:21:19 -04:00
|
|
|
|
|
|
|
_find_inputs_for_io_outputs = (_io->direction() == IO::Output);
|
|
|
|
|
2009-01-30 10:08:09 -05:00
|
|
|
if (_find_inputs_for_io_outputs) {
|
|
|
|
_other = 1;
|
|
|
|
_ours = 0;
|
|
|
|
} else {
|
|
|
|
_other = 0;
|
|
|
|
_ours = 1;
|
|
|
|
}
|
|
|
|
|
2009-05-20 16:54:07 -04:00
|
|
|
_port_group.reset (new PortGroup (""));
|
2009-01-30 10:08:09 -05:00
|
|
|
_ports[_ours].add_group (_port_group);
|
2009-01-20 09:46:00 -05:00
|
|
|
|
2009-02-08 22:18:10 -05:00
|
|
|
setup_all_ports ();
|
2009-01-20 09:46:00 -05:00
|
|
|
}
|
2008-12-14 04:35:23 -05:00
|
|
|
|
2009-01-20 09:46:00 -05:00
|
|
|
void
|
2009-02-08 22:18:10 -05:00
|
|
|
IOSelector::setup_ports (int dim)
|
2009-01-20 09:46:00 -05:00
|
|
|
{
|
2009-02-08 22:18:10 -05:00
|
|
|
_ports[dim].suspend_signals ();
|
2009-01-20 09:46:00 -05:00
|
|
|
|
2009-02-08 22:18:10 -05:00
|
|
|
if (dim == _other) {
|
|
|
|
|
|
|
|
_ports[_other].gather (_session, _find_inputs_for_io_outputs);
|
2009-01-20 09:46:00 -05:00
|
|
|
|
2008-09-29 09:34:35 -04:00
|
|
|
} else {
|
2008-12-14 04:35:23 -05:00
|
|
|
|
2009-02-08 22:18:10 -05:00
|
|
|
_port_group->clear ();
|
2009-06-09 16:21:19 -04:00
|
|
|
_port_group->add_bundle (_io->bundle ());
|
2007-10-12 20:58:03 -04:00
|
|
|
}
|
2009-01-12 20:15:19 -05:00
|
|
|
|
2009-02-08 22:18:10 -05:00
|
|
|
_ports[dim].resume_signals ();
|
2007-10-10 14:37:13 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-10-10 14:37:13 -04:00
|
|
|
void
|
2009-01-30 10:08:09 -05:00
|
|
|
IOSelector::set_state (ARDOUR::BundleChannel c[2], bool s)
|
2007-10-10 14:37:13 -04:00
|
|
|
{
|
2009-01-30 10:08:09 -05:00
|
|
|
ARDOUR::Bundle::PortList const & our_ports = c[_ours].bundle->channel_ports (c[_ours].channel);
|
|
|
|
ARDOUR::Bundle::PortList const & other_ports = c[_other].bundle->channel_ports (c[_other].channel);
|
2009-01-20 09:46:00 -05:00
|
|
|
|
|
|
|
for (ARDOUR::Bundle::PortList::const_iterator i = our_ports.begin(); i != our_ports.end(); ++i) {
|
|
|
|
for (ARDOUR::Bundle::PortList::const_iterator j = other_ports.begin(); j != other_ports.end(); ++j) {
|
|
|
|
|
|
|
|
Port* f = _session.engine().get_port_by_name (*i);
|
|
|
|
if (!f) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (s) {
|
2009-06-09 16:21:19 -04:00
|
|
|
_io->connect (f, *j, 0);
|
2009-01-20 09:46:00 -05:00
|
|
|
} else {
|
2009-06-09 16:21:19 -04:00
|
|
|
_io->disconnect (f, *j, 0);
|
2009-01-20 09:46:00 -05:00
|
|
|
}
|
2008-10-07 18:24:00 -04:00
|
|
|
}
|
|
|
|
}
|
2007-10-10 14:37:13 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-05-03 10:31:42 -04:00
|
|
|
PortMatrixNode::State
|
2009-01-30 10:08:09 -05:00
|
|
|
IOSelector::get_state (ARDOUR::BundleChannel c[2]) const
|
2007-10-10 14:37:13 -04:00
|
|
|
{
|
2009-01-30 10:08:09 -05:00
|
|
|
ARDOUR::Bundle::PortList const & our_ports = c[_ours].bundle->channel_ports (c[_ours].channel);
|
|
|
|
ARDOUR::Bundle::PortList const & other_ports = c[_other].bundle->channel_ports (c[_other].channel);
|
2007-10-31 14:24:43 -04:00
|
|
|
|
2009-02-14 15:17:45 -05:00
|
|
|
if (our_ports.empty() || other_ports.empty()) {
|
|
|
|
/* we're looking at a bundle with no parts associated with this channel,
|
|
|
|
so nothing to connect */
|
2009-05-03 10:31:42 -04:00
|
|
|
return PortMatrixNode::UNKNOWN;
|
2009-02-14 15:17:45 -05:00
|
|
|
}
|
|
|
|
|
2009-01-20 09:46:00 -05:00
|
|
|
for (ARDOUR::Bundle::PortList::const_iterator i = our_ports.begin(); i != our_ports.end(); ++i) {
|
|
|
|
for (ARDOUR::Bundle::PortList::const_iterator j = other_ports.begin(); j != other_ports.end(); ++j) {
|
|
|
|
|
|
|
|
Port* f = _session.engine().get_port_by_name (*i);
|
|
|
|
|
2009-01-21 12:44:41 -05:00
|
|
|
/* since we are talking about an IO, our ports should all have an associated Port *,
|
|
|
|
so the above call should never fail */
|
|
|
|
assert (f);
|
|
|
|
|
2009-01-20 09:46:00 -05:00
|
|
|
if (!f->connected_to (*j)) {
|
|
|
|
/* if any one thing is not connected, all bets are off */
|
2009-05-03 10:31:42 -04:00
|
|
|
return PortMatrixNode::NOT_ASSOCIATED;
|
2009-01-20 09:46:00 -05:00
|
|
|
}
|
|
|
|
}
|
2007-10-31 14:24:43 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-05-03 10:31:42 -04:00
|
|
|
return PortMatrixNode::ASSOCIATED;
|
2007-10-10 14:37:13 -04:00
|
|
|
}
|
2006-11-19 11:45:16 -05:00
|
|
|
|
2007-10-19 09:30:07 -04:00
|
|
|
uint32_t
|
2009-01-30 10:08:09 -05:00
|
|
|
IOSelector::n_io_ports () const
|
2007-10-10 14:37:13 -04:00
|
|
|
{
|
2009-01-30 10:08:09 -05:00
|
|
|
if (!_find_inputs_for_io_outputs) {
|
2009-06-09 16:21:19 -04:00
|
|
|
return _io->n_ports().get (_io->default_type());
|
2007-10-19 09:30:07 -04:00
|
|
|
} else {
|
2009-06-09 16:21:19 -04:00
|
|
|
return _io->n_ports().get (_io->default_type());
|
2007-10-12 08:13:11 -04:00
|
|
|
}
|
2007-10-12 20:58:03 -04:00
|
|
|
}
|
2006-11-19 11:45:16 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2009-01-20 09:46:00 -05:00
|
|
|
IOSelector::add_channel (boost::shared_ptr<ARDOUR::Bundle> b)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2009-01-20 09:46:00 -05:00
|
|
|
/* we ignore the bundle parameter, as we know what it is that we're adding to */
|
|
|
|
|
2006-08-11 03:15:30 -04:00
|
|
|
// The IO selector only works for single typed IOs
|
2007-10-12 20:58:03 -04:00
|
|
|
const ARDOUR::DataType t = _io->default_type ();
|
2006-08-11 03:15:30 -04:00
|
|
|
|
2009-06-09 16:21:19 -04:00
|
|
|
try {
|
|
|
|
_io->add_port ("", this);
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (AudioEngine::PortRegistrationFailure& err) {
|
|
|
|
MessageDialog msg (_("There are no more JACK ports available."));
|
|
|
|
msg.run ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-01-30 10:08:09 -05:00
|
|
|
IOSelector::remove_channel (ARDOUR::BundleChannel bc)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2009-01-30 10:08:09 -05:00
|
|
|
Port* f = _session.engine().get_port_by_name (bc.bundle->channel_ports(bc.channel)[0]);
|
2009-01-20 09:46:00 -05:00
|
|
|
if (!f) {
|
|
|
|
return;
|
|
|
|
}
|
2006-11-19 11:45:16 -05:00
|
|
|
|
2009-06-09 16:21:19 -04:00
|
|
|
_io->remove_port (f, this);
|
2007-10-10 14:37:13 -04:00
|
|
|
}
|
2005-10-31 19:56:09 -05:00
|
|
|
|
2009-02-08 22:18:10 -05:00
|
|
|
bool
|
|
|
|
IOSelector::list_is_global (int dim) const
|
|
|
|
{
|
|
|
|
return (dim == _other);
|
|
|
|
}
|
|
|
|
|
2009-06-09 16:21:19 -04:00
|
|
|
IOSelectorWindow::IOSelectorWindow (ARDOUR::Session& session, boost::shared_ptr<ARDOUR::IO> io, bool can_cancel)
|
2009-07-17 18:54:45 -04:00
|
|
|
: _selector (session, io)
|
2007-10-10 14:37:13 -04:00
|
|
|
{
|
|
|
|
set_name ("IOSelectorWindow2");
|
2009-07-17 18:54:45 -04:00
|
|
|
set_title (_("I/O selector"));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
add (_selector);
|
2006-11-19 11:45:16 -05:00
|
|
|
|
2007-10-10 14:37:13 -04:00
|
|
|
set_position (Gtk::WIN_POS_MOUSE);
|
2006-11-19 11:45:16 -05:00
|
|
|
|
2008-09-30 10:18:15 -04:00
|
|
|
io_name_changed (this);
|
2008-10-01 05:18:30 -04:00
|
|
|
|
2007-10-10 14:37:13 -04:00
|
|
|
show_all ();
|
2006-11-19 11:45:16 -05:00
|
|
|
|
2008-09-30 10:18:15 -04:00
|
|
|
signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), this));
|
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
resize (32768, 32768);
|
2007-10-10 14:37:13 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-10-10 14:37:13 -04:00
|
|
|
void
|
|
|
|
IOSelectorWindow::on_map ()
|
|
|
|
{
|
2009-02-08 22:18:10 -05:00
|
|
|
_selector.setup_all_ports ();
|
2007-10-10 14:37:13 -04:00
|
|
|
Window::on_map ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2008-09-30 10:18:15 -04:00
|
|
|
void
|
|
|
|
IOSelectorWindow::io_name_changed (void* src)
|
|
|
|
{
|
|
|
|
ENSURE_GUI_THREAD(bind (mem_fun(*this, &IOSelectorWindow::io_name_changed), src));
|
|
|
|
|
|
|
|
string title;
|
|
|
|
|
2009-01-30 10:08:09 -05:00
|
|
|
if (!_selector.find_inputs_for_io_outputs()) {
|
2008-09-30 10:18:15 -04:00
|
|
|
title = string_compose(_("%1 input"), _selector.io()->name());
|
|
|
|
} else {
|
|
|
|
title = string_compose(_("%1 output"), _selector.io()->name());
|
|
|
|
}
|
|
|
|
|
|
|
|
set_title (title);
|
|
|
|
}
|
2007-10-10 14:37:13 -04:00
|
|
|
|
2009-07-17 18:54:45 -04:00
|
|
|
void
|
|
|
|
IOSelectorWindow::on_realize ()
|
|
|
|
{
|
|
|
|
Window::on_realize ();
|
|
|
|
|
|
|
|
pair<uint32_t, uint32_t> const m = _selector.max_size ();
|
|
|
|
|
|
|
|
GdkGeometry g;
|
|
|
|
g.max_width = m.first;
|
|
|
|
g.max_height = m.second;
|
|
|
|
|
|
|
|
set_geometry_hints (*this, g, Gdk::HINT_MAX_SIZE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-10 14:37:13 -04:00
|
|
|
PortInsertUI::PortInsertUI (ARDOUR::Session& sess, boost::shared_ptr<ARDOUR::PortInsert> pi)
|
2009-06-09 16:21:19 -04:00
|
|
|
: input_selector (sess, pi->input())
|
|
|
|
, output_selector (sess, pi->output())
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2009-02-09 21:09:46 -05:00
|
|
|
output_selector.set_min_height_divisor (2);
|
|
|
|
input_selector.set_min_height_divisor (2);
|
|
|
|
|
2009-01-20 09:46:00 -05:00
|
|
|
pack_start (output_selector, true, true);
|
|
|
|
pack_start (input_selector, true, true);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-10-10 14:37:13 -04:00
|
|
|
PortInsertUI::redisplay ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2009-02-08 22:18:10 -05:00
|
|
|
input_selector.setup_ports (input_selector.other());
|
|
|
|
output_selector.setup_ports (output_selector.other());
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-10-10 14:37:13 -04:00
|
|
|
PortInsertUI::finished (IOSelector::Result r)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
input_selector.Finished (r);
|
|
|
|
output_selector.Finished (r);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-10 14:37:13 -04:00
|
|
|
PortInsertWindow::PortInsertWindow (ARDOUR::Session& sess, boost::shared_ptr<ARDOUR::PortInsert> pi, bool can_cancel)
|
2005-09-25 14:42:24 -04:00
|
|
|
: ArdourDialog ("port insert dialog"),
|
2006-07-27 21:08:57 -04:00
|
|
|
_portinsertui (sess, pi),
|
2005-09-25 14:42:24 -04:00
|
|
|
ok_button (can_cancel ? _("OK"): _("Close")),
|
2009-07-17 18:54:45 -04:00
|
|
|
cancel_button (_("Cancel"))
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
|
|
|
|
set_name ("IOSelectorWindow");
|
|
|
|
string title = _("ardour: ");
|
2006-07-27 21:08:57 -04:00
|
|
|
title += pi->name();
|
2005-09-25 14:42:24 -04:00
|
|
|
set_title (title);
|
|
|
|
|
|
|
|
ok_button.set_name ("IOSelectorButton");
|
2007-10-10 14:37:13 -04:00
|
|
|
if (!can_cancel) {
|
|
|
|
ok_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::CLOSE, Gtk::ICON_SIZE_BUTTON)));
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
cancel_button.set_name ("IOSelectorButton");
|
|
|
|
|
|
|
|
if (can_cancel) {
|
2007-10-10 14:37:13 -04:00
|
|
|
cancel_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::CANCEL, Gtk::ICON_SIZE_BUTTON)));
|
|
|
|
get_action_area()->pack_start (cancel_button, false, false);
|
|
|
|
} else {
|
2005-09-25 14:42:24 -04:00
|
|
|
cancel_button.hide();
|
|
|
|
}
|
2007-10-10 14:37:13 -04:00
|
|
|
get_action_area()->pack_start (ok_button, false, false);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-03-05 05:24:31 -05:00
|
|
|
get_vbox()->pack_start (_portinsertui);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-10-10 14:37:13 -04:00
|
|
|
ok_button.signal_clicked().connect (mem_fun (*this, &PortInsertWindow::accept));
|
|
|
|
cancel_button.signal_clicked().connect (mem_fun (*this, &PortInsertWindow::cancel));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-10-09 01:03:29 -04:00
|
|
|
signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), reinterpret_cast<Window *> (this)));
|
2007-04-12 19:20:37 -04:00
|
|
|
|
2007-10-10 14:37:13 -04:00
|
|
|
going_away_connection = pi->GoingAway.connect (mem_fun (*this, &PortInsertWindow::plugin_going_away));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-08-29 17:21:48 -04:00
|
|
|
PortInsertWindow::plugin_going_away ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2007-10-10 14:37:13 -04:00
|
|
|
ENSURE_GUI_THREAD (mem_fun (*this, &PortInsertWindow::plugin_going_away));
|
|
|
|
|
2007-04-12 19:20:37 -04:00
|
|
|
going_away_connection.disconnect ();
|
2005-09-25 14:42:24 -04:00
|
|
|
delete_when_idle (this);
|
|
|
|
}
|
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
void
|
|
|
|
PortInsertWindow::on_map ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
_portinsertui.redisplay ();
|
2005-10-31 19:56:09 -05:00
|
|
|
Window::on_map ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
PortInsertWindow::cancel ()
|
|
|
|
{
|
2007-10-10 14:37:13 -04:00
|
|
|
_portinsertui.finished (IOSelector::Cancelled);
|
2005-09-25 14:42:24 -04:00
|
|
|
hide ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PortInsertWindow::accept ()
|
|
|
|
{
|
2007-10-10 14:37:13 -04:00
|
|
|
_portinsertui.finished (IOSelector::Accepted);
|
2005-09-25 14:42:24 -04:00
|
|
|
hide ();
|
|
|
|
}
|
2009-02-08 22:18:10 -05:00
|
|
|
|