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.

132 lines
3.4KB

  1. /*
  2. * Carla Plugin Host
  3. * Copyright (C) 2011-2014 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 "CarlaHost.h"
  18. #include "CarlaString.hpp"
  19. #include "juce_core.h"
  20. namespace CB = CarlaBackend;
  21. // -------------------------------------------------------------------------------------------------------------------
  22. // Always return a valid string ptr
  23. static const char* const gNullCharPtr = "";
  24. #ifdef CARLA_COMMON_NEED_CHECKSTRINGPTR
  25. static void checkStringPtr(const char*& charPtr) noexcept
  26. {
  27. if (charPtr == nullptr)
  28. charPtr = gNullCharPtr;
  29. }
  30. #endif
  31. // -------------------------------------------------------------------------------------------------------------------
  32. // Constructors
  33. _CarlaPluginInfo::_CarlaPluginInfo() noexcept
  34. : type(CB::PLUGIN_NONE),
  35. category(CB::PLUGIN_CATEGORY_NONE),
  36. hints(0x0),
  37. optionsAvailable(0x0),
  38. optionsEnabled(0x0),
  39. filename(gNullCharPtr),
  40. name(gNullCharPtr),
  41. label(gNullCharPtr),
  42. maker(gNullCharPtr),
  43. copyright(gNullCharPtr),
  44. iconName(gNullCharPtr),
  45. uniqueId(0) {}
  46. _CarlaPluginInfo::~_CarlaPluginInfo() noexcept
  47. {
  48. if (label != gNullCharPtr)
  49. delete[] label;
  50. if (maker != gNullCharPtr)
  51. delete[] maker;
  52. if (copyright != gNullCharPtr)
  53. delete[] copyright;
  54. }
  55. _CarlaParameterInfo::_CarlaParameterInfo() noexcept
  56. : name(gNullCharPtr),
  57. symbol(gNullCharPtr),
  58. unit(gNullCharPtr),
  59. scalePointCount(0) {}
  60. _CarlaParameterInfo::~_CarlaParameterInfo() noexcept
  61. {
  62. if (name != gNullCharPtr)
  63. delete[] name;
  64. if (symbol != gNullCharPtr)
  65. delete[] symbol;
  66. if (unit != gNullCharPtr)
  67. delete[] unit;
  68. }
  69. _CarlaScalePointInfo::_CarlaScalePointInfo() noexcept
  70. : value(0.0f),
  71. label(gNullCharPtr) {}
  72. _CarlaScalePointInfo::~_CarlaScalePointInfo() noexcept
  73. {
  74. if (label != gNullCharPtr)
  75. delete[] label;
  76. }
  77. _CarlaTransportInfo::_CarlaTransportInfo() noexcept
  78. : playing(false),
  79. frame(0),
  80. bar(0),
  81. beat(0),
  82. tick(0),
  83. bpm(0.0) {}
  84. // -------------------------------------------------------------------------------------------------------------------
  85. const char* carla_get_library_filename()
  86. {
  87. carla_debug("carla_get_library_filename()");
  88. static CarlaString ret;
  89. if (ret.isEmpty())
  90. {
  91. using namespace juce;
  92. ret = File(File::getSpecialLocation(File::currentExecutableFile)).getFullPathName().toRawUTF8();
  93. }
  94. return ret;
  95. }
  96. const char* carla_get_library_folder()
  97. {
  98. carla_debug("carla_get_library_folder()");
  99. static CarlaString ret;
  100. if (ret.isEmpty())
  101. {
  102. using namespace juce;
  103. ret = File(File::getSpecialLocation(File::currentExecutableFile).getParentDirectory()).getFullPathName().toRawUTF8();
  104. }
  105. return ret;
  106. }
  107. // -------------------------------------------------------------------------------------------------------------------