| Index: webrtc/modules/media_file/media_file_impl.cc
|
| diff --git a/webrtc/modules/media_file/media_file_impl.cc b/webrtc/modules/media_file/media_file_impl.cc
|
| index 9f9511d837ea6dfe424f38834628ee23e9be552e..35e87e2a0cc2b94d127e83a5a7ce5f99fde3a585 100644
|
| --- a/webrtc/modules/media_file/media_file_impl.cc
|
| +++ b/webrtc/modules/media_file/media_file_impl.cc
|
| @@ -31,10 +31,10 @@ MediaFileImpl::MediaFileImpl(const int32_t id)
|
| : _id(id),
|
| _crit(CriticalSectionWrapper::CreateCriticalSection()),
|
| _callbackCrit(CriticalSectionWrapper::CreateCriticalSection()),
|
| - _ptrFileUtilityObj(NULL),
|
| + _ptrFileUtilityObj(nullptr),
|
| codec_info_(),
|
| - _ptrInStream(NULL),
|
| - _ptrOutStream(NULL),
|
| + _ptrInStream(nullptr),
|
| + _ptrOutStream(nullptr),
|
| _fileFormat((FileFormats)-1),
|
| _recordDurationMs(0),
|
| _playoutPositionMs(0),
|
| @@ -44,12 +44,11 @@ MediaFileImpl::MediaFileImpl(const int32_t id)
|
| _isStereo(false),
|
| _openFile(false),
|
| _fileName(),
|
| - _ptrCallback(NULL)
|
| -{
|
| - WEBRTC_TRACE(kTraceMemory, kTraceFile, id, "Created");
|
| + _ptrCallback(nullptr) {
|
| + WEBRTC_TRACE(kTraceMemory, kTraceFile, id, "Created");
|
|
|
| - codec_info_.plname[0] = '\0';
|
| - _fileName[0] = '\0';
|
| + codec_info_.plname[0] = '\0';
|
| + _fileName[0] = '\0';
|
| }
|
|
|
|
|
| @@ -74,9 +73,9 @@ MediaFileImpl::~MediaFileImpl()
|
| if(_openFile)
|
| {
|
| delete _ptrInStream;
|
| - _ptrInStream = NULL;
|
| + _ptrInStream = nullptr;
|
| delete _ptrOutStream;
|
| - _ptrOutStream = NULL;
|
| + _ptrOutStream = nullptr;
|
| }
|
| }
|
|
|
| @@ -110,11 +109,10 @@ int32_t MediaFileImpl::PlayoutAudioData(int8_t* buffer,
|
| const size_t bufferLengthInBytes = dataLengthInBytes;
|
| dataLengthInBytes = 0;
|
|
|
| - if(buffer == NULL || bufferLengthInBytes == 0)
|
| - {
|
| - WEBRTC_TRACE(kTraceError, kTraceFile, _id,
|
| - "Buffer pointer or length is NULL!");
|
| - return -1;
|
| + if (buffer == nullptr || bufferLengthInBytes == 0) {
|
| + WEBRTC_TRACE(kTraceError, kTraceFile, _id,
|
| + "Buffer pointer or length is null!");
|
| + return -1;
|
| }
|
|
|
| int32_t bytesRead = 0;
|
| @@ -242,11 +240,11 @@ int32_t MediaFileImpl::PlayoutStereoData(
|
| const size_t bufferLengthInBytes = dataLengthInBytes;
|
| dataLengthInBytes = 0;
|
|
|
| - if(bufferLeft == NULL || bufferRight == NULL || bufferLengthInBytes == 0)
|
| - {
|
| - WEBRTC_TRACE(kTraceError, kTraceFile, _id,
|
| - "A buffer pointer or the length is NULL!");
|
| - return -1;
|
| + if (bufferLeft == nullptr || bufferRight == nullptr ||
|
| + bufferLengthInBytes == 0) {
|
| + WEBRTC_TRACE(kTraceError, kTraceFile, _id,
|
| + "A buffer pointer or the length is null!");
|
| + return -1;
|
| }
|
|
|
| bool playEnded = false;
|
| @@ -263,13 +261,10 @@ int32_t MediaFileImpl::PlayoutStereoData(
|
|
|
| if(!_ptrFileUtilityObj)
|
| {
|
| - WEBRTC_TRACE(
|
| - kTraceError,
|
| - kTraceFile,
|
| - _id,
|
| - "Playing stereo, but the FileUtility objects is NULL!");
|
| - StopPlaying();
|
| - return -1;
|
| + WEBRTC_TRACE(kTraceError, kTraceFile, _id,
|
| + "Playing stereo, but the FileUtility objects is null!");
|
| + StopPlaying();
|
| + return -1;
|
| }
|
|
|
| // Stereo playout only supported for WAV files.
|
| @@ -364,11 +359,10 @@ int32_t MediaFileImpl::StartPlayingAudioFile(
|
| }
|
|
|
| FileWrapper* inputStream = FileWrapper::Create();
|
| - if(inputStream == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceMemory, kTraceFile, _id,
|
| - "Failed to allocate input stream for file %s", fileName);
|
| - return -1;
|
| + if (inputStream == nullptr) {
|
| + WEBRTC_TRACE(kTraceMemory, kTraceFile, _id,
|
| + "Failed to allocate input stream for file %s", fileName);
|
| + return -1;
|
| }
|
|
|
| if (!inputStream->OpenFile(fileName, true)) {
|
| @@ -436,22 +430,18 @@ int32_t MediaFileImpl::StartPlayingStream(
|
| return -1;
|
| }
|
|
|
| - if(_ptrFileUtilityObj != NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceError,
|
| - kTraceFile,
|
| - _id,
|
| - "StartPlaying called, but FileUtilityObj already exists!");
|
| - StopPlaying();
|
| - return -1;
|
| + if (_ptrFileUtilityObj != nullptr) {
|
| + WEBRTC_TRACE(kTraceError, kTraceFile, _id,
|
| + "StartPlaying called, but FileUtilityObj already exists!");
|
| + StopPlaying();
|
| + return -1;
|
| }
|
|
|
| _ptrFileUtilityObj = new ModuleFileUtility(_id);
|
| - if(_ptrFileUtilityObj == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceMemory, kTraceFile, _id,
|
| - "Failed to create FileUtilityObj!");
|
| - return -1;
|
| + if (_ptrFileUtilityObj == nullptr) {
|
| + WEBRTC_TRACE(kTraceMemory, kTraceFile, _id,
|
| + "Failed to create FileUtilityObj!");
|
| + return -1;
|
| }
|
|
|
| switch(format)
|
| @@ -487,8 +477,8 @@ int32_t MediaFileImpl::StartPlayingStream(
|
| case kFileFormatPcm32kHzFile:
|
| {
|
| // ValidFileFormat() called in the beginneing of this function
|
| - // prevents codecInst from being NULL here.
|
| - assert(codecInst != NULL);
|
| + // prevents codecInst from being null here.
|
| + assert(codecInst != nullptr);
|
| if(!ValidFrequency(codecInst->plfreq) ||
|
| _ptrFileUtilityObj->InitPCMReading(stream, startPointMs,
|
| stopPointMs,
|
| @@ -506,8 +496,8 @@ int32_t MediaFileImpl::StartPlayingStream(
|
| case kFileFormatPreencodedFile:
|
| {
|
| // ValidFileFormat() called in the beginneing of this function
|
| - // prevents codecInst from being NULL here.
|
| - assert(codecInst != NULL);
|
| + // prevents codecInst from being null here.
|
| + assert(codecInst != nullptr);
|
| if(_ptrFileUtilityObj->InitPreEncodedReading(stream, *codecInst) ==
|
| -1)
|
| {
|
| @@ -560,7 +550,7 @@ int32_t MediaFileImpl::StopPlaying()
|
| if(_ptrFileUtilityObj)
|
| {
|
| delete _ptrFileUtilityObj;
|
| - _ptrFileUtilityObj = NULL;
|
| + _ptrFileUtilityObj = nullptr;
|
| }
|
| if(_ptrInStream)
|
| {
|
| @@ -570,7 +560,7 @@ int32_t MediaFileImpl::StopPlaying()
|
| delete _ptrInStream;
|
| _openFile = false;
|
| }
|
| - _ptrInStream = NULL;
|
| + _ptrInStream = nullptr;
|
| }
|
|
|
| codec_info_.pltype = 0;
|
| @@ -602,11 +592,10 @@ int32_t MediaFileImpl::IncomingAudioData(
|
| "MediaFile::IncomingData(buffer= 0x%x, bufLen= %" PRIuS,
|
| buffer, bufferLengthInBytes);
|
|
|
| - if(buffer == NULL || bufferLengthInBytes == 0)
|
| - {
|
| - WEBRTC_TRACE(kTraceError, kTraceFile, _id,
|
| - "Buffer pointer or length is NULL!");
|
| - return -1;
|
| + if (buffer == nullptr || bufferLengthInBytes == 0) {
|
| + WEBRTC_TRACE(kTraceError, kTraceFile, _id,
|
| + "Buffer pointer or length is null!");
|
| + return -1;
|
| }
|
|
|
| bool recordingEnded = false;
|
| @@ -620,12 +609,11 @@ int32_t MediaFileImpl::IncomingAudioData(
|
| "Not currently recording!");
|
| return -1;
|
| }
|
| - if(_ptrOutStream == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceError, kTraceFile, _id,
|
| - "Recording is active, but output stream is NULL!");
|
| - assert(false);
|
| - return -1;
|
| + if (_ptrOutStream == nullptr) {
|
| + WEBRTC_TRACE(kTraceError, kTraceFile, _id,
|
| + "Recording is active, but output stream is null!");
|
| + assert(false);
|
| + return -1;
|
| }
|
|
|
| int32_t bytesWritten = 0;
|
| @@ -740,11 +728,10 @@ int32_t MediaFileImpl::StartRecordingAudioFile(
|
| }
|
|
|
| FileWrapper* outputStream = FileWrapper::Create();
|
| - if(outputStream == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceMemory, kTraceFile, _id,
|
| - "Failed to allocate memory for output stream");
|
| - return -1;
|
| + if (outputStream == nullptr) {
|
| + WEBRTC_TRACE(kTraceMemory, kTraceFile, _id,
|
| + "Failed to allocate memory for output stream");
|
| + return -1;
|
| }
|
|
|
| if (!outputStream->OpenFile(fileName, false)) {
|
| @@ -798,23 +785,18 @@ int32_t MediaFileImpl::StartRecordingAudioStream(
|
| return -1;
|
| }
|
|
|
| - if(_ptrFileUtilityObj != NULL)
|
| - {
|
| - WEBRTC_TRACE(
|
| - kTraceError,
|
| - kTraceFile,
|
| - _id,
|
| - "StartRecording called, but fileUtilityObj already exists!");
|
| - StopRecording();
|
| - return -1;
|
| + if (_ptrFileUtilityObj != nullptr) {
|
| + WEBRTC_TRACE(kTraceError, kTraceFile, _id,
|
| + "StartRecording called, but fileUtilityObj already exists!");
|
| + StopRecording();
|
| + return -1;
|
| }
|
|
|
| _ptrFileUtilityObj = new ModuleFileUtility(_id);
|
| - if(_ptrFileUtilityObj == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceMemory, kTraceFile, _id,
|
| - "Cannot allocate fileUtilityObj!");
|
| - return -1;
|
| + if (_ptrFileUtilityObj == nullptr) {
|
| + WEBRTC_TRACE(kTraceMemory, kTraceFile, _id,
|
| + "Cannot allocate fileUtilityObj!");
|
| + return -1;
|
| }
|
|
|
| CodecInst tmpAudioCodec;
|
| @@ -828,7 +810,7 @@ int32_t MediaFileImpl::StartRecordingAudioStream(
|
| WEBRTC_TRACE(kTraceError, kTraceFile, _id,
|
| "Failed to initialize WAV file!");
|
| delete _ptrFileUtilityObj;
|
| - _ptrFileUtilityObj = NULL;
|
| + _ptrFileUtilityObj = nullptr;
|
| return -1;
|
| }
|
| _fileFormat = kFileFormatWavFile;
|
| @@ -843,7 +825,7 @@ int32_t MediaFileImpl::StartRecordingAudioStream(
|
| WEBRTC_TRACE(kTraceError, kTraceFile, _id,
|
| "Failed to initialize Compressed file!");
|
| delete _ptrFileUtilityObj;
|
| - _ptrFileUtilityObj = NULL;
|
| + _ptrFileUtilityObj = nullptr;
|
| return -1;
|
| }
|
| _fileFormat = kFileFormatCompressedFile;
|
| @@ -859,7 +841,7 @@ int32_t MediaFileImpl::StartRecordingAudioStream(
|
| WEBRTC_TRACE(kTraceError, kTraceFile, _id,
|
| "Failed to initialize 8 or 16KHz PCM file!");
|
| delete _ptrFileUtilityObj;
|
| - _ptrFileUtilityObj = NULL;
|
| + _ptrFileUtilityObj = nullptr;
|
| return -1;
|
| }
|
| _fileFormat = format;
|
| @@ -873,7 +855,7 @@ int32_t MediaFileImpl::StartRecordingAudioStream(
|
| WEBRTC_TRACE(kTraceError, kTraceFile, _id,
|
| "Failed to initialize Pre-Encoded file!");
|
| delete _ptrFileUtilityObj;
|
| - _ptrFileUtilityObj = NULL;
|
| + _ptrFileUtilityObj = nullptr;
|
| return -1;
|
| }
|
|
|
| @@ -885,7 +867,7 @@ int32_t MediaFileImpl::StartRecordingAudioStream(
|
| WEBRTC_TRACE(kTraceError, kTraceFile, _id,
|
| "Invalid file format %d specified!", format);
|
| delete _ptrFileUtilityObj;
|
| - _ptrFileUtilityObj = NULL;
|
| + _ptrFileUtilityObj = nullptr;
|
| return -1;
|
| }
|
| }
|
| @@ -933,28 +915,23 @@ int32_t MediaFileImpl::StopRecording()
|
|
|
| _isStereo = false;
|
|
|
| - if(_ptrFileUtilityObj != NULL)
|
| - {
|
| - // Both AVI and WAV header has to be updated before closing the stream
|
| - // because they contain size information.
|
| - if((_fileFormat == kFileFormatWavFile) &&
|
| - (_ptrOutStream != NULL))
|
| - {
|
| - _ptrFileUtilityObj->UpdateWavHeader(*_ptrOutStream);
|
| - }
|
| - delete _ptrFileUtilityObj;
|
| - _ptrFileUtilityObj = NULL;
|
| + if (_ptrFileUtilityObj != nullptr) {
|
| + // Both AVI and WAV header has to be updated before closing the stream
|
| + // because they contain size information.
|
| + if ((_fileFormat == kFileFormatWavFile) && (_ptrOutStream != nullptr)) {
|
| + _ptrFileUtilityObj->UpdateWavHeader(*_ptrOutStream);
|
| + }
|
| + delete _ptrFileUtilityObj;
|
| + _ptrFileUtilityObj = nullptr;
|
| }
|
|
|
| - if(_ptrOutStream != NULL)
|
| - {
|
| - // If MediaFileImpl opened the OutStream it must be reclaimed here.
|
| - if(_openFile)
|
| - {
|
| - delete _ptrOutStream;
|
| - _openFile = false;
|
| - }
|
| - _ptrOutStream = NULL;
|
| + if (_ptrOutStream != nullptr) {
|
| + // If MediaFileImpl opened the OutStream it must be reclaimed here.
|
| + if (_openFile) {
|
| + delete _ptrOutStream;
|
| + _openFile = false;
|
| + }
|
| + _ptrOutStream = nullptr;
|
| }
|
|
|
| _recordingActive = false;
|
| @@ -1016,11 +993,10 @@ int32_t MediaFileImpl::FileDurationMs(const char* fileName,
|
| }
|
|
|
| ModuleFileUtility* utilityObj = new ModuleFileUtility(_id);
|
| - if(utilityObj == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceError, kTraceFile, _id,
|
| - "failed to allocate utility object!");
|
| - return -1;
|
| + if (utilityObj == nullptr) {
|
| + WEBRTC_TRACE(kTraceError, kTraceFile, _id,
|
| + "failed to allocate utility object!");
|
| + return -1;
|
| }
|
|
|
| const int32_t duration = utilityObj->FileDurationMs(fileName, format,
|
| @@ -1071,27 +1047,23 @@ int32_t MediaFileImpl::codec_info(CodecInst& codecInst) const
|
| bool MediaFileImpl::ValidFileFormat(const FileFormats format,
|
| const CodecInst* codecInst)
|
| {
|
| - if(codecInst == NULL)
|
| - {
|
| - if(format == kFileFormatPreencodedFile ||
|
| - format == kFileFormatPcm8kHzFile ||
|
| - format == kFileFormatPcm16kHzFile ||
|
| - format == kFileFormatPcm32kHzFile)
|
| - {
|
| - WEBRTC_TRACE(kTraceError, kTraceFile, -1,
|
| - "Codec info required for file format specified!");
|
| - return false;
|
| - }
|
| + if (codecInst == nullptr) {
|
| + if (format == kFileFormatPreencodedFile ||
|
| + format == kFileFormatPcm8kHzFile || format == kFileFormatPcm16kHzFile ||
|
| + format == kFileFormatPcm32kHzFile) {
|
| + WEBRTC_TRACE(kTraceError, kTraceFile, -1,
|
| + "Codec info required for file format specified!");
|
| + return false;
|
| + }
|
| }
|
| return true;
|
| }
|
|
|
| bool MediaFileImpl::ValidFileName(const char* fileName)
|
| {
|
| - if((fileName == NULL) ||(fileName[0] == '\0'))
|
| - {
|
| - WEBRTC_TRACE(kTraceError, kTraceFile, -1, "FileName not specified!");
|
| - return false;
|
| + if ((fileName == nullptr) || (fileName[0] == '\0')) {
|
| + WEBRTC_TRACE(kTraceError, kTraceFile, -1, "FileName not specified!");
|
| + return false;
|
| }
|
| return true;
|
| }
|
|
|