1
0
mirror of https://github.com/danog/libtgvoip.git synced 2024-11-26 20:24:38 +01:00

Merge multiple fixes

This commit is contained in:
Daniil Gentili 2020-03-10 19:36:27 +01:00
parent 72c288afa0
commit b152e32208
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
17 changed files with 117 additions and 92 deletions

View File

@ -1,3 +1,5 @@
#include <mutex>
#include "TgVoip.h" #include "TgVoip.h"
#include "VoIPController.h" #include "VoIPController.h"
@ -73,17 +75,11 @@ tgvoip::CryptoFunctions tgvoip::VoIPController::crypto = {
tgvoip_openssl_aes_ctr_encrypt, tgvoip_openssl_aes_ctr_encrypt,
tgvoip_openssl_aes_cbc_encrypt, tgvoip_openssl_aes_cbc_encrypt,
tgvoip_openssl_aes_cbc_decrypt}; tgvoip_openssl_aes_cbc_decrypt};
#else
tgvoip::CryptoFunctions tgvoip::VoIPController::crypto; // set it yourself upon initialization
#endif #endif
class TgVoipImpl : public TgVoip class TgVoipImpl : public TgVoip
{ {
public: public:
tgvoip::VoIPController *controller_;
std::function<void(TgVoipState)> onStateUpdated_;
std::function<void(int)> onSignalBarsUpdated_;
TgVoipImpl( TgVoipImpl(
std::vector<TgVoipEndpoint> const &endpoints, std::vector<TgVoipEndpoint> const &endpoints,
TgVoipPersistentState const &persistentState, TgVoipPersistentState const &persistentState,
@ -135,7 +131,7 @@ public:
std::vector<tgvoip::Endpoint> mappedEndpoints; std::vector<tgvoip::Endpoint> mappedEndpoints;
for (auto endpoint : endpoints) for (auto endpoint : endpoints)
{ {
tgvoip::Endpoint::Type mappedType = tgvoip::Endpoint::Type::UDP_RELAY; tgvoip::Endpoint::Type mappedType;
switch (endpoint.type) switch (endpoint.type)
{ {
case TgVoipEndpointType::UdpRelay: case TgVoipEndpointType::UdpRelay:
@ -158,10 +154,10 @@ public:
tgvoip::IPv4Address address(endpoint.host.ipv4); tgvoip::IPv4Address address(endpoint.host.ipv4);
tgvoip::IPv6Address addressv6(endpoint.host.ipv6); tgvoip::IPv6Address addressv6(endpoint.host.ipv6);
mappedEndpoints.push_back(tgvoip::Endpoint(endpoint.endpointId, endpoint.port, address, addressv6, mappedType, endpoint.peerTag)); mappedEndpoints.emplace_back(endpoint.endpointId, endpoint.port, address, addressv6, mappedType, endpoint.peerTag);
} }
int mappedDataSaving = tgvoip::DATA_SAVING_NEVER; int mappedDataSaving;
switch (config.dataSaving) switch (config.dataSaving)
{ {
case TgVoipDataSaving::Mobile: case TgVoipDataSaving::Mobile:
@ -198,19 +194,23 @@ public:
controller_->Connect(); controller_->Connect();
} }
~TgVoipImpl() override = default; ~TgVoipImpl()
{
}
void setOnStateUpdated(std::function<void(TgVoipState)> onStateUpdated) void setOnStateUpdated(std::function<void(TgVoipState)> onStateUpdated)
{ {
std::lock_guard<std::mutex> lock(m_onStateUpdated);
onStateUpdated_ = onStateUpdated; onStateUpdated_ = onStateUpdated;
} }
void setOnSignalBarsUpdated(std::function<void(int)> onSignalBarsUpdated) void setOnSignalBarsUpdated(std::function<void(int)> onSignalBarsUpdated)
{ {
std::lock_guard<std::mutex> lock(m_onSignalBarsUpdated);
onSignalBarsUpdated_ = onSignalBarsUpdated; onSignalBarsUpdated_ = onSignalBarsUpdated;
} }
void setNetworkType(TgVoipNetworkType networkType) void setNetworkType(TgVoipNetworkType networkType) override
{ {
int mappedType; int mappedType;
@ -265,66 +265,67 @@ public:
controller_->SetMicMute(muteMicrophone); controller_->SetMicMute(muteMicrophone);
} }
void setEchoCancellationStrength(int strength) override { void setAudioOutputGainControlEnabled(bool enabled) override
{
controller_->SetAudioOutputGainControlEnabled(enabled);
}
void setEchoCancellationStrength(int strength) override
{
controller_->SetEchoCancellationStrength(strength); controller_->SetEchoCancellationStrength(strength);
} }
std::string getLastError() override { std::string getLastError() override
switch (controller_->GetLastError()) { {
case tgvoip::ERROR_INCOMPATIBLE: return "ERROR_INCOMPATIBLE"; switch (controller_->GetLastError())
case tgvoip::ERROR_TIMEOUT: return "ERROR_TIMEOUT"; {
case tgvoip::ERROR_AUDIO_IO: return "ERROR_AUDIO_IO"; case tgvoip::ERROR_INCOMPATIBLE:
case tgvoip::ERROR_PROXY: return "ERROR_PROXY"; return "ERROR_INCOMPATIBLE";
default: return "ERROR_UNKNOWN"; case tgvoip::ERROR_TIMEOUT:
return "ERROR_TIMEOUT";
case tgvoip::ERROR_AUDIO_IO:
return "ERROR_AUDIO_IO";
case tgvoip::ERROR_PROXY:
return "ERROR_PROXY";
default:
return "ERROR_UNKNOWN";
} }
} }
std::string getVersion()
{
return controller_->GetVersion();
}
TgVoipPersistentState getPersistentState()
{
std::vector<uint8_t> persistentStateValue = controller_->GetPersistentState();
TgVoipPersistentState persistentState = {
.value = persistentStateValue};
return persistentState;
}
std::string getDebugInfo() override std::string getDebugInfo() override
{ {
return controller_->GetDebugString(); return controller_->GetDebugString();
} }
int64_t getPreferredRelayId() override { int64_t getPreferredRelayId() override
{
return controller_->GetPreferredRelayID(); return controller_->GetPreferredRelayID();
} }
TgVoipFinalState stop() TgVoipTrafficStats getTrafficStats() override
{ {
controller_->Stop();
auto debugLog = controller_->GetDebugLog();
tgvoip::VoIPController::TrafficStats stats; tgvoip::VoIPController::TrafficStats stats;
controller_->GetStats(&stats); controller_->GetStats(&stats);
return {
TgVoipTrafficStats trafficStats = {
.bytesSentWifi = stats.bytesSentWifi, .bytesSentWifi = stats.bytesSentWifi,
.bytesReceivedWifi = stats.bytesRecvdWifi, .bytesReceivedWifi = stats.bytesRecvdWifi,
.bytesSentMobile = stats.bytesSentMobile, .bytesSentMobile = stats.bytesSentMobile,
.bytesReceivedMobile = stats.bytesRecvdMobile}; .bytesReceivedMobile = stats.bytesRecvdMobile};
}
std::vector<uint8_t> persistentStateValue = controller_->GetPersistentState(); TgVoipPersistentState getPersistentState() override
TgVoipPersistentState persistentState = { {
.value = persistentStateValue}; return {controller_->GetPersistentState()};
}
TgVoipFinalState stop() override
{
controller_->Stop();
TgVoipFinalState finalState = { TgVoipFinalState finalState = {
.persistentState = persistentState, .persistentState = getPersistentState(),
.debugLog = debugLog, .debugLog = controller_->GetDebugLog(),
.trafficStats = trafficStats, .trafficStats = getTrafficStats(),
.isRatingSuggested = controller_->NeedRate()}; .isRatingSuggested = controller_->NeedRate()};
delete controller_; delete controller_;
@ -335,7 +336,9 @@ public:
static void controllerStateCallback(tgvoip::VoIPController *controller, int state) static void controllerStateCallback(tgvoip::VoIPController *controller, int state)
{ {
TgVoipImpl *self = (TgVoipImpl *)controller->implData; TgVoipImpl *self = reinterpret_cast<TgVoipImpl *>(controller->implData);
std::lock_guard<std::mutex> lock(self->m_onStateUpdated);
if (self->onStateUpdated_) if (self->onStateUpdated_)
{ {
TgVoipState mappedState; TgVoipState mappedState;
@ -367,12 +370,20 @@ public:
static void signalBarsCallback(tgvoip::VoIPController *controller, int signalBars) static void signalBarsCallback(tgvoip::VoIPController *controller, int signalBars)
{ {
TgVoipImpl *self = (TgVoipImpl *)controller->implData; TgVoipImpl *self = reinterpret_cast<TgVoipImpl *>(controller->implData);
std::lock_guard<std::mutex> lock(self->m_onSignalBarsUpdated);
if (self->onSignalBarsUpdated_) if (self->onSignalBarsUpdated_)
{ {
self->onSignalBarsUpdated_(signalBars); self->onSignalBarsUpdated_(signalBars);
} }
} }
private:
tgvoip::VoIPController *controller_;
std::function<void(TgVoipState)> onStateUpdated_;
std::function<void(int)> onSignalBarsUpdated_;
std::mutex m_onStateUpdated, m_onSignalBarsUpdated;
}; };
std::function<void(std::string const &)> globalLoggingFunction; std::function<void(std::string const &)> globalLoggingFunction;
@ -384,7 +395,7 @@ void __tgvoip_call_tglog(const char *format, ...)
va_list vaCopy; va_list vaCopy;
va_copy(vaCopy, vaArgs); va_copy(vaCopy, vaArgs);
const int length = std::vsnprintf(NULL, 0, format, vaCopy); const int length = std::vsnprintf(nullptr, 0, format, vaCopy);
va_end(vaCopy); va_end(vaCopy);
std::vector<char> zc(length + 1); std::vector<char> zc(length + 1);
@ -407,6 +418,16 @@ void TgVoip::setGlobalServerConfig(const std::string &serverConfig)
tgvoip::ServerConfig::GetSharedInstance()->Update(serverConfig); tgvoip::ServerConfig::GetSharedInstance()->Update(serverConfig);
} }
int TgVoip::getConnectionMaxLayer()
{
return tgvoip::VoIPController::GetConnectionMaxLayer();
}
std::string TgVoip::getVersion()
{
return tgvoip::VoIPController::GetVersion();
}
TgVoip *TgVoip::makeInstance( TgVoip *TgVoip::makeInstance(
TgVoipConfig const &config, TgVoipConfig const &config,
TgVoipPersistentState const &persistentState, TgVoipPersistentState const &persistentState,
@ -442,6 +463,4 @@ TgVoip *TgVoip::makeInstance(
); );
} }
TgVoip::~TgVoip() TgVoip::~TgVoip() = default;
{
}

View File

@ -22,7 +22,7 @@ enum class TgVoipEndpointType
TcpRelay TcpRelay
}; };
struct TgVoipEndpointHost struct TgVoipEdpointHost
{ {
std::string ipv4; std::string ipv4;
std::string ipv6; std::string ipv6;
@ -31,7 +31,7 @@ struct TgVoipEndpointHost
struct TgVoipEndpoint struct TgVoipEndpoint
{ {
int64_t endpointId; int64_t endpointId;
TgVoipEndpointHost host; TgVoipEdpointHost host;
uint16_t port; uint16_t port;
TgVoipEndpointType type; TgVoipEndpointType type;
unsigned char peerTag[16]; unsigned char peerTag[16];
@ -89,7 +89,11 @@ struct TgVoipConfig
bool enableNS; bool enableNS;
bool enableAGC; bool enableAGC;
bool enableCallUpgrade; bool enableCallUpgrade;
#ifndef _WIN32
std::string logPath; std::string logPath;
#else
std::wstring logPath;
#endif
int maxApiLayer; int maxApiLayer;
}; };

4
aclocal.m4 vendored
View File

@ -8963,11 +8963,11 @@ m4_define([lt_dict_filter],
# serial 4221 ltversion.m4 # serial 4221 ltversion.m4
# This file is part of GNU Libtool # This file is part of GNU Libtool
m4_define([LT_PACKAGE_VERSION], [2.4.6.42-b88ce]) m4_define([LT_PACKAGE_VERSION], [2.4.6.42-b88ce-dirty])
m4_define([LT_PACKAGE_REVISION], [2.4.6.42]) m4_define([LT_PACKAGE_REVISION], [2.4.6.42])
AC_DEFUN([LTVERSION_VERSION], AC_DEFUN([LTVERSION_VERSION],
[macro_version='2.4.6.42-b88ce' [macro_version='2.4.6.42-b88ce-dirty'
macro_revision='2.4.6.42' macro_revision='2.4.6.42'
_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
_LT_DECL(, macro_revision, 0) _LT_DECL(, macro_revision, 0)

2
configure vendored
View File

@ -3270,7 +3270,7 @@ esac
macro_version='2.4.6.42-b88ce' macro_version='2.4.6.42-b88ce-dirty'
macro_revision='2.4.6.42' macro_revision='2.4.6.42'

View File

@ -79,7 +79,7 @@ void AudioPacketSender::SendFrame(unsigned char *data, size_t len, unsigned char
if (hasExtraFEC) if (hasExtraFEC)
{ {
Buffer ecBuf(secondaryLen); Buffer ecBuf(secondaryLen);
ecBuf.CopyFrom(*secondaryDataBufPtr, 0, secondaryLen); ecBuf.CopyFromOtherBuffer(*secondaryDataBufPtr, secondaryLen);
if (ecAudioPackets.size() == 4) if (ecAudioPackets.size() == 4)
{ {
ecAudioPackets.pop_front(); ecAudioPackets.pop_front();
@ -135,7 +135,7 @@ void AudioPacketSender::SendFrame(unsigned char *data, size_t len, unsigned char
if (PeerVersion() < 7 && secondaryLen && shittyInternetMode) if (PeerVersion() < 7 && secondaryLen && shittyInternetMode)
{ {
Buffer ecBuf(secondaryLen); Buffer ecBuf(secondaryLen);
ecBuf.CopyFrom(*secondaryDataBufPtr, 0, secondaryLen); ecBuf.CopyFromOtherBuffer(*secondaryDataBufPtr, secondaryLen);
if (ecAudioPackets.size() == 4) if (ecAudioPackets.size() == 4)
{ {
ecAudioPackets.pop_front(); ecAudioPackets.pop_front();

View File

@ -99,11 +99,12 @@ EchoCanceller::EchoCanceller(bool enableAEC, bool enableNS, bool enableAGC)
EchoCanceller::~EchoCanceller() EchoCanceller::~EchoCanceller()
{ {
#ifndef TGVOIP_NO_DSP #ifndef TGVOIP_NO_DSP
delete apm;
delete audioFrame;
farendQueue->Put(Buffer()); farendQueue->Put(Buffer());
bufferFarendThread->Join(); bufferFarendThread->Join();
delete bufferFarendThread; delete bufferFarendThread;
delete farendQueue;
delete audioFrame;
delete apm;
#endif #endif
} }

View File

@ -16,12 +16,15 @@ using namespace tgvoip;
void MediaStreamItf::SetCallback(size_t (*f)(unsigned char *, size_t, void *), void *param) void MediaStreamItf::SetCallback(size_t (*f)(unsigned char *, size_t, void *), void *param)
{ {
MutexGuard m(callbackMutex);
callback = f; callback = f;
callbackParam = param; callbackParam = param;
} }
size_t MediaStreamItf::InvokeCallback(unsigned char *data, size_t length) size_t MediaStreamItf::InvokeCallback(unsigned char *data, size_t length)
{ {
MutexGuard m(callbackMutex);
if (callback) if (callback)
return (*callback)(data, length, callbackParam); return (*callback)(data, length, callbackParam);
return 0; return 0;

View File

@ -33,6 +33,7 @@ public:
private: private:
size_t (*callback)(unsigned char *, size_t, void *) = NULL; size_t (*callback)(unsigned char *, size_t, void *) = NULL;
void *callbackParam; void *callbackParam;
Mutex callbackMutex;
}; };
class AudioMixer : public MediaStreamItf class AudioMixer : public MediaStreamItf

View File

@ -99,7 +99,7 @@ void JitterBuffer::PutInternal(jitter_packet_t *pkt, bool overwriteExisting)
//LOGV("Found existing packet for timestamp %u, overwrite %d", pkt->timestamp, overwriteExisting); //LOGV("Found existing packet for timestamp %u, overwrite %d", pkt->timestamp, overwriteExisting);
if (overwriteExisting) if (overwriteExisting)
{ {
slots[i].buffer.CopyFrom(pkt->buffer, pkt->size); slots[i].buffer.CopyFromOtherBuffer(pkt->buffer, pkt->size);
slots[i].size = pkt->size; slots[i].size = pkt->size;
slots[i].isEC = pkt->isEC; slots[i].isEC = pkt->isEC;
} }
@ -113,7 +113,7 @@ void JitterBuffer::PutInternal(jitter_packet_t *pkt, bool overwriteExisting)
outstandingDelayChange = 0; outstandingDelayChange = 0;
nextFetchTimestamp = static_cast<int64_t>(static_cast<int64_t>(pkt->timestamp) - step * minDelay); nextFetchTimestamp = static_cast<int64_t>(static_cast<int64_t>(pkt->timestamp) - step * minDelay);
first = true; first = true;
LOGI("jitter: resyncing, next timestamp = %lld (step=%d, minDelay=%f)", (long long int)nextFetchTimestamp, step, minDelay); LOGI("jitter: resyncing, next timestamp = %lld (step=%d, minDelay=%f)", (long long int)nextFetchTimestamp, step, (double)minDelay);
} }
for (i = 0; i < JITTER_SLOT_COUNT; i++) for (i = 0; i < JITTER_SLOT_COUNT; i++)
@ -194,7 +194,7 @@ void JitterBuffer::PutInternal(jitter_packet_t *pkt, bool overwriteExisting)
slots[i].buffer = bufferPool.Get(); slots[i].buffer = bufferPool.Get();
slots[i].recvTimeDiff = time - prevRecvTime; slots[i].recvTimeDiff = time - prevRecvTime;
slots[i].isEC = pkt->isEC; slots[i].isEC = pkt->isEC;
slots[i].buffer.CopyFrom(pkt->buffer, pkt->size); slots[i].buffer.CopyFromOtherBuffer(pkt->buffer, pkt->size);
#ifdef TGVOIP_DUMP_JITTER_STATS #ifdef TGVOIP_DUMP_JITTER_STATS
fprintf(dump, "%u\t%.03f\t%d\t%.03f\t%.03f\t%.03f\n", pkt->timestamp, time, GetCurrentDelay(), lastMeasuredJitter, lastMeasuredDelay, minDelay); fprintf(dump, "%u\t%.03f\t%d\t%.03f\t%.03f\t%.03f\n", pkt->timestamp, time, GetCurrentDelay(), lastMeasuredJitter, lastMeasuredDelay, minDelay);
#endif #endif
@ -322,7 +322,7 @@ int JitterBuffer::GetInternal(jitter_packet_t *pkt, int offset, bool advance)
{ {
pkt->size = slots[i].size; pkt->size = slots[i].size;
pkt->timestamp = slots[i].timestamp; pkt->timestamp = slots[i].timestamp;
pkt->buffer.CopyFrom(slots[i].buffer, slots[i].size); pkt->buffer.CopyFromOtherBuffer(slots[i].buffer, slots[i].size);
pkt->isEC = slots[i].isEC; pkt->isEC = slots[i].isEC;
} }
} }
@ -428,7 +428,7 @@ void JitterBuffer::Tick()
if ((diff > 0 && dontIncMinDelay == 0) || (diff < 0 && dontDecMinDelay == 0)) if ((diff > 0 && dontIncMinDelay == 0) || (diff < 0 && dontDecMinDelay == 0))
{ {
//nextFetchTimestamp+=diff*(int32_t)step; //nextFetchTimestamp+=diff*(int32_t)step;
minDelay += diff; minDelay.store(minDelay + diff);
outstandingDelayChange += diff * 60; outstandingDelayChange += diff * 60;
dontChangeDelay += 32; dontChangeDelay += 32;
//LOGD("new delay from stddev %f", minDelay); //LOGD("new delay from stddev %f", minDelay);

View File

@ -73,8 +73,8 @@ private:
Mutex mutex; Mutex mutex;
uint32_t step; uint32_t step;
std::array<jitter_packet_t, JITTER_SLOT_COUNT> slots{0}; std::array<jitter_packet_t, JITTER_SLOT_COUNT> slots{0};
std::atomic<int64_t> nextFetchTimestamp = ATOMIC_VAR_INIT(0); // What frame to read next std::atomic<int64_t> nextFetchTimestamp{0}; // What frame to read next (protected for GetSeqTooLate)
double minDelay = 6; std::atomic<double> minDelay{6};
uint32_t minMinDelay; uint32_t minMinDelay;
uint32_t maxMinDelay; uint32_t maxMinDelay;
uint32_t maxUsedSlots; uint32_t maxUsedSlots;

View File

@ -64,7 +64,7 @@ void VoIPController::UpdateReliablePackets()
if (qp->firstSentTime == 0) if (qp->firstSentTime == 0)
qp->firstSentTime = qp->lastSentTime; qp->firstSentTime = qp->lastSentTime;
if (qp->data.Length()) if (qp->data.Length())
buf.CopyFrom(qp->data, qp->data.Length()); buf.CopyFromOtherBuffer(qp->data, qp->data.Length());
packetsToSend.push_back(PendingOutgoingPacket{ packetsToSend.push_back(PendingOutgoingPacket{
/*.seq=*/seq, /*.seq=*/seq,
/*.type=*/qp->type, /*.type=*/qp->type,

View File

@ -9,7 +9,7 @@
#include <string.h> #include <string.h>
#include <exception> #include <exception>
#include <stdexcept> #include <stdexcept>
#include <stdlib.h> #include <cstdlib>
#include "tools/logging.h" #include "tools/logging.h"
using namespace tgvoip; using namespace tgvoip;
@ -145,7 +145,7 @@ BufferOutputStream::BufferOutputStream(size_t size_)
bufferProvided(false) bufferProvided(false)
{ {
buffer = (unsigned char *)malloc(size_); buffer = reinterpret_cast<unsigned char *>(std::malloc(size_));
if (!buffer) if (!buffer)
throw std::bad_alloc(); throw std::bad_alloc();
bufferProvided = false; bufferProvided = false;
@ -239,18 +239,16 @@ void BufferOutputStream::ExpandBufferIfNeeded(size_t need)
{ {
throw std::out_of_range("buffer overflow"); throw std::out_of_range("buffer overflow");
} }
if (need < 1024) size += std::max(need, size_t{1024});
unsigned char *newBuffer = reinterpret_cast<unsigned char*>(std::realloc(buffer, size));
if (!newBuffer)
{ {
buffer = (unsigned char *)realloc(buffer, size + 1024); std::free(buffer);
size += 1024; buffer = nullptr;
} size = 0;
else
{
buffer = (unsigned char *)realloc(buffer, size + need);
size += need;
}
if (!buffer)
throw std::bad_alloc(); throw std::bad_alloc();
}
buffer = newBuffer;
} }
} }

View File

@ -211,7 +211,7 @@ public:
{ {
return data; return data;
} }
void CopyFrom(const Buffer &other, size_t count, size_t srcOffset = 0, size_t dstOffset = 0) void CopyFromOtherBuffer(const Buffer &other, size_t count, size_t srcOffset = 0, size_t dstOffset = 0)
{ {
if (!other.data) if (!other.data)
throw std::invalid_argument("CopyFrom can't copy from NULL"); throw std::invalid_argument("CopyFrom can't copy from NULL");
@ -248,7 +248,7 @@ public:
if (other.IsEmpty()) if (other.IsEmpty())
return Buffer(); return Buffer();
Buffer buf(other.length); Buffer buf(other.length);
buf.CopyFrom(other, other.length); buf.CopyFromOtherBuffer(other, other.length);
return buf; return buf;
} }
static Buffer CopyOf(const Buffer &other, size_t offset, size_t length) static Buffer CopyOf(const Buffer &other, size_t offset, size_t length)
@ -256,7 +256,7 @@ public:
if (offset + length > other.Length()) if (offset + length > other.Length())
throw std::out_of_range("offset+length out of bounds"); throw std::out_of_range("offset+length out of bounds");
Buffer buf(length); Buffer buf(length);
buf.CopyFrom(other, length, offset); buf.CopyFromOtherBuffer(other, length, offset);
return buf; return buf;
} }
static Buffer Wrap(unsigned char *data, size_t size, const std::function<void(void *)> &freeFn, const std::function<void *(void *, size_t)> &reallocFn) static Buffer Wrap(unsigned char *data, size_t size, const std::function<void(void *)> &freeFn, const std::function<void *(void *, size_t)> &reallocFn)

View File

@ -18,9 +18,8 @@
using namespace tgvoip; using namespace tgvoip;
MessageThread::MessageThread() : Thread(std::bind(&MessageThread::Run, this)) MessageThread::MessageThread() : Thread(std::bind(&MessageThread::Run, this)), running(true)
{ {
running = true;
SetName("MessageThread"); SetName("MessageThread");
#ifdef _WIN32 #ifdef _WIN32

View File

@ -27,7 +27,7 @@ Buffer ParityFEC::Encode(std::vector<Buffer>& packets){
_result[maxSize+1] ^= (uint8_t)(len >> 8); _result[maxSize+1] ^= (uint8_t)(len >> 8);
} }
return std::move(result); return result;
} }
Buffer ParityFEC::Decode(std::vector<Buffer>& dataPackets, Buffer &fecPacket){ Buffer ParityFEC::Decode(std::vector<Buffer>& dataPackets, Buffer &fecPacket){
@ -68,5 +68,5 @@ Buffer ParityFEC::Decode(std::vector<Buffer>& dataPackets, Buffer &fecPacket){
LOGV("ParityFEC decoded packet size %u", len); LOGV("ParityFEC decoded packet size %u", len);
result.Resize(len); result.Resize(len);
return std::move(result); return result;
} }

View File

@ -47,7 +47,7 @@ size_t WebRtcSpl_FilterAR(const int16_t* a,
// because of this. // because of this.
int filtered_ix = (int)i - 1; int filtered_ix = (int)i - 1;
int16_t* state_ptr = &state[state_length - 1]; int16_t* state_ptr = &state[state_length - 1];
int16_t* state_low_ptr = &state_low[state_length - 1]; int16_t* state_low_ptr = &state_low[state_low_length - 1];
o = (int32_t)(*x_ptr++) * (1 << 12); o = (int32_t)(*x_ptr++) * (1 << 12);
oLOW = (int32_t)0; oLOW = (int32_t)0;
@ -87,7 +87,7 @@ size_t WebRtcSpl_FilterAR(const int16_t* a,
for (i = 0; i < x_length; i++) for (i = 0; i < x_length; i++)
{ {
state[state_length - x_length + i] = filtered[i]; state[state_length - x_length + i] = filtered[i];
state[state_length - x_length + i] = filtered_low[i]; state_low[state_low_length - x_length + i] = filtered_low[i];
} }
} }

View File

@ -182,7 +182,7 @@ struct TypeOr {
"The specified type isn't large enough"); "The specified type isn't large enough");
static_assert(IsIntlike<type>::value == IsIntlike<B>::value && static_assert(IsIntlike<type>::value == IsIntlike<B>::value &&
std::is_floating_point<type>::value == std::is_floating_point<type>::value ==
std::is_floating_point<type>::value, std::is_floating_point<B>::value,
"float<->int conversions not allowed"); "float<->int conversions not allowed");
}; };