Browse Source

Merge remote-tracking branch 'bsp2/v0.6' into v0.6-linux-lglw

pull/1639/head
Cameron Leger 6 years ago
parent
commit
d7509c0063
2 changed files with 76 additions and 17 deletions
  1. +42
    -15
      dep/lglw/lglw_linux.c
  2. +34
    -2
      src/vst2_main.cpp

+ 42
- 15
dep/lglw/lglw_linux.c View File

@@ -34,6 +34,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdarg.h>


#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
@@ -52,25 +53,25 @@
// Regular log entry (low frequency) // Regular log entry (low frequency)
// //
// #define Dlog_verbose if(1);else printf // #define Dlog_verbose if(1);else printf
#define Dlog if(0);else printf
#define Dlog if(0);else lglw_log


// //
// Verbose log entry // Verbose log entry
// //
// #define Dlog_v if(1);else printf
#define Dlog_v if(0);else printf
// #define Dlog_v if(1);else lglw_log
#define Dlog_v if(0);else lglw_log


// //
// Very-verbose log entry // Very-verbose log entry
// //
// #define Dlog_vv if(1);else printf
#define Dlog_vv if(0);else printf
// #define Dlog_vv if(1);else lglw_log
#define Dlog_vv if(0);else lglw_log


// //
// Very-very-verbose log entry // Very-very-verbose log entry
// //
#define Dlog_vvv if(1);else printf
// #define Dlog_vvv if(0);else printf
#define Dlog_vvv if(0);else lglw_log
// #define Dlog_vvv if(0);else lglw_log


