- fix many compiler warnings

This commit is contained in:
2025-08-21 11:04:56 +03:00
parent 6b6f4147db
commit 178ebac88a
26 changed files with 74 additions and 79 deletions

View File

@@ -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);

View File

@@ -47,7 +47,7 @@ namespace Audio
public:
TimeSource(int quantTime, int nrOfQuants);
~TimeSource();
~TimeSource() = default;
void start();
void stop();

View File

@@ -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);

View File

@@ -38,6 +38,8 @@ namespace Audio
void* mBuffer = nullptr;
std::shared_ptr<NullTimer> mTimer;
int64_t mTimeCounter = 0, mDataCounter = 0;
void internalClose();
public:
NullInputDevice();
virtual ~NullInputDevice();
@@ -55,6 +57,8 @@ namespace Audio
std::shared_ptr<NullTimer> mTimer;
void* mBuffer = nullptr;
int64_t mDataCounter = 0, mTimeCounter = 0;
void internalClose();
public:
NullOutputDevice();
virtual ~NullOutputDevice();

View File

@@ -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<Resampler>();
r->start(AUDIO_CHANNELS, sourceRate, destRate);
mResamplerMap[RatePair(sourceRate, destRate)] = r;
}

View File

@@ -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;
}

View File

@@ -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)
{

View File

@@ -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();

View File

@@ -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)

View File

@@ -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<DatagramSocket> PDatagramSocket;

View File

@@ -278,12 +278,12 @@ std::shared_ptr<std::thread> 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)

View File

@@ -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<DatagramSocket>();
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<DatagramSocket>();
resultObject->mLocalPort = testport;
resultObject->mHandle = sock;
if (!resultObject->setBlocking(false))

View File

@@ -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