From 13cf4da0113b05622e7a71a3ed38e011cbf91886 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 23 Sep 2017 00:18:18 +0200 Subject: [PATCH] Consolidate check for internal/non-removable processors --- libs/ardour/ardour/route.h | 2 ++ libs/ardour/route.cc | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h index bf8d05dd12..693bbd157a 100644 --- a/libs/ardour/ardour/route.h +++ b/libs/ardour/ardour/route.h @@ -703,6 +703,8 @@ public: boost::shared_ptr _meter; boost::shared_ptr _delayline; + bool is_internal_processor (boost::shared_ptr) const; + boost::shared_ptr the_instrument_unlocked() const; SlavableControlList slavables () const; diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 00b484ca6c..cc2a9e4aec 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -1251,7 +1251,7 @@ Route::clear_processors (Placement p) seen_amp = true; } - if ((*i) == _amp || (*i) == _meter || (*i) == _main_outs || (*i) == _delayline || (*i) == _trim) { + if (is_internal_processor (*i)) { /* you can't remove these */ @@ -1301,6 +1301,15 @@ Route::clear_processors (Placement p) } } +bool +Route::is_internal_processor (boost::shared_ptr p) const +{ + if (p == _amp || p == _meter || p == _main_outs || p == _delayline || p == _trim) { + return true; + } + return false; +} + int Route::remove_processor (boost::shared_ptr processor, ProcessorStreams* err, bool need_process_lock) { @@ -1320,7 +1329,7 @@ Route::remove_processor (boost::shared_ptr processor, ProcessorStream /* these can never be removed */ - if (processor == _amp || processor == _meter || processor == _main_outs || processor == _delayline || processor == _trim) { + if (is_internal_processor (processor)) { return 0; } @@ -1422,11 +1431,11 @@ int Route::replace_processor (boost::shared_ptr old, boost::shared_ptr sub, ProcessorStreams* err) { /* these can never be removed */ - if (old == _amp || old == _meter || old == _main_outs || old == _delayline || old == _trim) { + if (is_internal_processor (old)) { return 1; } /* and can't be used as substitute, either */ - if (sub == _amp || sub == _meter || sub == _main_outs || sub == _delayline || sub == _trim) { + if (is_internal_processor (sub)) { return 1; } @@ -1541,7 +1550,7 @@ Route::remove_processors (const ProcessorList& to_be_deleted, ProcessorStreams* /* these can never be removed */ - if (processor == _amp || processor == _meter || processor == _main_outs || processor == _delayline || processor == _trim) { + if (is_internal_processor (processor)) { ++i; continue; } -- 2.30.2