Mercurial > hg > svcore
comparison data/fileio/CodedAudioFileReader.cpp @ 1582:70e172e6cc59 fix-static-analysis
Use nullptr throughout
author | Chris Cannam |
---|---|
date | Mon, 26 Nov 2018 14:33:41 +0000 |
parents | cee1be4fb8c1 |
children | 14747f24ad04 |
comparison
equal
deleted
inserted
replaced
1581:ad5f892c0c4d | 1582:70e172e6cc59 |
---|---|
34 CodedAudioFileReader::CodedAudioFileReader(CacheMode cacheMode, | 34 CodedAudioFileReader::CodedAudioFileReader(CacheMode cacheMode, |
35 sv_samplerate_t targetRate, | 35 sv_samplerate_t targetRate, |
36 bool normalised) : | 36 bool normalised) : |
37 m_cacheMode(cacheMode), | 37 m_cacheMode(cacheMode), |
38 m_initialised(false), | 38 m_initialised(false), |
39 m_serialiser(0), | 39 m_serialiser(nullptr), |
40 m_fileRate(0), | 40 m_fileRate(0), |
41 m_cacheFileWritePtr(0), | 41 m_cacheFileWritePtr(nullptr), |
42 m_cacheFileReader(0), | 42 m_cacheFileReader(nullptr), |
43 m_cacheWriteBuffer(0), | 43 m_cacheWriteBuffer(nullptr), |
44 m_cacheWriteBufferIndex(0), | 44 m_cacheWriteBufferIndex(0), |
45 m_cacheWriteBufferFrames(65536), | 45 m_cacheWriteBufferFrames(65536), |
46 m_resampler(0), | 46 m_resampler(nullptr), |
47 m_resampleBuffer(0), | 47 m_resampleBuffer(nullptr), |
48 m_resampleBufferFrames(0), | 48 m_resampleBufferFrames(0), |
49 m_fileFrameCount(0), | 49 m_fileFrameCount(0), |
50 m_normalised(normalised), | 50 m_normalised(normalised), |
51 m_max(0.f), | 51 m_max(0.f), |
52 m_gain(1.f), | 52 m_gain(1.f), |
117 CodedAudioFileReader::endSerialised() | 117 CodedAudioFileReader::endSerialised() |
118 { | 118 { |
119 SVDEBUG << "CodedAudioFileReader(" << this << ")::endSerialised: id = " << (m_serialiser ? m_serialiser->getId() : "(none)") << endl; | 119 SVDEBUG << "CodedAudioFileReader(" << this << ")::endSerialised: id = " << (m_serialiser ? m_serialiser->getId() : "(none)") << endl; |
120 | 120 |
121 delete m_serialiser; | 121 delete m_serialiser; |
122 m_serialiser = 0; | 122 m_serialiser = nullptr; |
123 } | 123 } |
124 | 124 |
125 void | 125 void |
126 CodedAudioFileReader::initialiseDecodeCache() | 126 CodedAudioFileReader::initialiseDecodeCache() |
127 { | 127 { |
216 m_cacheFileReader = new WavFileReader(m_cacheFileName); | 216 m_cacheFileReader = new WavFileReader(m_cacheFileName); |
217 | 217 |
218 if (!m_cacheFileReader->isOK()) { | 218 if (!m_cacheFileReader->isOK()) { |
219 SVDEBUG << "ERROR: CodedAudioFileReader::initialiseDecodeCache: Failed to construct WAV file reader for temporary file: " << m_cacheFileReader->getError() << endl; | 219 SVDEBUG << "ERROR: CodedAudioFileReader::initialiseDecodeCache: Failed to construct WAV file reader for temporary file: " << m_cacheFileReader->getError() << endl; |
220 delete m_cacheFileReader; | 220 delete m_cacheFileReader; |
221 m_cacheFileReader = 0; | 221 m_cacheFileReader = nullptr; |
222 m_cacheMode = CacheInMemory; | 222 m_cacheMode = CacheInMemory; |
223 sf_close(m_cacheFileWritePtr); | 223 sf_close(m_cacheFileWritePtr); |
224 } | 224 } |
225 | 225 |
226 } else { | 226 } else { |
329 } | 329 } |
330 | 330 |
331 pushCacheWriteBufferMaybe(true); | 331 pushCacheWriteBufferMaybe(true); |
332 | 332 |
333 delete[] m_cacheWriteBuffer; | 333 delete[] m_cacheWriteBuffer; |
334 m_cacheWriteBuffer = 0; | 334 m_cacheWriteBuffer = nullptr; |
335 | 335 |
336 delete[] m_resampleBuffer; | 336 delete[] m_resampleBuffer; |
337 m_resampleBuffer = 0; | 337 m_resampleBuffer = nullptr; |
338 | 338 |
339 delete m_resampler; | 339 delete m_resampler; |
340 m_resampler = 0; | 340 m_resampler = nullptr; |
341 | 341 |
342 if (m_cacheMode == CacheInTemporaryFile) { | 342 if (m_cacheMode == CacheInTemporaryFile) { |
343 | 343 |
344 sf_close(m_cacheFileWritePtr); | 344 sf_close(m_cacheFileWritePtr); |
345 m_cacheFileWritePtr = 0; | 345 m_cacheFileWritePtr = nullptr; |
346 if (m_cacheFileReader) m_cacheFileReader->updateFrameCount(); | 346 if (m_cacheFileReader) m_cacheFileReader->updateFrameCount(); |
347 | 347 |
348 } else { | 348 } else { |
349 // I know, I know, we already allocated it... | 349 // I know, I know, we already allocated it... |
350 StorageAdviser::notifyPlannedAllocation | 350 StorageAdviser::notifyPlannedAllocation |
469 switch (m_cacheMode) { | 469 switch (m_cacheMode) { |
470 | 470 |
471 case CacheInTemporaryFile: | 471 case CacheInTemporaryFile: |
472 if (sf_writef_float(m_cacheFileWritePtr, buffer, sz) < sz) { | 472 if (sf_writef_float(m_cacheFileWritePtr, buffer, sz) < sz) { |
473 sf_close(m_cacheFileWritePtr); | 473 sf_close(m_cacheFileWritePtr); |
474 m_cacheFileWritePtr = 0; | 474 m_cacheFileWritePtr = nullptr; |
475 throw InsufficientDiscSpace(TempDirectory::getInstance()->getPath()); | 475 throw InsufficientDiscSpace(TempDirectory::getInstance()->getPath()); |
476 } | 476 } |
477 break; | 477 break; |
478 | 478 |
479 case CacheInMemory: | 479 case CacheInMemory: |