mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 20:36:49 +02:00
Merge pull request #2503 from birarda/master
increase NodeList send buffer size to 1MB
This commit is contained in:
commit
020f4b020e
4 changed files with 37 additions and 7 deletions
|
@ -32,6 +32,7 @@ const unsigned int AVATAR_DATA_SEND_INTERVAL_MSECS = (1.0f / 60.0f) * 1000;
|
||||||
|
|
||||||
AvatarMixer::AvatarMixer(const QByteArray& packet) :
|
AvatarMixer::AvatarMixer(const QByteArray& packet) :
|
||||||
ThreadedAssignment(packet),
|
ThreadedAssignment(packet),
|
||||||
|
_broadcastThread(),
|
||||||
_lastFrameTimestamp(QDateTime::currentMSecsSinceEpoch()),
|
_lastFrameTimestamp(QDateTime::currentMSecsSinceEpoch()),
|
||||||
_trailingSleepRatio(1.0f),
|
_trailingSleepRatio(1.0f),
|
||||||
_performanceThrottlingRatio(0.0f),
|
_performanceThrottlingRatio(0.0f),
|
||||||
|
@ -44,6 +45,11 @@ AvatarMixer::AvatarMixer(const QByteArray& packet) :
|
||||||
connect(NodeList::getInstance(), &NodeList::nodeKilled, this, &AvatarMixer::nodeKilled);
|
connect(NodeList::getInstance(), &NodeList::nodeKilled, this, &AvatarMixer::nodeKilled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AvatarMixer::~AvatarMixer() {
|
||||||
|
_broadcastThread.quit();
|
||||||
|
_broadcastThread.wait();
|
||||||
|
}
|
||||||
|
|
||||||
void attachAvatarDataToNode(Node* newNode) {
|
void attachAvatarDataToNode(Node* newNode) {
|
||||||
if (!newNode->getLinkedData()) {
|
if (!newNode->getLinkedData()) {
|
||||||
newNode->setLinkedData(new AvatarMixerClientData());
|
newNode->setLinkedData(new AvatarMixerClientData());
|
||||||
|
@ -309,18 +315,15 @@ void AvatarMixer::run() {
|
||||||
|
|
||||||
nodeList->linkedDataCreateCallback = attachAvatarDataToNode;
|
nodeList->linkedDataCreateCallback = attachAvatarDataToNode;
|
||||||
|
|
||||||
// create a thead for broadcast of avatar data
|
|
||||||
QThread* broadcastThread = new QThread(this);
|
|
||||||
|
|
||||||
// setup the timer that will be fired on the broadcast thread
|
// setup the timer that will be fired on the broadcast thread
|
||||||
QTimer* broadcastTimer = new QTimer();
|
QTimer* broadcastTimer = new QTimer();
|
||||||
broadcastTimer->setInterval(AVATAR_DATA_SEND_INTERVAL_MSECS);
|
broadcastTimer->setInterval(AVATAR_DATA_SEND_INTERVAL_MSECS);
|
||||||
broadcastTimer->moveToThread(broadcastThread);
|
broadcastTimer->moveToThread(&_broadcastThread);
|
||||||
|
|
||||||
// connect appropriate signals and slots
|
// connect appropriate signals and slots
|
||||||
connect(broadcastTimer, &QTimer::timeout, this, &AvatarMixer::broadcastAvatarData, Qt::DirectConnection);
|
connect(broadcastTimer, &QTimer::timeout, this, &AvatarMixer::broadcastAvatarData, Qt::DirectConnection);
|
||||||
connect(broadcastThread, SIGNAL(started()), broadcastTimer, SLOT(start()));
|
connect(&_broadcastThread, SIGNAL(started()), broadcastTimer, SLOT(start()));
|
||||||
|
|
||||||
// start the broadcastThread
|
// start the broadcastThread
|
||||||
broadcastThread->start();
|
_broadcastThread.start();
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
class AvatarMixer : public ThreadedAssignment {
|
class AvatarMixer : public ThreadedAssignment {
|
||||||
public:
|
public:
|
||||||
AvatarMixer(const QByteArray& packet);
|
AvatarMixer(const QByteArray& packet);
|
||||||
|
~AvatarMixer();
|
||||||
public slots:
|
public slots:
|
||||||
/// runs the avatar mixer
|
/// runs the avatar mixer
|
||||||
void run();
|
void run();
|
||||||
|
@ -30,6 +30,8 @@ public slots:
|
||||||
private:
|
private:
|
||||||
void broadcastAvatarData();
|
void broadcastAvatarData();
|
||||||
|
|
||||||
|
QThread _broadcastThread;
|
||||||
|
|
||||||
quint64 _lastFrameTimestamp;
|
quint64 _lastFrameTimestamp;
|
||||||
|
|
||||||
float _trailingSleepRatio;
|
float _trailingSleepRatio;
|
||||||
|
|
|
@ -86,6 +86,29 @@ NodeList::NodeList(char newOwnerType, unsigned short int newSocketListenPort) :
|
||||||
_packetStatTimer.start();
|
_packetStatTimer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NodeList::changeSendSocketBufferSize(int numSendBytes) {
|
||||||
|
// change the socket send buffer size to be 1MB
|
||||||
|
int oldBufferSize = 0;
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
int sizeOfInt = sizeof(oldBufferSize);
|
||||||
|
#else
|
||||||
|
unsigned int sizeOfInt = sizeof(oldBufferSize);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
getsockopt(_nodeSocket.socketDescriptor(), SOL_SOCKET, SO_SNDBUF, reinterpret_cast<char*>(&oldBufferSize), &sizeOfInt);
|
||||||
|
|
||||||
|
const int LARGER_SNDBUF_SIZE = 1048576;
|
||||||
|
|
||||||
|
setsockopt(_nodeSocket.socketDescriptor(), SOL_SOCKET, SO_SNDBUF, reinterpret_cast<const char*>(&LARGER_SNDBUF_SIZE),
|
||||||
|
sizeof(LARGER_SNDBUF_SIZE));
|
||||||
|
|
||||||
|
int newBufferSize = 0;
|
||||||
|
getsockopt(_nodeSocket.socketDescriptor(), SOL_SOCKET, SO_SNDBUF, reinterpret_cast<char*>(&newBufferSize), &sizeOfInt);
|
||||||
|
|
||||||
|
qDebug() << "Changed socket send buffer size from" << oldBufferSize << "to" << newBufferSize << "bytes";
|
||||||
|
}
|
||||||
|
|
||||||
bool NodeList::packetVersionAndHashMatch(const QByteArray& packet) {
|
bool NodeList::packetVersionAndHashMatch(const QByteArray& packet) {
|
||||||
PacketType checkType = packetTypeForPacket(packet);
|
PacketType checkType = packetTypeForPacket(packet);
|
||||||
if (packet[1] != versionForPacketType(checkType)
|
if (packet[1] != versionForPacketType(checkType)
|
||||||
|
|
|
@ -161,6 +161,8 @@ private:
|
||||||
void activateSocketFromNodeCommunication(const QByteArray& packet, const SharedNodePointer& sendingNode);
|
void activateSocketFromNodeCommunication(const QByteArray& packet, const SharedNodePointer& sendingNode);
|
||||||
void timePingReply(const QByteArray& packet, const SharedNodePointer& sendingNode);
|
void timePingReply(const QByteArray& packet, const SharedNodePointer& sendingNode);
|
||||||
|
|
||||||
|
void changeSendSocketBufferSize(int numSendBytes);
|
||||||
|
|
||||||
NodeHash _nodeHash;
|
NodeHash _nodeHash;
|
||||||
QMutex _nodeHashMutex;
|
QMutex _nodeHashMutex;
|
||||||
QUdpSocket _nodeSocket;
|
QUdpSocket _nodeSocket;
|
||||||
|
|
Loading…
Reference in a new issue