fix thinko when testing for internal seek with negative distance
[ardour.git] / libs / pbd / crossthread.cc
1 /*
2  * Copyright (C) 2009-2015 Paul Davis <paul@linuxaudiosystems.com>
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 along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18
19
20 #include <cstdlib>
21 #include <cerrno>
22 #include <cstring>
23 #include <fcntl.h>
24 #include <unistd.h>
25
26 #ifdef PLATFORM_WINDOWS
27 #include <winsock2.h>
28 #include <ws2tcpip.h>
29 #endif
30
31 #include "pbd/error.h"
32 #include "pbd/crossthread.h"
33
34 using namespace std;
35 using namespace PBD;
36 using namespace Glib;
37
38 #ifndef PLATFORM_WINDOWS
39 #include "crossthread.posix.cc"
40 #else
41 #include "crossthread.win.cc"
42 #endif
43
44 gboolean
45 cross_thread_channel_call_receive_slot (GIOChannel*, GIOCondition condition, void *data)
46 {
47         CrossThreadChannel* ctc = static_cast<CrossThreadChannel*>(data);
48         return ctc->receive_slot (Glib::IOCondition (condition));
49 }
50
51 void
52 CrossThreadChannel::set_receive_handler (sigc::slot<bool,Glib::IOCondition> s)
53 {
54         receive_slot = s;
55 }
56
57 void
58 CrossThreadChannel::attach (Glib::RefPtr<Glib::MainContext> context)
59 {
60         receive_source = g_io_create_watch (receive_channel, GIOCondition(G_IO_IN|G_IO_PRI|G_IO_ERR|G_IO_HUP|G_IO_NVAL));
61         g_source_set_callback (receive_source, (GSourceFunc) cross_thread_channel_call_receive_slot, this, NULL);
62         g_source_attach (receive_source, context->gobj());
63 }