1
0
mirror of https://github.com/RPCS3/soundtouch.git synced 2024-09-19 16:01:37 +02: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_DEFINITIONS /O2 /fp:fast)
set(COMPILE_OPTIONS ) set(COMPILE_OPTIONS )
else() else()
set(COMPILE_OPTIONS -Ofast -Wall -Wno-unknown-pragmas) set(COMPILE_OPTIONS -Ofast -Wall -Wextra -Wzero-as-null-pointer-constant -Wno-unknown-pragmas)
endif() endif()
##################### #####################

View File

@ -196,7 +196,7 @@ namespace soundtouch
/// - "values" receive array of beat detection strengths /// - "values" receive array of beat detection strengths
/// - max_num indicates max.size of "pos" and "values" array. /// - 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. /// \return number of beats in the arrays.
int getBeats(float *pos, float *strength, int max_num); int getBeats(float *pos, float *strength, int max_num);

View File

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

View File

@ -46,7 +46,7 @@ static void _setErrmsg(const char *msg)
#include <pthread.h> #include <pthread.h>
extern pthread_key_t gomp_tls_key; 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. /// 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 /// 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. /// 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, /// 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. /// 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" /// 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); void *ptr = pthread_getspecific(gomp_tls_key);
LOGV("JNI thread-specific TLS storage %ld", (long)ptr); 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); LOGV("JNI set missing TLS storage to %ld", (long)_p_gomp_tls);
pthread_setspecific(gomp_tls_key, _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; _p_gomp_tls = ptr;
} }
// Where critical, show warning if storage still not properly initialized // 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!"); _setErrmsg("Error - OpenMP threading not properly initialized: Call SoundTouch.getVersionString() from the App main thread!");
return -1; return -1;

View File

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

View File

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

View File

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

View File

