kopia lustrzana https://gitlab.com/eliggett/wfview
Set buffer size with a #define
rodzic
99ca97370b
commit
4696fe6824
|
@ -22,6 +22,8 @@
|
|||
#define AUDIO_SIZE 0x18
|
||||
#define DATA_SIZE 0x15
|
||||
|
||||
#define BUFSIZE 50 // Number of packets to buffer
|
||||
|
||||
// 0x10 length control packet (connect/disconnect/idle.)
|
||||
typedef union control_packet {
|
||||
struct {
|
||||
|
|
|
@ -1154,7 +1154,7 @@ void udpBase::dataReceived(QByteArray r)
|
|||
{
|
||||
rxBufferMutex.lock();
|
||||
if (rxSeqBuf.isEmpty()) {
|
||||
if (rxSeqBuf.size() > 400)
|
||||
if (rxSeqBuf.size() > BUFSIZE)
|
||||
{
|
||||
rxSeqBuf.erase(rxSeqBuf.begin());
|
||||
}
|
||||
|
@ -1178,7 +1178,7 @@ void udpBase::dataReceived(QByteArray r)
|
|||
{
|
||||
// Add incoming packet to the received buffer and if it is in the missing buffer, remove it.
|
||||
rxSeqBuf.insert(in->seq, QTime::currentTime());
|
||||
if (rxSeqBuf.size() > 400)
|
||||
if (rxSeqBuf.size() > BUFSIZE)
|
||||
{
|
||||
rxSeqBuf.erase(rxSeqBuf.begin());
|
||||
}
|
||||
|
@ -1242,7 +1242,7 @@ void udpBase::sendRetransmitRequest()
|
|||
rxMissing.erase(rxMissing.begin());
|
||||
}
|
||||
rxMissing.insert(j, 0);
|
||||
if (rxSeqBuf.size() > 400)
|
||||
if (rxSeqBuf.size() > BUFSIZE)
|
||||
{
|
||||
rxSeqBuf.erase(rxSeqBuf.begin());
|
||||
}
|
||||
|
@ -1388,7 +1388,7 @@ void udpBase::sendTrackedPacket(QByteArray d)
|
|||
congestion = 0;
|
||||
}
|
||||
txSeqBuf.insert(sendSeq,s);
|
||||
if (txSeqBuf.size() > 400)
|
||||
if (txSeqBuf.size() > BUFSIZE)
|
||||
{
|
||||
txSeqBuf.erase(txSeqBuf.begin());
|
||||
}
|
||||
|
|
|
@ -831,7 +831,7 @@ void udpServer::commonReceived(QList<CLIENT*>* l, CLIENT* current, QByteArray r)
|
|||
// Add incoming packet to the received buffer and if it is in the missing buffer, remove it.
|
||||
if (current->rxMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD)))
|
||||
{
|
||||
if (current->rxSeqBuf.size() > 400)
|
||||
if (current->rxSeqBuf.size() > BUFSIZE)
|
||||
{
|
||||
current->rxSeqBuf.remove(current->rxSeqBuf.firstKey());
|
||||
}
|
||||
|
@ -1126,7 +1126,7 @@ void udpServer::sendCapabilities(CLIENT* c)
|
|||
s.data = QByteArray::fromRawData((const char*)p.packet, sizeof(p));
|
||||
if (c->txMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD)))
|
||||
{
|
||||
if (c->txSeqBuf.size() > 400)
|
||||
if (c->txSeqBuf.size() > BUFSIZE)
|
||||
{
|
||||
c->txSeqBuf.remove(c->txSeqBuf.firstKey());
|
||||
}
|
||||
|
@ -1197,7 +1197,7 @@ void udpServer::sendConnectionInfo(CLIENT* c)
|
|||
|
||||
if (c->txMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD)))
|
||||
{
|
||||
if (c->txSeqBuf.size() > 400)
|
||||
if (c->txSeqBuf.size() > BUFSIZE)
|
||||
{
|
||||
c->txSeqBuf.remove(c->txSeqBuf.firstKey());
|
||||
}
|
||||
|
@ -1255,7 +1255,7 @@ void udpServer::sendTokenResponse(CLIENT* c, quint8 type)
|
|||
|
||||
if (c->txMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD)))
|
||||
{
|
||||
if (c->txSeqBuf.size() > 400)
|
||||
if (c->txSeqBuf.size() > BUFSIZE)
|
||||
{
|
||||
c->txSeqBuf.remove(c->txSeqBuf.firstKey());
|
||||
}
|
||||
|
@ -1373,7 +1373,7 @@ void udpServer::sendStatus(CLIENT* c)
|
|||
s.data = QByteArray::fromRawData((const char*)p.packet, sizeof(p));
|
||||
if (c->txMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD)))
|
||||
{
|
||||
if (c->txSeqBuf.size() > 400)
|
||||
if (c->txSeqBuf.size() > BUFSIZE)
|
||||
{
|
||||
c->txSeqBuf.remove(c->txSeqBuf.firstKey());
|
||||
}
|
||||
|
@ -1428,7 +1428,7 @@ void udpServer::dataForServer(QByteArray d)
|
|||
|
||||
if (client->txMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD)))
|
||||
{
|
||||
if (client->txSeqBuf.size() > 400)
|
||||
if (client->txSeqBuf.size() > BUFSIZE)
|
||||
{
|
||||
client->txSeqBuf.remove(client->txSeqBuf.firstKey());
|
||||
}
|
||||
|
@ -1510,7 +1510,7 @@ void udpServer::receiveAudioData(const audioPacket& d)
|
|||
s.data = t;
|
||||
if (client->txMutex.try_lock_for(std::chrono::milliseconds(LOCK_PERIOD)))
|
||||
{
|
||||
if (client->txSeqBuf.size() > 400)
|
||||
if (client->txSeqBuf.size() > BUFSIZE)
|
||||
{
|
||||
client->txSeqBuf.remove(client->txSeqBuf.firstKey());
|
||||
}
|
||||
|
@ -1605,7 +1605,7 @@ void udpServer::sendRetransmitRequest(CLIENT* c)
|
|||
qDebug(logUdp()) << this->metaObject()->className() << ": Adding to missing buffer (len=" << c->rxMissing.size() << "): " << j << dec << missingTime.msecsTo(QTime::currentTime()) << "ms";
|
||||
c->rxMissing.insert(j, 0);
|
||||
|
||||
if (c->rxSeqBuf.size() > 400)
|
||||
if (c->rxSeqBuf.size() > BUFSIZE)
|
||||
{
|
||||
c->rxSeqBuf.remove(c->rxSeqBuf.firstKey());
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue