Added AGC on audio output because some echo cancellation implementations don't like loud audio in speakerphone mode; this should only be enabled when using the earpiece speaker, on devices that have one. Also, the AGC on the input is now configured with a much lower target level.

This commit is contained in:
Grishka
2017-09-07 08:39:33 +03:00
parent a8aff0e64c
commit d348e56436
10 changed files with 173 additions and 18 deletions

View File

@@ -8,6 +8,7 @@
#include "audio/Resampler.h"
#include "logging.h"
#include <assert.h>
#include <algorithm>
#define PACKET_SIZE (960*2)
@@ -222,6 +223,9 @@ void tgvoip::OpusDecoder::RunThread(){
unsigned char *buf=bufferPool->Get();
if(buf){
if(size>0){
for(std::vector<AudioEffect*>::iterator effect=postProcEffects.begin();effect!=postProcEffects.end();++effect){
(*effect)->Process(reinterpret_cast<int16_t*>(processedBuffer+(PACKET_SIZE*i)), 960);
}
memcpy(buf, processedBuffer+(PACKET_SIZE*i), PACKET_SIZE);
}else{
LOGE("Error decoding, result=%d", size);
@@ -255,3 +259,13 @@ void tgvoip::OpusDecoder::ResetQueue(){
void tgvoip::OpusDecoder::SetJitterBuffer(JitterBuffer* jitterBuffer){
this->jitterBuffer=jitterBuffer;
}
void tgvoip::OpusDecoder::AddAudioEffect(AudioEffect *effect){
postProcEffects.push_back(effect);
}
void tgvoip::OpusDecoder::RemoveAudioEffect(AudioEffect *effect){
std::vector<AudioEffect*>::iterator i=std::find(postProcEffects.begin(), postProcEffects.end(), effect);
if(i!=postProcEffects.end())
postProcEffects.erase(i);
}