1
0
mirror of https://github.com/danog/libtgvoip.git synced 2024-11-30 04:39:03 +01:00

Fix memory leak; other minor changes

This commit is contained in:
Daniil Kovalev 2019-10-27 21:00:16 +03:00 committed by John Preston
parent 4dabb67eff
commit 33d3388df5
4 changed files with 22 additions and 15 deletions

View File

@ -96,6 +96,7 @@ EchoCanceller::~EchoCanceller(){
#ifndef TGVOIP_NO_DSP
delete apm;
delete audioFrame;
delete farendBufferPool;
#endif
}

View File

@ -364,8 +364,8 @@ bool NetworkSocketTCPObfuscated::IsFailed(){
NetworkSocketSOCKS5Proxy::NetworkSocketSOCKS5Proxy(NetworkSocket *tcp, NetworkSocket *udp, std::string username, std::string password) : NetworkSocketWrapper(udp ? PROTO_UDP : PROTO_TCP){
this->tcp=tcp;
this->udp=udp;
this->username=username;
this->password=password;
this->username=std::move(username);
this->password=std::move(password);
connectedAddress=NULL;
}

30
VoIPController.cpp Executable file → Normal file
View File

@ -773,10 +773,10 @@ string VoIPController::GetCurrentAudioOutputID(){
void VoIPController::SetProxy(int protocol, string address, uint16_t port, string username, string password){
proxyProtocol=protocol;
proxyAddress=address;
proxyAddress=std::move(address);
proxyPort=port;
proxyUsername=username;
proxyPassword=password;
proxyUsername=std::move(username);
proxyPassword=std::move(password);
}
int VoIPController::GetSignalBarsCount(){
@ -1116,10 +1116,11 @@ void VoIPController::HandleAudioInput(unsigned char *data, size_t len, unsigned
}
unsentStreamPackets++;
size_t pktLength = pkt.GetLength();
PendingOutgoingPacket p{
/*.seq=*/GenerateOutSeq(),
/*.type=*/PKT_STREAM_DATA,
/*.len=*/pkt.GetLength(),
/*.len=*/pktLength,
/*.data=*/Buffer(move(pkt)),
/*.endpoint=*/0,
};
@ -1142,10 +1143,11 @@ void VoIPController::HandleAudioInput(unsigned char *data, size_t len, unsigned
pkt.WriteBytes(*ecData);
}
pktLength = pkt.GetLength();
PendingOutgoingPacket p{
GenerateOutSeq(),
PKT_STREAM_EC,
pkt.GetLength(),
pktLength,
Buffer(move(pkt)),
0
};
@ -1486,10 +1488,11 @@ void VoIPController::SendInit(){
out.WriteInt32(id);
}*/
}
size_t outLength = out.GetLength();
SendOrEnqueuePacket(PendingOutgoingPacket{
/*.seq=*/initSeq,
/*.type=*/PKT_INIT,
/*.len=*/out.GetLength(),
/*.len=*/outLength,
/*.data=*/Buffer(move(out)),
/*.endpoint=*/e.id
});
@ -2310,10 +2313,11 @@ simpleAudioBlock random_id:long random_bytes:string raw_data:string = DecryptedA
out.WriteByte((unsigned char) ((*s)->enabled ? 1 : 0));
}
LOGI("Sending init ack");
size_t outLength = out.GetLength();
SendOrEnqueuePacket(PendingOutgoingPacket{
/*.seq=*/GenerateOutSeq(),
/*.type=*/PKT_INIT_ACK,
/*.len=*/out.GetLength(),
/*.len=*/outLength,
/*.data=*/Buffer(move(out)),
/*.endpoint=*/0
});
@ -2517,10 +2521,11 @@ simpleAudioBlock random_id:long random_bytes:string raw_data:string = DecryptedA
}
BufferOutputStream pkt(128);
pkt.WriteInt32(pseq);
size_t pktLength = pkt.GetLength();
SendOrEnqueuePacket(PendingOutgoingPacket{
/*.seq=*/GenerateOutSeq(),
/*.type=*/PKT_PONG,
/*.len=*/pkt.GetLength(),
/*.len=*/pktLength,
/*.data=*/Buffer(move(pkt)),
/*.endpoint=*/srcEndpoint.id,
});
@ -3031,7 +3036,7 @@ void VoIPController::AddTCPRelays(){
relays.push_back(tcpRelay);
}
for(Endpoint& e:relays){
endpoints[e.id]=move(e);
endpoints[e.id]=e;
}
didAddTcpRelays=true;
}
@ -3437,16 +3442,17 @@ void VoIPController::SendVideoFrame(const Buffer &frame, uint32_t flags){
pkt.WriteBytes(frame, offset, len);
uint32_t seq=GenerateOutSeq();
size_t pktLength = pkt.GetLength();
PendingOutgoingPacket p{
/*.seq=*/seq,
/*.type=*/PKT_STREAM_DATA,
/*.len=*/pkt.GetLength(),
/*.len=*/pktLength,
/*.data=*/Buffer(move(pkt)),
/*.endpoint=*/0,
};
unsentStreamPackets++;
SendOrEnqueuePacket(move(p));
videoCongestionControl.ProcessPacketSent(static_cast<unsigned int>(pkt.GetLength()));
videoCongestionControl.ProcessPacketSent(static_cast<unsigned int>(pktLength));
sentFrame.unacknowledgedPackets.push_back(seq);
}
MutexGuard m(sentVideoFramesMutex);
@ -3973,7 +3979,7 @@ Endpoint::~Endpoint(){
#pragma mark - AudioInputTester
AudioInputTester::AudioInputTester(std::string deviceID) : deviceID(deviceID){
AudioInputTester::AudioInputTester(std::string deviceID) : deviceID(std::move(deviceID)){
io=audio::AudioIO::Create(deviceID, "default");
if(io->Failed()){
LOGE("Audio IO failed");

View File

@ -58,7 +58,7 @@ static const int16_t hann[960]={
0x7FDE, 0x7FE1, 0x7FE4, 0x7FE7, 0x7FEA, 0x7FED, 0x7FEF, 0x7FF1, 0x7FF3, 0x7FF5, 0x7FF7, 0x7FF9, 0x7FFA, 0x7FFB, 0x7FFC, 0x7FFD, 0x7FFE, 0x7FFE, 0x7FFF, 0x7FFF
};
#define MIN(a, b) (a<b ? a : b)
#define MIN(a, b) (((a)<(b)) ? (a) : (b))
size_t Resampler::Convert48To44(int16_t *from, int16_t *to, size_t fromLen, size_t toLen){
size_t outLen=fromLen*147/160;