Assists music production by grouping standalone programs into sessions. Community version of "Non Session Manager".
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

209 lines
7.8KB

  1. //
  2. // LADSPAInfo.h - Header file for LADSPA Plugin info class
  3. //
  4. // Copyleft (C) 2002 Mike Rawes <myk@waxfrenzy.org>
  5. //
  6. // This program is free software; you can redistribute it and/or modify
  7. // it under the terms of the GNU General Public License as published by
  8. // the Free Software Foundation; either version 2 of the License, or
  9. // (at your option) any later version.
  10. //
  11. // This program is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. // GNU General Public License for more details.
  15. //
  16. // You should have received a copy of the GNU General Public License
  17. // along with this program; if not, write to the Free Software
  18. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. //
  20. #ifndef __ladspa_info_h__
  21. #define __ladspa_info_h__
  22. // #include <config.h>
  23. #include <string>
  24. #include <vector>
  25. #include <list>
  26. #include <map>
  27. #include <ladspa.h>
  28. class LADSPAInfo
  29. {
  30. public:
  31. // If override is false, examine $LADSPA_PATH
  32. // Also examine supplied path list
  33. // For all paths, add basic plugin information for later lookup,
  34. // instantiation and so on.
  35. LADSPAInfo(bool override = false, const char *path_list = "");
  36. // Unload all loaded plugins and clean up
  37. ~LADSPAInfo();
  38. // ************************************************************************
  39. // Loading/Unloading plugin libraries
  40. //
  41. // At first, no library dlls are loaded.
  42. //
  43. // A plugin library may have more than one plugin descriptor. The
  44. // descriptor is used to instantiate, activate, execute plugin instances.
  45. // Administration of plugin instances are outwith the scope of this class,
  46. // instead, descriptors are requested using GetDecriptorByID, and disposed
  47. // of using DiscardDescriptorByID.
  48. //
  49. // Each library keeps a reference count of descriptors requested. A library
  50. // is loaded when a descriptor is requested for the first time, and remains
  51. // loaded until the number of discards matches the number of requests.
  52. // Rescan all paths in $LADSPA_PATH, as per constructor.
  53. // This will also unload all libraries, and make any descriptors that
  54. // have not been discarded with DiscardDescriptorByID invalid.
  55. void RescanPlugins(void);
  56. // Unload all dlopened libraries. This will make any descriptors that
  57. // have not been discarded with DiscardDescriptorByID invalid.
  58. void UnloadAllLibraries(void);
  59. // Get descriptor of plugin with given ID. This increments the descriptor
  60. // count for the corresponding library.
  61. const LADSPA_Descriptor *GetDescriptorByID(unsigned long unique_id);
  62. // Notify that a descriptor corresponding to the given ID has been
  63. // discarded. This decrements the descriptor count for the corresponding
  64. // library.
  65. void DiscardDescriptorByID(unsigned long unique_id);
  66. // ************************************************************************
  67. // SSM Specific options
  68. // Get unique ID of plugin identified by given library filename and label.
  69. // This is for backwards compatibility with older versions of SSM where the
  70. // path and label of the plugin was stored in the configuration - current
  71. // versions store the Unique ID
  72. unsigned long GetIDFromFilenameAndLabel(std::string filename,
  73. std::string label);
  74. // Struct for plugin information returned by queries
  75. struct PluginEntry
  76. {
  77. unsigned int Depth;
  78. unsigned long UniqueID;
  79. std::string Name;
  80. std::string Category;
  81. bool operator<(const PluginEntry& pe)
  82. {
  83. return (Name<pe.Name);
  84. }
  85. };
  86. // For cached plugin information
  87. struct PluginInfo
  88. {
  89. unsigned long LibraryIndex; // Index of library in m_Libraries
  90. unsigned long Index; // Plugin index in library
  91. unsigned long UniqueID; // Unique ID
  92. std::string Label; // Plugin label
  93. std::string Name; // Plugin Name
  94. std::string Maker;
  95. unsigned int AudioInputs;
  96. unsigned int AudioOutputs;
  97. const LADSPA_Descriptor *Descriptor; // Descriptor, NULL
  98. };
  99. // Get ordered list of plugin names and IDs for plugin menu
  100. const std::vector<PluginEntry> GetMenuList(void);
  101. const std::vector<PluginInfo> GetPluginInfo(void);
  102. // Get the index in the above list for given Unique ID
  103. // If not found, this returns the size of the above list
  104. unsigned long GetPluginListEntryByID(unsigned long unique_id);
  105. // Get the number of input ports for the plugin with the most
  106. // input ports
  107. unsigned long GetMaxInputPortCount(void) { return m_MaxInputPortCount; }
  108. private:
  109. // See LADSPAInfo.C for comments on these functions
  110. void DescendGroup(std::string prefix,
  111. const std::string group,
  112. unsigned int depth);
  113. std::list<std::string> GetSubGroups(const std::string group);
  114. void CleanUp(void);
  115. void ScanPathList(const char *path_list,
  116. void (LADSPAInfo::*ExamineFunc)(const std::string,
  117. const std::string));
  118. void ExaminePluginLibrary(const std::string path,
  119. const std::string basename);
  120. bool CheckPlugin(const LADSPA_Descriptor *desc);
  121. LADSPA_Descriptor_Function GetDescriptorFunctionForLibrary(unsigned long library_index);
  122. #ifdef HAVE_LIBLRDF
  123. void ExamineRDFFile(const std::string path,
  124. const std::string basename);
  125. void MetadataRDFDescend(const char *uri,
  126. unsigned long parent);
  127. #endif
  128. // For cached library information
  129. struct LibraryInfo
  130. {
  131. unsigned long PathIndex; // Index of path in m_Paths
  132. std::string Basename; // Filename
  133. unsigned long RefCount; // Count of descriptors requested
  134. void *Handle; // DLL Handle, NULL
  135. };
  136. // For cached RDF uri information
  137. struct RDFURIInfo
  138. {
  139. std::string URI; // Full URI for use with lrdf
  140. std::string Label; // Label
  141. std::vector<unsigned long> Parents; // Index of parents in m_RDFURIs
  142. std::vector<unsigned long> Children; // Indices of children in m_RDFURIs
  143. std::vector<unsigned long> Plugins; // Indices of plugins in m_Plugins
  144. };
  145. // Lookup maps
  146. typedef std::map<unsigned long,
  147. unsigned long,
  148. std::less<unsigned long> > IDMap;
  149. typedef std::map<std::string,
  150. unsigned long,
  151. std::less<std::string> > StringMap;
  152. bool m_LADSPAPathOverride;
  153. char *m_ExtraPaths;
  154. // LADSPA Plugin information database
  155. std::vector<std::string> m_Paths;
  156. std::vector<LibraryInfo> m_Libraries;
  157. std::vector<PluginInfo> m_Plugins;
  158. // Plugin lookup maps
  159. IDMap m_IDLookup;
  160. // RDF URI database
  161. std::vector<RDFURIInfo> m_RDFURIs;
  162. // RDF URI lookup map
  163. StringMap m_RDFURILookup;
  164. // RDF Label lookup map
  165. StringMap m_RDFLabelLookup;
  166. // SSM specific data
  167. std::vector<PluginEntry> m_SSMMenuList;
  168. StringMap m_FilenameLookup;
  169. unsigned long m_MaxInputPortCount;
  170. };
  171. #endif // __ladspa_info_h__