Read recv timestamps from socket (posix only).
This helps a lot on Android devices where the user threads can be scheduled with low priority when the app is in the background, causing spurious significantly delayed before a packet can be read from the socket. With this patch the timestamp is taken by the kernel when the packet actually arrives. R=juberti@chromium.org TBR=juberti@webrtc.org BUG=webrtc:5773 Review URL: https://codereview.webrtc.org/1944683002 . Cr-Commit-Position: refs/heads/master@{#12850}
This commit is contained in:
@ -102,7 +102,8 @@ void AsyncUDPSocket::OnReadEvent(AsyncSocket* socket) {
|
||||
ASSERT(socket_.get() == socket);
|
||||
|
||||
SocketAddress remote_addr;
|
||||
int len = socket_->RecvFrom(buf_, size_, &remote_addr);
|
||||
int64_t timestamp;
|
||||
int len = socket_->RecvFrom(buf_, size_, &remote_addr, ×tamp);
|
||||
if (len < 0) {
|
||||
// An error here typically means we got an ICMP error in response to our
|
||||
// send datagram, indicating the remote address was unreachable.
|
||||
@ -116,8 +117,9 @@ void AsyncUDPSocket::OnReadEvent(AsyncSocket* socket) {
|
||||
|
||||
// TODO: Make sure that we got all of the packet.
|
||||
// If we did not, then we should resize our buffer to be large enough.
|
||||
SignalReadPacket(this, buf_, static_cast<size_t>(len), remote_addr,
|
||||
CreatePacketTime(0));
|
||||
SignalReadPacket(
|
||||
this, buf_, static_cast<size_t>(len), remote_addr,
|
||||
(timestamp > -1 ? PacketTime(timestamp, 0) : CreatePacketTime(0)));
|
||||
}
|
||||
|
||||
void AsyncUDPSocket::OnWriteEvent(AsyncSocket* socket) {
|
||||
|
||||
Reference in New Issue
Block a user