provide plugins with all available buffers.
[ardour.git] / libs / ardour / plugin_insert.cc
index 10368bfb428bf6a1b3efc3a235e22cf7c3d7a89c..6fbb5cb67908de7f318ecc46d087b034bdff5bab 100644 (file)
@@ -352,6 +352,9 @@ PluginInsert::connect_and_run (BufferSet& bufs, pframes_t nframes, framecnt_t of
                }
        }
 
+       bufs.set_count(ChanCount::max(bufs.count(), in_streams));
+       bufs.set_count(ChanCount::max(bufs.count(), out_streams));
+
        /* Note that we've already required that plugins
           be able to handle in-place processing.
        */
@@ -464,39 +467,31 @@ PluginInsert::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*end
                }
 
        } else {
-               if (has_no_audio_inputs()) {
+               uint32_t in = input_streams ().n_audio ();
+               uint32_t out = output_streams().n_audio ();
+
+               if (has_no_audio_inputs() || in == 0) {
 
                        /* silence all (audio) outputs. Should really declick
                         * at the transitions of "active"
                         */
 
-                       uint32_t out = output_streams().n_audio ();
-
                        for (uint32_t n = 0; n < out; ++n) {
                                bufs.get_audio (n).silence (nframes);
                        }
 
-                       bufs.count().set_audio (out);
-
-               } else {
-
-                       /* does this need to be done with MIDI? it appears not */
+               } else if (out > in) {
 
-                       uint32_t in = input_streams ().n_audio ();
-                       uint32_t out = output_streams().n_audio ();
+                       /* not active, but something has make up for any channel count increase */
 
-                       if (out > in) {
-
-                               /* not active, but something has make up for any channel count increase */
-                               
-                               // TODO: option round-robin (n % in) or silence additional buffers ??
-                               for (uint32_t n = in; n < out; ++n) {
-                                       bufs.get_audio(n).read_from(bufs.get_audio(in - 1), nframes);
-                               }
+                       // TODO: option round-robin (n % in) or silence additional buffers ??
+                       // for now , simply replicate last buffer
+                       for (uint32_t n = in; n < out; ++n) {
+                               bufs.get_audio(n).read_from(bufs.get_audio(in - 1), nframes);
                        }
-
-                       bufs.count().set_audio (out);
                }
+
+               bufs.count().set_audio (out);
        }
 
        _active = _pending_active;
@@ -719,6 +714,10 @@ PluginInsert::can_support_io_configuration (const ChanCount& in, ChanCount& out)
 PluginInsert::Match
 PluginInsert::private_can_support_io_configuration (ChanCount const & inx, ChanCount& out)
 {
+       if (_plugins.empty()) {
+               return Match();
+       }
+
        PluginInfoPtr info = _plugins.front()->get_info();
        ChanCount in; in += inx;
        midi_bypass.reset();
@@ -977,6 +976,22 @@ PluginInsert::set_state(const XMLNode& node, int version)
 
        boost::shared_ptr<Plugin> plugin = find_plugin (_session, prop->value(), type);
 
+       /* treat linux and windows VST plugins equivalent if they have the same uniqueID
+        * allow to move sessions windows <> linux */
+#ifdef LXVST_SUPPORT
+       if (plugin == 0 && type == ARDOUR::Windows_VST) {
+               type = ARDOUR::LXVST;
+               plugin = find_plugin (_session, prop->value(), type);
+       }
+#endif
+
+#ifdef WINDOWS_VST_SUPPORT
+       if (plugin == 0 && type == ARDOUR::LXVST) {
+               type = ARDOUR::Windows_VST;
+               plugin = find_plugin (_session, prop->value(), type);
+       }
+#endif
+
        if (plugin == 0) {
                error << string_compose(
                        _("Found a reference to a plugin (\"%1\") that is unknown.\n"