Restart audio device if stopped/suspended

qcpfix
Phil Taylor 2023-02-17 16:56:01 +00:00
rodzic acaed4601e
commit f9ca8e7e84
1 zmienionych plików z 5 dodań i 3 usunięć

Wyświetl plik

@ -105,17 +105,20 @@ void cwSidetone::init()
#endif #endif
output->setVolume((qreal)volume/100.0); output->setVolume((qreal)volume/100.0);
outputDevice = output->start();
} }
} }
void cwSidetone::send(QString text) void cwSidetone::send(QString text)
{ {
if (output != Q_NULLPTR) { if (output != Q_NULLPTR && outputDevice != Q_NULLPTR) {
text=text.simplified(); text=text.simplified();
buffer.clear(); buffer.clear();
QString currentChar; QString currentChar;
int pos = 0; int pos = 0;
outputDevice = output->start(); if (output->state() == QAudio::StoppedState || output->state() == QAudio::SuspendedState) {
output->resume();
}
while (pos < text.size()) while (pos < text.size())
{ {
QChar ch = text.at(pos).toUpper(); QChar ch = text.at(pos).toUpper();
@ -145,7 +148,6 @@ void cwSidetone::send(QString text)
} }
//qInfo(logCW()) << "Sending" << this->currentChar; //qInfo(logCW()) << "Sending" << this->currentChar;
emit finished(); emit finished();
output->stop();
return; return;
} }