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-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_HOST_IMPL_HPP_INCLUDED
  18. #define CARLA_HOST_IMPL_HPP_INCLUDED
  19. #include "CarlaHost.h"
  20. #include "CarlaUtils.h"
  21. #include "CarlaEngine.hpp"
  22. #include "CarlaUtils.hpp"
  23. #if !(defined(BUILD_BRIDGE) || defined(CARLA_OS_WASM))
  24. # define CARLA_CAN_USE_LOG_THREAD
  25. # include "CarlaLogThread.hpp"
  26. #else
  27. # include "distrho/extra/String.hpp"
  28. #endif
  29. namespace CB = CARLA_BACKEND_NAMESPACE;
  30. using CB::EngineOptions;
  31. // --------------------------------------------------------------------------------------------------------------------
  32. // Shared code, WIP
  33. typedef struct _CarlaHostHandle {
  34. // required pointers
  35. CarlaEngine* engine;
  36. // flags
  37. bool isStandalone : 1;
  38. bool isPlugin : 1;
  39. _CarlaHostHandle() noexcept
  40. : engine(nullptr),
  41. isStandalone(false),
  42. isPlugin(false) {}
  43. } CarlaHostHandleImpl;
  44. // --------------------------------------------------------------------------------------------------------------------
  45. // Single, standalone engine
  46. struct CarlaHostStandalone : CarlaHostHandleImpl {
  47. EngineCallbackFunc engineCallback;
  48. void* engineCallbackPtr;
  49. FileCallbackFunc fileCallback;
  50. void* fileCallbackPtr;
  51. EngineOptions engineOptions;
  52. #ifdef CARLA_CAN_USE_LOG_THREAD
  53. CarlaLogThread logThread;
  54. bool logThreadEnabled;
  55. #endif
  56. String lastError;
  57. CarlaHostStandalone() noexcept
  58. : CarlaHostHandleImpl(),
  59. engineCallback(nullptr),
  60. engineCallbackPtr(nullptr),
  61. fileCallback(nullptr),
  62. fileCallbackPtr(nullptr),
  63. engineOptions(),
  64. #ifdef CARLA_CAN_USE_LOG_THREAD
  65. logThread(),
  66. logThreadEnabled(false),
  67. #endif
  68. lastError()
  69. {
  70. isStandalone = true;
  71. }
  72. ~CarlaHostStandalone() noexcept
  73. {
  74. CARLA_SAFE_ASSERT(engine == nullptr);
  75. }
  76. CARLA_PREVENT_HEAP_ALLOCATION
  77. CARLA_DECLARE_NON_COPYABLE(CarlaHostStandalone)
  78. };
  79. // --------------------------------------------------------------------------------------------------------------------
  80. #endif // CARLA_HOST_IMPL_HPP_INCLUDED