API to count max multi-channel plugin outputs
authorRobin Gareus <robin@gareus.org>
Tue, 15 Oct 2019 12:47:11 +0000 (14:47 +0200)
committerRobin Gareus <robin@gareus.org>
Tue, 15 Oct 2019 12:48:32 +0000 (14:48 +0200)
libs/ardour/ardour/audio_unit.h
libs/ardour/ardour/luaproc.h
libs/ardour/ardour/plugin.h
libs/ardour/audio_unit.cc
libs/ardour/luaproc.cc
libs/ardour/plugin_manager.cc

index 1ed1703c548f529d3e4ec3758d6b121dacf35e1d..feae338e8691da4a636607bf698910ec1e6f5699 100644 (file)
@@ -245,7 +245,7 @@ struct LIBARDOUR_API AUPluginCachedInfo {
 class LIBARDOUR_API AUPluginInfo : public PluginInfo {
   public:
         AUPluginInfo (boost::shared_ptr<CAComponentDescription>);
-       ~AUPluginInfo ();
+       ~AUPluginInfo () {}
 
        PluginPtr load (Session& session);
 
@@ -263,6 +263,7 @@ class LIBARDOUR_API AUPluginInfo : public PluginInfo {
        AUPluginCachedInfo cache;
 
        bool reconfigurable_io() const { return true; }
+       uint32_t max_configurable_ouputs () const { return max_outputs; }
 
        static void clear_cache ();
        static PluginInfoList* discover (bool scan_only);
@@ -274,6 +275,7 @@ class LIBARDOUR_API AUPluginInfo : public PluginInfo {
   private:
        boost::shared_ptr<CAComponentDescription> descriptor;
        UInt32 version;
+       uint32_t max_outputs;
        static FILE * _crashlog_fd;
        static bool _scan_only;
 
index 7d348e6e6c203dec5b3315c6da19b14ddebeaed7..dcb5ec13cc41dd017df16b2ee983159be4320ec5 100644 (file)
@@ -211,6 +211,12 @@ class LIBARDOUR_API LuaPluginInfo : public PluginInfo
        std::vector<Plugin::PresetRecord> get_presets (bool user_only) const;
 
        bool reconfigurable_io() const { return true; }
+       uint32_t max_configurable_ouputs () const {
+               return _max_outputs;
+       }
+
+       private:
+       uint32_t _max_outputs;
 };
 
 typedef boost::shared_ptr<LuaPluginInfo> LuaPluginInfoPtr;
index ad03806977c28eaae0c87ba7809a3cec0ca680ab..287f18ad6805d6d1507293f4e2428fac09ab7a6a 100644 (file)
@@ -496,6 +496,12 @@ public:
        /* @return true if the plugin can change its inputs or outputs on demand. */
        virtual bool reconfigurable_io () const { return false; }
 
+       /* max [re]configurable outputs (if finite, 0 otherwise) */
+       virtual uint32_t max_configurable_ouputs () const
+       {
+               return n_outputs.n_audio();
+       }
+
 protected:
        friend class PluginManager;
        uint32_t index; //< used for LADSPA, index in module
index cf268a04033c80291f4c0d66495f5757d87573a0..bf9ea888ab9ef975c9d6148007505d6c03fd100a 100644 (file)
@@ -2549,11 +2549,7 @@ AUPlugin::has_editor () const
 AUPluginInfo::AUPluginInfo (boost::shared_ptr<CAComponentDescription> d)
        : descriptor (d)
        , version (0)
-{
-       type = ARDOUR::AudioUnit;
-}
-
-AUPluginInfo::~AUPluginInfo ()
+       , max_outputs (0)
 {
        type = ARDOUR::AudioUnit;
 }
@@ -2922,6 +2918,8 @@ AUPluginInfo::discover_by_description (PluginInfoList& plugs, CAComponentDescrip
 
                const int rv = cached_io_configuration (info->unique_id, info->version, cacomp, info->cache, info->name);
 
+               info.max_outputs = 0;
+
                if (rv == 0) {
                        /* here we have to map apple's wildcard system to a simple pair
                           of values. in ::can_do() we use the whole system, but here
@@ -2936,8 +2934,18 @@ AUPluginInfo::discover_by_description (PluginInfoList& plugs, CAComponentDescrip
                           info to the user, which should perhaps be revisited.
                        */
 
-                       int32_t possible_in = info->cache.io_configs.front().first;
-                       int32_t possible_out = info->cache.io_configs.front().second;
+                       const vector<pair<int,int> >& ioc (info->cache.io_configs);
+                       for (vector<pair<int,int> >::const_iterator i = ioc.begin(); i != ioc.end(); ++i) {
+                               int32_t possible_out = i->second;
+                               if (possible_out < 0) {
+                                       continue;
+                               } else if (possible_out > info.max_outputs) {
+                                       info.max_outputs = possible_out;
+                               }
+                       }
+
+                       int32_t possible_in = ioc.front().first;
+                       int32_t possible_out = ioc.font().second;
 
                        if (possible_in > 0) {
                                info->n_inputs.set (DataType::AUDIO, possible_in);
index 64c7ca6c7cf5cb5b7352957bb0ace4506c3f78a1..a4fde501864b8d96231cad9fe41e1f2b3f57e2be 100644 (file)
@@ -1232,6 +1232,8 @@ LuaPluginInfo::LuaPluginInfo (LuaScriptInfoPtr lsi) {
        n_outputs.set (DataType::AUDIO, 1);
        type = Lua;
 
+       // TODO, parse script, get 'dsp_ioconfig', see can_support_io_configuration()
+       _max_outputs = 0;
 }
 
 PluginPtr
index f2c4b0322c90cabbdf130eec68a74c9e2ae24f30..9d21b6bb652dcdb788921fce59ffe1d23cfe8cec 100644 (file)
@@ -286,7 +286,7 @@ PluginManager::detect_name_ambiguities (PluginInfoList* pil)
                                * by listing number of audio outputs.
                                * This is used in the instrument selector.
                                */
-                        bool r = p->n_outputs.n_audio() != (*i)->n_outputs.n_audio();
+                        bool r = p->max_configurable_ouputs () != (*i)->max_configurable_ouputs ();
                         p->multichannel_name_ambiguity = r;
                         (*i)->multichannel_name_ambiguity = r;
                 }