Browse Source

More pipe work; Enable extui-plugins on Windows

tags/1.9.6
falkTX 11 years ago
parent
commit
ccfc583958
13 changed files with 103 additions and 81 deletions
  1. +4
    -1
      source/backend/Makefile
  2. +7
    -6
      source/backend/engine/CarlaEngineNative.cpp
  3. +4
    -10
      source/backend/engine/Makefile
  4. +1
    -1
      source/carla_app.py
  5. +5
    -5
      source/discovery/carla-discovery.cpp
  6. +30
    -32
      source/externalui.py
  7. +1
    -1
      source/modules/jackbridge/JackBridge1.cpp
  8. +0
    -2
      source/modules/native-plugins/Makefile
  9. +0
    -4
      source/modules/native-plugins/_all.c
  10. +1
    -5
      source/modules/native-plugins/bigmeter.cpp
  11. +1
    -5
      source/modules/native-plugins/notes.cpp
  12. +6
    -0
      source/modules/native-plugins/resources/carla-plugin
  13. +43
    -9
      source/utils/CarlaPipeUtils.cpp

+ 4
- 1
source/backend/Makefile View File

@@ -79,7 +79,10 @@ ifeq ($(UNIX),true)
STANDALONE_FLAGS += -lmagic STANDALONE_FLAGS += -lmagic
endif endif


UTILS_FLAGS = $(JUCE_CORE_LIBS)
UTILS_FLAGS = $(JUCE_CORE_LIBS)
ifneq ($(HAIKU),true)
UTILS_FLAGS += -lpthread
endif


# -------------------------------------------------------------- # --------------------------------------------------------------




+ 7
- 6
source/backend/engine/CarlaEngineNative.cpp View File

@@ -20,9 +20,6 @@
#ifdef BUILD_BRIDGE #ifdef BUILD_BRIDGE
# error This file should not be compiled if building bridge # error This file should not be compiled if building bridge
#endif #endif
#ifdef CARLA_OS_WIN
# error This file should not be compiled for Windows
#endif


#include "CarlaEngineInternal.hpp" #include "CarlaEngineInternal.hpp"
#include "CarlaPlugin.hpp" #include "CarlaPlugin.hpp"
@@ -1418,10 +1415,12 @@ protected:
CarlaString path(pHost->resourceDir); CarlaString path(pHost->resourceDir);


if (kIsPatchbay) if (kIsPatchbay)
path += "/carla-plugin-patchbay";
path += CARLA_OS_SEP_STR "carla-plugin-patchbay";
else else
path += "/carla-plugin";

path += CARLA_OS_SEP_STR "carla-plugin";
#ifdef CARLA_OS_WIN
path += ".exe";
#endif
carla_stdout("Trying to start carla-plugin using \"%s\"", path.buffer()); carla_stdout("Trying to start carla-plugin using \"%s\"", path.buffer());


fUiServer.setData(path, pData->sampleRate, pHost->uiName); fUiServer.setData(path, pData->sampleRate, pHost->uiName);
@@ -1463,6 +1462,7 @@ protected:
const CarlaMutexLocker cml(fUiServer.getLock()); const CarlaMutexLocker cml(fUiServer.getLock());
const ScopedLocale csl; const ScopedLocale csl;


#ifndef CARLA_OS_WIN // FIXME
// send transport // send transport
fUiServer.writeAndFixMsg("transport"); fUiServer.writeAndFixMsg("transport");
fUiServer.writeMsg(timeInfo.playing ? "true\n" : "false\n"); fUiServer.writeMsg(timeInfo.playing ? "true\n" : "false\n");
@@ -1482,6 +1482,7 @@ protected:
} }


fUiServer.flush(); fUiServer.flush();
#endif


// send peaks and param outputs for all plugins // send peaks and param outputs for all plugins
for (uint i=0; i < pData->curPluginCount; ++i) for (uint i=0; i < pData->curPluginCount; ++i)


+ 4
- 10
source/backend/engine/Makefile View File

@@ -20,23 +20,17 @@ OBJS = \
CarlaEngineThread.cpp.o CarlaEngineThread.cpp.o


OBJSa = $(OBJS) \ OBJSa = $(OBJS) \
CarlaEngineJack.cpp.o
CarlaEngineJack.cpp.o \
CarlaEngineNative.cpp.o


ifeq ($(MACOS_OR_WIN32),true) ifeq ($(MACOS_OR_WIN32),true)
OBJSa += \
CarlaEngineJuce.cpp.o
OBJSa += CarlaEngineJuce.cpp.o
else else
OBJSa += \
CarlaEngineRtAudio.cpp.o
OBJSa += CarlaEngineRtAudio.cpp.o
endif endif


