summaryrefslogtreecommitdiff
path: root/gtk2_ardour/engine_dialog.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2014-07-04 15:50:34 +0200
committerRobin Gareus <robin@gareus.org>2014-07-04 15:52:14 +0200
commit63d81d2419e08b357af2e9d94d077eb1556a72a6 (patch)
treec36e1cd6bd25c93e1c8355ffd6237d22c7f87491 /gtk2_ardour/engine_dialog.cc
parenta86c98df7a42df4e927936148e4708d83ccaed32 (diff)
purge states of Audio-backends that are N/A
fixes crashes/assert() when using different builds while sharing ardour.rc with n/a engine backends marked active.
Diffstat (limited to 'gtk2_ardour/engine_dialog.cc')
-rw-r--r--gtk2_ardour/engine_dialog.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/gtk2_ardour/engine_dialog.cc b/gtk2_ardour/engine_dialog.cc
index 27cf9b7719..437aea7d39 100644
--- a/gtk2_ardour/engine_dialog.cc
+++ b/gtk2_ardour/engine_dialog.cc
@@ -1337,6 +1337,21 @@ EngineControl::set_state (const XMLNode& root)
/* now see if there was an active state and switch the setup to it */
+ // purge states of backend that are not available in this built
+ vector<const ARDOUR::AudioBackendInfo*> backends = ARDOUR::AudioEngine::instance()->available_backends();
+ vector<std::string> backend_names;
+
+ for (vector<const ARDOUR::AudioBackendInfo*>::const_iterator i = backends.begin(); i != backends.end(); ++i) {
+ backend_names.push_back((*i)->name);
+ }
+ for (StateList::iterator i = states.begin(); i != states.end();) {
+ if (std::find(backend_names.begin(), backend_names.end(), (*i)->backend) == backend_names.end()) {
+ i = states.erase(i);
+ } else {
+ ++i;
+ }
+ }
+
for (StateList::const_iterator i = states.begin(); i != states.end(); ++i) {
if ((*i)->active) {