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.

116 lines
3.0KB

  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 "CarlaEngineInternal.hpp"
  18. #include "CarlaEngineUtils.hpp"
  19. // -----------------------------------------------------------------------
  20. CARLA_BACKEND_START_NAMESPACE
  21. #if 0
  22. } // Fix editor indentation
  23. #endif
  24. // -----------------------------------------------------------------------
  25. // Carla Engine client (Abstract)
  26. CarlaEngineClient::CarlaEngineClient(const CarlaEngine& engine)
  27. : fEngine(engine),
  28. fActive(false),
  29. fLatency(0)
  30. {
  31. carla_debug("CarlaEngineClient::CarlaEngineClient()");
  32. }
  33. CarlaEngineClient::~CarlaEngineClient()
  34. {
  35. CARLA_SAFE_ASSERT(! fActive);
  36. carla_debug("CarlaEngineClient::~CarlaEngineClient()");
  37. }
  38. void CarlaEngineClient::activate() noexcept
  39. {
  40. CARLA_SAFE_ASSERT(! fActive);
  41. carla_debug("CarlaEngineClient::activate()");
  42. fActive = true;
  43. }
  44. void CarlaEngineClient::deactivate() noexcept
  45. {
  46. CARLA_SAFE_ASSERT(fActive);
  47. carla_debug("CarlaEngineClient::deactivate()");
  48. fActive = false;
  49. }
  50. bool CarlaEngineClient::isActive() const noexcept
  51. {
  52. return fActive;
  53. }
  54. bool CarlaEngineClient::isOk() const noexcept
  55. {
  56. return true;
  57. }
  58. uint32_t CarlaEngineClient::getLatency() const noexcept
  59. {
  60. return fLatency;
  61. }
  62. void CarlaEngineClient::setLatency(const uint32_t samples) noexcept
  63. {
  64. fLatency = samples;
  65. }
  66. CarlaEnginePort* CarlaEngineClient::addPort(const EnginePortType portType, const char* const name, const bool isInput) /*noexcept*/
  67. {
  68. CARLA_SAFE_ASSERT_RETURN(name != nullptr && name[0] != '\0', nullptr);
  69. carla_debug("CarlaEngineClient::addPort(%i:%s, \"%s\", %s)", portType, EnginePortType2Str(portType), name, bool2str(isInput));
  70. CarlaEnginePort* ret = nullptr;
  71. try {
  72. switch (portType)
  73. {
  74. case kEnginePortTypeNull:
  75. break;
  76. case kEnginePortTypeAudio:
  77. ret = new CarlaEngineAudioPort(fEngine, isInput);
  78. case kEnginePortTypeCV:
  79. ret = new CarlaEngineCVPort(fEngine, isInput);
  80. case kEnginePortTypeEvent:
  81. ret = new CarlaEngineEventPort(fEngine, isInput);
  82. }
  83. }
  84. catch(...) {
  85. return nullptr;
  86. }
  87. if (ret != nullptr)
  88. return ret;
  89. carla_stderr("CarlaEngineClient::addPort(%i, \"%s\", %s) - invalid type", portType, name, bool2str(isInput));
  90. return nullptr;
  91. }
  92. // -----------------------------------------------------------------------
  93. CARLA_BACKEND_END_NAMESPACE