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