ifneq ($(WIN32),true)
OBJSa += \
CarlaEngineNative.cpp.o

OBJSp = $(OBJS) \ OBJSp = $(OBJS) \
CarlaEngineNative.cpp.exp.o CarlaEngineNative.cpp.exp.o
endif


TARGETS = \ TARGETS = \
../carla_engine.a \ ../carla_engine.a \


+ 1
- 1
source/carla_app.py View File

@@ -50,7 +50,7 @@ class CarlaApplication(object):
QApplication.addLibraryPath(CWD) QApplication.addLibraryPath(CWD)


# Needed for local wine build # Needed for local wine build
if WINDOWS and CWD.endswith("source"):
if WINDOWS and (CWD.endswith("source") or os.getenv("CXFREEZE") is not None):
QApplication.addLibraryPath("C:\\Python34\\Lib\\site-packages\\PyQt5\\plugins") QApplication.addLibraryPath("C:\\Python34\\Lib\\site-packages\\PyQt5\\plugins")


# Use binary dir as library path (except in Windows) # Use binary dir as library path (except in Windows)


+ 5
- 5
source/discovery/carla-discovery.cpp View File

@@ -401,7 +401,7 @@ private:


// ------------------------------ Plugin Checks ----------------------------- // ------------------------------ Plugin Checks -----------------------------


static void do_ladspa_check(void*& libHandle, const char* const filename, const bool doInit)
static void do_ladspa_check(lib_t& libHandle, const char* const filename, const bool doInit)
{ {
LADSPA_Descriptor_Function descFn = lib_symbol<LADSPA_Descriptor_Function>(libHandle, "ladspa_descriptor"); LADSPA_Descriptor_Function descFn = lib_symbol<LADSPA_Descriptor_Function>(libHandle, "ladspa_descriptor");


@@ -634,7 +634,7 @@ static void do_ladspa_check(void*& libHandle, const char* const filename, const
} }
} }


