- fix more warnings in .wav file reader/writer

This commit is contained in:
dmytro.bogovych 2019-03-21 13:02:51 +02:00
parent e7946b57e3
commit 4dc9e6900a
2 changed files with 9 additions and 9 deletions

View File

@ -275,7 +275,7 @@ bool WavFileWriter::open(const std::tstring& filename, int rate, int channels)
#else
mHandle = fopen(StringHelper::makeUtf8(filename).c_str(), "wb");
#endif
if (NULL == mHandle)
if (nullptr == mHandle)
{
ICELogError(<< "Failed to create .wav file: filename = " << StringHelper::makeUtf8(filename) << " , error = " << errno);
return false;
@ -334,11 +334,11 @@ void WavFileWriter::close()
if (mHandle)
{
fclose(mHandle);
mHandle = NULL;
mHandle = nullptr;
}
}
unsigned WavFileWriter::write(const void* buffer, unsigned bytes)
size_t WavFileWriter::write(const void* buffer, size_t bytes)
{
LOCK;
@ -354,11 +354,11 @@ unsigned WavFileWriter::write(const void* buffer, unsigned bytes)
// Write file length
fseek(mHandle, 4, SEEK_SET);
unsigned int fl = mWritten + 36;
size_t fl = mWritten + 36;
fwrite(&fl, sizeof(fl), 1, mHandle);
// Write data length
fseek(mHandle, mLengthOffset, SEEK_SET);
fseek(mHandle, static_cast<long>(mLengthOffset), SEEK_SET);
checkWriteResult( fwrite(&mWritten, 4, 1, mHandle) );
return bytes;
@ -368,7 +368,7 @@ bool WavFileWriter::isOpened()
{
LOCK;
return (mHandle != 0);
return (mHandle != nullptr);
}
std::tstring WavFileWriter::filename()

View File

@ -57,8 +57,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;
@ -71,7 +71,7 @@ namespace Audio
bool open(const std::tstring& filename, int rate, int channels);
void close();
bool isOpened();
unsigned write(const void* buffer, unsigned bytes);
size_t write(const void* buffer, size_t bytes);
std::tstring filename();
};