Browse Source

Make the experimental plugins not crash if using multiple instances

tags/1.9.6
falkTX 10 years ago
parent
commit
9e384d04fc
12 changed files with 91 additions and 112 deletions
  1. +5
    -3
      source/carla_app.py
  2. +4
    -3
      source/native-plugins/zita-at1.cpp
  3. +0
    -2
      source/native-plugins/zita-at1/mainwin.cc
  4. +4
    -16
      source/native-plugins/zita-at1/rotary.cc
  5. +3
    -5
      source/native-plugins/zita-at1/rotary.h
  6. +3
    -4
      source/native-plugins/zita-bls1/mainwin.cc
  7. +4
    -16
      source/native-plugins/zita-bls1/rotary.cc
  8. +3
    -5
      source/native-plugins/zita-bls1/rotary.h
  9. +56
    -32
      source/native-plugins/zita-common.hpp
  10. +2
    -4
      source/native-plugins/zita-rev1/mainwin.cc
  11. +4
    -17
      source/native-plugins/zita-rev1/rotary.cc
  12. +3
    -5
      source/native-plugins/zita-rev1/rotary.h

+ 5
- 3
source/carla_app.py View File

@@ -208,6 +208,11 @@ class CarlaApplication(object):
self.fApp.setPalette(self.fPalBlue)

def createApp(self, appName):
QApplication.setAttribute(Qt.AA_X11InitThreads)

if MACOS:
QApplication.setAttribute(Qt.AA_DontShowIconsInMenus)

self.fApp = QApplication(sys.argv)
self.fApp.setApplicationName(appName)
self.fApp.setApplicationVersion(VERSION)
@@ -218,9 +223,6 @@ class CarlaApplication(object):
else:
self.fApp.setWindowIcon(QIcon(":/scalable/carla.svg"))

if MACOS:
self.fApp.setAttribute(Qt.AA_DontShowIconsInMenus)

print("Using \"%s\" theme" % self.fApp.style().objectName())

def arguments(self):


+ 4
- 3
source/native-plugins/zita-at1.cpp View File

@@ -298,14 +298,15 @@ public:

rootwin = new X_rootwin(display);
mainwin = new Mainwin(rootwin, &xresman, 0, 0, jclient, this);
rootwin->handle_event();
mainwin->x_set_title(getUiName());

handler = new X_handler(display, mainwin, EV_X11);
mainwin->x_set_title(getUiName());

if (const uintptr_t winId = getUiParentId())
XSetTransientForHint(display->dpy(), mainwin->win(), static_cast<Window>(winId));

rootwin->handle_event();

handler = new X_handler(display, mainwin, EV_X11);
handler->next_event();
XFlush(display->dpy());



+ 0
- 2
source/native-plugins/zita-at1/mainwin.cc View File

@@ -88,7 +88,6 @@ Mainwin::Mainwin (X_rootwin *parent, X_resman *xres, int xp, int yp, Jclient *jc
}


