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.

148 lines
3.7KB

  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 "water/files/File.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. comment(gNullCharPtr),
  60. groupName(gNullCharPtr),
  61. scalePointCount(0) {}
  62. _CarlaParameterInfo::~_CarlaParameterInfo() noexcept
  63. {
  64. if (name != gNullCharPtr)
  65. delete[] name;
  66. if (symbol != gNullCharPtr)
  67. delete[] symbol;
  68. if (unit != gNullCharPtr)
  69. delete[] unit;
  70. if (comment != gNullCharPtr)
  71. delete[] comment;
  72. if (groupName != gNullCharPtr)
  73. delete[] groupName;
  74. }
  75. _CarlaScalePointInfo::_CarlaScalePointInfo() noexcept
  76. : value(0.0f),
  77. label(gNullCharPtr) {}
  78. _CarlaScalePointInfo::~_CarlaScalePointInfo() noexcept
  79. {
  80. if (label != gNullCharPtr)
  81. delete[] label;
  82. }
  83. _CarlaTransportInfo::_CarlaTransportInfo() noexcept
  84. : playing(false),
  85. frame(0),
  86. bar(0),
  87. beat(0),
  88. tick(0),
  89. bpm(0.0) {}
  90. void _CarlaTransportInfo::clear() noexcept
  91. {
  92. playing = false;
  93. frame = 0;
  94. bar = 0;
  95. beat = 0;
  96. tick = 0;
  97. bpm = 0.0;
  98. }
  99. // -------------------------------------------------------------------------------------------------------------------
  100. const char* carla_get_library_filename()
  101. {
  102. carla_debug("carla_get_library_filename()");
  103. static CarlaString ret;
  104. if (ret.isEmpty())
  105. {
  106. using water::File;
  107. ret = File(File::getSpecialLocation(File::currentExecutableFile)).getFullPathName().toRawUTF8();
  108. }
  109. return ret;
  110. }
  111. const char* carla_get_library_folder()
  112. {
  113. carla_debug("carla_get_library_folder()");
  114. static CarlaString ret;
  115. if (ret.isEmpty())
  116. {
  117. using water::File;
  118. ret = File(File::getSpecialLocation(File::currentExecutableFile).getParentDirectory()).getFullPathName().toRawUTF8();
  119. }
  120. return ret;
  121. }
  122. // -------------------------------------------------------------------------------------------------------------------