kopia lustrzana https://gitlab.com/eliggett/wfview
Add mutex for incoming audio on udp and server
rodzic
b5591e0867
commit
42675ae770
|
@ -856,7 +856,11 @@ void udpAudio::sendTxAudio()
|
|||
return;
|
||||
}
|
||||
QByteArray audio;
|
||||
if (audioMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD)))
|
||||
{
|
||||
txaudio->getNextAudioChunk(audio);
|
||||
// Now we have the next audio chunk, we can release the mutex.
|
||||
audioMutex.unlock();
|
||||
|
||||
if (audio.length() > 0) {
|
||||
int counter = 1;
|
||||
|
@ -886,6 +890,10 @@ void udpAudio::sendTxAudio()
|
|||
counter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
qInfo(logUdpServer()) << "Unable to lock mutex for rxaudio";
|
||||
}
|
||||
}
|
||||
|
||||
void udpAudio::changeLatency(quint16 value)
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#define AREYOUTHERE_PERIOD 500
|
||||
#define WATCHDOG_PERIOD 500
|
||||
#define RETRANSMIT_PERIOD 100
|
||||
#define LOCK_PERIOD 100
|
||||
|
||||
struct udpPreferences {
|
||||
QString ipAddress;
|
||||
|
@ -197,6 +198,8 @@ private:
|
|||
QTimer* txAudioTimer=Q_NULLPTR;
|
||||
bool enableTx = true;
|
||||
|
||||
QMutex audioMutex;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1469,8 +1469,12 @@ void udpServer::sendRxAudio()
|
|||
{
|
||||
QByteArray audio;
|
||||
if (rxaudio) {
|
||||
if (audioMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD)))
|
||||
{
|
||||
audio.clear();
|
||||
rxaudio->getNextAudioChunk(audio);
|
||||
// Now we have the next audio chunk, we can release the mutex.
|
||||
audioMutex.unlock();
|
||||
int len = 0;
|
||||
while (len < audio.length()) {
|
||||
audioPacket partial;
|
||||
|
@ -1479,6 +1483,10 @@ void udpServer::sendRxAudio()
|
|||
len = len + partial.data.length();
|
||||
}
|
||||
}
|
||||
else {
|
||||
qInfo(logUdpServer()) << "Unable to lock mutex for rxaudio";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -154,6 +154,7 @@ private:
|
|||
|
||||
QMutex udpMutex; // Used for critical operations.
|
||||
QMutex connMutex;
|
||||
QMutex audioMutex;
|
||||
|
||||
QList <CLIENT*> controlClients = QList<CLIENT*>();
|
||||
QList <CLIENT*> civClients = QList<CLIENT*>();
|
||||
|
|
Ładowanie…
Reference in New Issue