Prefer const references for Pin/Channel maps
[ardour.git] / libs / ardour / plugin_insert.cc
index 23c9f8eb7ade080209ad41ec68da242375b5a150..b24d065b5bc3ad275334d3e49244bbb449d12c1a 100644 (file)
@@ -824,14 +824,14 @@ PluginInsert::inplace_silence_unconnected (BufferSet& bufs, const PinMappings& o
 void
 PluginInsert::connect_and_run (BufferSet& bufs, samplepos_t start, samplepos_t end, double speed, pframes_t nframes, samplecnt_t offset, bool with_auto)
 {
 void
 PluginInsert::connect_and_run (BufferSet& bufs, samplepos_t start, samplepos_t end, double speed, pframes_t nframes, samplecnt_t offset, bool with_auto)
 {
-       // TODO: atomically copy maps & _no_inplace
-       PinMappings in_map (_in_map);
-       PinMappings out_map (_out_map);
-       ChanMapping thru_map (_thru_map);
-       if (_mapping_changed) { // ToDo use a counters, increment until match.
+       if (_mapping_changed) { // ToDo use a counter, increment until match
                _no_inplace = check_inplace ();
                _mapping_changed = false;
        }
                _no_inplace = check_inplace ();
                _mapping_changed = false;
        }
+       // TODO: atomically copy maps & _no_inplace
+       PinMappings in_map (_in_map); // TODO Split case below overrides, use const& in_map
+       PinMappings const& out_map (_out_map);
+       ChanMapping const& thru_map (_thru_map);
 
        if (_latency_changed) {
                /* delaylines are configured with the max possible latency (as reported by the plugin)
 
        if (_latency_changed) {
                /* delaylines are configured with the max possible latency (as reported by the plugin)
@@ -1081,14 +1081,13 @@ PluginInsert::bypass (BufferSet& bufs, pframes_t nframes)
        /* bypass the plugin(s) not the whole processor.
         * -> use mappings just like connect_and_run
         */
        /* bypass the plugin(s) not the whole processor.
         * -> use mappings just like connect_and_run
         */
-
-       // TODO: atomically copy maps & _no_inplace
-       const ChanMapping in_map (no_sc_input_map ());
-       const ChanMapping out_map (output_map ());
        if (_mapping_changed) {
                _no_inplace = check_inplace ();
                _mapping_changed = false;
        }
        if (_mapping_changed) {
                _no_inplace = check_inplace ();
                _mapping_changed = false;
        }
+       // TODO: atomically copy maps & _no_inplace
+       ChanMapping const& in_map (no_sc_input_map ());
+       ChanMapping const& out_map (output_map ());
 
        bufs.set_count(ChanCount::max(bufs.count(), _configured_internal));
        bufs.set_count(ChanCount::max(bufs.count(), _configured_out));
 
        bufs.set_count(ChanCount::max(bufs.count(), _configured_internal));
        bufs.set_count(ChanCount::max(bufs.count(), _configured_out));
@@ -1198,8 +1197,8 @@ PluginInsert::silence (samplecnt_t nframes, samplepos_t start_sample)
 
        _delaybuffers.flush ();
 
 
        _delaybuffers.flush ();
 
-       ChanMapping in_map (natural_input_streams ());
-       ChanMapping out_map (natural_output_streams ());
+       const ChanMapping in_map (natural_input_streams ());
+       const ChanMapping out_map (natural_output_streams ());
        ChanCount maxbuf = ChanCount::max (natural_input_streams (), natural_output_streams());
 #ifdef MIXBUS
        if (is_channelstrip ()) {
        ChanCount maxbuf = ChanCount::max (natural_input_streams (), natural_output_streams());
 #ifdef MIXBUS
        if (is_channelstrip ()) {
@@ -1646,7 +1645,7 @@ PluginInsert::check_inplace ()
                 *
                 * but allows     in-port 1 -> sink-pin 2  ||  source-pin 2 -> out port 1
                 */
                 *
                 * but allows     in-port 1 -> sink-pin 2  ||  source-pin 2 -> out port 1
                 */
-               ChanMapping in_map (input_map ());
+               ChanMapping const& in_map (input_map ());
                const ChanMapping::Mappings out_m (output_map ().mappings ());
                for (ChanMapping::Mappings::const_iterator t = out_m.begin (); t != out_m.end () && inplace_ok; ++t) {
                        for (ChanMapping::TypeMapping::const_iterator c = (*t).second.begin (); c != (*t).second.end () ; ++c) {
                const ChanMapping::Mappings out_m (output_map ().mappings ());
                for (ChanMapping::Mappings::const_iterator t = out_m.begin (); t != out_m.end () && inplace_ok; ++t) {
                        for (ChanMapping::TypeMapping::const_iterator c = (*t).second.begin (); c != (*t).second.end () ; ++c) {