13
0

move all bundle-related session methods into their own file

This commit is contained in:
Paul Davis 2019-09-22 11:50:44 -06:00
parent 86b23c0f19
commit 0b033a320d

View File

@ -1000,145 +1000,6 @@ Session::get_physical_ports (vector<string>& inputs, vector<string>& outputs, Da
_engine.get_physical_outputs (type, outputs, include, exclude);
}
void
Session::setup_bundles ()
{
{
RCUWriter<BundleList> writer (_bundles);
boost::shared_ptr<BundleList> b = writer.get_copy ();
for (BundleList::iterator i = b->begin(); i != b->end();) {
if (boost::dynamic_pointer_cast<UserBundle>(*i)) {
++i;
continue;
}
i = b->erase(i);
}
}
vector<string> inputs[DataType::num_types];
vector<string> outputs[DataType::num_types];
for (uint32_t i = 0; i < DataType::num_types; ++i) {
get_physical_ports (inputs[i], outputs[i], DataType (DataType::Symbol (i)),
MidiPortFlags (0), /* no specific inclusions */
MidiPortFlags (MidiPortControl|MidiPortVirtual) /* exclude control & virtual ports */
);
}
/* 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
and stereo tracks get bundles to put in their mixer strip
in / out menus. There may be a nicer way of achieving that;
it doesn't really scale that well to higher channel counts
*/
/* mono output bundles */
for (uint32_t np = 0; np < outputs[DataType::AUDIO].size(); ++np) {
char buf[64];
std::string pn = _engine.get_pretty_name_by_name (outputs[DataType::AUDIO][np]);
if (!pn.empty()) {
snprintf (buf, sizeof (buf), _("out %s"), pn.c_str());
} else {
snprintf (buf, sizeof (buf), _("out %" PRIu32), np+1);
}
boost::shared_ptr<Bundle> c (new Bundle (buf, true));
c->add_channel (_("mono"), DataType::AUDIO);
c->set_port (0, outputs[DataType::AUDIO][np]);
add_bundle (c, false);
}
/* stereo output bundles */
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);
boost::shared_ptr<Bundle> c (new Bundle (buf, true));
c->add_channel (_("L"), DataType::AUDIO);
c->set_port (0, outputs[DataType::AUDIO][np]);
c->add_channel (_("R"), DataType::AUDIO);
c->set_port (1, outputs[DataType::AUDIO][np + 1]);
add_bundle (c, false);
}
}
/* mono input bundles */
for (uint32_t np = 0; np < inputs[DataType::AUDIO].size(); ++np) {
char buf[64];
std::string pn = _engine.get_pretty_name_by_name (inputs[DataType::AUDIO][np]);
if (!pn.empty()) {
snprintf (buf, sizeof (buf), _("in %s"), pn.c_str());
} else {
snprintf (buf, sizeof (buf), _("in %" PRIu32), np+1);
}
boost::shared_ptr<Bundle> c (new Bundle (buf, false));
c->add_channel (_("mono"), DataType::AUDIO);
c->set_port (0, inputs[DataType::AUDIO][np]);
add_bundle (c, false);
}
/* stereo input bundles */
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);
boost::shared_ptr<Bundle> c (new Bundle (buf, false));
c->add_channel (_("L"), DataType::AUDIO);
c->set_port (0, inputs[DataType::AUDIO][np]);
c->add_channel (_("R"), DataType::AUDIO);
c->set_port (1, inputs[DataType::AUDIO][np + 1]);
add_bundle (c, false);
}
}
/* MIDI input bundles */
for (uint32_t np = 0; np < inputs[DataType::MIDI].size(); ++np) {
string n = inputs[DataType::MIDI][np];
std::string pn = _engine.get_pretty_name_by_name (n);
if (!pn.empty()) {
n = pn;
} else {
boost::erase_first (n, X_("alsa_pcm:"));
}
boost::shared_ptr<Bundle> c (new Bundle (n, false));
c->add_channel ("", DataType::MIDI);
c->set_port (0, inputs[DataType::MIDI][np]);
add_bundle (c, false);
}
/* MIDI output bundles */
for (uint32_t np = 0; np < outputs[DataType::MIDI].size(); ++np) {
string n = outputs[DataType::MIDI][np];
std::string pn = _engine.get_pretty_name_by_name (n);
if (!pn.empty()) {
n = pn;
} else {
boost::erase_first (n, X_("alsa_pcm:"));
}
boost::shared_ptr<Bundle> c (new Bundle (n, true));
c->add_channel ("", DataType::MIDI);
c->set_port (0, outputs[DataType::MIDI][np]);
add_bundle (c, false);
}
// we trust the backend to only calls us if there's a change
BundleAddedOrRemoved (); /* EMIT SIGNAL */
}
void
Session::auto_connect_master_bus ()
@ -5816,59 +5677,6 @@ Session::available_capture_duration ()
return (samplecnt_t) floor (_total_free_4k_blocks * scale);
}
void
Session::add_bundle (boost::shared_ptr<Bundle> bundle, bool emit_signal)
{
{
RCUWriter<BundleList> writer (_bundles);
boost::shared_ptr<BundleList> b = writer.get_copy ();
b->push_back (bundle);
}
if (emit_signal) {
BundleAddedOrRemoved (); /* EMIT SIGNAL */
}
set_dirty();
}
void
Session::remove_bundle (boost::shared_ptr<Bundle> bundle)
{
bool removed = false;
{
RCUWriter<BundleList> writer (_bundles);
boost::shared_ptr<BundleList> b = writer.get_copy ();
BundleList::iterator i = find (b->begin(), b->end(), bundle);
if (i != b->end()) {
b->erase (i);
removed = true;
}
}
if (removed) {
BundleAddedOrRemoved (); /* EMIT SIGNAL */
}
set_dirty();
}
boost::shared_ptr<Bundle>
Session::bundle_by_name (string name) const
{
boost::shared_ptr<BundleList> b = _bundles.reader ();
for (BundleList::const_iterator i = b->begin(); i != b->end(); ++i) {
if ((*i)->name() == name) {
return* i;
}
}
return boost::shared_ptr<Bundle> ();
}
void
Session::tempo_map_changed (const PropertyChange&)
{