Avoid accumulating audio latency from audio captured by the host before we're ready to play it
This commit is contained in:
parent
610c00bf2d
commit
f884003066
1 changed files with 13 additions and 0 deletions
|
|
@ -152,6 +152,7 @@ static void ReceiveThreadProc(void* context) {
|
||||||
PQUEUED_AUDIO_PACKET packet;
|
PQUEUED_AUDIO_PACKET packet;
|
||||||
int queueStatus;
|
int queueStatus;
|
||||||
int useSelect;
|
int useSelect;
|
||||||
|
int packetsToDrop = 100;
|
||||||
|
|
||||||
packet = NULL;
|
packet = NULL;
|
||||||
|
|
||||||
|
|
@ -182,6 +183,10 @@ static void ReceiveThreadProc(void* context) {
|
||||||
}
|
}
|
||||||
else if (packet->size == 0) {
|
else if (packet->size == 0) {
|
||||||
// Receive timed out; try again
|
// Receive timed out; try again
|
||||||
|
|
||||||
|
// If we hit this path, there are no queued audio packets on the host PC,
|
||||||
|
// so we don't need to drop anything.
|
||||||
|
packetsToDrop = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -196,6 +201,14 @@ static void ReceiveThreadProc(void* context) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GFE accumulates audio samples before we are ready to receive them,
|
||||||
|
// so we will drop the first 100 packets to avoid accumulating latency
|
||||||
|
// by sending audio frames to the player faster than they can be played.
|
||||||
|
if (packetsToDrop > 0) {
|
||||||
|
packetsToDrop--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// RTP sequence number must be in host order for the RTP queue
|
// RTP sequence number must be in host order for the RTP queue
|
||||||
rtp->sequenceNumber = htons(rtp->sequenceNumber);
|
rtp->sequenceNumber = htons(rtp->sequenceNumber);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue