NO-OP: <tab> after <space> fixes in libs
[ardour.git] / libs / pbd / crossthread.cc
1 /*
2   Copyright (C) 2009 Paul Davis
3
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.
8
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.
13
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.
17
18 */
19
20
21 #include <cstdlib>
22 #include <cerrno>
23 #include <cstring>
24 #include <fcntl.h>
25 #include <unistd.h>
26
27 #ifdef PLATFORM_WINDOWS
28 #include <winsock2.h>
29 #include <ws2tcpip.h>
30 #endif
31
32 #include "pbd/error.h"
33 #include "pbd/crossthread.h"
34
35 using namespace std;
36 using namespace PBD;
37 using namespace Glib;
38
39 #ifndef PLATFORM_WINDOWS
40 #include "crossthread.posix.cc"
41 #else
42 #include "crossthread.win.cc"
43 #endif
44
45 gboolean
46 cross_thread_channel_call_receive_slot (GIOChannel*, GIOCondition condition, void *data)
47 {
48         CrossThreadChannel* ctc = static_cast<CrossThreadChannel*>(data);
49         return ctc->receive_slot (Glib::IOCondition (condition));
50 }
51
52 void
53 CrossThreadChannel::set_receive_handler (sigc::slot<bool,Glib::IOCondition> s)
54 {
55         receive_slot = s;
56 }
57
58 void
59 CrossThreadChannel::attach (Glib::RefPtr<Glib::MainContext> context)
60 {
61         receive_source = g_io_create_watch (receive_channel, GIOCondition(G_IO_IN|G_IO_PRI|G_IO_ERR|G_IO_HUP|G_IO_NVAL));
62         g_source_set_callback (receive_source, (GSourceFunc) cross_thread_channel_call_receive_slot, this, NULL);
63         g_source_attach (receive_source, context->gobj());
64 }