comparison vamp-client/qt/ProcessQtTransport.h @ 286:b3b2e092bd61

Avoid deprecated API
author Chris Cannam <cannam@all-day-breakfast.com>
date Tue, 07 Jan 2020 11:20:47 +0000
parents b66077ee37a3
children
comparison
equal deleted inserted replaced
285:b66077ee37a3 286:b3b2e092bd61
40 #include "../Exceptions.h" 40 #include "../Exceptions.h"
41 41
42 #include <QProcess> 42 #include <QProcess>
43 #include <QString> 43 #include <QString>
44 #include <QMutex> 44 #include <QMutex>
45 #include <QTime> 45 #include <QElapsedTimer>
46 46
47 #include <iostream> 47 #include <iostream>
48 48
49 //#define DEBUG_TRANSPORT 1 49 //#define DEBUG_TRANSPORT 1
50 50
153 m_process->waitForBytesWritten(); 153 m_process->waitForBytesWritten();
154 154
155 std::vector<char> buffer; 155 std::vector<char> buffer;
156 bool complete = false; 156 bool complete = false;
157 157
158 QTime t; 158 QElapsedTimer t;
159 t.start(); 159 t.start();
160 160
161 // We don't like to timeout at all while waiting for a 161 // We don't like to timeout at all while waiting for a
162 // response -- we'd like to wait as long as the server 162 // response -- we'd like to wait as long as the server
163 // continues running. 163 // continues running.
164 // 164 //
165 int beforeResponseTimeout = 0; // ms, 0 = no timeout 165 qint64 beforeResponseTimeout = 0; // ms, 0 = no timeout
166 166
167 // But if the call is marked as fast (i.e. just retrieving 167 // But if the call is marked as fast (i.e. just retrieving
168 // info rather than calculating something) we will time out 168 // info rather than calculating something) we will time out
169 // after a bit. 169 // after a bit.
170 // 170 //
174 // then gets stuck. It's reasonable to assume that a server 174 // then gets stuck. It's reasonable to assume that a server
175 // that's already prepared its message and started sending has 175 // that's already prepared its message and started sending has
176 // finished doing any real work. In each case the timeout is 176 // finished doing any real work. In each case the timeout is
177 // measured since data was last read. 177 // measured since data was last read.
178 // 178 //
179 int duringResponseTimeout = 5000; // ms, 0 = no timeout 179 qint64 duringResponseTimeout = 5000; // ms, 0 = no timeout
180 180
181 while (!complete) { 181 while (!complete) {
182 182
183 bool responseStarted = !buffer.empty(); // already have something 183 bool responseStarted = !buffer.empty(); // already have something
184 int ms = t.elapsed(); // time since start or since last read 184 qint64 ms = t.elapsed(); // time since start or since last read
185 185
186 qint64 byteCount = m_process->bytesAvailable(); 186 qint64 byteCount = m_process->bytesAvailable();
187 187
188 if (!byteCount) { 188 if (!byteCount) {
189 189