- Apply parts of Ben Millwood's target bitfield patch (#3787)

- Fix Ryan's FIXME and have voip packet buffer on the server dynamically allocated via Z_Malloc and store pointers in a circular buffer
- Improve voip target parsing on top of Ben Millwood's patch
- Add new "spatial" target where speaker is spatialized in 3d space and can be heard by all clients in hearing range (s_alMaxDistance)
  (#4467)
- Decrease voip sound lengths from 240ms to 80ms per voip packet to mitigate udp packet loss and decrease latency
- Protocol version incremented to 71
This commit is contained in:
Thilo Schulz 2011-07-27 15:47:29 +00:00
parent 41ac8a232a
commit 2349148cf1
19 changed files with 403 additions and 241 deletions

View file

@ -663,6 +663,29 @@ qboolean CL_ShouldIgnoreVoipSender(int sender)
return qfalse;
}
/*
=====================
CL_PlayVoip
Play raw data
=====================
*/
static void CL_PlayVoip(int sender, int samplecnt, const byte *data, int flags)
{
if(flags & VOIP_DIRECT)
{
S_RawSamples(sender + 1, samplecnt, clc.speexSampleRate, 2, 1,
data, clc.voipGain[sender], -1);
}
if(flags & VOIP_SPATIAL)
{
S_RawSamples(sender + MAX_CLIENTS + 1, samplecnt, clc.speexSampleRate, 2, 1,
data, 1.0f, sender);
}
}
/*
=====================
CL_ParseVoip
@ -679,6 +702,7 @@ void CL_ParseVoip ( msg_t *msg ) {
const int sequence = MSG_ReadLong(msg);
const int frames = MSG_ReadByte(msg);
const int packetsize = MSG_ReadShort(msg);
const int flags = MSG_ReadBits(msg, VOIP_FLAGCNT);
char encoded[1024];
int seqdiff = sequence - clc.voipIncomingSequence[sender];
int written = 0;
@ -769,8 +793,8 @@ void CL_ParseVoip ( msg_t *msg ) {
if ((written + clc.speexFrameSize) * 2 > sizeof (decoded)) {
Com_DPrintf("VoIP: playback %d bytes, %d samples, %d frames\n",
written * 2, written, i);
S_RawSamples(sender + 1, written, clc.speexSampleRate, 2, 1,
(const byte *) decoded, clc.voipGain[sender]);
CL_PlayVoip(sender, written, (const byte *) decoded, flags);
written = 0;
}
@ -793,10 +817,8 @@ void CL_ParseVoip ( msg_t *msg ) {
Com_DPrintf("VoIP: playback %d bytes, %d samples, %d frames\n",
written * 2, written, i);
if (written > 0) {
S_RawSamples(sender + 1, written, clc.speexSampleRate, 2, 1,
(const byte *) decoded, clc.voipGain[sender]);
}
if(written > 0)
CL_PlayVoip(sender, written, (const byte *) decoded, flags);
clc.voipIncomingSequence[sender] = sequence + frames;
}