1 /* 2 * Carla Plugin Host 3 * Copyright (C) 2011-2021 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 18 #ifndef CARLA_HOST_IMPL_HPP_INCLUDED 19 #define CARLA_HOST_IMPL_HPP_INCLUDED 20 21 #include "CarlaHost.h" 22 #include "CarlaUtils.h" 23 #include "CarlaEngine.hpp" 24 25 #ifdef BUILD_BRIDGE 26 # include "CarlaString.hpp" 27 #else 28 # include "CarlaLogThread.hpp" 29 #endif 30 31 namespace CB = CarlaBackend; 32 using CB::EngineOptions; 33 34 // -------------------------------------------------------------------------------------------------------------------- 35 // Shared code, WIP 36 37 typedef struct _CarlaHostHandle { 38 // required pointers 39 CarlaEngine* engine; 40 41 // flags 42 bool isStandalone : 1; 43 bool isPlugin : 1; 44 _CarlaHostHandle_CarlaHostHandle45 _CarlaHostHandle() noexcept 46 : engine(nullptr), 47 isStandalone(false), 48 isPlugin(false) {} 49 } CarlaHostHandleImpl; 50 51 // -------------------------------------------------------------------------------------------------------------------- 52 // Single, standalone engine 53 54 struct CarlaHostStandalone : CarlaHostHandleImpl { 55 EngineCallbackFunc engineCallback; 56 void* engineCallbackPtr; 57 FileCallbackFunc fileCallback; 58 void* fileCallbackPtr; 59 60 EngineOptions engineOptions; 61 #ifndef BUILD_BRIDGE 62 CarlaLogThread logThread; 63 bool logThreadEnabled; 64 #endif 65 66 CarlaString lastError; 67 CarlaHostStandaloneCarlaHostStandalone68 CarlaHostStandalone() noexcept 69 : CarlaHostHandleImpl(), 70 engineCallback(nullptr), 71 engineCallbackPtr(nullptr), 72 fileCallback(nullptr), 73 fileCallbackPtr(nullptr), 74 engineOptions(), 75 #ifndef BUILD_BRIDGE 76 logThread(), 77 logThreadEnabled(false), 78 #endif 79 lastError() 80 { 81 isStandalone = true; 82 } 83 ~CarlaHostStandaloneCarlaHostStandalone84 ~CarlaHostStandalone() noexcept 85 { 86 CARLA_SAFE_ASSERT(engine == nullptr); 87 } 88 89 CARLA_PREVENT_HEAP_ALLOCATION 90 CARLA_DECLARE_NON_COPY_STRUCT(CarlaHostStandalone) 91 }; 92 93 // -------------------------------------------------------------------------------------------------------------------- 94 95 #endif // CARLA_HOST_IMPL_HPP_INCLUDED 96