diff --git a/src/engine/audio/Audio_Helper.cpp b/src/engine/audio/Audio_Helper.cpp index a1ad2f5c..99fd0f75 100644 --- a/src/engine/audio/Audio_Helper.cpp +++ b/src/engine/audio/Audio_Helper.cpp @@ -29,10 +29,6 @@ TimeSource::TimeSource(int quantTime, int nrOfQuants) mTailTime = 0; } -TimeSource::~TimeSource() -{ -} - void TimeSource::start() { #ifdef TARGET_WIN @@ -107,7 +103,7 @@ unsigned TimeSource::time() // --- StubTimer --- StubTimer::StubTimer(int bufferTime, int bufferCount) -:mBufferTime(bufferTime), mBufferCount(bufferCount), mTimeSource(bufferTime, bufferCount), mActive(false) +:mBufferTime(bufferTime), mBufferCount(bufferCount), mTimeSource(bufferTime, bufferCount), mActive(false), mCurrentTime(0) { #ifdef TARGET_WIN mStubSignal = ::CreateEvent(NULL, FALSE, FALSE, NULL); diff --git a/src/engine/audio/Audio_Helper.h b/src/engine/audio/Audio_Helper.h index e3744522..0a74de10 100644 --- a/src/engine/audio/Audio_Helper.h +++ b/src/engine/audio/Audio_Helper.h @@ -47,7 +47,7 @@ namespace Audio public: TimeSource(int quantTime, int nrOfQuants); - ~TimeSource(); + ~TimeSource() = default; void start(); void stop(); diff --git a/src/engine/audio/Audio_Null.cpp b/src/engine/audio/Audio_Null.cpp index 40cc18d9..9b69cb54 100644 --- a/src/engine/audio/Audio_Null.cpp +++ b/src/engine/audio/Audio_Null.cpp @@ -60,7 +60,7 @@ NullInputDevice::NullInputDevice() NullInputDevice::~NullInputDevice() { - close(); + internalClose(); } bool NullInputDevice::open() @@ -73,7 +73,7 @@ bool NullInputDevice::open() return true; } -void NullInputDevice::close() +void NullInputDevice::internalClose() { mTimer.reset(); if (mBuffer) @@ -84,6 +84,10 @@ void NullInputDevice::close() ICELogInfo(<<"Pseudocaptured " << mTimeCounter << " milliseconds , " << mDataCounter << " bytes."); } +void NullInputDevice::close() +{ + internalClose(); +} Format NullInputDevice::getFormat() { assert (Format().sizeFromTime(AUDIO_MIC_BUFFER_LENGTH) == AUDIO_MIC_BUFFER_SIZE); @@ -106,7 +110,7 @@ NullOutputDevice::NullOutputDevice() NullOutputDevice::~NullOutputDevice() { - close(); + internalClose(); } @@ -119,13 +123,18 @@ bool NullOutputDevice::open() return true; } -void NullOutputDevice::close() +void NullOutputDevice::internalClose() { mTimer.reset(); free(mBuffer); mBuffer = nullptr; ICELogInfo(<< "Pseudoplayed " << mTimeCounter << " milliseconds, " << mDataCounter << " bytes."); } +void NullOutputDevice::close() +{ + internalClose(); +} + Format NullOutputDevice::getFormat() { assert (Format().sizeFromTime(AUDIO_SPK_BUFFER_LENGTH) == AUDIO_SPK_BUFFER_SIZE); diff --git a/src/engine/audio/Audio_Null.h b/src/engine/audio/Audio_Null.h index d3dc4316..aa1c5749 100644 --- a/src/engine/audio/Audio_Null.h +++ b/src/engine/audio/Audio_Null.h @@ -38,6 +38,8 @@ namespace Audio void* mBuffer = nullptr; std::shared_ptr mTimer; int64_t mTimeCounter = 0, mDataCounter = 0; + void internalClose(); + public: NullInputDevice(); virtual ~NullInputDevice(); @@ -55,6 +57,8 @@ namespace Audio std::shared_ptr mTimer; void* mBuffer = nullptr; int64_t mDataCounter = 0, mTimeCounter = 0; + + void internalClose(); public: NullOutputDevice(); virtual ~NullOutputDevice(); diff --git a/src/engine/audio/Audio_Resampler.cpp b/src/engine/audio/Audio_Resampler.cpp index fb6d6ee8..8f38fb56 100644 --- a/src/engine/audio/Audio_Resampler.cpp +++ b/src/engine/audio/Audio_Resampler.cpp @@ -18,7 +18,7 @@ namespace Audio SpeexResampler::SpeexResampler() - :mContext(NULL), mErrorCode(0), mSourceRate(0), mDestRate(0), mLastSample(0) + :mContext(NULL), mErrorCode(0), mSourceRate(0), mDestRate(0), mLastSample(0), mChannels(0) { } @@ -274,7 +274,7 @@ PResampler UniversalResampler::findResampler(int sourceRate, int destRate) PResampler r; if (resamplerIter == mResamplerMap.end()) { - r = PResampler(new Resampler()); + r = std::make_shared(); r->start(AUDIO_CHANNELS, sourceRate, destRate); mResamplerMap[RatePair(sourceRate, destRate)] = r; } diff --git a/src/engine/audio/Audio_WavFile.cpp b/src/engine/audio/Audio_WavFile.cpp index 85cfba74..fa9137f2 100644 --- a/src/engine/audio/Audio_WavFile.cpp +++ b/src/engine/audio/Audio_WavFile.cpp @@ -40,7 +40,7 @@ using namespace Audio; // ---------------------- WavFileReader ------------------------- WavFileReader::WavFileReader() - :mHandle(nullptr), mSamplerate(0), mLastError(0) + :mHandle(nullptr), mSamplerate(0), mLastError(0), mChannels(0), mBits(0), mDataLength(0) { mDataOffset = 0; } diff --git a/src/engine/helper/HL_File.cpp b/src/engine/helper/HL_File.cpp index c2f0411e..226eb72c 100644 --- a/src/engine/helper/HL_File.cpp +++ b/src/engine/helper/HL_File.cpp @@ -32,23 +32,24 @@ void FileHelper::remove(const char* s) ::remove(s); } -std::string FileHelper::gettempname() -{ -#if defined(TARGET_LINUX) || defined(TARGET_ANDROID) - char template_filename[L_tmpnam] = "rtphone_XXXXXXX.tmp"; - mkstemp(template_filename); - return template_filename; -#elif defined(TARGET_WIN) - char buffer[L_tmpnam]; - tmpnam(buffer); +// std::string FileHelper::gettempname() +// { +// #if defined(TARGET_LINUX) || defined(TARGET_ANDROID) +// char template_filename[L_tmpnam] = "rtphone_XXXXXXX.tmp"; +// int code = mkstemp(template_filename); - return buffer; -#elif defined(TARGET_OSX) - char template_filename[L_tmpnam] = "rtphone_XXXXXXX.tmp"; - mktemp(template_filename); - return template_filename; -#endif -} +// return template_filename; +// #elif defined(TARGET_WIN) +// char buffer[L_tmpnam]; +// tmpnam(buffer); + +// return buffer; +// #elif defined(TARGET_OSX) +// char template_filename[L_tmpnam] = "rtphone_XXXXXXX.tmp"; +// mktemp(template_filename); +// return template_filename; +// #endif +// } bool FileHelper::isAbsolute(const std::string& s) { diff --git a/src/engine/helper/HL_File.h b/src/engine/helper/HL_File.h index b6fc32ef..f6ffc91d 100644 --- a/src/engine/helper/HL_File.h +++ b/src/engine/helper/HL_File.h @@ -12,7 +12,7 @@ public: static void remove(const std::string& s); static void remove(const char* s); - static std::string gettempname(); + // static std::string gettempname(); static bool isAbsolute(const std::string& s); static std::string getCurrentDir(); diff --git a/src/engine/helper/HL_NetworkSocket.cpp b/src/engine/helper/HL_NetworkSocket.cpp index bebaca6d..68ac5acf 100644 --- a/src/engine/helper/HL_NetworkSocket.cpp +++ b/src/engine/helper/HL_NetworkSocket.cpp @@ -27,7 +27,7 @@ DatagramSocket::DatagramSocket() DatagramSocket::~DatagramSocket() { - closeSocket(); + internalClose(); } void DatagramSocket::open(int family) @@ -85,7 +85,7 @@ unsigned DatagramSocket::recvDatagram(InternetAddress &src, void *packetBuffer, return 0; } -void DatagramSocket::closeSocket() +void DatagramSocket::internalClose() { if (mHandle != INVALID_SOCKET) { @@ -98,6 +98,11 @@ void DatagramSocket::closeSocket() } } +void DatagramSocket::closeSocket() +{ + internalClose(); +} + bool DatagramSocket::isValid() const { return mHandle != INVALID_SOCKET; @@ -163,7 +168,7 @@ unsigned DatagramAgreggator::count() bool DatagramAgreggator::hasDataAtIndex(unsigned index) { PDatagramSocket socket = mSocketVector[index]; - return (FD_ISSET(socket->mHandle, &mReadSet) != 0); + return FD_ISSET(socket->mHandle, &mReadSet); } PDatagramSocket DatagramAgreggator::socketAt(unsigned index) diff --git a/src/engine/helper/HL_NetworkSocket.h b/src/engine/helper/HL_NetworkSocket.h index b5566664..71e48375 100644 --- a/src/engine/helper/HL_NetworkSocket.h +++ b/src/engine/helper/HL_NetworkSocket.h @@ -36,10 +36,12 @@ public: virtual SOCKET socket() const; virtual void open(int family); + protected: int mFamily; SOCKET mHandle; int mLocalPort; + void internalClose(); }; typedef std::shared_ptr PDatagramSocket; diff --git a/src/engine/helper/HL_Process.cpp b/src/engine/helper/HL_Process.cpp index cbef6bf9..fdaf240d 100644 --- a/src/engine/helper/HL_Process.cpp +++ b/src/engine/helper/HL_Process.cpp @@ -278,12 +278,12 @@ std::shared_ptr OsProcess::asyncExecCommand(const std::string& cmdl } while (r == sizeof(buffer) - 1); - if (lines.find("\n") != std::string::npos && line_callback) + if (lines.find('\n') != std::string::npos && line_callback) { std::string::size_type p = 0; while (p < lines.size()) { - std::string::size_type d = lines.find("\n", p); + std::string::size_type d = lines.find('\n', p); if (d != std::string::npos) { if (line_callback) diff --git a/src/engine/helper/HL_SocketHeap.cpp b/src/engine/helper/HL_SocketHeap.cpp index 9514881f..bdcfeb40 100644 --- a/src/engine/helper/HL_SocketHeap.cpp +++ b/src/engine/helper/HL_SocketHeap.cpp @@ -127,7 +127,7 @@ PDatagramSocket SocketHeap::allocSocket(int family, SocketSink* sink, int port) if (sock == INVALID_SOCKET) { // Return null socket - PDatagramSocket result(new DatagramSocket()); + auto result = std::make_shared(); result->mLocalPort = port; result->mFamily = family; return result; @@ -170,7 +170,7 @@ PDatagramSocket SocketHeap::allocSocket(int family, SocketSink* sink, int port) closesocket(sock); throw Exception(ERR_NET_FAILED, WSAGetLastError()); } - PDatagramSocket resultObject(new DatagramSocket()); + auto resultObject = std::make_shared(); resultObject->mLocalPort = testport; resultObject->mHandle = sock; if (!resultObject->setBlocking(false)) diff --git a/src/engine/helper/HL_ThreadPool.cpp b/src/engine/helper/HL_ThreadPool.cpp index d58a1afb..a98ef82b 100644 --- a/src/engine/helper/HL_ThreadPool.cpp +++ b/src/engine/helper/HL_ThreadPool.cpp @@ -7,7 +7,7 @@ thread_pool::thread_pool(size_t num_of_threads, const std::string& name) num_of_threads = std::thread::hardware_concurrency(); for(size_t idx = 0; idx < num_of_threads; idx++) - this->workers.push_back(std::thread(&thread_pool::run_worker, this)); + this->workers.emplace_back(std::thread(&thread_pool::run_worker, this)); } // Add new work item to the pool diff --git a/src/libs/ice/ICEAddress.cpp b/src/libs/ice/ICEAddress.cpp index be8b3b80..975f0eb3 100644 --- a/src/libs/ice/ICEAddress.cpp +++ b/src/libs/ice/ICEAddress.cpp @@ -68,7 +68,7 @@ NetworkAddress NetworkAddress::parse(const std::string& s) if (ip4Pos == std::string::npos && ip6Pos == std::string::npos) { // Parse usual IP[:port] pair - std::string::size_type cp = s.find_last_of(":"); + std::string::size_type cp = s.find_last_of(':'); if (cp == std::string::npos) result.setIp(cp); else @@ -87,7 +87,7 @@ NetworkAddress NetworkAddress::parse(const std::string& s) std::string addr = s.substr(familyPos + 5); // Find IP substring and port - std::string::size_type colonPos = addr.find_last_of(":"); + std::string::size_type colonPos = addr.find_last_of(':'); if (colonPos != std::string::npos) { int port = atoi(addr.substr(colonPos+1).c_str()); @@ -230,10 +230,6 @@ NetworkAddress::NetworkAddress(const NetworkAddress& src) memcpy(&mAddr6, &src.mAddr6, sizeof mAddr6); } -NetworkAddress::~NetworkAddress() -{ -} - int NetworkAddress::family() const { assert(mInitialized == true); @@ -305,9 +301,10 @@ sockaddr_in6* NetworkAddress::sockaddr6() const void NetworkAddress::setIp(NetworkAddress ipOnly) { - // Save port + // Setup family mAddr4.sin_family = ipOnly.genericsockaddr()->sa_family; + // Copy address chunk only switch (ipOnly.family()) { case AF_INET: @@ -315,7 +312,7 @@ void NetworkAddress::setIp(NetworkAddress ipOnly) break; case AF_INET6: - memcpy(&mAddr4.sin_addr, &ipOnly.sockaddr6()->sin6_addr, 16); + memcpy(&mAddr6.sin6_addr, &ipOnly.sockaddr6()->sin6_addr, 16); break; default: diff --git a/src/libs/ice/ICEAddress.h b/src/libs/ice/ICEAddress.h index 2fabb5ff..a2813c65 100644 --- a/src/libs/ice/ICEAddress.h +++ b/src/libs/ice/ICEAddress.h @@ -37,7 +37,7 @@ namespace ice NetworkAddress(const in_addr& ip, unsigned short port); NetworkAddress(const sockaddr& addr, size_t addrLen); NetworkAddress(const NetworkAddress& src); - ~NetworkAddress(); + ~NetworkAddress() = default; // Returns AF_INET or AF_INET6 int family() const; diff --git a/src/libs/ice/ICEAuthTransaction.cpp b/src/libs/ice/ICEAuthTransaction.cpp index 9c37f299..d5778e90 100644 --- a/src/libs/ice/ICEAuthTransaction.cpp +++ b/src/libs/ice/ICEAuthTransaction.cpp @@ -14,7 +14,7 @@ using namespace ice; AuthTransaction::AuthTransaction() :Transaction(), mActive(false), mComposed(false), mConformsToKeepaliveSchedule(true), -mCredentialsEncoded(false) +mCredentialsEncoded(false), mErrorCode(0) { } @@ -29,7 +29,7 @@ void AuthTransaction::init() buildAuthenticatedMsg(); else { - std::shared_ptr msg(new StunMessage()); + auto msg = std::make_shared(); msg->setTransactionId(mTransactionID); setInitialRequest(*msg); mComposed = false; @@ -44,7 +44,7 @@ void AuthTransaction::buildAuthenticatedMsg() md5Bin(key.c_str(), key.size(), mKey); // Create new authenticated message - std::shared_ptr newMsg( new StunMessage() ); + auto newMsg = std::make_shared(); // Optional - generate new transaction ID // mTransactionID = StunMessage::TransactionID::GenerateNew(); diff --git a/src/libs/ice/ICEAuthTransaction.h b/src/libs/ice/ICEAuthTransaction.h index fa3b13b0..6c43258d 100644 --- a/src/libs/ice/ICEAuthTransaction.h +++ b/src/libs/ice/ICEAuthTransaction.h @@ -46,7 +46,7 @@ protected: int mErrorCode; std::string mErrorResponse; std::deque > mOutgoingMsgQueue; - unsigned char mKey[16]; + unsigned char mKey[16] = {0}; bool mConformsToKeepaliveSchedule; std::string mRealm; std::string mNonce; diff --git a/src/libs/ice/ICEByteBuffer.cpp b/src/libs/ice/ICEByteBuffer.cpp index ffc6d180..9f671691 100644 --- a/src/libs/ice/ICEByteBuffer.cpp +++ b/src/libs/ice/ICEByteBuffer.cpp @@ -284,9 +284,6 @@ void BitReader::init() mCurrentBit = 0; } -BitReader::~BitReader() -{} - // Check for valid position uint8_t BitReader::readBit() { @@ -357,9 +354,6 @@ void BitWriter::init() mCurrentBit = 0; } -BitWriter::~BitWriter() -{} - BitWriter& BitWriter::writeBit(int bit) { bit = bit ? 1 : 0; diff --git a/src/libs/ice/ICEByteBuffer.h b/src/libs/ice/ICEByteBuffer.h index 84ec1171..4e767d53 100644 --- a/src/libs/ice/ICEByteBuffer.h +++ b/src/libs/ice/ICEByteBuffer.h @@ -103,7 +103,7 @@ namespace ice public: BitReader(const void* input, size_t bytes); BitReader(const ByteBuffer& buffer); - ~BitReader(); + ~BitReader() = default; uint8_t readBit(); uint32_t readBits(size_t nrOfBits); @@ -126,7 +126,7 @@ namespace ice public: BitWriter(void* output); BitWriter(ByteBuffer& buffer); - ~BitWriter(); + ~BitWriter() = default; // Bit must be 0 or 1 BitWriter& writeBit(int bit); diff --git a/src/libs/ice/ICECRC32.cpp b/src/libs/ice/ICECRC32.cpp index 74e6dcb1..0524554a 100644 --- a/src/libs/ice/ICECRC32.cpp +++ b/src/libs/ice/ICECRC32.cpp @@ -19,13 +19,6 @@ CRC32::CRC32(void) } -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -CRC32::~CRC32(void) -{ - //No destructor code. -} - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /* This function initializes "CRC Lookup Table". You only need to call it once to diff --git a/src/libs/ice/ICECRC32.h b/src/libs/ice/ICECRC32.h index 94eb96b7..3d2b91d6 100644 --- a/src/libs/ice/ICECRC32.h +++ b/src/libs/ice/ICECRC32.h @@ -11,7 +11,7 @@ namespace ice { public: CRC32(void); - ~CRC32(void); + ~CRC32(void) = default; void initialize(void); @@ -29,4 +29,4 @@ namespace ice }; } -#endif \ No newline at end of file +#endif diff --git a/src/libs/ice/ICECheckList.cpp b/src/libs/ice/ICECheckList.cpp index 27c3d372..e1849eaf 100644 --- a/src/libs/ice/ICECheckList.cpp +++ b/src/libs/ice/ICECheckList.cpp @@ -215,7 +215,7 @@ PCandidatePair CheckList::findEqualPair(CandidatePair& _pair, ComparisionType ct unsigned CheckList::add(CandidatePair& p) { - mPairList.push_back(PCandidatePair(new CandidatePair(p))); + mPairList.push_back(std::make_shared(p)); // Sort list by priority std::sort(mPairList.begin(), mPairList.end(), ComparePairByPriority); diff --git a/src/libs/ice/ICEError.cpp b/src/libs/ice/ICEError.cpp index 5722c08f..13bf8af6 100644 --- a/src/libs/ice/ICEError.cpp +++ b/src/libs/ice/ICEError.cpp @@ -60,7 +60,7 @@ Exception::Exception(int code, int subcode) } Exception::Exception(const Exception& src) -:mErrorCode(src.mErrorCode), mErrorMsg(src.mErrorMsg) +:mErrorCode(src.mErrorCode), mErrorMsg(src.mErrorMsg), mSubcode(0) { } diff --git a/src/libs/ice/ICEPacketTimer.cpp b/src/libs/ice/ICEPacketTimer.cpp index 797598aa..980be02c 100644 --- a/src/libs/ice/ICEPacketTimer.cpp +++ b/src/libs/ice/ICEPacketTimer.cpp @@ -16,10 +16,6 @@ PacketScheduler::PacketScheduler() mLastRTO = 100; } -PacketScheduler::~PacketScheduler() -{ -} - void PacketScheduler::setInitialRTO(int value) { mInitialRTO = value; diff --git a/src/libs/ice/ICEPacketTimer.h b/src/libs/ice/ICEPacketTimer.h index 5fa1c0af..5c2d67eb 100644 --- a/src/libs/ice/ICEPacketTimer.h +++ b/src/libs/ice/ICEPacketTimer.h @@ -13,7 +13,7 @@ class PacketScheduler { public: PacketScheduler(); - ~PacketScheduler(); + ~PacketScheduler() = default; void setInitialRTO(int value); int initialRTO(); @@ -40,4 +40,4 @@ protected: } //end of namespace -#endif \ No newline at end of file +#endif diff --git a/src/libs/ice/ICEStream.h b/src/libs/ice/ICEStream.h index 995f6206..8b64caa5 100644 --- a/src/libs/ice/ICEStream.h +++ b/src/libs/ice/ICEStream.h @@ -63,9 +63,7 @@ namespace ice :mTag(NULL), mPort4(0), mPort6(0), mNominationWaitIntervalStartTime(0) {} - ~Component() - { - } + ~Component() = default; }; typedef std::map ComponentMap;