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.

142 lines
3.6KB

  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. 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. void _CarlaTransportInfo::clear() noexcept
  85. {
  86. playing = false;
  87. frame = 0;
  88. bar = 0;
  89. beat = 0;
  90. tick = 0;
  91. bpm = 0.0;
  92. }
  93. // -------------------------------------------------------------------------------------------------------------------
  94. const char* carla_get_library_filename()
  95. {
  96. carla_debug("carla_get_library_filename()");
  97. static CarlaString ret;
  98. if (ret.isEmpty())
  99. {
  100. using water::File;
  101. ret = File(File::getSpecialLocation(File::currentExecutableFile)).getFullPathName().toRawUTF8();
  102. }
  103. return ret;
  104. }
  105. const char* carla_get_library_folder()
  106. {
  107. carla_debug("carla_get_library_folder()");
  108. static CarlaString ret;
  109. if (ret.isEmpty())
  110. {
  111. using water::File;
  112. ret = File(File::getSpecialLocation(File::currentExecutableFile).getParentDirectory()).getFullPathName().toRawUTF8();
  113. }
  114. return ret;
  115. }
  116. // -------------------------------------------------------------------------------------------------------------------