13
0

Use pretty names of ports not just for mono bundles, but also stereo.

Session::setup_bundles() creates mono and stereo bundles from hardware
inputs and outputs. For mono bundles the name of the bundle was based on
the pretty name of the port (if the port has a pretty name), however
stereo bundles always used the indices of ports to make the name.
When using pipewire (or otherwise having multiple jack clients exposing
physical ports) the indices are even less meaningful than otherwise (as
different devices could appear in arbitrary order), so also using pretty
names for stereo bundles makes the UI less confusing in places where
these bundle names are used (for example the menu when clicking on an
IOButton).
This commit is contained in:
Marijn Kruisselbrink 2022-12-28 14:30:54 -08:00 committed by Robin Gareus
parent 345008bdfd
commit ef253d3fc9
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -165,8 +165,14 @@ Session::setup_bundles ()
for (uint32_t np = 0; np < outputs[DataType::AUDIO].size(); np += 2) { for (uint32_t np = 0; np < outputs[DataType::AUDIO].size(); np += 2) {
if (np + 1 < outputs[DataType::AUDIO].size()) { if (np + 1 < outputs[DataType::AUDIO].size()) {
char buf[32]; char buf[64];
std::string pn1 = _engine.get_pretty_name_by_name (outputs[DataType::AUDIO][np]);
std::string pn2 = _engine.get_pretty_name_by_name (outputs[DataType::AUDIO][np+1]);
if (!pn1.empty() && !pn2.empty()) {
snprintf (buf, sizeof(buf), _("out %s+%s"), pn1.c_str(), pn2.c_str());
} else {
snprintf (buf, sizeof(buf), _("out %" PRIu32 "+%" PRIu32), np + 1, np + 2); snprintf (buf, sizeof(buf), _("out %" PRIu32 "+%" PRIu32), np + 1, np + 2);
}
boost::shared_ptr<Bundle> c (new Bundle (buf, true)); boost::shared_ptr<Bundle> c (new Bundle (buf, true));
c->add_channel (_("L"), DataType::AUDIO); c->add_channel (_("L"), DataType::AUDIO);
c->set_port (0, outputs[DataType::AUDIO][np]); c->set_port (0, outputs[DataType::AUDIO][np]);
@ -199,8 +205,14 @@ Session::setup_bundles ()
for (uint32_t np = 0; np < inputs[DataType::AUDIO].size(); np += 2) { for (uint32_t np = 0; np < inputs[DataType::AUDIO].size(); np += 2) {
if (np + 1 < inputs[DataType::AUDIO].size()) { if (np + 1 < inputs[DataType::AUDIO].size()) {
char buf[32]; char buf[64];
std::string pn1 = _engine.get_pretty_name_by_name (inputs[DataType::AUDIO][np]);
std::string pn2 = _engine.get_pretty_name_by_name (inputs[DataType::AUDIO][np+1]);
if (!pn1.empty() && !pn2.empty()) {
snprintf (buf, sizeof(buf), _("in %s+%s"), pn1.c_str(), pn2.c_str());
} else {
snprintf (buf, sizeof(buf), _("in %" PRIu32 "+%" PRIu32), np + 1, np + 2); snprintf (buf, sizeof(buf), _("in %" PRIu32 "+%" PRIu32), np + 1, np + 2);
}
boost::shared_ptr<Bundle> c (new Bundle (buf, false)); boost::shared_ptr<Bundle> c (new Bundle (buf, false));
c->add_channel (_("L"), DataType::AUDIO); c->add_channel (_("L"), DataType::AUDIO);