block and wait for bytes to be written during broadcastAvatarData loop

This commit is contained in:
Stephen Birarda 2014-03-25 13:38:02 -07:00
parent 68d55152b9
commit 4e77afb4b2
2 changed files with 3 additions and 11 deletions

View file

@ -54,10 +54,6 @@ const float BILLBOARD_AND_IDENTITY_SEND_PROBABILITY = 1.0f / 300.0f;
// NOTE: some additional optimizations to consider.
// 1) use the view frustum to cull those avatars that are out of view. Since avatar data doesn't need to be present
// if the avatar is not in view or in the keyhole.
// 2) after culling for view frustum, sort order the avatars by distance, send the closest ones first.
// 3) if we need to rate limit the amount of data we send, we can use a distance weighted "semi-random" function to
// determine which avatars are included in the packet stream
// 4) we should optimize the avatar data format to be more compact (100 bytes is pretty wasteful).
void AvatarMixer::broadcastAvatarData() {
static QByteArray mixedAvatarByteArray;
@ -139,6 +135,8 @@ void AvatarMixer::broadcastAvatarData() {
++_sumIdentityPackets;
}
nodeList->getNodeSocket().waitForBytesWritten(-1);
}
}
}

View file

@ -171,13 +171,7 @@ qint64 NodeList::writeDatagram(const QByteArray& datagram, const HifiSockAddr& d
++_numCollectedPackets;
_numCollectedBytes += datagram.size();
qint64 bytesWritten = _nodeSocket.writeDatagram(datagramCopy,
destinationSockAddr.getAddress(),
destinationSockAddr.getPort());
// ask the underlying QUdpSocket to flush its buffers to avoid filling them up
_nodeSocket.flush();
return bytesWritten;
return _nodeSocket.writeDatagram(datagramCopy, destinationSockAddr.getAddress(), destinationSockAddr.getPort());
}