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.

CarlaHostImpl.hpp 2.7KB

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