Browse Source

Fix carla-plugin when using qt5

tags/1.9.4
falkTX 10 years ago
parent
commit
f2ba18f2a3
7 changed files with 48 additions and 52 deletions
  1. +3
    -3
      source/modules/native-plugins/resources/bigmeter-ui
  2. +2
    -2
      source/modules/native-plugins/resources/carla-plugin
  3. +3
    -3
      source/modules/native-plugins/resources/notes-ui
  4. +1
    -1
      source/tests/Makefile
  5. +3
    -40
      source/tests/PipeServer.cpp
  6. +30
    -0
      source/utils/CarlaMutex.hpp
  7. +6
    -3
      source/utils/CarlaPipeUtils.hpp

+ 3
- 3
source/modules/native-plugins/resources/bigmeter-ui View File

@@ -26,10 +26,10 @@ from digitalpeakmeter import DigitalPeakMeter
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
# External UI # External UI


class DistrhoUIBigMeter(DigitalPeakMeter, ExternalUI):
class DistrhoUIBigMeter(ExternalUI, DigitalPeakMeter):
def __init__(self): def __init__(self):
DigitalPeakMeter.__init__(self, None)
ExternalUI.__init__(self) ExternalUI.__init__(self)
DigitalPeakMeter.__init__(self, None)


channels = 2 #6 if argv[0].endswith("bigmeterM-ui") else 2 channels = 2 #6 if argv[0].endswith("bigmeterM-ui") else 2


@@ -91,7 +91,7 @@ class DistrhoUIBigMeter(DigitalPeakMeter, ExternalUI):


#--------------- main ------------------ #--------------- main ------------------
if __name__ == '__main__': if __name__ == '__main__':
import resources_rc
app = CarlaApplication("BigMeter") app = CarlaApplication("BigMeter")
#app...
gui = DistrhoUIBigMeter() gui = DistrhoUIBigMeter()
app.exit_exec() app.exit_exec()

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

@@ -519,10 +519,10 @@ class PluginHost(object):
# ------------------------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------------------------------
# Main Window # Main Window


class CarlaMiniW(HostWindow, ExternalUI):
class CarlaMiniW(ExternalUI, HostWindow):
def __init__(self): def __init__(self):
HostWindow.__init__(self, None)
ExternalUI.__init__(self) ExternalUI.__init__(self)
HostWindow.__init__(self, None)


if False: if False:
from carla_patchbay import CarlaPatchbayW from carla_patchbay import CarlaPatchbayW


+ 3
- 3
source/modules/native-plugins/resources/notes-ui View File

@@ -41,10 +41,10 @@ from paramspinbox import ParamSpinBox
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
# External UI # External UI


class DistrhoUINotes(QWidget, ExternalUI):
class DistrhoUINotes(ExternalUI, QWidget):
def __init__(self): def __init__(self):
QWidget.__init__(self, None)
ExternalUI.__init__(self) ExternalUI.__init__(self)
QWidget.__init__(self, None)


self.fCurPage = 1 self.fCurPage = 1
self.fSaveSizeNowChecker = -1 self.fSaveSizeNowChecker = -1
@@ -233,7 +233,7 @@ class DistrhoUINotes(QWidget, ExternalUI):


#--------------- main ------------------ #--------------- main ------------------
if __name__ == '__main__': if __name__ == '__main__':
import resources_rc
app = CarlaApplication("Notes") app = CarlaApplication("Notes")
#app...
gui = DistrhoUINotes() gui = DistrhoUINotes()
app.exit_exec() app.exit_exec()

+ 1
- 1
source/tests/Makefile View File

@@ -78,7 +78,7 @@ EngineEvents: EngineEvents.cpp
env LD_LIBRARY_PATH=../backend valgrind ./$@ env LD_LIBRARY_PATH=../backend valgrind ./$@


PipeServer: PipeServer.cpp ../utils/CarlaPipeUtils.hpp PipeServer: PipeServer.cpp ../utils/CarlaPipeUtils.hpp
$(CXX) $< $(PEDANTIC_CXX_FLAGS) -o $@
$(CXX) $< $(PEDANTIC_CXX_FLAGS) -lpthread -o $@
# valgrind ./$@ # valgrind ./$@


Print: Print.cpp ../utils/CarlaUtils.hpp Print: Print.cpp ../utils/CarlaUtils.hpp


+ 3
- 40
source/tests/PipeServer.cpp View File

@@ -26,17 +26,12 @@ public:
{ {
} }


~ExternalPluginUI() override
{
}

void fail(const char* const error) override void fail(const char* const error) override
{ {
carla_stderr2(error); carla_stderr2(error);
//fHost->dispatcher(fHost->handle, HOST_OPCODE_UI_UNAVAILABLE, 0, 0, nullptr, 0.0f);
} }


void msgReceived(const char* const msg) override
bool msgReceived(const char* const msg) noexcept override
{ {
carla_stderr("msgReceived : %s", msg); carla_stderr("msgReceived : %s", msg);


@@ -46,37 +41,7 @@ public:
gStopNow = true; gStopNow = true;
} }


