summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2010-07-28 01:40:36 +0000
committerCarl Hetherington <carl@carlh.net>2010-07-28 01:40:36 +0000
commitc2cf3c5bfd652db87b92b241676981a44daf3091 (patch)
treef30a6e6a34ecb53f73da09f909de26739565f558 /libs
parent922488427a09fdfd4f4685bb114bdc992680a39f (diff)
Trim get_nth_physical port methods.
git-svn-id: svn://localhost/ardour2/branches/3.0@7518 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/audioengine.h9
-rw-r--r--libs/ardour/audioengine.cc30
-rw-r--r--libs/ardour/auditioner.cc21
-rw-r--r--libs/ardour/session.cc88
4 files changed, 66 insertions, 82 deletions
diff --git a/libs/ardour/ardour/audioengine.h b/libs/ardour/ardour/audioengine.h
index 78d0a03e6a..fcbe6d3514 100644
--- a/libs/ardour/ardour/audioengine.h
+++ b/libs/ardour/ardour/audioengine.h
@@ -169,14 +169,6 @@ class AudioEngine : public SessionHandlePtr
void get_physical_outputs (DataType type, std::vector<std::string>&);
void get_physical_inputs (DataType type, std::vector<std::string>&);
- std::string get_nth_physical_output (DataType type, uint32_t n) {
- return get_nth_physical (type, n, JackPortIsInput);
- }
-
- std::string get_nth_physical_input (DataType type, uint32_t n) {
- return get_nth_physical (type, n, JackPortIsOutput);
- }
-
void update_total_latencies ();
void update_total_latency (const Port&);
@@ -282,7 +274,6 @@ _ the regular process() call to session->process() is not made.
void finish_process_cycle (int status);
void remove_all_ports ();
- std::string get_nth_physical (DataType type, uint32_t n, int flags);
ChanCount n_physical (unsigned long) const;
void get_physical (DataType, unsigned long, std::vector<std::string> &);
diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc
index 39c8d71534..c40180e91d 100644
--- a/libs/ardour/audioengine.cc
+++ b/libs/ardour/audioengine.cc
@@ -1178,36 +1178,6 @@ AudioEngine::get_physical_outputs (DataType type, vector<string>& outs)
get_physical (type, JackPortIsOutput, outs);
}
-string
-AudioEngine::get_nth_physical (DataType type, uint32_t n, int flag)
-{
- GET_PRIVATE_JACK_POINTER_RET (_jack,"");
- const char ** ports;
- uint32_t i;
- uint32_t idx;
- string ret;
-
- assert(type != DataType::NIL);
-
- if ((ports = jack_get_ports (_priv_jack, NULL, type.to_jack_type(), JackPortIsPhysical|flag)) == 0) {
- return ret;
- }
-
- for (i = 0, idx = 0; idx < n && ports[i]; ++i) {
- if (!strstr (ports[i], "Midi-Through")) {
- ++idx;
- }
- }
-
- if (ports[idx]) {
- ret = ports[idx];
- }
-
- free ((const char **) ports);
-
- return ret;
-}
-
void
AudioEngine::update_total_latency (const Port& port)
{
diff --git a/libs/ardour/auditioner.cc b/libs/ardour/auditioner.cc
index 45a836582d..868c8d4334 100644
--- a/libs/ardour/auditioner.cc
+++ b/libs/ardour/auditioner.cc
@@ -59,12 +59,17 @@ Auditioner::init ()
string left = _session.config.get_auditioner_output_left();
string right = _session.config.get_auditioner_output_right();
+ vector<string> outputs;
+ _session.engine().get_physical_outputs (DataType::AUDIO, outputs);
+
if (left == "default") {
if (_session.monitor_out()) {
left = _session.monitor_out()->input()->audio (0)->name();
via_monitor = true;
} else {
- left = _session.engine().get_nth_physical_output (DataType::AUDIO, 0);
+ if (outputs.size() > 0) {
+ left = outputs[0];
+ }
}
}
@@ -73,7 +78,9 @@ Auditioner::init ()
right = _session.monitor_out()->input()->audio (1)->name();
via_monitor = true;
} else {
- right = _session.engine().get_nth_physical_output (DataType::AUDIO, 1);
+ if (outputs.size() > 1) {
+ right = outputs[1];
+ }
}
}
@@ -231,8 +238,12 @@ Auditioner::output_changed (IOChange change, void* /*src*/)
if (change & ConnectionsChanged) {
string phys;
vector<string> connections;
+ vector<string> outputs;
+ _session.engine().get_physical_outputs (DataType::AUDIO, outputs);
if (_output->nth (0)->get_connections (connections)) {
- phys = _session.engine().get_nth_physical_output (DataType::AUDIO, 0);
+ if (outputs.size() > 0) {
+ phys = outputs[0];
+ }
if (phys != connections[0]) {
_session.config.set_auditioner_output_left (connections[0]);
} else {
@@ -245,7 +256,9 @@ Auditioner::output_changed (IOChange change, void* /*src*/)
connections.clear ();
if (_output->nth (1)->get_connections (connections)) {
- phys = _session.engine().get_nth_physical_output (DataType::AUDIO, 1);
+ if (outputs.size() > 1) {
+ phys = outputs[1];
+ }
if (phys != connections[0]) {
_session.config.set_auditioner_output_right (connections[0]);
} else {
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index 5485924f4a..9c1518e42c 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -397,22 +397,23 @@ Session::when_engine_running ()
/* default state for Click: dual-mono to first 2 physical outputs */
- for (int physport = 0; physport < 2; ++physport) {
- string physical_output = _engine.get_nth_physical_output (DataType::AUDIO, physport);
+ vector<string> outs;
+ _engine.get_physical_outputs (DataType::AUDIO, outs);
- if (physical_output.length()) {
- if (_click_io->add_port (physical_output, this)) {
- // relax, even though its an error
- }
- }
- }
-
- if (_click_io->n_ports () > ChanCount::ZERO) {
- _clicking = Config->get_clicking ();
- }
+ for (uint32_t physport = 0; physport < 2; ++physport) {
+ if (outs.size() > physport) {
+ if (_click_io->add_port (outs[physport], this)) {
+ // relax, even though its an error
+ }
+ }
+ }
+
+ if (_click_io->n_ports () > ChanCount::ZERO) {
+ _clicking = Config->get_clicking ();
+ }
}
}
-
+
catch (failed_constructor& err) {
error << _("cannot setup Click I/O") << endmsg;
}
@@ -427,6 +428,13 @@ Session::when_engine_running ()
BootMessage (_("Set up standard connections"));
+ vector<string> inputs[DataType::num_types];
+ vector<string> outputs[DataType::num_types];
+ for (uint32_t i = 0; i < DataType::num_types; ++i) {
+ _engine.get_physical_inputs (DataType (DataType::Symbol (i)), inputs[i]);
+ _engine.get_physical_outputs (DataType (DataType::Symbol (i)), outputs[i]);
+ }
+
/* Create a set of Bundle objects that map
to the physical I/O currently available. We create both
mono and stereo bundles, so that the common cases of mono
@@ -437,28 +445,28 @@ Session::when_engine_running ()
/* mono output bundles */
- for (uint32_t np = 0; np < n_physical_outputs.n_audio(); ++np) {
+ for (uint32_t np = 0; np < outputs[DataType::AUDIO].size(); ++np) {
char buf[32];
snprintf (buf, sizeof (buf), _("out %" PRIu32), np+1);
shared_ptr<Bundle> c (new Bundle (buf, true));
c->add_channel (_("mono"), DataType::AUDIO);
- c->set_port (0, _engine.get_nth_physical_output (DataType::AUDIO, np));
+ c->set_port (0, outputs[DataType::AUDIO][np]);
add_bundle (c);
}
/* stereo output bundles */
- for (uint32_t np = 0; np < n_physical_outputs.n_audio(); np += 2) {
- if (np + 1 < n_physical_outputs.n_audio ()) {
+ for (uint32_t np = 0; np < outputs[DataType::AUDIO].size(); np += 2) {
+ if (np + 1 < outputs[DataType::AUDIO].size()) {
char buf[32];
snprintf (buf, sizeof(buf), _("out %" PRIu32 "+%" PRIu32), np + 1, np + 2);
shared_ptr<Bundle> c (new Bundle (buf, true));
c->add_channel (_("L"), DataType::AUDIO);
- c->set_port (0, _engine.get_nth_physical_output (DataType::AUDIO, np));
+ c->set_port (0, outputs[DataType::AUDIO][np]);
c->add_channel (_("R"), DataType::AUDIO);
- c->set_port (1, _engine.get_nth_physical_output (DataType::AUDIO, np + 1));
+ c->set_port (1, outputs[DataType::AUDIO][np + 1]);
add_bundle (c);
}
@@ -466,29 +474,29 @@ Session::when_engine_running ()
/* mono input bundles */
- for (uint32_t np = 0; np < n_physical_inputs.n_audio(); ++np) {
+ for (uint32_t np = 0; np < inputs[DataType::AUDIO].size(); ++np) {
char buf[32];
snprintf (buf, sizeof (buf), _("in %" PRIu32), np+1);
shared_ptr<Bundle> c (new Bundle (buf, false));
c->add_channel (_("mono"), DataType::AUDIO);
- c->set_port (0, _engine.get_nth_physical_input (DataType::AUDIO, np));
+ c->set_port (0, inputs[DataType::AUDIO][np]);
add_bundle (c);
}
/* stereo input bundles */
- for (uint32_t np = 0; np < n_physical_inputs.n_audio(); np += 2) {
- if (np + 1 < n_physical_inputs.n_audio()) {
+ for (uint32_t np = 0; np < inputs[DataType::AUDIO].size(); np += 2) {
+ if (np + 1 < inputs[DataType::AUDIO].size()) {
char buf[32];
snprintf (buf, sizeof(buf), _("in %" PRIu32 "+%" PRIu32), np + 1, np + 2);
shared_ptr<Bundle> c (new Bundle (buf, false));
c->add_channel (_("L"), DataType::AUDIO);
- c->set_port (0, _engine.get_nth_physical_input (DataType::AUDIO, np));
+ c->set_port (0, inputs[DataType::AUDIO][np]);
c->add_channel (_("R"), DataType::AUDIO);
- c->set_port (1, _engine.get_nth_physical_input (DataType::AUDIO, np + 1));
+ c->set_port (1, inputs[DataType::AUDIO][np + 1]);
add_bundle (c);
}
@@ -496,29 +504,25 @@ Session::when_engine_running ()
/* MIDI input bundles */
- for (uint32_t np = 0; np < n_physical_inputs.n_midi(); ++np) {
- string const p = _engine.get_nth_physical_input (DataType::MIDI, np);
-
- string n = p;
+ for (uint32_t np = 0; np < inputs[DataType::MIDI].size(); ++np) {
+ string n = inputs[DataType::MIDI][np];
boost::erase_first (n, X_("alsa_pcm:"));
- shared_ptr<Bundle> c (new Bundle (n, false));
+ shared_ptr<Bundle> c (new Bundle (n, true));
c->add_channel ("", DataType::MIDI);
- c->set_port (0, p);
+ c->set_port (0, inputs[DataType::MIDI][np]);
add_bundle (c);
}
/* MIDI output bundles */
- for (uint32_t np = 0; np < n_physical_outputs.n_midi(); ++np) {
- string const p = _engine.get_nth_physical_output (DataType::MIDI, np);
-
- string n = p;
+ for (uint32_t np = 0; np < outputs[DataType::MIDI].size(); ++np) {
+ string n = outputs[DataType::MIDI][np];
boost::erase_first (n, X_("alsa_pcm:"));
- shared_ptr<Bundle> c (new Bundle (n, true));
+ shared_ptr<Bundle> c (new Bundle (n, false));
c->add_channel ("", DataType::MIDI);
- c->set_port (0, p);
+ c->set_port (0, outputs[DataType::MIDI][np]);
add_bundle (c);
}
@@ -539,7 +543,10 @@ Session::when_engine_running ()
for (uint32_t n = 0; n < limit; ++n) {
Port* p = _master_out->output()->nth (n);
- string connect_to = _engine.get_nth_physical_output (DataType (p->type()), n);
+ string connect_to;
+ if (outputs[p->type()].size() > n) {
+ connect_to = outputs[p->type()][n];
+ }
if (!connect_to.empty() && p->connected_to (connect_to) == false) {
if (_master_out->output()->connect (p, connect_to, this)) {
@@ -605,7 +612,10 @@ Session::when_engine_running ()
for (uint32_t n = 0; n < limit; ++n) {
Port* p = _monitor_out->output()->ports().port(*t, n);
- string connect_to = _engine.get_nth_physical_output (*t, (n % mod));
+ string connect_to;
+ if (outputs[*t].size() > (n % mod)) {
+ connect_to = outputs[*t][n % mod];
+ }
if (!connect_to.empty()) {
if (_monitor_out->output()->connect (p, connect_to, this)) {