register foreign LV2 external UI threads with GUI to avoid crashing when they try to notify ardour's GUI thread of parameter changes

git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@8685 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2011-02-03 03:26:39 +00:00
parent bc7dc158c4
commit e7032972a2
2 changed files with 17 additions and 4 deletions

View file

@ -18,9 +18,13 @@
*/
#include <pbd/pthread_utils.h>
#include <ardour/insert.h>
#include <ardour/lv2_plugin.h>
#include <gtkmm2ext/gtk_ui.h>
#include "ardour_ui.h"
#include "lv2_plugin_ui.h"
#include "gui_thread.h"
@ -36,10 +40,18 @@ LV2PluginUI::lv2_ui_write(LV2UI_Controller controller,
uint32_t format,
const void* buffer)
{
//cout << "lv2_ui_write" << endl;
LV2PluginUI* me = (LV2PluginUI*)controller;
cout << "lv2_ui_write, thread registered ? " << me->_thread_registered << endl;
if (!me->_thread_registered && !Gtkmm2ext::UI::instance()->caller_is_ui_thread()) {
cerr << "Registering LV2 external thread " << pthread_self() << endl;
PBD::notify_gui_about_thread_creation (pthread_self(), me->_lv2->name());
me->_thread_registered = true;
}
if (*(float*)buffer != me->_values[port_index]) {
//cout << "set_parameter " << port_index << ":" << *(float*)buffer << endl;
cout << "set_parameter " << port_index << ":" << *(float*)buffer << endl;
me->_lv2->set_parameter(port_index, *(float*)buffer);
}
}
@ -123,6 +135,7 @@ LV2PluginUI::output_update()
LV2PluginUI::LV2PluginUI (boost::shared_ptr<PluginInsert> pi, boost::shared_ptr<LV2Plugin> lv2p)
: PlugUIBase (pi)
, _lv2(lv2p)
, _thread_registered (false)
, _inst(NULL)
, _values(NULL)
, _external_ui_ptr(NULL)

View file

@ -58,11 +58,11 @@ class LV2PluginUI : public PlugUIBase, public Gtk::VBox
boost::shared_ptr<ARDOUR::LV2Plugin> _lv2;
std::vector<int> _output_ports;
sigc::connection _screen_update_connection;
bool _thread_registered;
Gtk::Widget* _gui_widget;
SLV2UIInstance _inst;
float* _values;
struct lv2_external_ui_host _external_ui_host;
LV2_Feature _external_ui_feature;
struct lv2_external_ui* _external_ui_ptr;