X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fpbd%2Fbase_ui.cc;h=f22d83264ef08b1c5d4519bd06f16d3ea79c1e71;hb=1ce58ad90aab58bca10af9c448b8e186ac532480;hp=3a4257ebdd9a9ecaf9bfc1109277543588e73427;hpb=6a436fd826d1c9d88b60287696cc0836ccce35aa;p=ardour.git diff --git a/libs/pbd/base_ui.cc b/libs/pbd/base_ui.cc index 3a4257ebdd..f22d83264e 100644 --- a/libs/pbd/base_ui.cc +++ b/libs/pbd/base_ui.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2007 Paul Davis + Copyright (C) 2000-2007 Paul Davis This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -35,31 +35,26 @@ #include "pbd/compose.h" #include "pbd/failed_constructor.h" -#include "i18n.h" +#include "pbd/i18n.h" #include "pbd/debug.h" using namespace std; using namespace PBD; using namespace Glib; - + uint64_t BaseUI::rt_bit = 1; BaseUI::RequestType BaseUI::CallSlot = BaseUI::new_request_type(); BaseUI::RequestType BaseUI::Quit = BaseUI::new_request_type(); -BaseUI::BaseUI (const string& str) - : m_context(MainContext::get_default()) +BaseUI::BaseUI (const string& loop_name) + : EventLoop (loop_name) + , m_context(MainContext::get_default()) , run_loop_thread (0) - , _name (str) -#ifndef PLATFORM_WINDOWS , request_channel (true) -#endif { base_ui_instance = this; - -#ifndef PLATFORM_WINDOWS - request_channel.ios()->connect (sigc::mem_fun (*this, &BaseUI::request_handler)); -#endif + request_channel.set_receive_handler (sigc::mem_fun (*this, &BaseUI::request_handler)); /* derived class must set _ok */ } @@ -84,7 +79,7 @@ BaseUI::new_request_type () void BaseUI::main_thread () { - DEBUG_TRACE (DEBUG::EventLoop, string_compose ("%1: event loop running in thread %2\n", name(), pthread_name())); + DEBUG_TRACE (DEBUG::EventLoop, string_compose ("%1: event loop running in thread %2\n", event_loop_name(), pthread_name())); set_event_loop_for_thread (this); thread_init (); _main_loop->get_context()->signal_idle().connect (sigc::mem_fun (*this, &BaseUI::signal_running)); @@ -96,7 +91,7 @@ BaseUI::signal_running () { Glib::Threads::Mutex::Lock lm (_run_lock); _running.signal (); - + return false; // don't call it again } @@ -124,24 +119,6 @@ BaseUI::quit () } } -#ifdef PLATFORM_WINDOWS -gboolean -BaseUI::_request_handler (gpointer data) -{ - BaseUI* ui = static_cast(data); - return ui->request_handler (); -} - -bool -BaseUI::request_handler () -{ - DEBUG_TRACE (DEBUG::EventLoop, "BaseUI::request_handler\n"); - handle_ui_requests (); - // keep calling indefinitely at the timeout interval - return true; -} - -#else bool BaseUI::request_handler (Glib::IOCondition ioc) { @@ -153,30 +130,25 @@ BaseUI::request_handler (Glib::IOCondition ioc) if (ioc & IO_IN) { request_channel.drain (); - + /* there may been an error. we'd rather handle requests first, and then get IO_HUP or IO_ERR on the next loop. */ /* handle requests */ - DEBUG_TRACE (DEBUG::EventLoop, "BaseUI::request_handler\n"); + DEBUG_TRACE (DEBUG::EventLoop, string_compose ("%1: request handler\n", event_loop_name())); handle_ui_requests (); } return true; } -#endif void BaseUI::signal_new_request () { - DEBUG_TRACE (DEBUG::EventLoop, "BaseUI::signal_new_request\n"); -#ifdef PLATFORM_WINDOWS - // handled in timeout, how to signal...? -#else + DEBUG_TRACE (DEBUG::EventLoop, string_compose ("%1: signal_new_request\n", event_loop_name())); request_channel.wakeup (); -#endif } /** @@ -185,14 +157,6 @@ BaseUI::signal_new_request () void BaseUI::attach_request_source () { - DEBUG_TRACE (DEBUG::EventLoop, "BaseUI::attach_request_source\n"); -#ifdef PLATFORM_WINDOWS - GSource* request_source = g_timeout_source_new(200); - g_source_set_callback (request_source, &BaseUI::_request_handler, this, NULL); - g_source_attach (request_source, m_context->gobj()); -#else - request_channel.ios()->attach (m_context); - /* glibmm hack - drop the refptr to the IOSource now before it can hurt */ - request_channel.drop_ios (); -#endif + DEBUG_TRACE (DEBUG::EventLoop, string_compose ("%1: attach request source\n", event_loop_name())); + request_channel.attach (m_context); }