2 Copyright (C) 2000-2007 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include "pbd/base_ui.h"
28 #include "pbd/error.h"
29 #include "pbd/compose.h"
30 #include "pbd/failed_constructor.h"
37 uint32_t BaseUI::rt_bit = 1;
38 BaseUI::RequestType BaseUI::CallSlot = BaseUI::new_request_type();
40 BaseUI::BaseUI (string str, bool with_signal_pipe)
43 /* odd pseudo-singleton semantics */
45 base_ui_instance = this;
50 if (with_signal_pipe) {
51 if (setup_signal_pipe ()) {
52 throw failed_constructor ();
59 if (signal_pipe[0] >= 0) {
60 close (signal_pipe[0]);
63 if (signal_pipe[1] >= 0) {
64 close (signal_pipe[1]);
69 BaseUI::new_request_type ()
73 /* XXX catch out-of-range */
75 rt = RequestType (rt_bit);
82 BaseUI::setup_signal_pipe ()
84 /* setup the pipe that other threads send us notifications/requests
88 if (pipe (signal_pipe)) {
89 error << string_compose (_("%1-UI: cannot create error signal pipe (%2)"), _name, ::strerror (errno))
95 if (fcntl (signal_pipe[0], F_SETFL, O_NONBLOCK)) {
96 error << string_compose (_("%1-UI: cannot set O_NONBLOCK on signal read pipe (%2)"), _name, ::strerror (errno))
101 if (fcntl (signal_pipe[1], F_SETFL, O_NONBLOCK)) {
102 error << string_compose (_("%1-UI: cannot set O_NONBLOCK on signal write pipe (%2)"), _name, ::strerror (errno))