mirror of
https://github.com/UberGames/lilium-voyager.git
synced 2024-12-13 13:40:56 +00:00
VoIP: Don't hardcode Speex sample rate.
This commit is contained in:
parent
13de2746ea
commit
26c706df15
5 changed files with 17 additions and 8 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue