Browse Source

engine: small code fixes related to voice chat

pull/2/head
SNMetamorph 2 years ago committed by Alibek Omarov
parent
commit
97879430e9
  1. 11
      engine/client/cl_parse.c
  2. 4
      engine/client/voice.c
  3. 2
      engine/client/voice.h
  4. 15
      engine/platform/linux/s_alsa.c
  5. 2
      engine/server/server.h
  6. 3
      engine/server/sv_client.c
  7. 2
      engine/server/sv_init.c

11
engine/client/cl_parse.c

@ -1700,14 +1700,14 @@ CL_ParseVoiceData @@ -1700,14 +1700,14 @@ CL_ParseVoiceData
void CL_ParseVoiceData( sizebuf_t *msg )
{
int size, idx, frames;
unsigned char received[8192];
static byte received[8192];
idx = MSG_ReadByte( msg ) + 1;
frames = MSG_ReadByte( msg );
size = MSG_ReadShort( msg );
size = Q_min( size, 8192 );
size = Q_min( size, sizeof( received ));
MSG_ReadBytes( msg, received, size );
@ -3149,13 +3149,6 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg, qboolean normal_message ) @@ -3149,13 +3149,6 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg, qboolean normal_message )
case svc_director:
CL_ParseDirector( msg );
break;
case svc_voiceinit:
CL_ParseVoiceInit( msg );
break;
case svc_voicedata:
CL_ParseVoiceData( msg );
cl.frames[cl.parsecountmod].graphdata.voicebytes += MSG_GetNumBytesRead( msg ) - bufStart;
break;
case svc_resourcelocation:
CL_ParseResLocation( msg );
break;

4
engine/client/voice.c

@ -306,9 +306,9 @@ void Voice_RecordStart( void ) @@ -306,9 +306,9 @@ void Voice_RecordStart( void )
Voice_Status( -1, true );
}
void Voice_AddIncomingData( int ent, byte *data, uint size, uint frames )
void Voice_AddIncomingData( int ent, const byte *data, uint size, uint frames )
{
int samples = opus_decode( voice.decoder, (const byte*)data, size, (short *)voice.decompress_buffer, voice.frame_size / voice.width * frames, false );
int samples = opus_decode( voice.decoder, data, size, (short *)voice.decompress_buffer, voice.frame_size / voice.width * frames, false );
if ( samples > 0 )
Voice_StartChannel( samples, voice.decompress_buffer, ent );

2
engine/client/voice.h

@ -61,7 +61,7 @@ void Voice_Idle( float frametime ); @@ -61,7 +61,7 @@ void Voice_Idle( float frametime );
qboolean Voice_IsRecording( void );
void Voice_RecordStop( void );
void Voice_RecordStart( void );
void Voice_AddIncomingData( int ent, byte *data, uint size, uint frames );
void Voice_AddIncomingData( int ent, const byte *data, uint size, uint frames );
qboolean Voice_GetLoopback( void );
void Voice_LocalPlayerTalkingAck( void );
void Voice_PlayerTalkingAck( int playerIndex );

15
engine/platform/linux/s_alsa.c

@ -341,4 +341,19 @@ void SNDDMA_Activate( qboolean active ) @@ -341,4 +341,19 @@ void SNDDMA_Activate( qboolean active )
}
}
qboolean VoiceCapture_Init( void )
{
return false;
}
qboolean VoiceCapture_RecordStart( void )
{
return false;
}
void VoiceCapture_RecordStop( void )
{
}
#endif

2
engine/server/server.h

@ -418,6 +418,8 @@ extern convar_t sv_stopspeed; @@ -418,6 +418,8 @@ extern convar_t sv_stopspeed;
extern convar_t sv_maxspeed;
extern convar_t sv_wateralpha;
extern convar_t sv_wateramp;
extern convar_t sv_voiceenable;
extern convar_t sv_voicequality;
extern convar_t sv_stepsize;
extern convar_t sv_maxvelocity;
extern convar_t sv_rollangle;

3
engine/server/sv_client.c

@ -2587,7 +2587,7 @@ void SV_ParseVoiceData( sv_client_t *cl, sizebuf_t *msg ) @@ -2587,7 +2587,7 @@ void SV_ParseVoiceData( sv_client_t *cl, sizebuf_t *msg )
return;
}
if ( !Cvar_VariableInteger( "sv_voiceenable" ) )
if ( (int)sv_voiceenable.value == 0 )
return;
MSG_ReadBytes( msg, received, size );
@ -2599,6 +2599,7 @@ void SV_ParseVoiceData( sv_client_t *cl, sizebuf_t *msg ) @@ -2599,6 +2599,7 @@ void SV_ParseVoiceData( sv_client_t *cl, sizebuf_t *msg )
length = size;
// 6 is a number of bytes for other parts of message
if ( MSG_GetNumBytesLeft( &cur->datagram ) < length + 6 )
continue;

2
engine/server/sv_init.c

@ -395,7 +395,7 @@ void SV_WriteVoiceCodec( sizebuf_t *msg ) @@ -395,7 +395,7 @@ void SV_WriteVoiceCodec( sizebuf_t *msg )
{
MSG_BeginServerCmd( msg, svc_voiceinit );
MSG_WriteString( msg, "opus" );
MSG_WriteByte( msg, Cvar_VariableInteger( "sv_voicequality" ));
MSG_WriteByte( msg, (int)sv_voicequality.value );
}
/*

Loading…
Cancel
Save