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.

CarlaEnginePorts.hpp 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Carla Plugin Host
  3. * Copyright (C) 2011-2022 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. #ifndef CARLA_ENGINE_PORTS_HPP_INCLUDED
  18. #define CARLA_ENGINE_PORTS_HPP_INCLUDED
  19. #include "CarlaEngine.hpp"
  20. #include "CarlaEngineInternal.hpp"
  21. CARLA_BACKEND_START_NAMESPACE
  22. // -----------------------------------------------------------------------
  23. // Carla Engine Meta CV Port Protected Data
  24. struct CarlaEngineEventCV {
  25. CarlaEngineCVPort* cvPort;
  26. uint32_t indexOffset;
  27. float previousValue;
  28. };
  29. struct CarlaEngineCVSourcePorts::ProtectedData {
  30. CarlaRecursiveMutex rmutex;
  31. #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
  32. PatchbayGraph* graph;
  33. CarlaPluginPtr plugin;
  34. #endif
  35. water::Array<CarlaEngineEventCV> cvs;
  36. ProtectedData() noexcept
  37. : rmutex(),
  38. #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
  39. graph(nullptr),
  40. plugin(nullptr),
  41. #endif
  42. cvs() {}
  43. ~ProtectedData()
  44. {
  45. CARLA_SAFE_ASSERT(cvs.size() == 0);
  46. }
  47. void cleanup()
  48. {
  49. const CarlaRecursiveMutexLocker crml(rmutex);
  50. for (int i = cvs.size(); --i >= 0;)
  51. delete cvs[i].cvPort;
  52. cvs.clear();
  53. }
  54. CARLA_DECLARE_NON_COPYABLE(ProtectedData)
  55. };
  56. #ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
  57. // -----------------------------------------------------------------------
  58. // Carla Engine Meta CV Port
  59. class CarlaEngineCVSourcePortsForStandalone : public CarlaEngineCVSourcePorts
  60. {
  61. public:
  62. CarlaEngineCVSourcePortsForStandalone() : CarlaEngineCVSourcePorts() {}
  63. ~CarlaEngineCVSourcePortsForStandalone() override {}
  64. inline void resetGraphAndPlugin() noexcept
  65. {
  66. pData->graph = nullptr;
  67. pData->plugin.reset();
  68. }
  69. inline void setGraphAndPlugin(PatchbayGraph* const graph, const CarlaPluginPtr plugin) noexcept
  70. {
  71. pData->graph = graph;
  72. pData->plugin = plugin;
  73. }
  74. };
  75. #endif
  76. // -----------------------------------------------------------------------
  77. CARLA_BACKEND_END_NAMESPACE
  78. #endif // CARLA_ENGINE_PORTS_HPP_INCLUDED