Audio plugin host https://kx.studio/carla
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.

carla-native-base.cpp 2.9KB

11 years ago
11 years ago
11 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * Carla Native Plugins
  3. * Copyright (C) 2013 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  16. */
  17. #include "CarlaEngine.hpp"
  18. #include "CarlaPlugin.hpp"
  19. #include "CarlaHost.h"
  20. #include "CarlaNative.h"
  21. #include "CarlaBackendUtils.hpp"
  22. #include "List.hpp"
  23. // TODO: remove
  24. #ifndef CARLA_NATIVE_PLUGIN_LV2
  25. # define CARLA_NATIVE_PLUGIN_LV2
  26. #endif
  27. #ifdef CARLA_NATIVE_PLUGIN_LV2
  28. # include "lv2/lv2.h"
  29. #endif
  30. // -----------------------------------------------------------------------
  31. const char* carla_file_callback(FileCallbackOpcode action, bool isDir, const char* title, const char* filter)
  32. {
  33. CARLA_SAFE_ASSERT_RETURN(title != nullptr && title[0] != '\0', nullptr);
  34. CARLA_SAFE_ASSERT_RETURN(filter != nullptr && filter[0] != '\0', nullptr);
  35. carla_debug("carla_file_callback(%i:%s, %s, \"%s\", \"%s\")", action, CarlaBackend::FileCallbackOpcode2Str(action), bool2str(isDir), title, filter);
  36. return nullptr;
  37. // unused
  38. (void)action;
  39. (void)isDir;
  40. }
  41. // -----------------------------------------------------------------------
  42. // Plugin List
  43. struct PluginListManager {
  44. PluginListManager()
  45. {
  46. for (size_t i=0, count = CarlaBackend::CarlaPlugin::getNativePluginCount(); i < count; ++i)
  47. {
  48. const NativePluginDescriptor* const desc(CarlaBackend::CarlaPlugin::getNativePluginDescriptor(i));
  49. carla_stderr2("PLM: %i/%i : %s", i+1, count, desc->name);
  50. #ifdef CARLA_NATIVE_PLUGIN_LV2
  51. // LV2 MIDI Out and Open/Save are not implemented yet
  52. if (desc->midiOuts > 0 || (desc->hints & PLUGIN_NEEDS_UI_OPEN_SAVE) != 0)
  53. continue;
  54. #endif
  55. descs.append(desc);
  56. }
  57. }
  58. ~PluginListManager()
  59. {
  60. #ifdef CARLA_NATIVE_PLUGIN_LV2
  61. for (List<const LV2_Descriptor*>::Itenerator it = lv2Descs.begin(); it.valid(); it.next())
  62. {
  63. const LV2_Descriptor*& lv2Desc(it.getValue());
  64. delete[] lv2Desc->URI;
  65. delete lv2Desc;
  66. }
  67. lv2Descs.clear();
  68. #endif
  69. descs.clear();
  70. }
  71. static PluginListManager& getInstance()
  72. {
  73. static PluginListManager plm;
  74. return plm;
  75. }
  76. #ifdef CARLA_NATIVE_PLUGIN_LV2
  77. List<const LV2_Descriptor*> lv2Descs;
  78. #endif
  79. List<const NativePluginDescriptor*> descs;
  80. };
  81. // -----------------------------------------------------------------------