#if 0
if (std::strcmp(msg, "control") == 0)
{
int index;
float value;

if (readNextLineAsInt(index) && readNextLineAsFloat(value))
handleSetParameterValue(index, value);
}
else if (std::strcmp(msg, "configure") == 0)
{
char* key;
char* value;

if (readNextLineAsString(key) && readNextLineAsString(value))
{
handleSetState(key, value);
std::free(key);
std::free(value);
}
}
else if (std::strcmp(msg, "exiting") == 0)
{
waitChildClose();
fHost->ui_closed(fHost->handle);
}
else
{
carla_stderr("unknown message HOST: \"%s\"", msg);
}
#endif
return false;
} }
}; };


@@ -84,7 +49,7 @@ int main()
{ {
ExternalPluginUI ui; ExternalPluginUI ui;


if (! ui.start("/home/falktx/FOSS/GIT-mine/Carla/source/notes-ui", "44100.0", "Ui title here"))
if (! ui.start("/home/falktx/FOSS/GIT-mine/Carla/bin/resources/carla-plugin", "44100.0", "Ui title here"))
{ {
carla_stderr("failed to start"); carla_stderr("failed to start");
return 1; return 1;
@@ -98,7 +63,5 @@ int main()
carla_msleep(10); carla_msleep(10);
} }


//ui.stop();

return 0; return 0;
} }

+ 30
- 0
source/utils/CarlaMutex.hpp View File

@@ -200,6 +200,33 @@ private:
CARLA_DECLARE_NON_COPY_CLASS(CarlaScopeLocker) CARLA_DECLARE_NON_COPY_CLASS(CarlaScopeLocker)
}; };


// -----------------------------------------------------------------------
// Helper class to try-lock&unlock a mutex during a function scope.

template <class Mutex>
class CarlaScopeTryLocker
{
public:
CarlaScopeTryLocker(const Mutex& mutex) noexcept
: fMutex(mutex),
fLocked(mutex.tryLock())
{
}

~CarlaScopeTryLocker() noexcept
{
if (fLocked)
fMutex.unlock();
}

private:
const Mutex& fMutex;
const bool fLocked;

CARLA_PREVENT_HEAP_ALLOCATION
CARLA_DECLARE_NON_COPY_CLASS(CarlaScopeTryLocker)
};

// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// Helper class to unlock&lock a mutex during a function scope. // Helper class to unlock&lock a mutex during a function scope.


@@ -231,6 +258,9 @@ private:
typedef CarlaScopeLocker<CarlaMutex> CarlaMutexLocker; typedef CarlaScopeLocker<CarlaMutex> CarlaMutexLocker;
typedef CarlaScopeLocker<CarlaRecursiveMutex> CarlaRecursiveMutexLocker; typedef CarlaScopeLocker<CarlaRecursiveMutex> CarlaRecursiveMutexLocker;


typedef CarlaScopeTryLocker<CarlaMutex> CarlaMutexTryLocker;
typedef CarlaScopeTryLocker<CarlaRecursiveMutex> CarlaRecursiveMutexTryLocker;

typedef CarlaScopeUnlocker<CarlaMutex> CarlaMutexUnlocker; typedef CarlaScopeUnlocker<CarlaMutex> CarlaMutexUnlocker;
typedef CarlaScopeUnlocker<CarlaRecursiveMutex> CarlaRecursiveMutexUnlocker; typedef CarlaScopeUnlocker<CarlaRecursiveMutex> CarlaRecursiveMutexUnlocker;




+ 6
- 3
source/utils/CarlaPipeUtils.hpp View File

@@ -425,7 +425,8 @@ public:
void writeMsg(const char* const msg) const noexcept void writeMsg(const char* const msg) const noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(fPipeSend != -1,); CARLA_SAFE_ASSERT_RETURN(fPipeSend != -1,);
CARLA_SAFE_ASSERT(! fWriteLock.tryLock());

const CarlaMutexTryLocker cmtl(fWriteLock);


try { try {
ssize_t ignore = ::write(fPipeSend, msg, std::strlen(msg)); ssize_t ignore = ::write(fPipeSend, msg, std::strlen(msg));
@@ -436,7 +437,8 @@ public:
void writeMsg(const char* const msg, size_t size) const noexcept void writeMsg(const char* const msg, size_t size) const noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(fPipeSend != -1,); CARLA_SAFE_ASSERT_RETURN(fPipeSend != -1,);
CARLA_SAFE_ASSERT(! fWriteLock.tryLock());

const CarlaMutexTryLocker cmtl(fWriteLock);


try { try {
ssize_t ignore = ::write(fPipeSend, msg, size); ssize_t ignore = ::write(fPipeSend, msg, size);
@@ -447,7 +449,8 @@ public:
void writeAndFixMsg(const char* const msg) noexcept void writeAndFixMsg(const char* const msg) noexcept
{ {
CARLA_SAFE_ASSERT_RETURN(fPipeSend != -1,); CARLA_SAFE_ASSERT_RETURN(fPipeSend != -1,);
CARLA_SAFE_ASSERT(! fWriteLock.tryLock());

const CarlaMutexTryLocker cmtl(fWriteLock);


const size_t size(msg != nullptr ? std::strlen(msg) : 0); const size_t size(msg != nullptr ? std::strlen(msg) : 0);




Loading…
Cancel
Save