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.

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