From a5fcdedbe4b65caae42ccc24cb232c9ba263dfeb Mon Sep 17 00:00:00 2001 From: falkTX Date: Thu, 30 Nov 2017 21:19:52 +0000 Subject: [PATCH] Run MacOS event loop in plugin bridges --- source/bridges-plugin/Makefile | 41 ++++++++++++++++++---------------- source/utils/CarlaMainLoop.hpp | 27 ++++++++++++++++++++-- 2 files changed, 47 insertions(+), 21 deletions(-) diff --git a/source/bridges-plugin/Makefile b/source/bridges-plugin/Makefile index eadf51dcc..df5d11373 100644 --- a/source/bridges-plugin/Makefile +++ b/source/bridges-plugin/Makefile @@ -206,44 +206,47 @@ $(BINDIR)/$(MODULENAME)-win64.exe: $(OBJS_win64) $(LIBS_win64) # ---------------------------------------------------------------------------------------------------------------------- # native -$(OBJDIR)/CarlaBridgeLV2.cpp.o: CarlaBridgeLV2.cpp +ifeq ($(MACOS),true) +$(OBJDIR)/CarlaPluginVST2.cpp.o: $(CWD)/backend/plugin/CarlaPluginVST2.cpp -@mkdir -p $(OBJDIR) - @echo "Compiling $<" - @$(CXX) $< $(BUILD_CXX_FLAGS) $(NATIVE_BUILD_FLAGS) -c -o $@ + @echo "Compiling CarlaPluginVST2.cpp (bridge)" + @$(CXX) $< $(BUILD_CXX_FLAGS) $(NATIVE_BUILD_FLAGS) -ObjC++ -c -o $@ + +$(OBJDIR)/CarlaStandalone.cpp.o: $(CWD)/backend/CarlaStandalone.cpp + -@mkdir -p $(OBJDIR) + @echo "Compiling CarlaStandalone.cpp (bridge)" + @$(CXX) $< $(BUILD_CXX_FLAGS) $(NATIVE_BUILD_FLAGS) -ObjC++ -c -o $@ $(OBJDIR)/CarlaBridgePlugin.cpp.o: CarlaBridgePlugin.cpp -@mkdir -p $(OBJDIR) @echo "Compiling $<" + @$(CXX) $< $(BUILD_CXX_FLAGS) $(NATIVE_BUILD_FLAGS) -ObjC++ -c -o $@ +else +$(OBJDIR)/CarlaStandalone.cpp.o: $(CWD)/backend/CarlaStandalone.cpp + -@mkdir -p $(OBJDIR) + @echo "Compiling CarlaStandalone.cpp (bridge)" @$(CXX) $< $(BUILD_CXX_FLAGS) $(NATIVE_BUILD_FLAGS) -c -o $@ -$(OBJDIR)/CarlaEng%.cpp.o: $(CWD)/backend/engine/CarlaEng%.cpp +$(OBJDIR)/CarlaBridgePlugin.cpp.o: CarlaBridgePlugin.cpp -@mkdir -p $(OBJDIR) - @echo "Compiling CarlaEng$*.cpp (bridge)" + @echo "Compiling $<" @$(CXX) $< $(BUILD_CXX_FLAGS) $(NATIVE_BUILD_FLAGS) -c -o $@ +endif -ifeq ($(MACOS),true) -$(OBJDIR)/CarlaPluginVST2.cpp.o: $(CWD)/backend/plugin/CarlaPluginVST2.cpp +$(OBJDIR)/CarlaBridgeLV2.cpp.o: CarlaBridgeLV2.cpp -@mkdir -p $(OBJDIR) - @echo "Compiling CarlaPluginVST2.cpp (bridge)" - @$(CXX) $< $(BUILD_CXX_FLAGS) $(NATIVE_BUILD_FLAGS) -ObjC++ -c -o $@ -endif + @echo "Compiling $<" + @$(CXX) $< $(BUILD_CXX_FLAGS) $(NATIVE_BUILD_FLAGS) -c -o $@ $(OBJDIR)/CarlaPlug%.cpp.o: $(CWD)/backend/plugin/CarlaPlug%.cpp -@mkdir -p $(OBJDIR) @echo "Compiling CarlaPlug$*.cpp (bridge)" @$(CXX) $< $(BUILD_CXX_FLAGS) $(NATIVE_BUILD_FLAGS) -c -o $@ -ifeq ($(MACOS),true) -$(OBJDIR)/CarlaStandalone.cpp.o: $(CWD)/backend/CarlaStandalone.cpp - -@mkdir -p $(OBJDIR) - @echo "Compiling CarlaStandalone.cpp (bridge)" - @$(CXX) $< $(BUILD_CXX_FLAGS) $(NATIVE_BUILD_FLAGS) -ObjC++ -c -o $@ -else -$(OBJDIR)/CarlaStandalone.cpp.o: $(CWD)/backend/CarlaStandalone.cpp +$(OBJDIR)/CarlaEng%.cpp.o: $(CWD)/backend/engine/CarlaEng%.cpp -@mkdir -p $(OBJDIR) - @echo "Compiling CarlaStandalone.cpp (bridge)" + @echo "Compiling CarlaEng$*.cpp (bridge)" @$(CXX) $< $(BUILD_CXX_FLAGS) $(NATIVE_BUILD_FLAGS) -c -o $@ -endif # ---------------------------------------------------------------------------------------------------------------------- # posix32 diff --git a/source/utils/CarlaMainLoop.hpp b/source/utils/CarlaMainLoop.hpp index 84b64bd5d..4c3031b7e 100644 --- a/source/utils/CarlaMainLoop.hpp +++ b/source/utils/CarlaMainLoop.hpp @@ -1,5 +1,5 @@ /* - * Carla DSSI utils + * Carla Main-Loop utils * Copyright (C) 2017 Filipe Coelho * * This program is free software; you can redistribute it and/or @@ -21,6 +21,10 @@ #include "CarlaBackend.h" #include "CarlaUtils.hpp" +#ifdef CARLA_OS_MAC +# import +#endif + // --------------------------------------------------------------------------------------------------------------------- CARLA_BACKEND_START_NAMESPACE @@ -28,7 +32,26 @@ CARLA_BACKEND_START_NAMESPACE static inline bool runMainLoopOnce() { -#if defined(CARLA_OS_WIN) +#if defined(CARLA_OS_MAC) + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + NSEvent* event; + + for (;;) + { + event = [NSApp + nextEventMatchingMask:NSAnyEventMask + untilDate:[NSDate distantPast] + inMode:NSDefaultRunLoopMode + dequeue:YES]; + + if (event == nil) + break; + + [NSApp sendEvent: event]; + } + + [pool release]; +#elif defined(CARLA_OS_WIN) MSG msg; if (! ::PeekMessage(&msg, nullptr, 0, 0, PM_NOREMOVE)) return true;