comparison vamp-client/ProcessQtTransport.h @ 104:387d38c96c16

Merge
author Chris Cannam <c.cannam@qmul.ac.uk>
date Fri, 14 Oct 2016 16:24:01 +0100
parents 8c449824e08d
children 247d8d533a9c
comparison
equal deleted inserted replaced
103:6fad5154778e 104:387d38c96c16
22 * serializes explicitly using a mutex. 22 * serializes explicitly using a mutex.
23 */ 23 */
24 class ProcessQtTransport : public SynchronousTransport 24 class ProcessQtTransport : public SynchronousTransport
25 { 25 {
26 public: 26 public:
27 ProcessQtTransport(QString processName) : 27 ProcessQtTransport(std::string processName) :
28 m_completenessChecker(0) { 28 m_completenessChecker(0) {
29 m_process = new QProcess(); 29 m_process = new QProcess();
30 m_process->setReadChannel(QProcess::StandardOutput); 30 m_process->setReadChannel(QProcess::StandardOutput);
31 m_process->setProcessChannelMode(QProcess::ForwardedErrorChannel); 31 m_process->setProcessChannelMode(QProcess::ForwardedErrorChannel);
32 m_process->start(processName); 32 m_process->start(QString::fromStdString(processName));
33 if (!m_process->waitForStarted()) { 33 if (!m_process->waitForStarted()) {
34 std::cerr << "server failed to start" << std::endl; 34 std::cerr << "server failed to start" << std::endl;
35 delete m_process; 35 delete m_process;
36 m_process = nullptr; 36 m_process = nullptr;
37 } 37 }
75 std::vector<char> buffer; 75 std::vector<char> buffer;
76 bool complete = false; 76 bool complete = false;
77 77
78 while (!complete) { 78 while (!complete) {
79 79
80 m_process->waitForReadyRead(1000);
81 qint64 byteCount = m_process->bytesAvailable(); 80 qint64 byteCount = m_process->bytesAvailable();
82 81
83 if (!byteCount) { 82 if (!byteCount) {
83 std::cerr << "waiting for data from server..." << endl;
84 m_process->waitForReadyRead(1000);
84 if (m_process->state() == QProcess::NotRunning) { 85 if (m_process->state() == QProcess::NotRunning) {
85 std::cerr << "ERROR: Subprocess exited: Load failed" << std::endl; 86 std::cerr << "ERROR: Subprocess exited: Load failed" << std::endl;
86 throw std::runtime_error("Piper server exited unexpectedly"); 87 throw std::runtime_error("Piper server exited unexpectedly");
87 } 88 }
88 } else { 89 } else {