1 |
/* |
/* |
2 |
* LSCP Shell |
* LSCP Shell |
3 |
* |
* |
4 |
* Copyright (c) 2014 - 2016 Christian Schoenebeck |
* Copyright (c) 2014 - 2020 Christian Schoenebeck |
5 |
* |
* |
6 |
* This program is part of LinuxSampler and released under the same terms. |
* This program is part of LinuxSampler and released under the same terms. |
7 |
*/ |
*/ |
316 |
* internal FIFO buffer. |
* internal FIFO buffer. |
317 |
*/ |
*/ |
318 |
int LSCPClient::Main() { |
int LSCPClient::Main() { |
319 |
|
#if DEBUG |
320 |
|
Thread::setNameOfCaller("LSCPClient"); |
321 |
|
#endif |
322 |
|
|
323 |
while (true) { |
while (true) { |
324 |
optional<String> pLine = receiveLine(); |
optional<String> pLine = receiveLine(); |
325 |
|
|
326 |
|
// prevent thread from being cancelled |
327 |
|
// (e.g. to prevent deadlocks while holding mutex lock(s)) |
328 |
|
pushCancelable(false); |
329 |
|
|
330 |
if (pLine) { // if there was a line received ... |
if (pLine) { // if there was a line received ... |
331 |
//lscpLog("[client receiveLine] '%s'\n", pLine->c_str()); |
//lscpLog("[client receiveLine] '%s'\n", pLine->c_str()); |
332 |
String s = *pLine; |
String s = *pLine; |
357 |
if (m_sync.GetUnsafe()) m_sync.Set(false); |
if (m_sync.GetUnsafe()) m_sync.Set(false); |
358 |
else if (m_callback) (*m_callback)(this); |
else if (m_callback) (*m_callback)(this); |
359 |
} else if (m_errorCallback) (*m_errorCallback)(this); |
} else if (m_errorCallback) (*m_errorCallback)(this); |
360 |
|
|
361 |
|
// now allow thread being cancelled again |
362 |
|
// (since all mutexes are now unlocked) |
363 |
|
popCancelable(); |
364 |
|
|
365 |
TestCancel(); |
TestCancel(); |
366 |
} |
} |
367 |
return 0; // just to avoid a warning with some old compilers |
return 0; // just to avoid a warning with some old compilers |