engine: client: voice: fixed initialization checks
This commit is contained in:
parent
327dcc0293
commit
76dbefb9ec
1 changed files with 9 additions and 5 deletions
|
@ -139,7 +139,7 @@ qboolean Voice_Init( const char *pszCodecName, int quality )
|
||||||
|
|
||||||
Voice_DeInit();
|
Voice_DeInit();
|
||||||
|
|
||||||
voice.initialized = true;
|
voice.initialized = false;
|
||||||
voice.channels = 1;
|
voice.channels = 1;
|
||||||
voice.width = 2;
|
voice.width = 2;
|
||||||
voice.samplerate = SOUND_48k;
|
voice.samplerate = SOUND_48k;
|
||||||
|
@ -149,13 +149,13 @@ qboolean Voice_Init( const char *pszCodecName, int quality )
|
||||||
if( !VoiceCapture_Init() )
|
if( !VoiceCapture_Init() )
|
||||||
{
|
{
|
||||||
Voice_DeInit();
|
Voice_DeInit();
|
||||||
return false;
|
return voice.initialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
voice.encoder = opus_encoder_create( voice.samplerate, voice.channels, OPUS_APPLICATION_VOIP, &err );
|
voice.encoder = opus_encoder_create( voice.samplerate, voice.channels, OPUS_APPLICATION_VOIP, &err );
|
||||||
|
|
||||||
if( err != OPUS_OK )
|
if( err != OPUS_OK )
|
||||||
return false;
|
return voice.initialized;
|
||||||
|
|
||||||
voice.decoder = opus_decoder_create( voice.samplerate, voice.channels, &err );
|
voice.decoder = opus_decoder_create( voice.samplerate, voice.channels, &err );
|
||||||
|
|
||||||
|
@ -183,7 +183,8 @@ qboolean Voice_Init( const char *pszCodecName, int quality )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return err == OPUS_OK;
|
voice.initialized = (err == OPUS_OK);
|
||||||
|
return voice.initialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Voice_DeInit( void )
|
void Voice_DeInit( void )
|
||||||
|
@ -353,6 +354,9 @@ static void Voice_StartChannel( uint samples, byte *data, int entnum )
|
||||||
|
|
||||||
void Voice_AddIncomingData( int ent, const byte *data, uint size, uint frames )
|
void Voice_AddIncomingData( int ent, const byte *data, uint size, uint frames )
|
||||||
{
|
{
|
||||||
|
if( !voice.initialized )
|
||||||
|
return;
|
||||||
|
|
||||||
int samples = opus_decode( voice.decoder, 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 )
|
if( samples > 0 )
|
||||||
|
|
Loading…
Add table
Reference in a new issue