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.

157 lines
5.9KB

  1. /*
  2. LADSPAInfo.h - Header file for LADSPA Plugin info class
  3. Copyright (C) 2002 Mike Rawes
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  15. */
  16. #ifndef __ladspa_info_h__
  17. #define __ladspa_info_h__
  18. #include <string>
  19. #include <vector>
  20. #include <map>
  21. #include <ladspa.h>
  22. class LADSPAInfo
  23. {
  24. public:
  25. // If override is false, examine $LADSPA_PATH
  26. // Also examine supplied path list
  27. // For all paths, add basic plugin information for later lookup,
  28. // instantiation and so on.
  29. LADSPAInfo(bool override, const char *path_list);
  30. // Unload all loaded plugins and clean up
  31. ~LADSPAInfo();
  32. // ************************************************************************
  33. // Loading/Unloading plugin libraries
  34. //
  35. // At first, no library dlls are loaded.
  36. //
  37. // Each library has an associated reference count, which is initially 0.
  38. // As descriptors are requested, using GetDescriptorByID, this count
  39. // is incremented. The library dll is loaded on the first request.
  40. // At descriptors are discarded, the count is decremented, and when this
  41. // reaches 0, the library is unloaded.
  42. // Rescan all paths in $LADSPA_PATH, as per constructor.
  43. // This will also unload all libraries, and make any descriptors that
  44. // have not been discarded with DiscardDescriptorByID invalid.
  45. void RescanPlugins(void);
  46. // Unload all dlopened libraries. This will make any descriptors that
  47. // have not been discarded with DiscardDescriptorByID invalid.
  48. void UnloadAllLibraries(void);
  49. // Get descriptor of plugin with given ID. This increments the descriptor
  50. // count for the corresponding library.
  51. const LADSPA_Descriptor *GetDescriptorByID(unsigned long unique_id);
  52. // Notify that a descriptor corresponding to the given ID has been
  53. // discarded. This decrements the descriptor count for the corresponding
  54. // library.
  55. void DiscardDescriptorByID(unsigned long unique_id);
  56. // Get unique ID of plugin identified by given library filename and label.
  57. unsigned long GetIDFromFilenameAndLabel(std::string filename,
  58. std::string label);
  59. struct PluginEntry
  60. {
  61. unsigned long UniqueID;
  62. std::string Name;
  63. };
  64. // Get a list of plugins ordered by name (duplicate names are
  65. // appended with a (number)
  66. const std::vector<PluginEntry> GetPluginList(void);
  67. // Get the index in the above list for given Unique ID
  68. // If not found, this returns the size of the above list
  69. unsigned long GetPluginListEntryByID(unsigned long unique_id);
  70. // Get the number of input ports for the plugin with the most
  71. // input ports
  72. unsigned long GetMaxInputPortCount(void) { return m_MaxInputPortCount; }
  73. void PrintInfo(void);
  74. private:
  75. void CleanUp(void);
  76. void ScanPathList(const char *path_list,
  77. void (LADSPAInfo::*ExamineFunc)(const std::string,
  78. const std::string));
  79. void ExaminePluginLibrary(const std::string path,
  80. const std::string basename);
  81. #ifdef HAVE_LIBLRDF
  82. void ExamineRDFFile(const std::string path,
  83. const std::string basename);
  84. #endif
  85. bool CheckPlugin(const LADSPA_Descriptor *desc);
  86. LADSPA_Descriptor_Function GetDescriptorFunctionForLibrary(unsigned long library_index);
  87. struct LibraryInfo
  88. {
  89. unsigned long PathIndex; // Index of path in m_Paths
  90. std::string Basename; // Filename
  91. unsigned long RefCount; // Count of descriptors requested from library
  92. void *Handle; // DLL Handle, NULL
  93. };
  94. struct PluginInfo
  95. {
  96. unsigned long LibraryIndex; // Index of library in m_Libraries
  97. unsigned long Index; // Plugin index in library
  98. const LADSPA_Descriptor *Descriptor; // Descriptor, NULL
  99. };
  100. typedef std::map<unsigned long,
  101. unsigned long,
  102. std::less<unsigned long> > IDMap;
  103. typedef std::map<std::string,
  104. unsigned long,
  105. std::less<std::string> > StringMap;
  106. // For sorting vectors of PluginEntries
  107. struct PluginEntrySortAsc
  108. {
  109. bool operator()(const PluginEntry &begin, const PluginEntry &end)
  110. {
  111. return begin.Name < end.Name;
  112. }
  113. };
  114. bool m_LADSPAPathOverride;
  115. char *m_ExtraPaths;
  116. std::vector<std::string> m_Paths;
  117. std::vector<LibraryInfo> m_Libraries;
  118. std::vector<PluginInfo> m_Plugins;
  119. IDMap m_IDLookup;
  120. StringMap m_FilenameLookup;
  121. std::vector<PluginEntry> m_OrderedPluginList;
  122. unsigned long m_MaxInputPortCount;
  123. };
  124. #endif // __ladspa_info_h__