@ -103,7 +103,7 @@ static void openFiles(WavInFile **inFile, WavOutFile **outFile, const RunParamet
} }
else else
{ {
*outFile = NULL; *outFile = nullptr;
} }
} }
@ -172,7 +172,7 @@ static void process(SoundTouch *pSoundTouch, WavInFile *inFile, WavOutFile *outF
int buffSizeSamples; int buffSizeSamples;
SAMPLETYPE sampleBuffer[BUFF_SIZE]; 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(); nChannels = (int)inFile->getNumChannels();
assert(nChannels > 0); assert(nChannels > 0);

View File

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

View File

@ -554,13 +554,13 @@ float BPMDetect::getBpm()
/// - "values" receive array of beat detection strengths /// - "values" receive array of beat detection strengths
/// - max_num indicates max.size of "pos" and "values" array. /// - 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. /// \return number of beats in the arrays.
int BPMDetect::getBeats(float *pos, float *values, int max_num) int BPMDetect::getBeats(float *pos, float *values, int max_num)
{ {
int num = (int)beats.size(); 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++) for (int i = 0; (i < num) && (i < max_num); i++)
{ {

View File

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

View File

@ -59,8 +59,8 @@ FIRFilter::FIRFilter()
resultDivider = 0; resultDivider = 0;
length = 0; length = 0;
lengthDiv8 = 0; lengthDiv8 = 0;
filterCoeffs = NULL; filterCoeffs = nullptr;
filterCoeffsStereo = NULL; 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 // hint compiler autovectorization that loop length is divisible by 8
uint ilength = length & -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); assert(numSamples > ilength);
end = 2 * (numSamples - ilength); end = 2 * (numSamples - ilength);
@ -152,9 +152,9 @@ uint FIRFilter::evaluateFilterMulti(SAMPLETYPE *dest, const SAMPLETYPE *src, uin
int j, end; int j, end;
assert(length != 0); assert(length != 0);
assert(src != NULL); assert(src != nullptr);
assert(dest != NULL); assert(dest != nullptr);
assert(filterCoeffs != NULL); assert(filterCoeffs != nullptr);
assert(numChannels < 16); assert(numChannels < 16);
// hint compiler autovectorization that loop length is divisible by 8 // 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 // Operator 'new' is overloaded so that it automatically creates a suitable instance
// depending on if we've a MMX-capable CPU available or not. // 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! // 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!"); 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; virtual void resetRegisters() override;
int getLatency() const virtual int getLatency() const override
{ {
return 1; return 1;
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -54,25 +54,6 @@ using namespace soundtouch;
#define max(x, y) (((x) > (y)) ? (x) : (y)) #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' * Implementation of the class 'TDStretch'
@ -85,8 +66,8 @@ TDStretch::TDStretch() : FIFOProcessor(&outputBuffer)
bQuickSeek = false; bQuickSeek = false;
channels = 2; channels = 2;
pMidBuffer = NULL; pMidBuffer = nullptr;
pMidBufferUnaligned = NULL; pMidBufferUnaligned = nullptr;
overlapLength = 0; overlapLength = 0;
bAutoSeqSetting = true; bAutoSeqSetting = true;
@ -162,7 +143,7 @@ void TDStretch::setParameters(int aSampleRate, int aSequenceMS,
/// Get routine control parameters, see setParameters() function. /// 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. /// value isn't returned.
void TDStretch::getParameters(int *pSampleRate, int *pSequenceMs, int *pSeekWindowMs, int *pOverlapMs) const 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 // 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. // 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! // 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!"); 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. /// 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. /// value isn't returned.
void getParameters(int *pSampleRate, int *pSequenceMs, int *pSeekWindowMs, int *pOverlapMs) const; 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() FIRFilterMMX::FIRFilterMMX() : FIRFilter()
{ {
filterCoeffsAlign = NULL; filterCoeffsAlign = nullptr;
filterCoeffsUnalign = NULL; filterCoeffsUnalign = nullptr;
} }

View File

@ -195,16 +195,16 @@ double TDStretchSSE::calcCrossCorrAccumulate(const float *pV1, const float *pV2,
FIRFilterSSE::FIRFilterSSE() : FIRFilter() FIRFilterSSE::FIRFilterSSE() : FIRFilter()
{ {
filterCoeffsAlign = NULL; filterCoeffsAlign = nullptr;
filterCoeffsUnalign = NULL; filterCoeffsUnalign = nullptr;
} }
FIRFilterSSE::~FIRFilterSSE() FIRFilterSSE::~FIRFilterSSE()
{ {
delete[] filterCoeffsUnalign; delete[] filterCoeffsUnalign;
filterCoeffsAlign = NULL; filterCoeffsAlign = nullptr;
filterCoeffsUnalign = NULL; filterCoeffsUnalign = nullptr;
} }
@ -245,10 +245,10 @@ uint FIRFilterSSE::evaluateFilterStereo(float *dest, const float *source, uint n
if (count < 2) return 0; if (count < 2) return 0;
assert(source != NULL); assert(source != nullptr);
assert(dest != NULL); assert(dest != nullptr);
assert((length % 8) == 0); assert((length % 8) == 0);
assert(filterCoeffsAlign != NULL); assert(filterCoeffsAlign != nullptr);
assert(((ulongptr)filterCoeffsAlign) % 16 == 0); assert(((ulongptr)filterCoeffsAlign) % 16 == 0);
// filter is evaluated for two stereo samples with each iteration, thus use of 'j += 2' // 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. /// 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; TSoundTouchReceiveSamples = function (Handle: TSoundTouchHandle;
OutBuffer: PSingle; //< Buffer where to copy output samples. OutBuffer: PSingle; //< Buffer where to copy output samples.
MaxSamples: Integer //< How many samples to receive at max. 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->dwMagic = STMAGIC;
tmp->pst = new SoundTouch(); tmp->pst = new SoundTouch();
if (tmp->pst == NULL) if (tmp->pst == nullptr)
{ {
delete tmp; delete tmp;
tmp = NULL; tmp = nullptr;
} }
} }
return (HANDLE)tmp; return (HANDLE)tmp;
@ -107,7 +107,7 @@ SOUNDTOUCHDLL_API void __cdecl soundtouch_destroyInstance(HANDLE h)
sth->dwMagic = 0; sth->dwMagic = 0;
if (sth->pst) delete sth->pst; if (sth->pst) delete sth->pst;
sth->pst = NULL; sth->pst = nullptr;
delete sth; delete sth;
} }
@ -375,7 +375,7 @@ SOUNDTOUCHDLL_API uint __cdecl soundtouch_numUnprocessedSamples(HANDLE h)
/// Receive ready samples from the processing pipeline. /// 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, SOUNDTOUCHDLL_API uint __cdecl soundtouch_receiveSamples(HANDLE h,
SAMPLETYPE *outBuffer, ///< Buffer where to copy output samples. SAMPLETYPE *outBuffer, ///< Buffer where to copy output samples.
unsigned int maxSamples ///< How many samples to receive at max. 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; if (sth->dwMagic != STMAGIC) return 0;
uint outTotal = 0; uint outTotal = 0;
if (outBuffer == NULL) if (outBuffer == nullptr)
{ {
// only reduce sample count, not receive samples // only reduce sample count, not receive samples
return sth->pst->receiveSamples(maxSamples); return sth->pst->receiveSamples(maxSamples);
@ -480,12 +480,12 @@ SOUNDTOUCHDLL_API HANDLE __cdecl bpm_createInstance(int numChannels, int sampleR
} }
catch (const std::exception&) catch (const std::exception&)
{ {
tmp->pbpm = NULL; tmp->pbpm = nullptr;
} }
if (tmp->pbpm == NULL) if (tmp->pbpm == nullptr)
{ {
delete tmp; delete tmp;
tmp = NULL; tmp = nullptr;
} }
} }
return (HANDLE)tmp; return (HANDLE)tmp;
@ -499,7 +499,7 @@ SOUNDTOUCHDLL_API void __cdecl bpm_destroyInstance(HANDLE h)
sth->dwMagic = 0; sth->dwMagic = 0;
if (sth->pbpm) delete sth->pbpm; if (sth->pbpm) delete sth->pbpm;
sth->pbpm = NULL; sth->pbpm = nullptr;
delete sth; delete sth;
} }