static void do_dssi_check(void*& libHandle, const char* const filename, const bool doInit)
static void do_dssi_check(lib_t& libHandle, const char* const filename, const bool doInit)
{ {
DSSI_Descriptor_Function descFn = lib_symbol<DSSI_Descriptor_Function>(libHandle, "dssi_descriptor"); DSSI_Descriptor_Function descFn = lib_symbol<DSSI_Descriptor_Function>(libHandle, "dssi_descriptor");


@@ -984,7 +984,7 @@ static void do_lv2_check(const char* const bundle, const bool doInit)
if (doInit) if (doInit)
{ {
// test if DLL is loadable, twice // test if DLL is loadable, twice
void* const libHandle1 = lib_open(rdfDescriptor->Binary);
const lib_t libHandle1 = lib_open(rdfDescriptor->Binary);


if (libHandle1 == nullptr) if (libHandle1 == nullptr)
{ {
@@ -995,7 +995,7 @@ static void do_lv2_check(const char* const bundle, const bool doInit)


lib_close(libHandle1); lib_close(libHandle1);


void* const libHandle2 = lib_open(rdfDescriptor->Binary);
const lib_t libHandle2 = lib_open(rdfDescriptor->Binary);


if (libHandle2 == nullptr) if (libHandle2 == nullptr)
{ {
@@ -1142,7 +1142,7 @@ static void do_lv2_check(const char* const bundle, const bool doInit)
} }


#ifndef CARLA_OS_MAC #ifndef CARLA_OS_MAC
static void do_vst_check(void*& libHandle, const bool doInit)
static void do_vst_check(lib_t& libHandle, const bool doInit)
{ {
VST_Function vstFn = lib_symbol<VST_Function>(libHandle, "VSTPluginMain"); VST_Function vstFn = lib_symbol<VST_Function>(libHandle, "VSTPluginMain");




+ 30
- 32
source/externalui.py View File

@@ -16,11 +16,6 @@
# #
# For a full copy of the GNU General Public License see the doc/GPL.txt file. # For a full copy of the GNU General Public License see the doc/GPL.txt file.


# ------------------------------------------------------------------------------------------------------------
# Imports (Global)

from sys import argv

# ------------------------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------------------------------
# Imports (Custom Stuff) # Imports (Custom Stuff)


@@ -35,9 +30,9 @@ class ExternalUI(object):


self.fQuitReceived = False self.fQuitReceived = False


if len(argv) > 1:
self.fSampleRate = float(argv[1])
self.fUiName = argv[2]
if len(sys.argv) > 1:
self.fSampleRate = float(sys.argv[1])
self.fUiName = sys.argv[2]
self.fPipeClient = gCarla.utils.pipe_client_new(lambda s,msg: self.msgCallback(msg)) self.fPipeClient = gCarla.utils.pipe_client_new(lambda s,msg: self.msgCallback(msg))
else: else:
self.fSampleRate = 44100.0 self.fSampleRate = 44100.0
@@ -48,10 +43,7 @@ class ExternalUI(object):
# Public methods # Public methods


def ready(self): def ready(self):
if self.fPipeClient is not None:
# send empty line (just newline char)
self.send([""])
else:
if self.fPipeClient is None:
# testing, show UI only # testing, show UI only
self.uiShow() self.uiShow()


@@ -65,12 +57,14 @@ class ExternalUI(object):
gCarla.utils.pipe_client_idle(self.fPipeClient) gCarla.utils.pipe_client_idle(self.fPipeClient)


def closeExternalUI(self): def closeExternalUI(self):
if self.fPipeClient is None:
return

if not self.fQuitReceived: if not self.fQuitReceived:
self.send(["exiting"]) self.send(["exiting"])


if self.fPipeClient is not None:
gCarla.utils.pipe_client_destroy(self.fPipeClient)
self.fPipeClient = None
gCarla.utils.pipe_client_destroy(self.fPipeClient)
self.fPipeClient = None


# ------------------------------------------------------------------- # -------------------------------------------------------------------
# Host DSP State # Host DSP State
@@ -176,7 +170,7 @@ class ExternalUI(object):
if self.fPipeClient is None: if self.fPipeClient is None:
return "" return ""


return gCarla.utils.pipe_client_readlineblock(self.fPipeClient, 50)
return gCarla.utils.pipe_client_readlineblock(self.fPipeClient, 5000)


def send(self, lines): def send(self, lines):
if self.fPipeClient is None or len(lines) == 0: if self.fPipeClient is None or len(lines) == 0:
@@ -184,21 +178,25 @@ class ExternalUI(object):


gCarla.utils.pipe_client_lock(self.fPipeClient) gCarla.utils.pipe_client_lock(self.fPipeClient)


for line in lines:
if line is None:
line2 = "(null)"
elif isinstance(line, str):
line2 = line.replace("\n", "\r")
elif isinstance(line, bool):
line2 = "true" if line else "false"
elif isinstance(line, int):
line2 = "%i" % line
elif isinstance(line, float):
line2 = "%.10f" % line
else:
print("unknown data type to send:", type(line))
return

gCarla.utils.pipe_client_write_msg(self.fPipeClient, line2 + "\n")
# this must never fail, we need to unlock at the end
try:
for line in lines:
if line is None:
line2 = "(null)"
elif isinstance(line, str):
line2 = line.replace("\n", "\r")
elif isinstance(line, bool):
line2 = "true" if line else "false"
elif isinstance(line, int):
line2 = "%i" % line
elif isinstance(line, float):
line2 = "%.10f" % line
else:
print("unknown data type to send:", type(line))
return

gCarla.utils.pipe_client_write_msg(self.fPipeClient, line2 + "\n")
except:
pass


gCarla.utils.pipe_client_flush_and_unlock(self.fPipeClient) gCarla.utils.pipe_client_flush_and_unlock(self.fPipeClient)

+ 1
- 1
source/modules/jackbridge/JackBridge1.cpp View File

@@ -140,7 +140,7 @@ typedef int (__cdecl *jacksym_set_property_change_callback)(jack_client_t*, Jac
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------


struct JackBridge { struct JackBridge {
void* lib;
lib_t lib;


jacksym_get_version get_version_ptr; jacksym_get_version get_version_ptr;
jacksym_get_version_string get_version_string_ptr; jacksym_get_version_string get_version_string_ptr;


+ 0
- 2
source/modules/native-plugins/Makefile View File

@@ -57,14 +57,12 @@ OBJS += \
audio-file.cpp.o \ audio-file.cpp.o \
midi-file.cpp.o midi-file.cpp.o


ifneq ($(WIN32),true)
# -------------------------------------------------------------- # --------------------------------------------------------------
# External-UI plugins # External-UI plugins


OBJS += \ OBJS += \
bigmeter.cpp.o \ bigmeter.cpp.o \
notes.cpp.o notes.cpp.o
endif


# -------------------------------------------------------------- # --------------------------------------------------------------
# ZynAddSubFX # ZynAddSubFX


+ 0
- 4
source/modules/native-plugins/_all.c View File

@@ -32,14 +32,12 @@ extern void carla_register_native_plugin_audiofile(void);
// MIDI File // MIDI File
extern void carla_register_native_plugin_midifile(void); extern void carla_register_native_plugin_midifile(void);


#ifndef CARLA_OS_WIN
// Carla // Carla
extern void carla_register_native_plugin_carla(void); extern void carla_register_native_plugin_carla(void);


// External-UI plugins // External-UI plugins
extern void carla_register_native_plugin_bigmeter(void); extern void carla_register_native_plugin_bigmeter(void);
extern void carla_register_native_plugin_notes(void); extern void carla_register_native_plugin_notes(void);
#endif


#ifdef WANT_ZYNADDSUBFX #ifdef WANT_ZYNADDSUBFX
// ZynAddSubFX // ZynAddSubFX
@@ -66,14 +64,12 @@ void carla_register_all_plugins(void)
// MIDI File // MIDI File
carla_register_native_plugin_midifile(); carla_register_native_plugin_midifile();


#ifndef CARLA_OS_WIN
// Carla // Carla
carla_register_native_plugin_carla(); carla_register_native_plugin_carla();


// External-UI plugins // External-UI plugins
carla_register_native_plugin_bigmeter(); carla_register_native_plugin_bigmeter();
carla_register_native_plugin_notes(); carla_register_native_plugin_notes();
#endif


#ifdef WANT_ZYNADDSUBFX #ifdef WANT_ZYNADDSUBFX
// ZynAddSubFX // ZynAddSubFX


+ 1
- 5
source/modules/native-plugins/bigmeter.cpp View File

@@ -17,10 +17,6 @@


#include "CarlaDefines.h" #include "CarlaDefines.h"


#ifdef CARLA_OS_WIN
# error This file should not be compiled for Windows
#endif

#include "CarlaMathUtils.hpp" #include "CarlaMathUtils.hpp"
#include "CarlaNativeExtUI.hpp" #include "CarlaNativeExtUI.hpp"


@@ -34,7 +30,7 @@ class BigMeterPlugin : public NativePluginAndUiClass
{ {
public: public:
BigMeterPlugin(const NativeHostDescriptor* const host) BigMeterPlugin(const NativeHostDescriptor* const host)
: NativePluginAndUiClass(host, "/bigmeter-ui"),
: NativePluginAndUiClass(host, CARLA_OS_SEP_STR "bigmeter-ui"),
fColor(1), fColor(1),
fStyle(1), fStyle(1),
fOutLeft(0.0f), fOutLeft(0.0f),


+ 1
- 5
source/modules/native-plugins/notes.cpp View File

@@ -17,10 +17,6 @@


#include "CarlaDefines.h" #include "CarlaDefines.h"


#ifdef CARLA_OS_WIN
# error This file should not be compiled for Windows
#endif

#include "CarlaNativeExtUI.hpp" #include "CarlaNativeExtUI.hpp"


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -29,7 +25,7 @@ class NotesPlugin : public NativePluginAndUiClass
{ {
public: public:
NotesPlugin(const NativeHostDescriptor* const host) NotesPlugin(const NativeHostDescriptor* const host)
: NativePluginAndUiClass(host, "/notes-ui"),
: NativePluginAndUiClass(host, CARLA_OS_SEP_STR "notes-ui"),
fCurPage(1), fCurPage(1),
leakDetector_NotesPlugin() {} leakDetector_NotesPlugin() {}




+ 6
- 0
source/modules/native-plugins/resources/carla-plugin View File

@@ -117,6 +117,12 @@ class CarlaMiniW(ExternalUI, HostWindow):
# Custom callback # Custom callback


def msgCallback(self, msg): def msgCallback(self, msg):
try:
self.msgCallback2(msg)
except:
print("msgCallback error, skipped for", msg)

def msgCallback2(self, msg):
msg = charPtrToString(msg) msg = charPtrToString(msg)


#if not msg: #if not msg:


+ 43
- 9
source/utils/CarlaPipeUtils.cpp View File

@@ -60,7 +60,7 @@ struct OverlappedEvent {
}; };


static inline static inline
ssize_t ReadFileNonBlock(const HANDLE pipeh, const HANDLE cancelh, void* buf, size_t numBytes)
ssize_t ReadFileNonBlock(const HANDLE pipeh, const HANDLE cancelh, void* const buf, const std::size_t numBytes)
{ {
DWORD dsize; DWORD dsize;
OverlappedEvent over; OverlappedEvent over;
@@ -68,17 +68,47 @@ ssize_t ReadFileNonBlock(const HANDLE pipeh, const HANDLE cancelh, void* buf, si
if (::ReadFile(pipeh, buf, numBytes, &dsize, &over.over) != FALSE) if (::ReadFile(pipeh, buf, numBytes, &dsize, &over.over) != FALSE)
return static_cast<ssize_t>(dsize); return static_cast<ssize_t>(dsize);


if (GetLastError() == ERROR_IO_PENDING)
if (::GetLastError() == ERROR_IO_PENDING)
{ {
HANDLE handles[] = { over.over.hEvent, cancelh }; HANDLE handles[] = { over.over.hEvent, cancelh };


if (WaitForMultipleObjects(2, handles, FALSE, 0) != WAIT_OBJECT_0)
if (::WaitForMultipleObjects(2, handles, FALSE, 0) != WAIT_OBJECT_0)
{ {
CancelIo(pipeh);
::CancelIo(pipeh);
return -1; return -1;
} }


if (GetOverlappedResult(pipeh, &over.over, &dsize, FALSE) != FALSE)
if (::GetOverlappedResult(pipeh, &over.over, &dsize, FALSE) != FALSE)
return static_cast<ssize_t>(dsize);
}

return -1;
}
static inline
ssize_t WriteFileNonBlock(const HANDLE pipeh, const HANDLE cancelh, const void* const buf, const std::size_t numBytes)
{
DWORD dsize;
if (::WriteFile(pipeh, buf, numBytes, &dsize, nullptr) != FALSE)
return static_cast<ssize_t>(dsize);
return -1;

//DWORD dsize;
OverlappedEvent over;

if (::WriteFile(pipeh, buf, numBytes, &dsize, &over.over) != FALSE)
return static_cast<ssize_t>(dsize);

if (::GetLastError() == ERROR_IO_PENDING)
{
HANDLE handles[] = { over.over.hEvent, cancelh };

if (::WaitForMultipleObjects(2, handles, FALSE, 0) != WAIT_OBJECT_0)
{
::CancelIo(pipeh);
return -1;
}

if (::GetOverlappedResult(pipeh, &over.over, &dsize, FALSE) != FALSE)
return static_cast<ssize_t>(dsize); return static_cast<ssize_t>(dsize);
} }


@@ -113,12 +143,12 @@ bool startProcess(const char* const argv[], PROCESS_INFORMATION& processInfo)


STARTUPINFOW startupInfo; STARTUPINFOW startupInfo;
carla_zeroStruct(startupInfo); carla_zeroStruct(startupInfo);
//# if 1
# if 0
startupInfo.hStdInput = INVALID_HANDLE_VALUE; startupInfo.hStdInput = INVALID_HANDLE_VALUE;
startupInfo.hStdOutput = INVALID_HANDLE_VALUE; startupInfo.hStdOutput = INVALID_HANDLE_VALUE;
startupInfo.hStdError = INVALID_HANDLE_VALUE; startupInfo.hStdError = INVALID_HANDLE_VALUE;
startupInfo.dwFlags = STARTF_USESTDHANDLES; startupInfo.dwFlags = STARTF_USESTDHANDLES;
//# endif
# endif
startupInfo.cb = sizeof(STARTUPINFOW); startupInfo.cb = sizeof(STARTUPINFOW);


return CreateProcessW(nullptr, const_cast<LPWSTR>(command.toWideCharPointer()), return CreateProcessW(nullptr, const_cast<LPWSTR>(command.toWideCharPointer()),
@@ -798,13 +828,17 @@ bool CarlaPipeCommon::writeMsgBuffer(const char* const msg, const std::size_t si


CARLA_SAFE_ASSERT_RETURN(pData->pipeSend != INVALID_PIPE_VALUE, false); CARLA_SAFE_ASSERT_RETURN(pData->pipeSend != INVALID_PIPE_VALUE, false);


ssize_t ret;

try { try {
#ifdef CARLA_OS_WIN #ifdef CARLA_OS_WIN
return (::WriteFile(pData->pipeSend, msg, size, nullptr, nullptr) != FALSE);
ret = ::WriteFileNonBlock(pData->pipeSend, pData->cancelEvent, msg, size);
#else #else
return (::write(pData->pipeSend, msg, size) == static_cast<ssize_t>(size));
ret = ::write(pData->pipeSend, msg, size);
#endif #endif
} CARLA_SAFE_EXCEPTION_RETURN("CarlaPipeCommon::writeMsgBuffer", false); } CARLA_SAFE_EXCEPTION_RETURN("CarlaPipeCommon::writeMsgBuffer", false);

return (ret == static_cast<ssize_t>(size));
} }


// ----------------------------------------------------------------------- // -----------------------------------------------------------------------


Loading…
Cancel
Save