Add API to check if backend was used previously

This is backported from LiveTrax, yet potentially handy
for future auto-connect policy in Ardour as well.
This commit is contained in:
Robin Gareus
2024-08-12 21:23:39 +02:00
parent 84506a041c
commit 58120f75d5
2 changed files with 25 additions and 0 deletions

View File

@@ -261,6 +261,7 @@ public:
bool cannot_save () const { return _state_of_the_state & CannotSave; }
bool in_cleanup () const { return _state_of_the_state & InCleanup; }
bool inital_connect_or_deletion_in_progress () const { return _state_of_the_state & (InitialConnecting | Deletion); }
bool have_external_connections_for_current_backend (bool tracks_only = true) const;
bool unnamed() const;
void end_unnamed_status () const;

View File

@@ -8158,3 +8158,27 @@ Session::foreach_route (void (Route::*method)())
}
}
bool
Session::have_external_connections_for_current_backend (bool tracks_only) const
{
std::shared_ptr<RouteList const> rl = routes.reader();
for (auto const& r : *rl) {
if (tracks_only && !std::dynamic_pointer_cast<Track> (r)) {
continue;
}
if (r->is_singleton ()) {
continue;
}
for (auto const& p : *r->input()->ports()) {
if (p->has_ext_connection ()) {
return true;
}
}
for (auto const& p : *r->output()->ports()) {
if (p->has_ext_connection ()) {
return true;
}
}
}
return false;
}