diff options
Diffstat (limited to 'code')
-rw-r--r-- | code/client/cl_cgame.c | 8 | ||||
-rw-r--r-- | code/client/cl_main.c | 4 | ||||
-rw-r--r-- | code/client/cl_parse.c | 8 | ||||
-rw-r--r-- | code/client/client.h | 1 | ||||
-rw-r--r-- | code/client/snd_openal.c | 4 |
5 files changed, 17 insertions, 8 deletions
diff --git a/code/client/cl_cgame.c b/code/client/cl_cgame.c index e93a73e..1c7dd2b 100644 --- a/code/client/cl_cgame.c +++ b/code/client/cl_cgame.c @@ -923,6 +923,12 @@ void CL_FirstSnapshot( void ) { speex_bits_init(&clc.speexEncoderBits); speex_bits_reset(&clc.speexEncoderBits); clc.speexEncoder = speex_encoder_init(&speex_nb_mode); + + speex_encoder_ctl(clc.speexEncoder, SPEEX_GET_FRAME_SIZE, + &clc.speexFrameSize); + speex_encoder_ctl(clc.speexEncoder, SPEEX_GET_SAMPLING_RATE, + &clc.speexSamplingRate); + for (i = 0; i < MAX_CLIENTS; i++) { speex_bits_init(&clc.speexDecoderBits[i]); speex_bits_reset(&clc.speexDecoderBits[i]); @@ -930,8 +936,6 @@ void CL_FirstSnapshot( void ) { clc.voipIgnore[i] = qfalse; clc.voipGain[i] = 1.0f; } - speex_encoder_ctl(clc.speexEncoder, SPEEX_GET_FRAME_SIZE, - &clc.speexFrameSize); clc.speexInitialized = qtrue; clc.voipMuteAll = qfalse; Cmd_AddCommand ("voip", CL_Voip_f); diff --git a/code/client/cl_main.c b/code/client/cl_main.c index cd6a146..0129558 100644 --- a/code/client/cl_main.c +++ b/code/client/cl_main.c @@ -310,14 +310,14 @@ void CL_CaptureVoip(void) } if ((cl_voipSend->integer) || (finalFrame)) { // user wants to capture audio? - // !!! FIXME: 8000, MONO16, 4096 samples are hardcoded in snd_openal.c int samples = S_AvailableCaptureSamples(); const int mult = (finalFrame) ? 1 : 12; // 12 == 240ms of audio. // enough data buffered in audio hardware to process yet? if (samples >= (clc.speexFrameSize * mult)) { // audio capture is always MONO16 (and that's what speex wants!). - static int16_t sampbuffer[4096]; // !!! FIXME: don't hardcode. + // 2048 will cover 12 uncompressed frames in narrowband mode. + static int16_t sampbuffer[2048]; int16_t voipPower = 0; int speexFrames = 0; int wpos = 0; diff --git a/code/client/cl_parse.c b/code/client/cl_parse.c index e8d78dc..b00e861 100644 --- a/code/client/cl_parse.c +++ b/code/client/cl_parse.c @@ -759,8 +759,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, 8000, 2, 1, - (const byte *) decoded, clc.voipGain[sender]); // !!! FIXME: hardcoding! + S_RawSamples(sender + 1, written, clc.speexSampleRate, 2, 1, + (const byte *) decoded, clc.voipGain[sender]); written = 0; } @@ -784,8 +784,8 @@ void CL_ParseVoip ( msg_t *msg ) { written * 2, written, i); if (written > 0) { - S_RawSamples(sender + 1, written, 8000, 2, 1, - (const byte *) decoded, clc.voipGain[sender]); // !!! FIXME: hardcoding! + S_RawSamples(sender + 1, written, clc.speexSampleRate, 2, 1, + (const byte *) decoded, clc.voipGain[sender]); } clc.voipIncomingSequence[sender] = sequence + frames; diff --git a/code/client/client.h b/code/client/client.h index 152d0b9..9e9b212 100644 --- a/code/client/client.h +++ b/code/client/client.h @@ -232,6 +232,7 @@ typedef struct { #if USE_VOIP qboolean speexInitialized; int speexFrameSize; + int speexSampleRate; // incoming data... // !!! FIXME: convert from parallel arrays to array of a struct. diff --git a/code/client/snd_openal.c b/code/client/snd_openal.c index 5f88ab0..1cb48b8 100644 --- a/code/client/snd_openal.c +++ b/code/client/snd_openal.c @@ -2088,6 +2088,10 @@ qboolean S_AL_Init( soundInterface_t *si ) if (qalcCaptureOpenDevice == NULL) { Com_Printf("No ALC_EXT_capture support, can't record audio.\n"); } else { + // !!! FIXME: 8000Hz is what Speex narrowband mode needs, but we + // !!! FIXME: should probably open the capture device after + // !!! FIXME: initializing Speex so we can change to wideband + // !!! FIXME: if we like. Com_Printf("OpenAL default capture device is '%s'\n", qalcGetString(NULL, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER)); alCaptureDevice = qalcCaptureOpenDevice(NULL, 8000, AL_FORMAT_MONO16, 4096); |