| @@ -52,7 +52,9 @@ const unsigned int MAX_PARAMETERS = 200; //!< Default value for the maximum numb | |||
| * \see CarlaPlugin::hints() | |||
| * @{ | |||
| */ | |||
| #ifndef BUILD_BRIDGE | |||
| const unsigned int PLUGIN_IS_BRIDGE = 0x001; //!< Plugin is a bridge (ie, BridgePlugin). This hint is required because "bridge" itself is not a plugin type. | |||
| #endif | |||
| const unsigned int PLUGIN_IS_SYNTH = 0x002; //!< Plugin is a synthesizer (produces sound). | |||
| const unsigned int PLUGIN_HAS_GUI = 0x004; //!< Plugin has its own custom GUI. | |||
| const unsigned int PLUGIN_USES_CHUNKS = 0x008; //!< Plugin uses chunks to save internal data.\see CarlaPlugin::chunkData() | |||
| @@ -405,6 +405,9 @@ doxygen: carla_bridge.doxygen | |||
| clean: | |||
| rm -f *.o *.dll *.so *.exe | |||
| rm -f $(OBJS_POSIX32) | |||
| rm -f $(OBJS_POSIX64) | |||
| rm -f $(OBJS_WIN32) | |||
| rm -f $(OBJS_WIN64) | |||
| rm -f carla-bridge-lv2-gtk2 carla-bridge-lv2-gtk3 carla-bridge-lv2-qt4 carla-bridge-lv2-qt5 carla-bridge-lv2-x11 carla-bridge-vst-x11 | |||
| rm -f carla-bridge-posix32 carla-bridge-posix64 | |||
| rm -f $(OBJS_POSIX32) $(OBJS_POSIX64) $(OBJS_WIN32) $(OBJS_WIN64) | |||
| @@ -180,7 +180,7 @@ void CarlaBridgeClient::toolkitHide() | |||
| m_toolkit->hide(); | |||
| } | |||
| void CarlaBridgeClient::toolkitResize(int width, int height) | |||
| void CarlaBridgeClient::toolkitResize(const int width, const int height) | |||
| { | |||
| qDebug("CarlaBridgeClient::toolkitResize(%i, %i)", width, height); | |||
| @@ -282,12 +282,12 @@ void CarlaBridgeClient::sendOscLv2TransferEvent(const int32_t portIndex, const c | |||
| // --------------------------------------------------------------------- | |||
| #ifdef BUILD_BRIDGE_UI | |||
| void* CarlaBridgeClient::getContainerId() | |||
| { | |||
| return m_toolkit->getContainerId(); | |||
| } | |||
| #ifdef BUILD_BRIDGE_UI | |||
| bool CarlaBridgeClient::uiLibOpen(const char* const filename) | |||
| { | |||
| CARLA_ASSERT(! m_uiLib); | |||
| @@ -99,7 +99,7 @@ public: | |||
| void toolkitShow(); | |||
| void toolkitHide(); | |||
| void toolkitResize(int width, int height); | |||
| void toolkitResize(const int width, const int height); | |||
| void toolkitExec(const bool showGui); | |||
| void toolkitQuit(); | |||
| @@ -120,8 +120,9 @@ protected: | |||
| // --------------------------------------------------------------------- | |||
| #ifdef BUILD_BRIDGE_UI | |||
| void* getContainerId(); | |||
| #ifdef BUILD_BRIDGE_UI | |||
| bool uiLibOpen(const char* const filename); | |||
| bool uiLibClose(); | |||
| void* uiLibSymbol(const char* const symbol); | |||
| @@ -21,7 +21,6 @@ | |||
| #include "carla_bridge_toolkit.hpp" | |||
| #include "carla_plugin.hpp" | |||
| //#include <QtCore/QTimerEvent> | |||
| #include <QtCore/QDir> | |||
| #include <QtCore/QFile> | |||
| #include <QtCore/QTextStream> | |||
| @@ -110,8 +109,9 @@ public: | |||
| app = nullptr; | |||
| gui = nullptr; | |||
| m_hasUI = false; | |||
| m_uiQuit = false; | |||
| m_uiShow = true; | |||
| m_uiShow = false; | |||
| init(); | |||
| } | |||
| @@ -119,8 +119,23 @@ public: | |||
| ~CarlaBridgeToolkitPlugin() | |||
| { | |||
| qDebug("CarlaBridgeToolkitPlugin::~CarlaBridgeToolkitPlugin()"); | |||
| CARLA_ASSERT(! app); | |||
| CARLA_ASSERT(! gui); | |||
| if (gui) | |||
| { | |||
| gui->close(); | |||
| delete gui; | |||
| gui = nullptr; | |||
| } | |||
| if (app) | |||
| { | |||
| if (! app->closingDown()) | |||
| app->quit(); | |||
| delete app; | |||
| app = nullptr; | |||
| } | |||
| } | |||
| void init() | |||
| @@ -143,7 +158,7 @@ public: | |||
| if (showGui) | |||
| { | |||
| if (m_uiShow) | |||
| if (m_hasUI) | |||
| show(); | |||
| } | |||
| else | |||
| @@ -164,41 +179,12 @@ public: | |||
| qDebug("CarlaBridgeToolkitPlugin::quit()"); | |||
| CARLA_ASSERT(app); | |||
| if (gui) | |||
| { | |||
| gui->close(); | |||
| delete gui; | |||
| gui = nullptr; | |||
| } | |||
| if (app) | |||
| { | |||
| if (! app->closingDown()) | |||
| app->quit(); | |||
| delete app; | |||
| app = nullptr; | |||
| } | |||
| if (app && ! app->closingDown()) | |||
| app->quit(); | |||
| } | |||
| void show() | |||
| { | |||
| qDebug("CarlaBridgeToolkitPlugin::show()"); | |||
| CARLA_ASSERT(gui); | |||
| if (gui && m_uiShow) | |||
| gui->setVisible(true); | |||
| } | |||
| void hide() | |||
| { | |||
| qDebug("CarlaBridgeToolkitPlugin::hide()"); | |||
| CARLA_ASSERT(gui); | |||
| if (gui && m_uiShow) | |||
| gui->setVisible(false); | |||
| } | |||
| void show(); | |||
| void hide(); | |||
| void resize(const int width, const int height) | |||
| { | |||
| @@ -229,9 +215,10 @@ public: | |||
| return nullptr; | |||
| } | |||
| void hasUI(const bool yesNo) | |||
| void setHasUI(const bool hasUI, const bool showUI) | |||
| { | |||
| m_uiShow = yesNo; | |||
| m_hasUI = hasUI; | |||
| m_uiShow = showUI; | |||
| } | |||
| protected: | |||
| @@ -241,6 +228,7 @@ protected: | |||
| void guiClosedCallback(); | |||
| private: | |||
| bool m_hasUI; | |||
| bool m_uiQuit; | |||
| bool m_uiShow; | |||
| }; | |||
| @@ -294,14 +282,25 @@ public: | |||
| plugin->getGuiInfo(&guiType, &guiResizable); | |||
| CarlaBridgeToolkitPlugin* const plugToolkit = (CarlaBridgeToolkitPlugin*)m_toolkit; | |||
| plugToolkit->hasUI(guiType != CarlaBackend::GUI_NONE); | |||
| qWarning("----------------------------------------------------- trying..., %s", CarlaBackend::GuiType2Str(guiType)); | |||
| if (guiType == CarlaBackend::GUI_INTERNAL_QT4 || guiType == CarlaBackend::GUI_INTERNAL_COCOA || guiType == CarlaBackend::GUI_INTERNAL_HWND || guiType == CarlaBackend::GUI_INTERNAL_X11) | |||
| { | |||
| plugin->setGuiContainer(plugToolkit->getContainer()); | |||
| plugToolkit->setHasUI(true, true); | |||
| } | |||
| else | |||
| { | |||
| plugToolkit->setHasUI(guiType != CarlaBackend::GUI_NONE, false); | |||
| } | |||
| } | |||
| void quit() | |||
| { | |||
| engine = nullptr; | |||
| plugin = nullptr; | |||
| if (msgTimerGUI != 0) | |||
| { | |||
| killTimer(msgTimerGUI); | |||
| @@ -345,6 +344,14 @@ public: | |||
| engine->osc_send_bridge_configure(CarlaBackend::CARLA_BRIDGE_MSG_HIDE_GUI, ""); | |||
| } | |||
| void showPluginGui(const bool yesNo) | |||
| { | |||
| CARLA_ASSERT(plugin); | |||
| if (plugin) | |||
| plugin->showGui(yesNo); | |||
| } | |||
| // --------------------------------------------------------------------- | |||
| static void callback(void* const ptr, CarlaBackend::CallbackType const action, const unsigned short, const int value1, const int value2, const double value3, const char* const valueStr) | |||
| @@ -570,8 +577,37 @@ protected: | |||
| // ------------------------------------------------------------------------- | |||
| void CarlaBridgeToolkitPlugin::show() | |||
| { | |||
| qDebug("----------------------------------------------------------------------------------------------------------"); | |||
| qDebug("CarlaBridgeToolkitPlugin::show()"); | |||
| CARLA_ASSERT(gui); | |||
| CarlaPluginClient* const plugClient = (CarlaPluginClient*)client; | |||
| plugClient->showPluginGui(true); | |||
| if (gui && m_uiShow) | |||
| gui->setVisible(true); | |||
| } | |||
| void CarlaBridgeToolkitPlugin::hide() | |||
| { | |||
| qDebug("CarlaBridgeToolkitPlugin::hide()"); | |||
| CARLA_ASSERT(gui); | |||
| CarlaPluginClient* const plugClient = (CarlaPluginClient*)client; | |||
| if (gui && m_uiShow) | |||
| gui->setVisible(false); | |||
| plugClient->showPluginGui(false); | |||
| } | |||
| void CarlaBridgeToolkitPlugin::guiClosedCallback() | |||
| { | |||
| qDebug("CarlaBridgeToolkitPlugin::guiClosedCallback()"); | |||
| CarlaPluginClient* const plugClient = (CarlaPluginClient*)client; | |||
| if (m_uiQuit) | |||
| @@ -692,7 +728,13 @@ int main(int argc, char* argv[]) | |||
| engine->setCallback(client.callback, &client); | |||
| client.setEngine(engine); | |||
| if (! engine->init("")) | |||
| // Init engine | |||
| CarlaString engName(name ? name : label); | |||
| engName += " (master)"; | |||
| engName.toBasic(); | |||
| engName.truncate(engine->maxClientNameSize()); | |||
| if (! engine->init(engName)) | |||
| { | |||
| if (const char* const lastError = engine->getLastError()) | |||
| { | |||
| @@ -97,6 +97,7 @@ public: | |||
| { | |||
| qDebug("CarlaBridgeToolkitQt::~CarlaBridgeToolkitQt()"); | |||
| CARLA_ASSERT(! app); | |||
| CARLA_ASSERT(! window); | |||
| CARLA_ASSERT(! msgTimer); | |||
| } | |||
| @@ -568,6 +568,21 @@ public: | |||
| return false; | |||
| #else | |||
| // open temp client to get initial buffer-size and sample-rate values | |||
| if (bufferSize == 0 || sampleRate == 0.0) | |||
| { | |||
| m_client = jackbridge_client_open(clientName, JackNullOption, nullptr); | |||
| if (m_client) | |||
| { | |||
| bufferSize = jackbridge_get_buffer_size(m_client); | |||
| sampleRate = jackbridge_get_sample_rate(m_client); | |||
| jackbridge_client_close(m_client); | |||
| m_client = nullptr; | |||
| } | |||
| } | |||
| name = clientName; | |||
| name.toBasic(); | |||
| @@ -1063,8 +1063,10 @@ void CarlaPlugin::updateOscData(const lo_address source, const char* const url) | |||
| free((void*)host); | |||
| free((void*)port); | |||
| #ifndef BUILD_BRIDGE | |||
| if (m_hints & PLUGIN_IS_BRIDGE) | |||
| return; | |||
| #endif | |||
| osc_send_sample_rate(&osc.data, x_engine->getSampleRate()); | |||
| @@ -1581,6 +1583,7 @@ CarlaPluginGUI::~CarlaPluginGUI() | |||
| qDebug("CarlaPluginGUI::~CarlaPluginGUI()"); | |||
| CARLA_ASSERT(m_container); | |||
| // FIXME, automatically deleted by parent ? | |||
| delete m_container; | |||
| } | |||
| @@ -973,6 +973,8 @@ public: | |||
| void showGui(const bool yesNo) | |||
| { | |||
| qDebug("Lv2Plugin::showGui(%s)", bool2str(yesNo)); | |||
| switch(gui.type) | |||
| { | |||
| case GUI_NONE: | |||
| @@ -4241,7 +4243,7 @@ public: | |||
| break; | |||
| case LV2_UI_GTK2: | |||
| #ifdef WANT_SUIL | |||
| #if defined(WANT_SUIL) || defined(BUILD_BRIDGE) | |||
| if (isUiBridgeable(i) && preferUiBridges) | |||
| eGtk2 = i; | |||
| #else | |||
| @@ -4293,8 +4295,10 @@ public: | |||
| else if (iSuil >= 0) | |||
| iFinal = iSuil; | |||
| const bool isBridged = false; //(iFinal == eQt4 || iFinal == eCocoa || iFinal == eHWND || iFinal == eX11 || iFinal == eGtk2 || iFinal == eGtk3); | |||
| #ifdef WANT_SUIL | |||
| #ifndef WANT_SUIL | |||
| const bool isBridged = (iFinal == eQt4 || iFinal == eCocoa || iFinal == eHWND || iFinal == eX11 || iFinal == eGtk2 || iFinal == eGtk3); | |||
| #else | |||
| const bool isBridged = false; | |||
| const bool isSuil = (iFinal == iSuil && !isBridged); | |||
| #endif | |||
| @@ -1549,12 +1549,16 @@ public: | |||
| intptr_t handleAudioMasterGetBlockSize() | |||
| { | |||
| return x_engine->getBufferSize(); | |||
| const uint32_t bufferSize = x_engine->getBufferSize(); | |||
| effect->dispatcher(effect, effSetBlockSize, 0, bufferSize, nullptr, 0.0f); | |||
| return bufferSize; | |||
| } | |||
| intptr_t handleAudioMasterGetSampleRate() | |||
| { | |||
| return x_engine->getSampleRate(); | |||
| const double sampleRate = x_engine->getSampleRate(); | |||
| effect->dispatcher(effect, effSetSampleRate, 0, 0, nullptr, sampleRate); | |||
| return sampleRate; | |||
| } | |||
| intptr_t handleAudioMasterGetTime() | |||