- fix compiler warnings

This commit is contained in:
2023-06-05 11:55:40 +03:00
parent 6b8549346c
commit 42cc9ee096
14 changed files with 37 additions and 35 deletions

View File

@@ -17,7 +17,10 @@
using namespace Audio;
#define SHRT_MAX 32767 /* maximum (signed) short value */
#ifndef SHRT_MAX
# define SHRT_MAX 32767 /* maximum (signed) short value */
#endif
AgcFilter::AgcFilter(int channels)
{
static const float DefaultLevel = 0.8f;

View File

@@ -105,7 +105,7 @@ bool WavFileReader::open(const std::tstring& filename)
THROW_READERROR;
// Read the file size
unsigned int filesize = 0;
uint32_t filesize = 0;
if (fread(&filesize, 4, 1, mHandle) < 1)
THROW_READERROR;
@@ -117,20 +117,19 @@ bool WavFileReader::open(const std::tstring& filename)
if (strcmp(wavefmt, "WAVEfmt ") != 0)
THROW_READERROR;
unsigned fmtSize = 0;
uint32_t fmtSize = 0;
if (fread(&fmtSize, 4, 1, mHandle) < 1)
THROW_READERROR;
unsigned fmtStart = ftell(mHandle);
uint32_t fmtStart = ftell(mHandle);
unsigned short formattag = 0;
uint16_t formattag = 0;
if (fread(&formattag, 2, 1, mHandle) < 1)
THROW_READERROR;
if (formattag != 1/*WAVE_FORMAT_PCM*/)
THROW_READERROR;
mChannels = 0;
if (fread(&mChannels, 2, 1, mHandle) < 1)
THROW_READERROR;
@@ -220,8 +219,8 @@ size_t WavFileReader::read(short* buffer, size_t samples)
unsigned filePosition = ftell(mHandle);
// Check how much data we can read
unsigned fileAvailable = mDataLength + mDataOffset - filePosition;
requiredBytes = (int)fileAvailable < requiredBytes ? (int)fileAvailable : requiredBytes;
size_t fileAvailable = mDataLength + mDataOffset - filePosition;
requiredBytes = fileAvailable < requiredBytes ? fileAvailable : requiredBytes;
}
size_t readBytes = fread(temp, 1, requiredBytes, mHandle);
@@ -282,7 +281,7 @@ std::tstring WavFileReader::filename() const
return mFileName;
}
unsigned WavFileReader::size() const
size_t WavFileReader::size() const
{
LOCK;

View File

@@ -21,14 +21,14 @@ namespace Audio
{
protected:
FILE* mHandle;
short mChannels;
short mBits;
uint16_t mChannels;
uint16_t mBits;
int mSamplerate;
std::tstring mFileName;
mutable std::recursive_mutex
mFileMtx;
unsigned mDataOffset;
unsigned mDataLength;
size_t mDataOffset;
size_t mDataLength;
Resampler mResampler;
unsigned mLastError;
@@ -53,7 +53,7 @@ namespace Audio
size_t readRaw(short* buffer, size_t samples);
std::tstring filename() const;
unsigned size() const;
size_t size() const;
unsigned lastError() const;
};
@@ -66,8 +66,8 @@ namespace Audio
FILE* mHandle; /// Handle of audio file.
std::tstring mFileName; /// Path to requested audio file.
std::recursive_mutex mFileMtx; /// Mutex to protect this instance.
int mWritten; /// Amount of written data (in bytes)
int mLengthOffset; /// Position of length field.
size_t mWritten; /// Amount of written data (in bytes)
size_t mLengthOffset; /// Position of length field.
int mRate,
mChannels;