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

View File

@ -57,8 +57,8 @@ namespace Audio
FILE* mHandle; /// Handle of audio file. FILE* mHandle; /// Handle of audio file.
std::tstring mFileName; /// Path to requested audio file. std::tstring mFileName; /// Path to requested audio file.
std::recursive_mutex mFileMtx; /// Mutex to protect this instance. std::recursive_mutex mFileMtx; /// Mutex to protect this instance.
int mWritten; /// Amount of written data (in bytes) size_t mWritten; /// Amount of written data (in bytes)
int mLengthOffset; /// Position of length field. size_t mLengthOffset; /// Position of length field.
int mRate, int mRate,
mChannels; mChannels;
@ -71,7 +71,7 @@ namespace Audio
bool open(const std::tstring& filename, int rate, int channels); bool open(const std::tstring& filename, int rate, int channels);
void close(); void close();
bool isOpened(); bool isOpened();
unsigned write(const void* buffer, unsigned bytes); size_t write(const void* buffer, size_t bytes);
std::tstring filename(); std::tstring filename();
}; };