// //
// Print to stdout // Print to stdout
@@ -228,9 +229,16 @@ static uint32_t loc_millisec_delta (lglw_int_t *lglw) {
static FILE *logfile; static FILE *logfile;


void lglw_log(const char *logData, ...) { void lglw_log(const char *logData, ...) {
fprintf(logfile, logData);
static char buf[16*1024];
va_list va;
va_start(va, logData);
vsprintf(buf, logData, va);
va_end(va);
printf(buf);
//fprintf(logfile, logData);
fputs(buf, logfile);
fflush(logfile); fflush(logfile);
printf(logData);
// printf(logData);
} }




@@ -353,6 +361,11 @@ static lglw_bool_t loc_create_hidden_window(lglw_int_t *lglw, int32_t _w, int32_
Dlog_v("lglw:loc_create_hidden_window: 5\n"); Dlog_v("lglw:loc_create_hidden_window: 5\n");
lglw->ctx = glXCreateContext(lglw->xdsp, lglw->vi, None, True); lglw->ctx = glXCreateContext(lglw->xdsp, lglw->vi, None, True);


if(NULL == lglw->ctx)
{
Dlog("lglw: FAILED to create context!!!\n");
}

Dlog_v("lglw:loc_create_hidden_window: 6\n"); Dlog_v("lglw:loc_create_hidden_window: 6\n");
if(NULL == lglw->ctx) if(NULL == lglw->ctx)
{ {
@@ -431,7 +444,7 @@ static void loc_eventProc(XEvent *xev, lglw_int_t *lglw) {
break; break;


case Expose: case Expose:
Dlog_v("lglw:loc_eventProc: xev Expose\n");
Dlog_vv("lglw:loc_eventProc: xev Expose\n");
loc_handle_queued_mouse_warp(lglw); loc_handle_queued_mouse_warp(lglw);
eventHandled = LGLW_FALSE; eventHandled = LGLW_FALSE;
if(NULL != lglw->redraw.cbk) if(NULL != lglw->redraw.cbk)
@@ -1172,7 +1185,7 @@ lglw_bool_t lglw_window_open (lglw_t _lglw, void *_parentHWNDOrNull, int32_t _x,


if(NULL != lglw) if(NULL != lglw)
{ {
Dlog_v("lglw:lglw_window_open: 1, %p, %i \n", (Window)_parentHWNDOrNull, (Window)_parentHWNDOrNull);
Dlog_v("lglw:lglw_window_open: 1, %p, %i p=(%d; %d) s=(%d; %d)\n", (Window)_parentHWNDOrNull, (Window)_parentHWNDOrNull, _x, _y, _w, _h);
lglw->parent_xwnd = (0 == _parentHWNDOrNull) ? DefaultRootWindow(lglw->xdsp) : (Window)_parentHWNDOrNull; lglw->parent_xwnd = (0 == _parentHWNDOrNull) ? DefaultRootWindow(lglw->xdsp) : (Window)_parentHWNDOrNull;


Dlog_v("lglw:lglw_window_open: 2 lglw=%p\n", lglw); Dlog_v("lglw:lglw_window_open: 2 lglw=%p\n", lglw);
@@ -1342,12 +1355,24 @@ void lglw_window_close (lglw_t _lglw) {
Dlog_v("lglw:lglw_window_close: 3\n"); Dlog_v("lglw:lglw_window_close: 3\n");
if(lglw->win.b_owner) if(lglw->win.b_owner)
{ {
XUnmapWindow(lglw->xdsp, lglw->win.xwnd);
XDestroyWindow(lglw->xdsp, lglw->win.xwnd); XDestroyWindow(lglw->xdsp, lglw->win.xwnd);
lglw->win.b_owner = LGLW_FALSE; lglw->win.b_owner = LGLW_FALSE;
} }
XSync(lglw->xdsp, False); XSync(lglw->xdsp, False);
lglw->win.xwnd = 0; lglw->win.xwnd = 0;
lglw->win.mapped = LGLW_FALSE; lglw->win.mapped = LGLW_FALSE;

{
XEvent xev;
int queued = XPending(lglw->xdsp);
Dlog_vvv("lglw:lglw_window_close: consume %d pending events\n", queued);
while(queued)
{
XNextEvent(lglw->xdsp, &xev);
queued--;
}
}
} }
} }
Dlog_v("lglw:lglw_window_close: EXIT\n"); Dlog_v("lglw:lglw_window_close: EXIT\n");
@@ -1389,14 +1414,14 @@ lglw_bool_t lglw_window_is_visible(lglw_t _lglw) {
lglw_bool_t r = LGLW_FALSE; lglw_bool_t r = LGLW_FALSE;
LGLW(_lglw); LGLW(_lglw);


Dlog_vvv("lglw:lglw_window_is_visible: 1\n");
// Dlog_vvv("lglw:lglw_window_is_visible: 1\n");
if(NULL != lglw && 0 != lglw->win.xwnd) if(NULL != lglw && 0 != lglw->win.xwnd)
{ {
Dlog_vvv("lglw:lglw_window_is_visible: 2\n");
// Dlog_vvv("lglw:lglw_window_is_visible: 2\n");
r = lglw->win.mapped; r = lglw->win.mapped;
} }


Dlog_vvv("lglw:lglw_window_is_visible: EXIT\n");
// Dlog_vvv("lglw:lglw_window_is_visible: EXIT\n");
return r; return r;
} }


@@ -1478,6 +1503,7 @@ void lglw_glcontext_push(lglw_t _lglw) {
{ {
Dlog("[---] lglw_glcontext_push: glXMakeCurrent() failed. win.xwnd=%p hidden.xwnd=%p ctx=%p glGetError()=%d\n", lglw->win.xwnd, lglw->hidden.xwnd, lglw->ctx, glGetError()); Dlog("[---] lglw_glcontext_push: glXMakeCurrent() failed. win.xwnd=%p hidden.xwnd=%p ctx=%p glGetError()=%d\n", lglw->win.xwnd, lglw->hidden.xwnd, lglw->ctx, glGetError());
} }
// Dlog_vvv("lglw:lglw_glcontext_push: LEAVE\n");
} }
} }


@@ -2142,7 +2168,8 @@ void lglw_events(lglw_t _lglw) {
{ {
XEvent xev; XEvent xev;
int queued = XPending(lglw->xdsp); int queued = XPending(lglw->xdsp);
Dlog_v("lglw:lglw_events: (events: %i)\n", queued);
if(queued > 0)
Dlog_vvv("lglw:lglw_events: (events: %i)\n", queued);
while(queued) while(queued)
{ {
XNextEvent(lglw->xdsp, &xev); XNextEvent(lglw->xdsp, &xev);


+ 34
- 2
src/vst2_main.cpp View File

@@ -148,6 +148,23 @@ struct PluginMutex {
#include <fcntl.h> #include <fcntl.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <fenv.h> // fesetround() #include <fenv.h> // fesetround()
#include <stdarg.h>

static FILE *logfile;
#undef Dprintf
#define Dprintf log_printf

static void log_printf(const char *logData, ...) {
static char buf[16*1024];
va_list va;
va_start(va, logData);
vsprintf(buf, logData, va);
va_end(va);
printf(buf);
fputs(buf, logfile);
fflush(logfile);
}



// #define _GNU_SOURCE // #define _GNU_SOURCE
#include <dlfcn.h> #include <dlfcn.h>
@@ -689,7 +706,6 @@ public:
} }


void closeEffect(void) { void closeEffect(void) {

closeEditor(); closeEditor();


// (todo) use mutex // (todo) use mutex
@@ -998,18 +1014,26 @@ public:
} }


bool setProgramChunk(size_t _size, uint8_t *_addr) { bool setProgramChunk(size_t _size, uint8_t *_addr) {
Dprintf("xxx vstrack_plugin:setProgramChunk: 1\n");
setGlobals(); setGlobals();
Dprintf("xxx vstrack_plugin:setProgramChunk: 2\n");
lockAudio(); lockAudio();
Dprintf("xxx vstrack_plugin:setProgramChunk: 3\n");
vst2_set_shared_plugin_tls_globals(); vst2_set_shared_plugin_tls_globals();
Dprintf("xxx vstrack_plugin:setProgramChunk: 4\n");
#if 0 #if 0
Dprintf("xxx vstrack_plugin:setProgramChunk: size=%u\n", _size); Dprintf("xxx vstrack_plugin:setProgramChunk: size=%u\n", _size);
#endif #endif
lglw_glcontext_push(rack::global_ui->window.lglw); lglw_glcontext_push(rack::global_ui->window.lglw);
Dprintf("xxx vstrack_plugin:setProgramChunk: 5\n");
bool r = rack::global_ui->app.gRackWidget->loadPatchFromString((const char*)_addr); bool r = rack::global_ui->app.gRackWidget->loadPatchFromString((const char*)_addr);
Dprintf("xxx vstrack_plugin:setProgramChunk: 6\n");
rack::global_ui->ui.gScene->step(); // w/o this the patch is bypassed rack::global_ui->ui.gScene->step(); // w/o this the patch is bypassed
Dprintf("xxx vstrack_plugin:setProgramChunk: 7\n");
lglw_glcontext_pop(rack::global_ui->window.lglw); lglw_glcontext_pop(rack::global_ui->window.lglw);
Dprintf("xxx vstrack_plugin:setProgramChunk: r=%d\n", r);
Dprintf("xxx vstrack_plugin:setProgramChunk: 8 r=%d\n", r);
unlockAudio(); unlockAudio();
Dprintf("xxx vstrack_plugin:setProgramChunk: 9\n");
return r; return r;
} }


@@ -1102,6 +1126,7 @@ public:
} }


void redraw(void) { void redraw(void) {
#if 1
setGlobals(); setGlobals();


if(lglw_window_is_visible(rack::global_ui->window.lglw)) if(lglw_window_is_visible(rack::global_ui->window.lglw))
@@ -1116,6 +1141,7 @@ public:
// Restore the DAW's GL context // Restore the DAW's GL context
lglw_glcontext_pop(rack::global_ui->window.lglw); lglw_glcontext_pop(rack::global_ui->window.lglw);
} }
#endif
} }


#ifdef YAC_LINUX #ifdef YAC_LINUX
@@ -1690,6 +1716,7 @@ VstIntPtr VSTPluginDispatcher(VSTPlugin *vstPlugin,
// // { // // {
r = wrapper->setProgramChunk(size_t(value), (uint8_t*)ptr) ? 1 : 0; r = wrapper->setProgramChunk(size_t(value), (uint8_t*)ptr) ? 1 : 0;
// // } // // }
Dprintf("xxx vstrack_plugin: effSetChunk LEAVE\n");
break; break;


case effShellGetNextPlugin: case effShellGetNextPlugin:
@@ -2205,6 +2232,11 @@ void vst2_idle_detect_mode_get(int *_mode) {
* Implementation of the main entry point of the plugin * Implementation of the main entry point of the plugin
*/ */
VST_EXPORT VSTPlugin *VSTPluginMain(VSTHostCallback vstHostCallback) { VST_EXPORT VSTPlugin *VSTPluginMain(VSTHostCallback vstHostCallback) {

#ifdef YAC_LINUX
logfile = fopen("/tmp/vst2_log.txt", "w");
#endif

Dprintf("vstrack_plugin: called VSTPluginMain... \n"); Dprintf("vstrack_plugin: called VSTPluginMain... \n");


#if 0 #if 0


Loading…
Cancel
Save