Commit 2cf3b842 authored by Hanspeter Portner's avatar Hanspeter Portner

fix trace buffer overflow and missing log newlines.

* fix trace buffer overflow
* fix missing log newlines
* increase initial rt memory pool to 512KB
* prepare for updated nk_pugl
parent 5ab35d2a
* doc: Parameter
* doc: Canvas
* api: xpress
* dsp: send updates of moony:editorHidden et al. together with moony:code
* gui: clipboard support
* gui: external editor
* gui: fix dial/boolean widget input focus
......@@ -325,7 +325,7 @@ _log(lua_State *L)
luaL_Buffer buf;
luaL_buffinit(L, &buf);
lua_getglobal(L, "tostring");
lua_getglobal(L, "tostring"); //TODO cache this
for(int i=1; i<=n; i++)
{
lua_pushvalue(L, -1); // function to be called
......@@ -341,22 +341,32 @@ _log(lua_State *L)
luaL_pushresult(&buf);
const char *res = lua_tostring(L, -1);
size_t len;
const char *res = lua_tolstring(L, -1, &len);
if(moony->log)
lv2_log_trace(&moony->logger, "%s", res);
lv2_log_trace(&moony->logger, "%s\n", res);
// feedback to UI
char *end = strrchr(moony->trace, '\0'); // search end of string
if(end)
if(!moony->trace_overflow)
{
if(end != moony->trace)
char *end = strrchr(moony->trace, '\0'); // search end of string
if(end)
{
*end++ = '\n'; // append to
*end = '\0';
const size_t sz = end - moony->trace + 1;
if(MOONY_MAX_TRACE_LEN - sz > len)
{
if(end != moony->trace)
{
*end++ = '\n'; // append to
*end = '\0';
}
snprintf(end, len + 1, "%s", res);
moony->trace_out = 1; // set flag
}
else
moony->trace_overflow = 1;
}
const size_t remaining = MOONY_MAX_TRACE_LEN - (end - moony->trace);
snprintf(end, remaining, "%s", res);
moony->trace_out = 1; // set flag
}
return 0;
......@@ -735,7 +745,7 @@ _state_save(LV2_Handle instance, LV2_State_Store_Function store,
if(lua_pcall(L, 0, 0, 0))
{
if(moony->log) //TODO send to UI, too
lv2_log_error(&moony->logger, "%s", lua_tostring(L, -1));
lv2_log_error(&moony->logger, "%s\n", lua_tostring(L, -1));
lua_pop(L, 1);
}
#ifdef USE_MANUAL_GC
......@@ -962,7 +972,7 @@ _state_restore(LV2_Handle instance, LV2_State_Retrieve_Function retrieve, LV2_St
if(lua_pcall(L, 0, 0, 0))
{
if(moony->log) //TODO send to UI, too
lv2_log_error(&moony->logger, "%s", lua_tostring(L, -1));
lv2_log_error(&moony->logger, "%s\n", lua_tostring(L, -1));
lua_pop(L, 1);
}
#ifdef USE_MANUAL_GC
......@@ -1036,7 +1046,7 @@ _work_response(LV2_Handle instance, uint32_t size, const void *body)
LV2_Worker_Status status = moony->sched->schedule_work(
moony->sched->handle, sizeof(moony_mem_t), &req);
if( (status != LV2_WORKER_SUCCESS) && moony->log)
lv2_log_warning(&moony->logger, "moony: schedule_work failed");
lv2_log_warning(&moony->logger, "moony: schedule_work failed\n");
return LV2_WORKER_ERR_UNKNOWN;
}
......@@ -2320,6 +2330,8 @@ moony_in(moony_t *moony, const LV2_Atom_Sequence *control, LV2_Atom_Sequence *no
if(ref)
ref = _moony_patch(&moony->uris.patch, forge, moony->uris.moony_code, moony->chunk, len);
//FIXME also send moony:editorHidden et al.
moony->dirty_out = 0; // reset flag
}
......@@ -2406,6 +2418,13 @@ moony_out(moony_t *moony, LV2_Atom_Sequence *notify, uint32_t frames)
moony->trace_out = 0; // reset flag
}
if(moony->trace_overflow)
{
if(moony->log)
lv2_log_trace(&moony->logger, "trace buffer overflow\n");
moony->trace_overflow = 0; // reset flag
}
if(moony->graph_out)
{
if(moony->render.graph)
......
......@@ -30,7 +30,7 @@
extern int luaopen_lpeg(lua_State *L);
#define MEM_SIZE 0x40000UL // 256KB
#define MEM_SIZE 0x80000UL // 512KB
//#define MOONY_LOG_MEM
#ifdef MOONY_LOG_MEM
......@@ -66,8 +66,9 @@ _log_mem(moony_t *moony, void *ptr, size_t osize, size_t nsize)
used >>= 10;
}
lv2_log_trace(&moony->logger, "space: %4zu%c, used: %4zu%c, old: %4zu, new: %4zu, data: %p",
space, suffix0, used, suffix1, osize, nsize, ptr);
if(moony->log)
lv2_log_trace(&moony->logger, "space: %4zu%c, used: %4zu%c, old: %4zu, new: %4zu, data: %p\n",
space, suffix0, used, suffix1, osize, nsize, ptr);
}
}
#endif
......
......@@ -309,6 +309,7 @@ struct _moony_t {
volatile int dirty_out;
volatile int error_out;
volatile int trace_out;
volatile int trace_overflow;
volatile int graph_out;
// udata cache
......@@ -377,7 +378,7 @@ moony_err(moony_t *moony, const char *msg)
: error; // use whole error string alternatively
if(moony->log)
lv2_log_trace(&moony->logger, "%s", err);
lv2_log_trace(&moony->logger, "%s\n", err);
snprintf(moony->error, MOONY_MAX_ERROR_LEN, "%s", err);
......
......@@ -122,16 +122,6 @@ moony:c4a1xc4a1
@NK_WRAP@ui:ui moony:ui_3_nk ;
rdfs:seeAlso <moony.ttl> .
# Web UI
moony:ui_1_web_1_ui
a ui:UI ;
ui:binary <moony_web@CMAKE_SHARED_MODULE_SUFFIX@> ;
rdfs:seeAlso <moony_ui.ttl> .
moony:ui_1_web_2_kx
a kx:Widget ;
ui:binary <moony_web@CMAKE_SHARED_MODULE_SUFFIX@> ;
rdfs:seeAlso <moony_ui.ttl> .
# Simple UI
moony:ui_2_simple_1_ui
a ui:UI ;
......
......@@ -22,6 +22,7 @@
#include <limits.h>
#include <inttypes.h>
#include <dirent.h>
#include <unistd.h>
#include <moony.h>
......@@ -1981,22 +1982,16 @@ _expose(struct nk_context *ctx, struct nk_rect wbounds, void *data)
const bool has_control_down = nk_input_is_key_down(in, NK_KEY_CTRL);
const bool has_shift_down = nk_input_is_key_down(in, NK_KEY_SHIFT);
const bool has_enter_pressed = nk_input_is_key_pressed(in, NK_KEY_ENTER);
char control_letter = 0;
if(has_control_down && (in->keyboard.text_len == 1) )
{
control_letter = in->keyboard.text[0];
in->keyboard.text_len = 0;
}
const bool has_shift_enter = has_shift_down && has_enter_pressed;
const bool has_control_enter = has_control_down && has_enter_pressed;
const bool has_control_l = control_letter == 'l';
const bool has_control_d = control_letter == 'd';
const bool has_control_e = control_letter == 'e';
const bool has_control_p = control_letter == 'p';
const bool has_control_f = control_letter == 'f';
const bool has_control_n = control_letter == 'n';
const bool has_control_t = control_letter == 't';
const bool has_control_a = control_letter == 'a';
const bool has_control_l = nk_pugl_is_shortcut_pressed(in, 'l', true);
const bool has_control_d = nk_pugl_is_shortcut_pressed(in, 'd', true);
const bool has_control_e = nk_pugl_is_shortcut_pressed(in, 'e', true);
const bool has_control_p = nk_pugl_is_shortcut_pressed(in, 'p', true);
const bool has_control_f = nk_pugl_is_shortcut_pressed(in, 'f', true);
const bool has_control_n = nk_pugl_is_shortcut_pressed(in, 'n', true);
const bool has_control_t = nk_pugl_is_shortcut_pressed(in, 't', true);
const bool has_control_a = nk_pugl_is_shortcut_pressed(in, 'a', true);
bool has_commited = false;
nk_layout_row_begin(ctx, NK_DYNAMIC, dy, 3);
......
......@@ -70,7 +70,7 @@ static inline void
_err2(ui_t *ui, const char *from)
{
if(ui->log)
lv2_log_error(&ui->logger, "%s", from);
lv2_log_error(&ui->logger, "%s\n", from);
else
fprintf(stderr, "%s\n", from);
}
......@@ -88,10 +88,10 @@ _moony_message_send(ui_t *ui, LV2_URID key, const char *str, uint32_t size)
ui->write_function(ui->controller, ui->control_port, lv2_atom_total_size(&obj->atom),
ui->uris.event_transfer, ui->buf);
if(ui->log)
lv2_log_note(&ui->logger, str && size ? "send code chunk" : "query code chunk");
lv2_log_note(&ui->logger, str && size ? "send code chunk\n" : "query code chunk\n");
}
else if(ui->log)
lv2_log_error(&ui->logger, "code chunk too long");
lv2_log_error(&ui->logger, "code chunk too long\n");
}
static void
......@@ -374,7 +374,7 @@ instantiate(const LV2UI_Descriptor *descriptor, const char *plugin_uri,
sprintf(ui->path, "%s", tmp_template);
if(ui->log)
lv2_log_note(&ui->logger, "moony simple_ui path: %s", ui->path);
lv2_log_note(&ui->logger, "moony simple_ui path: %s\n", ui->path);
free(tmp_template);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment