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.

200 lines
7.5KB

  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. bool operator<(const PluginEntry& pe)
  81. {
  82. return (Name<pe.Name);
  83. }
  84. };
  85. // Get ordered list of plugin names and IDs for plugin menu
  86. const std::vector<PluginEntry> GetMenuList(void);
  87. // Get the index in the above list for given Unique ID
  88. // If not found, this returns the size of the above list
  89. unsigned long GetPluginListEntryByID(unsigned long unique_id);
  90. // Get the number of input ports for the plugin with the most
  91. // input ports
  92. unsigned long GetMaxInputPortCount(void) { return m_MaxInputPortCount; }
  93. private:
  94. // See LADSPAInfo.C for comments on these functions
  95. void DescendGroup(std::string prefix,
  96. const std::string group,
  97. unsigned int depth);
  98. std::list<std::string> GetSubGroups(const std::string group);
  99. void CleanUp(void);
  100. void ScanPathList(const char *path_list,
  101. void (LADSPAInfo::*ExamineFunc)(const std::string,
  102. const std::string));
  103. void ExaminePluginLibrary(const std::string path,
  104. const std::string basename);
  105. bool CheckPlugin(const LADSPA_Descriptor *desc);
  106. LADSPA_Descriptor_Function GetDescriptorFunctionForLibrary(unsigned long library_index);
  107. #ifdef HAVE_LIBLRDF
  108. void ExamineRDFFile(const std::string path,
  109. const std::string basename);
  110. void MetadataRDFDescend(const char *uri,
  111. unsigned long parent);
  112. #endif
  113. // For cached library information
  114. struct LibraryInfo
  115. {
  116. unsigned long PathIndex; // Index of path in m_Paths
  117. std::string Basename; // Filename
  118. unsigned long RefCount; // Count of descriptors requested
  119. void *Handle; // DLL Handle, NULL
  120. };
  121. // For cached plugin information
  122. struct PluginInfo
  123. {
  124. unsigned long LibraryIndex; // Index of library in m_Libraries
  125. unsigned long Index; // Plugin index in library
  126. unsigned long UniqueID; // Unique ID
  127. std::string Label; // Plugin label
  128. std::string Name; // Plugin Name
  129. const LADSPA_Descriptor *Descriptor; // Descriptor, NULL
  130. };
  131. // For cached RDF uri information
  132. struct RDFURIInfo
  133. {
  134. std::string URI; // Full URI for use with lrdf
  135. std::string Label; // Label
  136. std::vector<unsigned long> Parents; // Index of parents in m_RDFURIs
  137. std::vector<unsigned long> Children; // Indices of children in m_RDFURIs
  138. std::vector<unsigned long> Plugins; // Indices of plugins in m_Plugins
  139. };
  140. // Lookup maps
  141. typedef std::map<unsigned long,
  142. unsigned long,
  143. std::less<unsigned long> > IDMap;
  144. typedef std::map<std::string,
  145. unsigned long,
  146. std::less<std::string> > StringMap;
  147. bool m_LADSPAPathOverride;
  148. char *m_ExtraPaths;
  149. // LADSPA Plugin information database
  150. std::vector<std::string> m_Paths;
  151. std::vector<LibraryInfo> m_Libraries;
  152. std::vector<PluginInfo> m_Plugins;
  153. // Plugin lookup maps
  154. IDMap m_IDLookup;
  155. // RDF URI database
  156. std::vector<RDFURIInfo> m_RDFURIs;
  157. // RDF URI lookup map
  158. StringMap m_RDFURILookup;
  159. // RDF Label lookup map
  160. StringMap m_RDFLabelLookup;
  161. // SSM specific data
  162. std::vector<PluginEntry> m_SSMMenuList;
  163. StringMap m_FilenameLookup;
  164. unsigned long m_MaxInputPortCount;
  165. };
  166. #endif // __ladspa_info_h__