Mercurial > hg > svcore
comparison data/osc/OSCQueue.cpp @ 847:2d53205f70cd tonioni
Merge from default branch
author | Chris Cannam |
---|---|
date | Tue, 26 Nov 2013 14:37:01 +0000 |
parents | e802e550a1f2 |
children | 59e7fe1b1003 |
comparison
equal
deleted
inserted
replaced
841:226733f3cf3f | 847:2d53205f70cd |
---|---|
30 #ifdef HAVE_LIBLO | 30 #ifdef HAVE_LIBLO |
31 | 31 |
32 void | 32 void |
33 OSCQueue::oscError(int num, const char *msg, const char *path) | 33 OSCQueue::oscError(int num, const char *msg, const char *path) |
34 { | 34 { |
35 std::cerr << "ERROR: OSCQueue::oscError: liblo server error " << num | 35 cerr << "ERROR: OSCQueue::oscError: liblo server error " << num |
36 << " in path " << path << ": " << msg << std::endl; | 36 << " in path " << path << ": " << msg << endl; |
37 } | 37 } |
38 | 38 |
39 int | 39 int |
40 OSCQueue::oscMessageHandler(const char *path, const char *types, lo_arg **argv, | 40 OSCQueue::oscMessageHandler(const char *path, const char *types, lo_arg **argv, |
41 int argc, lo_message, void *user_data) | 41 int argc, lo_message, void *user_data) |
71 case 'f': message.addArg(arg->f); break; | 71 case 'f': message.addArg(arg->f); break; |
72 case 'd': message.addArg(arg->d); break; | 72 case 'd': message.addArg(arg->d); break; |
73 case 'c': message.addArg(arg->c); break; | 73 case 'c': message.addArg(arg->c); break; |
74 case 't': message.addArg(arg->i); break; | 74 case 't': message.addArg(arg->i); break; |
75 case 's': message.addArg(&arg->s); break; | 75 case 's': message.addArg(&arg->s); break; |
76 default: std::cerr << "WARNING: OSCQueue::oscMessageHandler: " | 76 default: cerr << "WARNING: OSCQueue::oscMessageHandler: " |
77 << "Unsupported OSC type '" << type << "'" | 77 << "Unsupported OSC type '" << type << "'" |
78 << std::endl; | 78 << endl; |
79 break; | 79 break; |
80 } | 80 } |
81 | 81 |
82 ++i; | 82 ++i; |
83 } | 83 } |
102 lo_server_thread_add_method(m_thread, NULL, NULL, | 102 lo_server_thread_add_method(m_thread, NULL, NULL, |
103 oscMessageHandler, this); | 103 oscMessageHandler, this); |
104 | 104 |
105 lo_server_thread_start(m_thread); | 105 lo_server_thread_start(m_thread); |
106 | 106 |
107 std::cout << "OSCQueue::OSCQueue: Base OSC URL is " | 107 cout << "OSCQueue::OSCQueue: Base OSC URL is " |
108 << lo_server_thread_get_url(m_thread) << std::endl; | 108 << lo_server_thread_get_url(m_thread) << endl; |
109 #endif | 109 #endif |
110 } | 110 } |
111 | 111 |
112 OSCQueue::~OSCQueue() | 112 OSCQueue::~OSCQueue() |
113 { | 113 { |
161 OSCQueue::postMessage(OSCMessage message) | 161 OSCQueue::postMessage(OSCMessage message) |
162 { | 162 { |
163 int count = 0, max = 5; | 163 int count = 0, max = 5; |
164 while (m_buffer.getWriteSpace() == 0) { | 164 while (m_buffer.getWriteSpace() == 0) { |
165 if (count == max) { | 165 if (count == max) { |
166 std::cerr << "ERROR: OSCQueue::postMessage: OSC message queue is full and not clearing -- abandoning incoming message" << std::endl; | 166 cerr << "ERROR: OSCQueue::postMessage: OSC message queue is full and not clearing -- abandoning incoming message" << endl; |
167 return; | 167 return; |
168 } | 168 } |
169 std::cerr << "WARNING: OSCQueue::postMessage: OSC message queue (capacity " << m_buffer.getSize() << " is full!" << std::endl; | 169 cerr << "WARNING: OSCQueue::postMessage: OSC message queue (capacity " << m_buffer.getSize() << " is full!" << endl; |
170 SVDEBUG << "Waiting for something to be processed" << endl; | 170 SVDEBUG << "Waiting for something to be processed" << endl; |
171 #ifdef _WIN32 | 171 #ifdef _WIN32 |
172 Sleep(1); | 172 Sleep(1); |
173 #else | 173 #else |
174 sleep(1); | 174 sleep(1); |
210 } | 210 } |
211 | 211 |
212 method = path.section('/', i, -1); | 212 method = path.section('/', i, -1); |
213 | 213 |
214 if (method.contains('/')) { | 214 if (method.contains('/')) { |
215 std::cerr << "ERROR: OSCQueue::parseOSCPath: malformed path \"" | 215 cerr << "ERROR: OSCQueue::parseOSCPath: malformed path \"" |
216 << path << "\" (should be target/data/method or " | 216 << path << "\" (should be target/data/method or " |
217 << "target/method or method, where target and data " | 217 << "target/method or method, where target and data " |
218 << "are numeric)" << std::endl; | 218 << "are numeric)" << endl; |
219 return false; | 219 return false; |
220 } | 220 } |
221 | 221 |
222 SVDEBUG << "OSCQueue::parseOSCPath: good path \"" << path << "\"" << endl; | 222 SVDEBUG << "OSCQueue::parseOSCPath: good path \"" << path << "\"" << endl; |
223 | 223 |