Mercurial > hg > svcore
comparison data/osc/OSCQueue.cpp @ 1678:1078f0ef3012 single-point
Make it possible to start queue without port (even when compiled in)
author | Chris Cannam |
---|---|
date | Thu, 28 Mar 2019 13:37:09 +0000 |
parents | 813dadf7c086 |
children | c077a97d055f |
comparison
equal
deleted
inserted
replaced
1677:f97d64b8674f | 1678:1078f0ef3012 |
---|---|
89 return 0; | 89 return 0; |
90 } | 90 } |
91 | 91 |
92 #endif | 92 #endif |
93 | 93 |
94 OSCQueue::OSCQueue() : | 94 OSCQueue::OSCQueue(bool withNetworkPort) : |
95 #ifdef HAVE_LIBLO | 95 #ifdef HAVE_LIBLO |
96 m_thread(nullptr), | 96 m_thread(nullptr), |
97 #endif | 97 #endif |
98 m_withPort(withNetworkPort), | |
98 m_buffer(OSC_MESSAGE_QUEUE_SIZE) | 99 m_buffer(OSC_MESSAGE_QUEUE_SIZE) |
99 { | 100 { |
100 Profiler profiler("OSCQueue::OSCQueue"); | 101 Profiler profiler("OSCQueue::OSCQueue"); |
101 | 102 |
102 #ifdef HAVE_LIBLO | 103 #ifdef HAVE_LIBLO |
103 m_thread = lo_server_thread_new(nullptr, oscError); | 104 if (m_withPort) { |
104 | 105 m_thread = lo_server_thread_new(nullptr, oscError); |
105 lo_server_thread_add_method(m_thread, nullptr, nullptr, | 106 |
106 oscMessageHandler, this); | 107 lo_server_thread_add_method(m_thread, nullptr, nullptr, |
107 | 108 oscMessageHandler, this); |
108 lo_server_thread_start(m_thread); | 109 |
109 | 110 lo_server_thread_start(m_thread); |
110 cout << "OSCQueue::OSCQueue: Base OSC URL is " | 111 |
111 << lo_server_thread_get_url(m_thread) << endl; | 112 SVDEBUG << "OSCQueue::OSCQueue: Started OSC thread, URL is " |
113 << lo_server_thread_get_url(m_thread) << endl; | |
114 | |
115 cout << "OSCQueue::OSCQueue: Base OSC URL is " | |
116 << lo_server_thread_get_url(m_thread) << endl; | |
117 } | |
118 #else | |
119 if (m_withPort) { | |
120 SVDEBUG << "OSCQueue::OSCQueue: Note: OSC port support not " | |
121 << "compiled in; not opening port, falling back to " | |
122 << "internal-only queue" << endl; | |
123 m_withPort = false; | |
124 } | |
112 #endif | 125 #endif |
113 } | 126 } |
114 | 127 |
115 OSCQueue::~OSCQueue() | 128 OSCQueue::~OSCQueue() |
116 { | 129 { |
126 } | 139 } |
127 | 140 |
128 bool | 141 bool |
129 OSCQueue::isOK() const | 142 OSCQueue::isOK() const |
130 { | 143 { |
131 #ifdef HAVE_LIBLO | 144 if (!m_withPort) { |
132 return (m_thread != nullptr); | 145 return true; |
146 } else { | |
147 #ifdef HAVE_LIBLO | |
148 return (m_thread != nullptr); | |
133 #else | 149 #else |
134 return false; | 150 return false; |
135 #endif | 151 #endif |
152 } | |
136 } | 153 } |
137 | 154 |
138 QString | 155 QString |
139 OSCQueue::getOSCURL() const | 156 OSCQueue::getOSCURL() const |
140 { | 157 { |
141 QString url = ""; | 158 QString url = ""; |
142 #ifdef HAVE_LIBLO | 159 #ifdef HAVE_LIBLO |
143 url = lo_server_thread_get_url(m_thread); | 160 if (m_thread) { |
161 url = lo_server_thread_get_url(m_thread); | |
162 } | |
144 #endif | 163 #endif |
145 return url; | 164 return url; |
146 } | 165 } |
147 | 166 |
148 int | 167 int |
183 } | 202 } |
184 | 203 |
185 OSCMessage *mp = new OSCMessage(message); | 204 OSCMessage *mp = new OSCMessage(message); |
186 m_buffer.write(&mp, 1); | 205 m_buffer.write(&mp, 1); |
187 SVDEBUG << "OSCQueue::postMessage: Posted OSC message: target " | 206 SVDEBUG << "OSCQueue::postMessage: Posted OSC message: target " |
188 << message.getTarget() << ", target data " << message.getTargetData() | 207 << message.getTarget() << ", target data " |
189 << ", method " << message.getMethod() << endl; | 208 << message.getTargetData() << ", method " |
209 << message.getMethod() << endl; | |
190 emit messagesAvailable(); | 210 emit messagesAvailable(); |
191 } | 211 } |
192 | 212 |
193 bool | 213 bool |
194 OSCQueue::parseOSCPath(QString path, int &target, int &targetData, | 214 OSCQueue::parseOSCPath(QString path, int &target, int &targetData, |
223 << "target/method or method, where target and data " | 243 << "target/method or method, where target and data " |
224 << "are numeric)" << endl; | 244 << "are numeric)" << endl; |
225 return false; | 245 return false; |
226 } | 246 } |
227 | 247 |
228 SVDEBUG << "OSCQueue::parseOSCPath: good path \"" << path << "\"" << endl; | 248 SVDEBUG << "OSCQueue::parseOSCPath: good path \"" << path |
249 << "\"" << endl; | |
229 | 250 |
230 return true; | 251 return true; |
231 } | 252 } |
232 | 253 |