mirror of
https://github.com/FWGS/xash3d-fwgs
synced 2024-11-22 09:56:22 +01:00
engine: client: voice: allow restoring voice after toggling voice_enable while connected to server
This commit is contained in:
parent
5554d13f7f
commit
2e30acf611
@ -32,6 +32,11 @@ CVAR_DEFINE_AUTO( voice_inputfromfile, "0", FCVAR_PRIVILEGED, "input voice from
|
||||
|
||||
static void Voice_ApplyGainAdjust( int16_t *samples, int count, float scale );
|
||||
|
||||
// in case user enabled voice after connection
|
||||
// can't keep in `voice` struct because it gets zeroed on shutdown
|
||||
static string voice_codec_init;
|
||||
static int voice_quality_init;
|
||||
|
||||
/*
|
||||
===============================================================================
|
||||
|
||||
@ -591,10 +596,17 @@ void Voice_Idle( double frametime )
|
||||
{
|
||||
int i;
|
||||
|
||||
if( FBitSet( voice_enable.flags, FCVAR_CHANGED ) && !voice_enable.value )
|
||||
if( FBitSet( voice_enable.flags, FCVAR_CHANGED ))
|
||||
{
|
||||
Voice_Shutdown();
|
||||
return;
|
||||
ClearBits( voice_enable.flags, FCVAR_CHANGED );
|
||||
|
||||
if( voice_enable.value )
|
||||
{
|
||||
if( cls.state == ca_active && COM_CheckString( voice_codec_init ) && voice_quality_init != 0 )
|
||||
Voice_Init( voice_codec_init, voice_quality_init, false );
|
||||
}
|
||||
else
|
||||
Voice_Shutdown();
|
||||
}
|
||||
|
||||
// update local player status first
|
||||
@ -613,6 +625,19 @@ Initialize the voice subsystem
|
||||
*/
|
||||
qboolean Voice_Init( const char *pszCodecName, int quality, qboolean preinit )
|
||||
{
|
||||
if( Q_strcmp( pszCodecName, VOICE_OPUS_CUSTOM_CODEC ))
|
||||
{
|
||||
Con_Printf( S_ERROR "Server requested unsupported codec: %s\n", pszCodecName );
|
||||
|
||||
// reset saved codec name, we won't enable voice for this connection
|
||||
voice_codec_init[0] = 0;
|
||||
voice_quality_init = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
Q_strncpy( voice_codec_init, pszCodecName, sizeof( voice_codec_init ));
|
||||
voice_quality_init = quality;
|
||||
|
||||
if( !voice_enable.value )
|
||||
return false;
|
||||
|
||||
@ -620,13 +645,6 @@ qboolean Voice_Init( const char *pszCodecName, int quality, qboolean preinit )
|
||||
if( Q_strcmp( pszCodecName, voice.codec ) || voice.quality != quality )
|
||||
{
|
||||
Voice_Shutdown();
|
||||
|
||||
if( Q_strcmp( pszCodecName, VOICE_OPUS_CUSTOM_CODEC ))
|
||||
{
|
||||
Con_Printf( S_ERROR "Server requested unsupported codec: %s\n", pszCodecName );
|
||||
return false;
|
||||
}
|
||||
|
||||
voice.autogain.block_size = 128;
|
||||
|
||||
if( !Voice_InitCustomMode( ))
|
||||
|
Loading…
Reference in New Issue
Block a user