Browse Source

engine: client: fixed players voice state changing

pull/2/head
SNMetamorph 2 years ago committed by Alibek Omarov
parent
commit
c5d7e3c783
  1. 6
      engine/client/cl_parse.c
  2. 30
      engine/client/voice.c
  3. 6
      engine/client/voice.h

6
engine/client/cl_parse.c

@ -1714,9 +1714,11 @@ void CL_ParseVoiceData( sizebuf_t *msg )
if ( idx <= 0 || idx > cl.maxclients ) if ( idx <= 0 || idx > cl.maxclients )
return; return;
if ( idx == cl.playernum + 1 ) if( idx == cl.playernum + 1 )
Voice_LocalPlayerTalkingAck(); Voice_LocalPlayerTalkingAck();
else
Voice_PlayerTalkingAck( idx );
if ( !size ) if ( !size )
return; return;

30
engine/client/voice.c

@ -171,6 +171,8 @@ uint Voice_GetCompressedData( byte *out, uint maxsize, uint *frames )
void Voice_Idle( float frametime ) void Voice_Idle( float frametime )
{ {
int i;
if ( !voice_enable.value ) if ( !voice_enable.value )
{ {
Voice_DeInit(); Voice_DeInit();
@ -180,13 +182,26 @@ void Voice_Idle( float frametime )
if ( voice.talking_ack ) if ( voice.talking_ack )
{ {
voice.talking_timeout += frametime; voice.talking_timeout += frametime;
if( voice.talking_timeout > 0.2f )
if ( voice.talking_timeout > 0.2f )
{ {
voice.talking_ack = false; voice.talking_ack = false;
Voice_Status( -2, false ); Voice_Status( -2, false );
} }
} }
for ( i = 0; i < 32; i++ )
{
if ( voice.players_status[i].talking_ack )
{
voice.players_status[i].talking_timeout += frametime;
if ( voice.players_status[i].talking_timeout > 0.2f )
{
voice.players_status[i].talking_ack = false;
if ( i < cl.maxclients )
Voice_Status( i, false );
}
}
}
} }
qboolean Voice_IsRecording( void ) qboolean Voice_IsRecording( void )
@ -286,6 +301,17 @@ void Voice_LocalPlayerTalkingAck( void )
voice.talking_timeout = 0.0f; voice.talking_timeout = 0.0f;
} }
void Voice_PlayerTalkingAck(int playerIndex)
{
if( !voice.players_status[playerIndex].talking_ack )
{
Voice_Status( playerIndex, true );
}
voice.players_status[playerIndex].talking_ack = true;
voice.players_status[playerIndex].talking_timeout = 0.0f;
}
void Voice_StartChannel( uint samples, byte *data, int entnum ) void Voice_StartChannel( uint samples, byte *data, int entnum )
{ {
SND_ForceInitMouth( entnum ); SND_ForceInitMouth( entnum );

6
engine/client/voice.h

@ -19,6 +19,11 @@ typedef struct voice_state_s
qboolean talking_ack; qboolean talking_ack;
float talking_timeout; float talking_timeout;
struct {
qboolean talking_ack;
float talking_timeout;
} players_status[32];
// opus stuff // opus stuff
OpusEncoder *encoder; OpusEncoder *encoder;
OpusDecoder *decoder; OpusDecoder *decoder;
@ -51,6 +56,7 @@ void Voice_RecordStart( void );
void Voice_AddIncomingData( int ent, byte *data, uint size, uint frames ); void Voice_AddIncomingData( int ent, byte *data, uint size, uint frames );
qboolean Voice_GetLoopback( void ); qboolean Voice_GetLoopback( void );
void Voice_LocalPlayerTalkingAck( void ); void Voice_LocalPlayerTalkingAck( void );
void Voice_PlayerTalkingAck( int playerIndex );
void Voice_StartChannel( uint samples, byte *data, int entnum ); void Voice_StartChannel( uint samples, byte *data, int entnum );
#endif // VOICE_H #endif // VOICE_H

Loading…
Cancel
Save