RotaryCtl::init (disp ());
x = 270;
_rotary [R_TUNE] = new Rlinctl (this, this, R_TUNE, &r_tune_geom, x, 0, 400, 5, 400.0, 480.0, 440.0);
_rotary [R_BIAS] = new Rlinctl (this, this, R_BIAS, &r_bias_geom, x, 0, 270, 5, 0.0, 1.0, 0.5);
@@ -111,7 +110,6 @@ Mainwin::Mainwin (X_rootwin *parent, X_resman *xres, int xp, int yp, Jclient *jc
Mainwin::~Mainwin (void)
{
RotaryCtl::fini ();
}



+ 4
- 16
source/native-plugins/zita-at1/rotary.cc View File

@@ -28,9 +28,6 @@
namespace AT1 {


cairo_t *RotaryCtl::_cairotype = 0;
cairo_surface_t *RotaryCtl::_cairosurf = 0;


int RotaryCtl::_wb_up = 4;
int RotaryCtl::_wb_dn = 5;
@@ -62,6 +59,10 @@ RotaryCtl::RotaryCtl (X_window *parent,
{
x_add_events ( ExposureMask
| Button1MotionMask | ButtonPressMask | ButtonReleaseMask);

_cairo->initIfNeeded(parent->disp());
_cairotype = _cairo->type;
_cairosurf = _cairo->surf;
}


@@ -70,19 +71,6 @@ RotaryCtl::~RotaryCtl (void)
}


void RotaryCtl::init (X_display *disp)
{
_cairosurf = cairo_xlib_surface_create (disp->dpy (), 0, disp->dvi (), 50, 50);
_cairotype = cairo_create (_cairosurf);
}


void RotaryCtl::fini (void)
{
cairo_destroy (_cairotype);
cairo_surface_destroy (_cairosurf);
}


void RotaryCtl::handle_event (XEvent *E)
{


+ 3
- 5
source/native-plugins/zita-at1/rotary.h View File

@@ -72,9 +72,6 @@ public:
virtual void set_value (double v) = 0;
virtual void get_string (char *p, int n) {}

static void init (X_display *disp);
static void fini (void);

static int _wb_up;
static int _wb_dn;

@@ -109,8 +106,9 @@ private:
virtual int handle_motion (int dx, int dy) = 0;
virtual int handle_mwheel (int dw) = 0;

static cairo_t *_cairotype;
static cairo_surface_t *_cairosurf;
juce::SharedResourcePointer<x_cairo_t> _cairo;
cairo_t *_cairotype;
cairo_surface_t *_cairosurf;
};




+ 3
- 4
source/native-plugins/zita-bls1/mainwin.cc View File

@@ -56,7 +56,6 @@ Mainwin::Mainwin (X_rootwin *parent, X_resman *xres, int xp, int yp, Jclient *jc
H.rclas (xres->rclas ());
x_apply (&H);

RotaryCtl::init (disp ());
_rotary [INPBAL] = new Rlinctl (this, this, &inpbal_img, 20, 0, 120, 4, -3.0f, 3.0f, 0.0f, INPBAL);
_rotary [HPFILT] = new Rlogctl (this, this, &hpfilt_img, 20, 0, 120, 4, 10.0f, 320.0f, 40.0f, HPFILT);
_rotary [SHGAIN] = new Rlinctl (this, this, &shgain_img, 190, 0, 120, 5, 0.0f, 24.0f, 15.0f, SHGAIN);
@@ -79,7 +78,6 @@ Mainwin::Mainwin (X_rootwin *parent, X_resman *xres, int xp, int yp, Jclient *jc
Mainwin::~Mainwin (void)
{
RotaryCtl::fini ();
}

@@ -134,8 +132,6 @@ void Mainwin::handle_time (void)
{
if (--_timeout == 0) numdisp (-1);
}
inc_time (100000);
XFlush (dpy ());

if (_touch && _jclient->shuffler ()->ready ())
{
@@ -145,6 +141,9 @@ void Mainwin::handle_time (void)
_valuecb->valueChangedCallback (SHFREQ, v2);
_touch = 0;
}

inc_time (50000);
XFlush (dpy ());
}




+ 4
- 16
source/native-plugins/zita-bls1/rotary.cc View File

@@ -28,8 +28,6 @@
namespace BLS1 {


cairo_t *RotaryCtl::_cairotype = 0;
cairo_surface_t *RotaryCtl::_cairosurf = 0;

int RotaryCtl::_wb_up = 4;
int RotaryCtl::_wb_dn = 5;
@@ -61,6 +59,10 @@ RotaryCtl::RotaryCtl (X_window *parent,
{
x_add_events ( ExposureMask
| Button1MotionMask | ButtonPressMask | ButtonReleaseMask);

_cairo->initIfNeeded(parent->disp());
_cairotype = _cairo->type;
_cairosurf = _cairo->surf;
}


@@ -69,20 +71,6 @@ RotaryCtl::~RotaryCtl (void)
}


void RotaryCtl::init (X_display *disp)
{
_cairosurf = cairo_xlib_surface_create (disp->dpy (), 0, disp->dvi (), 50, 50);
_cairotype = cairo_create (_cairosurf);
}


void RotaryCtl::fini (void)
{
cairo_destroy (_cairotype);
cairo_surface_destroy (_cairosurf);
}


void RotaryCtl::handle_event (XEvent *E)
{
switch (E->type)


+ 3
- 5
source/native-plugins/zita-bls1/rotary.h View File

@@ -73,9 +73,6 @@ public:
virtual void set_value (double v) = 0;
virtual void get_string (char *p, int n) {}

static void init (X_display *disp);
static void fini (void);

static int _wb_up;
static int _wb_dn;

@@ -110,8 +107,9 @@ private:
virtual int handle_motion (int dx, int dy) = 0;
virtual int handle_mwheel (int dw) = 0;

static cairo_t *_cairotype;
static cairo_surface_t *_cairosurf;
juce::SharedResourcePointer<x_cairo_t> _cairo;
cairo_t *_cairotype;
cairo_surface_t *_cairosurf;
};




+ 56
- 32
source/native-plugins/zita-common.hpp View File

@@ -25,11 +25,40 @@
#include <png.h>
#include <clxclient.h>

#include <cairo/cairo.h>
#include <cairo/cairo-xlib.h>

#define EV_X11 16
#define EV_EXIT 31

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

struct x_cairo_t {
cairo_t * type;
cairo_surface_t* surf;

x_cairo_t() noexcept
: type(nullptr),
surf(nullptr) {}

~x_cairo_t()
{
cairo_destroy(type);
cairo_surface_destroy(surf);
}

void initIfNeeded(X_display* const disp)
{
if (surf != nullptr)
return;

surf = cairo_xlib_surface_create(disp->dpy(), 0, disp->dvi(), 50, 50);
type = cairo_create(surf);
}
};

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

struct X_handler_Param {
uint32_t index;
float value;
@@ -132,46 +161,41 @@ private:
{
for (; ! shouldThreadExit();)
{
int ev;

{
const CarlaMutexLocker cml(fMutex);

CARLA_SAFE_ASSERT_RETURN(fMainwin != nullptr,);

{
const CarlaMutexLocker cml(fParamMutex);
const CarlaMutexLocker cml(fMutex);

for (ParamList::Itenerator it = fParamChanges.begin(); it.valid(); it.next())
{
const X_handler_Param& param(it.getValue());
fCallback->setParameterValueFromHandlerThread(param.index, param.value);
}
CARLA_SAFE_ASSERT_RETURN(fMainwin != nullptr,);

fParamChanges.clear();
}
{
const CarlaMutexLocker cml(fParamMutex);

for (; (ev = fMainwin->process()) == EV_X11;)
for (ParamList::Itenerator it = fParamChanges.begin(); it.valid(); it.next())
{
fRootwin->handle_event();
fHandler->next_event();
const X_handler_Param& param(it.getValue());
fCallback->setParameterValueFromHandlerThread(param.index, param.value);
}

if (ev == Esync::EV_TIME)
{
fRootwin->handle_event();
}
else if (ev == EV_EXIT)
{
fClosed = true;
fHandler = nullptr;
fMainwin = nullptr;
fRootwin = nullptr;
return;
}
fParamChanges.clear();
}

carla_msleep(10);
switch (fMainwin->process())
{
case EV_X11:
fRootwin->handle_event();
fHandler->next_event();
break;
case EV_EXIT:
fClosed = true;
fHandler = nullptr;
fMainwin = nullptr;
fRootwin = nullptr;
return;
case Esync::EV_TIME:
fRootwin->handle_event();
break;
default:
carla_stdout("custom X11 event for zita plugs");
break;
}
}
}
};


+ 2
- 4
source/native-plugins/zita-rev1/mainwin.cc View File

@@ -56,7 +56,6 @@ Mainwin::Mainwin (X_rootwin *parent, X_resman *xres, int xp, int yp, Jclient *jc
x_apply (&H);

_ambis = xres->getb (".ambisonic", false);
RotaryCtl::init (disp ());
x = 0;
_rotary [R_DELAY] = new Rlinctl (this, this, &r_delay_img, x, 0, 160, 5, 0.02, 0.100, 0.04, R_DELAY);
_rotary [R_XOVER] = new Rlogctl (this, this, &r_xover_img, x, 0, 200, 5, 50.0, 1000.0, 200.0, R_XOVER);
@@ -79,13 +78,12 @@ Mainwin::Mainwin (X_rootwin *parent, X_resman *xres, int xp, int yp, Jclient *jc
x_add_events (ExposureMask);
x_map ();
set_time (0);
inc_time (500000);
inc_time (250000);
}

Mainwin::~Mainwin (void)
{
RotaryCtl::fini ();
}

@@ -137,7 +135,7 @@ void Mainwin::clmesg (XClientMessageEvent *E)
void Mainwin::handle_time (void)
{
inc_time (500000);
// XFlush (dpy ());
XFlush (dpy ());
}




+ 4
- 17
source/native-plugins/zita-rev1/rotary.cc View File

@@ -28,9 +28,6 @@
namespace REV1 {


cairo_t *RotaryCtl::_cairotype = 0;
cairo_surface_t *RotaryCtl::_cairosurf = 0;

int RotaryCtl::_wb_up = 4;
int RotaryCtl::_wb_dn = 5;
int RotaryCtl::_keymod = 0;
@@ -61,6 +58,10 @@ RotaryCtl::RotaryCtl (X_window *parent,
{
x_add_events ( ExposureMask
| Button1MotionMask | ButtonPressMask | ButtonReleaseMask);

_cairo->initIfNeeded(parent->disp());
_cairotype = _cairo->type;
_cairosurf = _cairo->surf;
}


@@ -69,20 +70,6 @@ RotaryCtl::~RotaryCtl (void)
}


void RotaryCtl::init (X_display *disp)
{
_cairosurf = cairo_xlib_surface_create (disp->dpy (), 0, disp->dvi (), 50, 50);
_cairotype = cairo_create (_cairosurf);
}


void RotaryCtl::fini (void)
{
cairo_destroy (_cairotype);
cairo_surface_destroy (_cairosurf);
}


void RotaryCtl::handle_event (XEvent *E)
{
switch (E->type)


+ 3
- 5
source/native-plugins/zita-rev1/rotary.h View File

@@ -72,9 +72,6 @@ public:
virtual void set_value (double v) = 0;
virtual void get_string (char *p, int n) {}

static void init (X_display *disp);
static void fini (void);

static int _wb_up;
static int _wb_dn;

@@ -109,8 +106,9 @@ private:
virtual int handle_motion (int dx, int dy) = 0;
virtual int handle_mwheel (int dw) = 0;

static cairo_t *_cairotype;
static cairo_surface_t *_cairosurf;
juce::SharedResourcePointer<x_cairo_t> _cairo;
cairo_t *_cairotype;
cairo_surface_t *_cairosurf;
};




Loading…
Cancel
Save