3 Copyright (C) 2011 Grame
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 Grame Research Laboratory, 9 rue du Garet, 69001 Lyon - France
29 #include "OSCListener.h"
34 //--------------------------------------------------------------------------
36 \brief a specific thread to listen incoming osc packets
38 class OscThread
: public TThreads
41 SOSCListener fListener
;
43 OscThread(MessageProcessor
* mp
, int udpport
)
44 { fListener
= OSCListener::create (mp
, udpport
); }
45 virtual ~OscThread() { stop(); }
47 /// \brief starts the osc listener
48 void run () { fListener
->run(); }
49 void stop () { fListener
->stop(); quit(); }
50 SOSCListener
& listener() { return fListener
; }
53 //--------------------------------------------------------------------------
54 OSCSetup::~OSCSetup() { stop(); }
55 bool OSCSetup::running() const { return fOSCThread
? fOSCThread
->isRunning() : false; }
57 //--------------------------------------------------------------------------
58 bool OSCSetup::start(MessageProcessor
* mp
, int& inPort
, int outPort
, int errPort
, const char* address
)
65 oscout
.setPort(outPort
);
66 oscerr
.setPort (errPort
);
67 oscout
.setAddress(address
);
68 oscerr
.setAddress(address
);
69 fOSCThread
= new OscThread (mp
, port
);
73 catch (std::runtime_error e
) {
74 if ( port
- inPort
> 1000) return false;
77 } while ((port
== outPort
) || (port
== errPort
));
84 //--------------------------------------------------------------------------