diff --git a/source/bridges-plugin/CarlaBridgePlugin.cpp b/source/bridges-plugin/CarlaBridgePlugin.cpp index 8c312eca3..9085eb815 100644 --- a/source/bridges-plugin/CarlaBridgePlugin.cpp +++ b/source/bridges-plugin/CarlaBridgePlugin.cpp @@ -229,7 +229,7 @@ public: gIsInitiated = true; #if defined(USING_JUCE) && (defined(CARLA_OS_MAC) || defined(CARLA_OS_WIN)) - CarlaJUCE::setupAndUseMainApplication(); + CarlaJUCE::setupAndUseMainApplication(gIdle, &gCloseNow); #else int64_t timeToEnd = 0; diff --git a/source/bridges-plugin/Makefile b/source/bridges-plugin/Makefile index 31f1726e9..cce113e66 100644 --- a/source/bridges-plugin/Makefile +++ b/source/bridges-plugin/Makefile @@ -366,6 +366,11 @@ $(OBJDIR)/CarlaBridgePlugin.cpp.arm32.o: CarlaBridgePlugin.cpp @echo "Compiling $< (arm32 bridge)" $(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(ARM32_FLAGS) -c -o $@ +$(OBJDIR)/CarlaPluginJuce.arm32.o: $(CWD)/backend/plugin/CarlaPluginJuce.cpp + -@mkdir -p $(OBJDIR) + @echo "Compiling CarlaPluginJuce.cpp (arm32 bridge)" + $(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(ARM32_FLAGS) -std=gnu++14 -c -o $@ + $(OBJDIR)/CarlaStandalone.cpp.arm32.o: $(CWD)/backend/CarlaStandalone.cpp -@mkdir -p $(OBJDIR) @echo "Compiling CarlaStandalone.cpp (arm32 bridge)" @@ -393,7 +398,7 @@ $(OBJDIR)/CarlaPluginVST2.cpp.posix32.o: $(CWD)/backend/plugin/CarlaPluginVST2.c $(OBJDIR)/CarlaPluginJuce.cpp.posix32.o: $(CWD)/backend/plugin/CarlaPluginJuce.cpp -@mkdir -p $(OBJDIR) @echo "Compiling CarlaPluginJuce.cpp (posix32 bridge)" - $(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(32BIT_FLAGS) -ObjC++ -c -o $@ + $(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(32BIT_FLAGS) -ObjC++ -std=gnu++14 -c -o $@ $(OBJDIR)/CarlaBridgePlugin.cpp.posix32.o: CarlaBridgePlugin.cpp -@mkdir -p $(OBJDIR) @@ -405,6 +410,11 @@ $(OBJDIR)/CarlaStandalone.cpp.posix32.o: $(CWD)/backend/CarlaStandalone.cpp @echo "Compiling CarlaStandalone.cpp (posix32 bridge)" $(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(32BIT_FLAGS) -ObjC++ -c -o $@ else +$(OBJDIR)/CarlaPluginJuce.cpp.posix32.o: $(CWD)/backend/plugin/CarlaPluginJuce.cpp + -@mkdir -p $(OBJDIR) + @echo "Compiling CarlaPluginJuce.cpp (posix32 bridge)" + $(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(32BIT_FLAGS) -std=gnu++14 -c -o $@ + $(OBJDIR)/CarlaBridgePlugin.cpp.posix32.o: CarlaBridgePlugin.cpp -@mkdir -p $(OBJDIR) @echo "Compiling $< (posix32 bridge)" @@ -438,7 +448,7 @@ $(OBJDIR)/CarlaPluginVST2.cpp.posix64.o: $(CWD)/backend/plugin/CarlaPluginVST2.c $(OBJDIR)/CarlaPluginJuce.cpp.posix64.o: $(CWD)/backend/plugin/CarlaPluginJuce.cpp -@mkdir -p $(OBJDIR) @echo "Compiling CarlaPluginJuce.cpp (posix64 bridge)" - $(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(64BIT_FLAGS) -ObjC++ -c -o $@ + $(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(64BIT_FLAGS) -ObjC++ -std=gnu++14 -c -o $@ $(OBJDIR)/CarlaBridgePlugin.cpp.posix64.o: CarlaBridgePlugin.cpp -@mkdir -p $(OBJDIR) @@ -450,6 +460,11 @@ $(OBJDIR)/CarlaStandalone.cpp.posix64.o: $(CWD)/backend/CarlaStandalone.cpp @echo "Compiling CarlaStandalone.cpp (posix64 bridge)" $(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(64BIT_FLAGS) -ObjC++ -c -o $@ else +$(OBJDIR)/CarlaPluginJuce.cpp.posix64.o: $(CWD)/backend/plugin/CarlaPluginJuce.cpp + -@mkdir -p $(OBJDIR) + @echo "Compiling CarlaPluginJuce.cpp (posix64 bridge)" + $(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(64BIT_FLAGS) -std=gnu++14 -c -o $@ + $(OBJDIR)/CarlaBridgePlugin.cpp.posix64.o: CarlaBridgePlugin.cpp -@mkdir -p $(OBJDIR) @echo "Compiling $< (posix64 bridge)" @@ -479,6 +494,16 @@ $(OBJDIR)/CarlaBridgePlugin.cpp.win32.o: CarlaBridgePlugin.cpp @echo "Compiling $< (win32 bridge)" $(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(32BIT_FLAGS) -c -o $@ +$(OBJDIR)/CarlaPluginJuce.cpp.win32.o: $(CWD)/backend/plugin/CarlaPluginJuce.cpp + -@mkdir -p $(OBJDIR) + @echo "Compiling CarlaPluginJuce.cpp (win32 bridge)" + $(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(32BIT_FLAGS) -std=gnu++14 -c -o $@ + +$(OBJDIR)/CarlaStandalone.cpp.win32.o: $(CWD)/backend/CarlaStandalone.cpp + -@mkdir -p $(OBJDIR) + @echo "Compiling CarlaStandalone.cpp (win32 bridge)" + $(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(32BIT_FLAGS) -c -o $@ + $(OBJDIR)/CarlaEng%.cpp.win32.o: $(CWD)/backend/engine/CarlaEng%.cpp -@mkdir -p $(OBJDIR) @echo "Compiling CarlaEng$*.cpp (win32 bridge)" @@ -489,11 +514,6 @@ $(OBJDIR)/CarlaPlug%.cpp.win32.o: $(CWD)/backend/plugin/CarlaPlug%.cpp @echo "Compiling CarlaPlug$*.cpp (win32 bridge)" $(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(32BIT_FLAGS) -c -o $@ -$(OBJDIR)/CarlaStandalone.cpp.win32.o: $(CWD)/backend/CarlaStandalone.cpp - -@mkdir -p $(OBJDIR) - @echo "Compiling CarlaStandalone.cpp (win32 bridge)" - $(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(32BIT_FLAGS) -c -o $@ - # --------------------------------------------------------------------------------------------------------------------- # win64 @@ -502,6 +522,16 @@ $(OBJDIR)/CarlaBridgePlugin.cpp.win64.o: CarlaBridgePlugin.cpp @echo "Compiling $< (win64 bridge)" $(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(64BIT_FLAGS) -c -o $@ +$(OBJDIR)/CarlaPluginJuce.cpp.win64.o: $(CWD)/backend/plugin/CarlaPluginJuce.cpp + -@mkdir -p $(OBJDIR) + @echo "Compiling CarlaPluginJuce.cpp (win64 bridge)" + $(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(64BIT_FLAGS) -std=gnu++14 -c -o $@ + +$(OBJDIR)/CarlaStandalone.cpp.win64.o: $(CWD)/backend/CarlaStandalone.cpp + -@mkdir -p $(OBJDIR) + @echo "Compiling CarlaStandalone.cpp (win64 bridge)" + $(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(64BIT_FLAGS) -c -o $@ + $(OBJDIR)/CarlaEng%.cpp.win64.o: $(CWD)/backend/engine/CarlaEng%.cpp -@mkdir -p $(OBJDIR) @echo "Compiling CarlaEng$*.cpp (win64 bridge)" @@ -512,11 +542,6 @@ $(OBJDIR)/CarlaPlug%.cpp.win64.o: $(CWD)/backend/plugin/CarlaPlug%.cpp @echo "Compiling CarlaPlug$*.cpp (win64 bridge)" $(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(64BIT_FLAGS) -c -o $@ -$(OBJDIR)/CarlaStandalone.cpp.win64.o: $(CWD)/backend/CarlaStandalone.cpp - -@mkdir -p $(OBJDIR) - @echo "Compiling CarlaStandalone.cpp (win64 bridge)" - $(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(64BIT_FLAGS) -c -o $@ - # --------------------------------------------------------------------------------------------------------------------- -include $(OBJS_lv2:%.o=%.d) diff --git a/source/modules/carla_juce/carla_juce.cpp b/source/modules/carla_juce/carla_juce.cpp index c63b49069..097d143c5 100644 --- a/source/modules/carla_juce/carla_juce.cpp +++ b/source/modules/carla_juce/carla_juce.cpp @@ -123,6 +123,9 @@ void dispatchMessageManagerMessages() #endif #ifdef USE_STANDALONE_JUCE_APPLICATION +static std::function sIdleFn; +static volatile bool* sClosedSignalPtr; + class CarlaJuceApp : public juce::JUCEApplication, private juce::Timer { @@ -137,7 +140,7 @@ public: void shutdown() override { - gCloseNow = true; + *sClosedSignalPtr = true; stopTimer(); } @@ -153,23 +156,26 @@ public: void timerCallback() override { - gIdle(); + sIdleFn(); - if (gCloseNow) + if (*sClosedSignalPtr) { quit(); - gCloseNow = false; + *sClosedSignalPtr = false; } } }; -void setupAndUseMainApplication() +static juce::JUCEApplicationBase* juce_CreateApplication() { return new CarlaJuceApp(); } + +void setupAndUseMainApplication(std::function idleFn, volatile bool* closedSignalPtr) { #ifndef CARLA_OS_WIN static const int argc = 0; static const char* argv[] = {}; #endif - static juce::JUCEApplicationBase* juce_CreateApplication() { return new CarlaJuceApp(); } + sIdleFn = idleFn; + sClosedSignalPtr = closedSignalPtr; juce::JUCEApplicationBase::createInstance = &juce_CreateApplication; juce::JUCEApplicationBase::main(JUCE_MAIN_FUNCTION_ARGS); } diff --git a/source/modules/carla_juce/carla_juce.h b/source/modules/carla_juce/carla_juce.h index e0ac3ad1b..2870003ae 100644 --- a/source/modules/carla_juce/carla_juce.h +++ b/source/modules/carla_juce/carla_juce.h @@ -29,6 +29,10 @@ # endif #endif +#ifdef USE_STANDALONE_JUCE_APPLICATION +# include +#endif + namespace juce { class MessageManager; } @@ -58,7 +62,7 @@ void dispatchMessageManagerMessages(); #endif #ifdef USE_STANDALONE_JUCE_APPLICATION -void setupAndUseMainApplication(); +void setupAndUseMainApplication(std::function idleFn, volatile bool* closedSignalPtr); #endif } // namespace CarlaJUCE