1
0
mirror of https://github.com/RPCS3/soundtouch.git synced 2024-11-09 12:22:51 +01:00

Merge pull request 'Increase warning settings' (#10) from Minty-Meeo/soundtouch:master into master

Reviewed-on: https://codeberg.org/soundtouch/soundtouch/pulls/10
This commit is contained in:
Olli Parviainen 2023-03-25 09:44:23 +00:00
commit 05d2835f65
24 changed files with 70 additions and 92 deletions

View File

@ -7,7 +7,7 @@ if(MSVC)
set(COMPILE_DEFINITIONS /O2 /fp:fast)
set(COMPILE_OPTIONS )
else()
set(COMPILE_OPTIONS -Ofast -Wall -Wno-unknown-pragmas)
set(COMPILE_OPTIONS -Ofast -Wall -Wextra -Wzero-as-null-pointer-constant -Wno-unknown-pragmas)
endif()
#####################

View File

@ -196,7 +196,7 @@ namespace soundtouch
/// - "values" receive array of beat detection strengths
/// - max_num indicates max.size of "pos" and "values" array.
///
/// You can query a suitable array sized by calling this with NULL in "pos" & "values".
/// You can query a suitable array sized by calling this with nullptr in "pos" & "values".
///
/// \return number of beats in the arrays.
int getBeats(float *pos, float *strength, int max_num);

View File

@ -144,8 +144,8 @@ protected:
/// Sets output pipe.
void setOutPipe(FIFOSamplePipe *pOutput)
{
assert(output == NULL);
assert(pOutput != NULL);
assert(output == nullptr);
assert(pOutput != nullptr);
output = pOutput;
}
@ -153,7 +153,7 @@ protected:
/// 'setOutPipe' function.
FIFOProcessor()
{
output = NULL;
output = nullptr;
}
/// Constructor. Configures output pipe.

View File

@ -46,7 +46,7 @@ static void _setErrmsg(const char *msg)
#include <pthread.h>
extern pthread_key_t gomp_tls_key;
static void * _p_gomp_tls = NULL;
static void * _p_gomp_tls = nullptr;
/// Function to initialize threading for OpenMP.
///
@ -54,7 +54,7 @@ static void * _p_gomp_tls = NULL;
/// called from the Android App main thread because in the main thread the gomp_tls storage is
/// properly set, however, Android does not properly initialize gomp_tls storage for other threads.
/// Thus if OpenMP routines are invoked from some other thread than the main thread,
/// the OpenMP routine will crash the application due to NULL pointer access on uninitialized storage.
/// the OpenMP routine will crash the application due to nullptr access on uninitialized storage.
///
/// This workaround stores the gomp_tls storage from main thread, and copies to other threads.
/// In order this to work, the Application main thread needws to call at least "getVersionString"
@ -63,7 +63,7 @@ static int _init_threading(bool warn)
{
void *ptr = pthread_getspecific(gomp_tls_key);
LOGV("JNI thread-specific TLS storage %ld", (long)ptr);
if (ptr == NULL)
if (ptr == nullptr)
{
LOGV("JNI set missing TLS storage to %ld", (long)_p_gomp_tls);
pthread_setspecific(gomp_tls_key, _p_gomp_tls);
@ -74,7 +74,7 @@ static int _init_threading(bool warn)
_p_gomp_tls = ptr;
}
// Where critical, show warning if storage still not properly initialized
if ((warn) && (_p_gomp_tls == NULL))
if ((warn) && (_p_gomp_tls == nullptr))
{
_setErrmsg("Error - OpenMP threading not properly initialized: Call SoundTouch.getVersionString() from the App main thread!");
return -1;

View File

@ -115,8 +115,8 @@ RunParameters::RunParameters(const int nParams, const char * const paramStr[])
ST_THROW_RT_ERROR(msg.c_str());
}
inFileName = NULL;
outFileName = NULL;
inFileName = nullptr;
outFileName = nullptr;
tempoDelta = 0;
pitchDelta = 0;
rateDelta = 0;
@ -133,7 +133,7 @@ RunParameters::RunParameters(const int nParams, const char * const paramStr[])
if (outFileName[0] == '-')
{
// no outputfile name was given but parameters
outFileName = NULL;
outFileName = nullptr;
nFirstParam = 2;
}
else

View File

@ -123,7 +123,7 @@ static const char dataStr[] = "data";
}
// dummy helper-function
static inline void _swap16Buffer(short *pData, int numBytes)
static inline void _swap16Buffer(short *, int)
{
// do nothing
}
@ -138,7 +138,7 @@ static const char dataStr[] = "data";
WavFileBase::WavFileBase()
{
convBuff = NULL;
convBuff = nullptr;
convBuffSize = 0;
}
@ -173,7 +173,7 @@ WavInFile::WavInFile(const char *fileName)
{
// Try to open the file for reading
fptr = fopen(fileName, "rb");
if (fptr == NULL)
if (fptr == nullptr)
{
// didn't succeed
string msg = "Error : Unable to open file \"";
@ -234,7 +234,7 @@ void WavInFile::init()
WavInFile::~WavInFile()
{
if (fptr) fclose(fptr);
fptr = NULL;
fptr = nullptr;
}
@ -707,7 +707,7 @@ WavOutFile::WavOutFile(const char *fileName, int sampleRate, int bits, int chann
{
bytesWritten = 0;
fptr = fopen(fileName, "wb");
if (fptr == NULL)
if (fptr == nullptr)
{
string msg = "Error : Unable to open file \"";
msg += fileName;
@ -725,7 +725,7 @@ WavOutFile::WavOutFile(FILE *file, int sampleRate, int bits, int channels)
{
bytesWritten = 0;
fptr = file;
if (fptr == NULL)
if (fptr == nullptr)
{
string msg = "Error : Unable to access output file stream.";
ST_THROW_RT_ERROR(msg.c_str());
@ -740,7 +740,7 @@ WavOutFile::~WavOutFile()
{
finishHeader();
if (fptr) fclose(fptr);
fptr = NULL;
fptr = nullptr;
}

View File

@ -118,9 +118,6 @@ private:
/// File pointer.
FILE *fptr;
/// Position within the audio stream
long position;
/// Counter of how many bytes of sample data have been read from the file.
long dataRead;

View File

@ -103,7 +103,7 @@ static void openFiles(WavInFile **inFile, WavOutFile **outFile, const RunParamet
}
else
{
*outFile = NULL;
*outFile = nullptr;
}
}
@ -172,7 +172,7 @@ static void process(SoundTouch *pSoundTouch, WavInFile *inFile, WavOutFile *outF
int buffSizeSamples;
SAMPLETYPE sampleBuffer[BUFF_SIZE];
if ((inFile == NULL) || (outFile == NULL)) return; // nothing to do.
if ((inFile == nullptr) || (outFile == nullptr)) return; // nothing to do.
nChannels = (int)inFile->getNumChannels();
assert(nChannels > 0);

View File

@ -54,7 +54,7 @@ using namespace soundtouch;
static void _DEBUG_SAVE_AAFIR_COEFFS(SAMPLETYPE *coeffs, int len)
{
FILE *fptr = fopen("aa_filter_coeffs.txt", "wt");
if (fptr == NULL) return;
if (fptr == nullptr) return;
for (int i = 0; i < len; i ++)
{

View File

@ -554,13 +554,13 @@ float BPMDetect::getBpm()
/// - "values" receive array of beat detection strengths
/// - max_num indicates max.size of "pos" and "values" array.
///
/// You can query a suitable array sized by calling this with NULL in "pos" & "values".
/// You can query a suitable array sized by calling this with nullptr in "pos" & "values".
///
/// \return number of beats in the arrays.
int BPMDetect::getBeats(float *pos, float *values, int max_num)
{
int num = (int)beats.size();
if ((!pos) || (!values)) return num; // pos or values NULL, return just size
if ((!pos) || (!values)) return num; // pos or values nullptr, return just size
for (int i = 0; (i < num) && (i < max_num); i++)
{

View File

@ -50,8 +50,8 @@ FIFOSampleBuffer::FIFOSampleBuffer(int numChannels)
{
assert(numChannels > 0);
sizeInBytes = 0; // reasonable initial value
buffer = NULL;
bufferUnaligned = NULL;
buffer = nullptr;
bufferUnaligned = nullptr;
samplesInBuffer = 0;
bufferPos = 0;
channels = (uint)numChannels;
@ -63,8 +63,8 @@ FIFOSampleBuffer::FIFOSampleBuffer(int numChannels)
FIFOSampleBuffer::~FIFOSampleBuffer()
{
delete[] bufferUnaligned;
bufferUnaligned = NULL;
buffer = NULL;
bufferUnaligned = nullptr;
buffer = nullptr;
}
@ -166,7 +166,7 @@ void FIFOSampleBuffer::ensureCapacity(uint capacityRequirement)
sizeInBytes = (capacityRequirement * channels * sizeof(SAMPLETYPE) + 4095) & (uint)-4096;
assert(sizeInBytes % 2 == 0);
tempUnaligned = new SAMPLETYPE[sizeInBytes / sizeof(SAMPLETYPE) + 16 / sizeof(SAMPLETYPE)];
if (tempUnaligned == NULL)
if (tempUnaligned == nullptr)
{
ST_THROW_RT_ERROR("Couldn't allocate memory!\n");
}

View File

@ -59,8 +59,8 @@ FIRFilter::FIRFilter()
resultDivider = 0;
length = 0;
lengthDiv8 = 0;
filterCoeffs = NULL;
filterCoeffsStereo = NULL;
filterCoeffs = nullptr;
filterCoeffsStereo = nullptr;
}
@ -78,7 +78,7 @@ uint FIRFilter::evaluateFilterStereo(SAMPLETYPE *dest, const SAMPLETYPE *src, ui
// hint compiler autovectorization that loop length is divisible by 8
uint ilength = length & -8;
assert((length != 0) && (length == ilength) && (src != NULL) && (dest != NULL) && (filterCoeffs != NULL));
assert((length != 0) && (length == ilength) && (src != nullptr) && (dest != nullptr) && (filterCoeffs != nullptr));
assert(numSamples > ilength);
end = 2 * (numSamples - ilength);
@ -152,9 +152,9 @@ uint FIRFilter::evaluateFilterMulti(SAMPLETYPE *dest, const SAMPLETYPE *src, uin
int j, end;
assert(length != 0);
assert(src != NULL);
assert(dest != NULL);
assert(filterCoeffs != NULL);
assert(src != nullptr);
assert(dest != nullptr);
assert(filterCoeffs != nullptr);
assert(numChannels < 16);
// hint compiler autovectorization that loop length is divisible by 8
@ -273,7 +273,7 @@ uint FIRFilter::evaluate(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSample
// Operator 'new' is overloaded so that it automatically creates a suitable instance
// depending on if we've a MMX-capable CPU available or not.
void * FIRFilter::operator new(size_t s)
void * FIRFilter::operator new(size_t)
{
// Notice! don't use "new FIRFilter" directly, use "newInstance" to create a new instance instead!
ST_THROW_RT_ERROR("Error in FIRFilter::new: Don't use 'new FIRFilter', use 'newInstance' member instead!");

View File

@ -58,7 +58,7 @@ public:
virtual void resetRegisters() override;
int getLatency() const
virtual int getLatency() const override
{
return 1;
}

View File

@ -61,7 +61,7 @@ public:
virtual void resetRegisters() override;
int getLatency() const
virtual int getLatency() const override
{
return 0;
}

View File

@ -171,9 +171,9 @@ int InterpolateShannon::transposeStereo(SAMPLETYPE *pdest,
/// Transpose stereo audio. Returns number of produced output samples, and
/// updates "srcSamples" to amount of consumed source samples
int InterpolateShannon::transposeMulti(SAMPLETYPE *pdest,
const SAMPLETYPE *psrc,
int &srcSamples)
int InterpolateShannon::transposeMulti(SAMPLETYPE *,
const SAMPLETYPE *,
int &)
{
// not implemented
assert(false);

View File

@ -63,7 +63,7 @@ public:
void resetRegisters() override;
int getLatency() const
virtual int getLatency() const override
{
return 3;
}

View File

@ -307,7 +307,7 @@ TransposerBase *TransposerBase::newInstance()
default:
assert(false);
return NULL;
return nullptr;
}
#endif
}

View File

@ -413,15 +413,15 @@ int SoundTouch::getSetting(int settingId) const
return (uint)pTDStretch->isQuickSeekEnabled();
case SETTING_SEQUENCE_MS:
pTDStretch->getParameters(NULL, &temp, NULL, NULL);
pTDStretch->getParameters(nullptr, &temp, nullptr, nullptr);
return temp;
case SETTING_SEEKWINDOW_MS:
pTDStretch->getParameters(NULL, NULL, &temp, NULL);
pTDStretch->getParameters(nullptr, nullptr, &temp, nullptr);
return temp;
case SETTING_OVERLAP_MS:
pTDStretch->getParameters(NULL, NULL, NULL, &temp);
pTDStretch->getParameters(nullptr, nullptr, nullptr, &temp);
return temp;
case SETTING_NOMINAL_INPUT_SEQUENCE :

View File

@ -54,25 +54,6 @@ using namespace soundtouch;
#define max(x, y) (((x) > (y)) ? (x) : (y))
/*****************************************************************************
*
* Constant definitions
*
*****************************************************************************/
// Table for the hierarchical mixing position seeking algorithm
const short _scanOffsets[5][24]={
{ 124, 186, 248, 310, 372, 434, 496, 558, 620, 682, 744, 806,
868, 930, 992, 1054, 1116, 1178, 1240, 1302, 1364, 1426, 1488, 0},
{-100, -75, -50, -25, 25, 50, 75, 100, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ -20, -15, -10, -5, 5, 10, 15, 20, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ -4, -3, -2, -1, 1, 2, 3, 4, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 121, 114, 97, 114, 98, 105, 108, 32, 104, 99, 117, 111,
116, 100, 110, 117, 111, 115, 0, 0, 0, 0, 0, 0}};
/*****************************************************************************
*
* Implementation of the class 'TDStretch'
@ -85,8 +66,8 @@ TDStretch::TDStretch() : FIFOProcessor(&outputBuffer)
bQuickSeek = false;
channels = 2;
pMidBuffer = NULL;
pMidBufferUnaligned = NULL;
pMidBuffer = nullptr;
pMidBufferUnaligned = nullptr;
overlapLength = 0;
bAutoSeqSetting = true;
@ -162,7 +143,7 @@ void TDStretch::setParameters(int aSampleRate, int aSequenceMS,
/// Get routine control parameters, see setParameters() function.
/// Any of the parameters to this function can be NULL, in such case corresponding parameter
/// Any of the parameters to this function can be nullptr, in such case corresponding parameter
/// value isn't returned.
void TDStretch::getParameters(int *pSampleRate, int *pSequenceMs, int *pSeekWindowMs, int *pOverlapMs) const
{
@ -759,7 +740,7 @@ void TDStretch::acceptNewOverlapLength(int newOverlapLength)
// Operator 'new' is overloaded so that it automatically creates a suitable instance
// depending on if we've a MMX/SSE/etc-capable CPU available or not.
void * TDStretch::operator new(size_t s)
void * TDStretch::operator new(size_t)
{
// Notice! don't use "new TDStretch" directly, use "newInstance" to create a new instance instead!
ST_THROW_RT_ERROR("Error in TDStretch::new: Don't use 'new TDStretch' directly, use 'newInstance' member instead!");

View File

@ -217,7 +217,7 @@ public:
);
/// Get routine control parameters, see setParameters() function.
/// Any of the parameters to this function can be NULL, in such case corresponding parameter
/// Any of the parameters to this function can be nullptr, in such case corresponding parameter
/// value isn't returned.
void getParameters(int *pSampleRate, int *pSequenceMs, int *pSeekWindowMs, int *pOverlapMs) const;

View File

@ -294,8 +294,8 @@ void TDStretchMMX::overlapStereo(short *output, const short *input) const
FIRFilterMMX::FIRFilterMMX() : FIRFilter()
{
filterCoeffsAlign = NULL;
filterCoeffsUnalign = NULL;
filterCoeffsAlign = nullptr;
filterCoeffsUnalign = nullptr;
}

View File

@ -195,16 +195,16 @@ double TDStretchSSE::calcCrossCorrAccumulate(const float *pV1, const float *pV2,
FIRFilterSSE::FIRFilterSSE() : FIRFilter()
{
filterCoeffsAlign = NULL;
filterCoeffsUnalign = NULL;
filterCoeffsAlign = nullptr;
filterCoeffsUnalign = nullptr;
}
FIRFilterSSE::~FIRFilterSSE()
{
delete[] filterCoeffsUnalign;
filterCoeffsAlign = NULL;
filterCoeffsUnalign = NULL;
filterCoeffsAlign = nullptr;
filterCoeffsUnalign = nullptr;
}
@ -245,10 +245,10 @@ uint FIRFilterSSE::evaluateFilterStereo(float *dest, const float *source, uint n
if (count < 2) return 0;
assert(source != NULL);
assert(dest != NULL);
assert(source != nullptr);
assert(dest != nullptr);
assert((length % 8) == 0);
assert(filterCoeffsAlign != NULL);
assert(filterCoeffsAlign != nullptr);
assert(((ulongptr)filterCoeffsAlign) % 16 == 0);
// filter is evaluated for two stereo samples with each iteration, thus use of 'j += 2'

View File

@ -137,7 +137,7 @@ type
/// Receive ready samples from the processing pipeline.
///
/// if called with outBuffer=NULL, just reduces amount of ready samples within the pipeline.
/// if called with outBuffer=nullptr, just reduces amount of ready samples within the pipeline.
TSoundTouchReceiveSamples = function (Handle: TSoundTouchHandle;
OutBuffer: PSingle; //< Buffer where to copy output samples.
MaxSamples: Integer //< How many samples to receive at max.

View File

@ -90,10 +90,10 @@ SOUNDTOUCHDLL_API HANDLE __cdecl soundtouch_createInstance()
{
tmp->dwMagic = STMAGIC;
tmp->pst = new SoundTouch();
if (tmp->pst == NULL)
if (tmp->pst == nullptr)
{
delete tmp;
tmp = NULL;
tmp = nullptr;
}
}
return (HANDLE)tmp;
@ -107,7 +107,7 @@ SOUNDTOUCHDLL_API void __cdecl soundtouch_destroyInstance(HANDLE h)
sth->dwMagic = 0;
if (sth->pst) delete sth->pst;
sth->pst = NULL;
sth->pst = nullptr;
delete sth;
}
@ -375,7 +375,7 @@ SOUNDTOUCHDLL_API uint __cdecl soundtouch_numUnprocessedSamples(HANDLE h)
/// Receive ready samples from the processing pipeline.
///
/// if called with outBuffer=NULL, just reduces amount of ready samples within the pipeline.
/// if called with outBuffer=nullptr, just reduces amount of ready samples within the pipeline.
SOUNDTOUCHDLL_API uint __cdecl soundtouch_receiveSamples(HANDLE h,
SAMPLETYPE *outBuffer, ///< Buffer where to copy output samples.
unsigned int maxSamples ///< How many samples to receive at max.
@ -406,7 +406,7 @@ SOUNDTOUCHDLL_API uint __cdecl soundtouch_receiveSamples_i16(HANDLE h,
if (sth->dwMagic != STMAGIC) return 0;
uint outTotal = 0;
if (outBuffer == NULL)
if (outBuffer == nullptr)
{
// only reduce sample count, not receive samples
return sth->pst->receiveSamples(maxSamples);
@ -480,12 +480,12 @@ SOUNDTOUCHDLL_API HANDLE __cdecl bpm_createInstance(int numChannels, int sampleR
}
catch (const std::exception&)
{
tmp->pbpm = NULL;
tmp->pbpm = nullptr;
}
if (tmp->pbpm == NULL)
if (tmp->pbpm == nullptr)
{
delete tmp;
tmp = NULL;
tmp = nullptr;
}
}
return (HANDLE)tmp;
@ -499,7 +499,7 @@ SOUNDTOUCHDLL_API void __cdecl bpm_destroyInstance(HANDLE h)
sth->dwMagic = 0;
if (sth->pbpm) delete sth->pbpm;
sth->pbpm = NULL;
sth->pbpm = nullptr;
delete sth;
}