use glib event callback to invoke per-thread code every time the GUI event loop does stuff
This commit is contained in:
parent
09c84d1de8
commit
772d70ae4c
@ -85,6 +85,8 @@
|
|||||||
#include "pbd/scoped_file_descriptor.h"
|
#include "pbd/scoped_file_descriptor.h"
|
||||||
#include "pbd/xml++.h"
|
#include "pbd/xml++.h"
|
||||||
|
|
||||||
|
#include "temporal/superclock.h"
|
||||||
|
|
||||||
#include "gtkmm2ext/application.h"
|
#include "gtkmm2ext/application.h"
|
||||||
#include "gtkmm2ext/bindings.h"
|
#include "gtkmm2ext/bindings.h"
|
||||||
#include "gtkmm2ext/gtk_ui.h"
|
#include "gtkmm2ext/gtk_ui.h"
|
||||||
@ -3111,3 +3113,15 @@ ARDOUR_UI::setup_toplevel_window (Gtk::Window& window, const string& name, void*
|
|||||||
window.signal_key_press_event().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::key_event_handler), &window), false);
|
window.signal_key_press_event().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::key_event_handler), &window), false);
|
||||||
window.signal_key_release_event().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::key_event_handler), &window), false);
|
window.signal_key_release_event().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::key_event_handler), &window), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ARDOUR_UI::event_loop_precall ()
|
||||||
|
{
|
||||||
|
std::cout << "ev precall\n";
|
||||||
|
|
||||||
|
if (_session) {
|
||||||
|
Temporal::_thread_sample_rate = _session->sample_rate ();
|
||||||
|
} else {
|
||||||
|
Temporal::_thread_sample_rate = 44100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -408,6 +408,8 @@ protected:
|
|||||||
void toggle_rc_options_window ();
|
void toggle_rc_options_window ();
|
||||||
void toggle_session_options_window ();
|
void toggle_session_options_window ();
|
||||||
|
|
||||||
|
void event_loop_precall ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Gtk::Window _main_window;
|
Gtk::Window _main_window;
|
||||||
|
@ -48,6 +48,8 @@
|
|||||||
#include "pbd/boost_debug.h"
|
#include "pbd/boost_debug.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "temporal/superclock.h"
|
||||||
|
|
||||||
#include "ardour/revision.h"
|
#include "ardour/revision.h"
|
||||||
#include "ardour/ardour.h"
|
#include "ardour/ardour.h"
|
||||||
#include "ardour/audioengine.h"
|
#include "ardour/audioengine.h"
|
||||||
@ -383,7 +385,14 @@ int main (int argc, char *argv[])
|
|||||||
SetErrorMode (prev_error_mode);
|
SetErrorMode (prev_error_mode);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!ARDOUR::init (ARDOUR_COMMAND_LINE::try_hw_optimization, localedir.c_str(), true)) {
|
/* this is the GUI thread. Normally this will be done by
|
||||||
|
* Gtkmm2ext::UI::event_loop_precall() but we need to make sure that
|
||||||
|
* things are set up for this thread before we get started
|
||||||
|
*/
|
||||||
|
|
||||||
|
Temporal::_thread_sample_rate = 44100;
|
||||||
|
|
||||||
|
if (!ARDOUR::init (ARDOUR_COMMAND_LINE::use_vst, ARDOUR_COMMAND_LINE::try_hw_optimization, localedir.c_str(), true)) {
|
||||||
error << string_compose (_("could not initialize %1."), PROGRAM_NAME) << endmsg;
|
error << string_compose (_("could not initialize %1."), PROGRAM_NAME) << endmsg;
|
||||||
Gtk::Main main (argc, argv);
|
Gtk::Main main (argc, argv);
|
||||||
Gtk::MessageDialog msg (string_compose (_("Could not initialize %1 (likely due to corrupt config files).\n"
|
Gtk::MessageDialog msg (string_compose (_("Could not initialize %1 (likely due to corrupt config files).\n"
|
||||||
|
@ -73,11 +73,17 @@ BaseUI::RequestType Gtkmm2ext::AddTimeout = BaseUI::new_request_type();
|
|||||||
|
|
||||||
template class AbstractUI<Gtkmm2ext::UIRequest>;
|
template class AbstractUI<Gtkmm2ext::UIRequest>;
|
||||||
|
|
||||||
|
void
|
||||||
|
UI::event_loop_precall ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
UI::UI (string application_name, string thread_name, int *argc, char ***argv)
|
UI::UI (string application_name, string thread_name, int *argc, char ***argv)
|
||||||
: AbstractUI<UIRequest> (thread_name)
|
: AbstractUI<UIRequest> (thread_name)
|
||||||
, _receiver (*this)
|
, _receiver (*this)
|
||||||
, global_bindings (0)
|
, global_bindings (0)
|
||||||
, errors (0)
|
, errors (0)
|
||||||
|
, event_callback (boost::bind (&UI::event_loop_precall, this))
|
||||||
{
|
{
|
||||||
theMain = new Main (argc, argv);
|
theMain = new Main (argc, argv);
|
||||||
|
|
||||||
@ -111,6 +117,12 @@ UI::UI (string application_name, string thread_name, int *argc, char ***argv)
|
|||||||
|
|
||||||
EventLoop::register_request_buffer_factory ("gui", request_buffer_factory);
|
EventLoop::register_request_buffer_factory ("gui", request_buffer_factory);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* every time the main loop runs (i.e. before any actual event handling
|
||||||
|
*/
|
||||||
|
|
||||||
|
event_callback.attach (MainContext::get_default());
|
||||||
|
|
||||||
/* attach our request source to the default main context */
|
/* attach our request source to the default main context */
|
||||||
|
|
||||||
attach_request_source ();
|
attach_request_source ();
|
||||||
|
@ -50,6 +50,7 @@
|
|||||||
#define ABSTRACT_UI_EXPORTS
|
#define ABSTRACT_UI_EXPORTS
|
||||||
#endif
|
#endif
|
||||||
#include "pbd/abstract_ui.h"
|
#include "pbd/abstract_ui.h"
|
||||||
|
#include "pbd/glib_event_source.h"
|
||||||
#include "pbd/ringbufferNPT.h"
|
#include "pbd/ringbufferNPT.h"
|
||||||
#include "pbd/pool.h"
|
#include "pbd/pool.h"
|
||||||
#include "pbd/error.h"
|
#include "pbd/error.h"
|
||||||
@ -170,6 +171,8 @@ protected:
|
|||||||
Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag,
|
Glib::RefPtr<Gtk::TextBuffer::Tag> ptag, Glib::RefPtr<Gtk::TextBuffer::Tag> mtag,
|
||||||
const char *msg);
|
const char *msg);
|
||||||
|
|
||||||
|
virtual void event_loop_precall ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static UI *theGtkUI;
|
static UI *theGtkUI;
|
||||||
|
|
||||||
@ -203,6 +206,7 @@ private:
|
|||||||
|
|
||||||
void do_request (UIRequest*);
|
void do_request (UIRequest*);
|
||||||
|
|
||||||
|
GlibEventLoopCallback event_callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace */
|
} /* namespace */
|
||||||
|
Loading…
Reference in New Issue
Block a user