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.

136 lines
4.6KB

  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. // Rescan all paths in $LADSPA_PATH, as per constructor
  33. // This will also unload all libraries
  34. void RescanPlugins(void);
  35. // Unload all dlopened libraries
  36. void UnloadAllLibraries(void);
  37. // Unload library containing plugin id
  38. void UnloadLibraryByID(unsigned long unique_id);
  39. // Get descriptor of plugin in list, loading library if necessary
  40. // and optionally unloading previously loaded library (if different
  41. // from library containing requested plugin. Phew!)
  42. const LADSPA_Descriptor *GetDescriptorByID(unsigned long unique_id,
  43. bool unload_previous_library);
  44. unsigned long GetIDFromFilenameAndLabel(std::string filename,
  45. std::string label);
  46. struct PluginEntry
  47. {
  48. unsigned long UniqueID;
  49. std::string Name;
  50. };
  51. // Get a list of plugins ordered by name (duplicate names are
  52. // appended with a (number)
  53. const std::vector<PluginEntry> GetPluginList(void);
  54. // Get the index in the above list for given Unique ID
  55. // If not found, this returns the size of the above list
  56. unsigned long GetPluginListEntryByID(unsigned long unique_id);
  57. // Get the number of input ports for the plugin with the most
  58. // input ports
  59. unsigned long GetMaxInputPortCount(void) { return m_MaxInputPortCount; }
  60. private:
  61. void CleanUp(void);
  62. void ScanPathList(const char *path_list);
  63. void ExaminePath(const char *path);
  64. bool CheckPlugin(LADSPA_Descriptor_Function desc_func);
  65. LADSPA_Descriptor_Function GetDescriptorFunctionForLibrary(unsigned long library_index);
  66. void UnloadLibraryByPlugin(unsigned long plugin_index);
  67. struct LibraryInfo
  68. {
  69. unsigned long PathIndex; // Index of path in m_Paths
  70. std::string Basename; // Filename
  71. void *Handle; // DLL Handle, NULL
  72. };
  73. struct PluginInfo
  74. {
  75. unsigned long LibraryIndex; // Index of library in m_Libraries
  76. unsigned long Index; // Plugin index in library
  77. const LADSPA_Descriptor *Descriptor; // Descriptor, NULL
  78. };
  79. typedef std::map<unsigned long,
  80. unsigned long,
  81. std::less<unsigned long> > IDMap;
  82. typedef std::map<std::string,
  83. unsigned long,
  84. std::less<std::string> > StringMap;
  85. // For sorting vectors of PluginEntries
  86. struct PluginEntrySortAsc
  87. {
  88. bool operator()(const PluginEntry &begin, const PluginEntry &end)
  89. {
  90. return begin.Name < end.Name;
  91. }
  92. };
  93. bool m_LADSPAPathOverride;
  94. char *m_ExtraPaths;
  95. std::vector<std::string> m_Paths;
  96. std::vector<LibraryInfo> m_Libraries;
  97. std::vector<PluginInfo> m_Plugins;
  98. unsigned long m_LastLoadedLibraryIndex;
  99. unsigned long m_LastLoadedPluginIndex;
  100. IDMap m_IDLookup;
  101. StringMap m_FilenameLookup;
  102. std::vector<PluginEntry> m_OrderedPluginList;
  103. unsigned long m_MaxInputPortCount;
  104. };
  105. #endif // __ladspa_info_h__