diff options
author | Robin Gareus <robin@gareus.org> | 2013-12-12 14:40:45 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2013-12-12 14:42:02 +0100 |
commit | fd1eb73ef21e8a938e34ca49378a866c381c48e3 (patch) | |
tree | c7dcd425678ee9b7beb6e27e4d20ef08317cfc13 | |
parent | 527b0a78a182b84818fd216f941c91733cb8f229 (diff) |
adjust LV2 ringbuffer size according to LV2:resize-port
The message-size itself is part of the message which
stored in the ringbuffer. If the rinbuffer overflows
the message is misinterpreted -> segfault.
Choose a more conservative ring-buffer size and take
the requested LV2 size into account.
-rw-r--r-- | libs/ardour/lv2_plugin.cc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc index da514f92e4..a1d9de1e53 100644 --- a/libs/ardour/lv2_plugin.cc +++ b/libs/ardour/lv2_plugin.cc @@ -1162,10 +1162,14 @@ LV2Plugin::write_from_ui(uint32_t index, * e.g 48kSPS / 128fpp -> audio-periods = 375 Hz * ui-periods = 25 Hz (SuperRapidScreenUpdate) * default minimumSize = 32K (see LV2Plugin::allocate_atom_event_buffers() - * -> 15 * 32K - * it is safe to overflow (but the plugin state may be inconsistent). + * + * it is NOT safe to overflow (msg.size will be misinterpreted) */ - rbs = max((size_t) 32768 * 6, rbs); + uint32_t bufsiz = 32768; + if (_atom_ev_buffers && _atom_ev_buffers[0]) { + bufsiz = lv2_evbuf_get_capacity(_atom_ev_buffers[0]); + } + rbs = max((size_t) bufsiz * 8, rbs); _from_ui = new RingBuffer<uint8_t>(rbs); } @@ -1194,8 +1198,12 @@ LV2Plugin::enable_ui_emmission() { if (!_to_ui) { /* see note in LV2Plugin::write_from_ui() */ + uint32_t bufsiz = 32768; + if (_atom_ev_buffers && _atom_ev_buffers[0]) { + bufsiz = lv2_evbuf_get_capacity(_atom_ev_buffers[0]); + } size_t rbs = _session.engine().raw_buffer_size(DataType::MIDI) * NBUFS; - rbs = max((size_t) 32768 * 8, rbs); + rbs = max((size_t) bufsiz * 8, rbs); _to_ui = new RingBuffer<uint8_t>(rbs); } } |