comparison data/fileio/MP3FileReader.cpp @ 1858:14747f24ad04

Use cancellable serialiser; add some more profiling points
author Chris Cannam
date Thu, 14 May 2020 16:36:48 +0100
parents 70e172e6cc59
children
comparison
equal deleted inserted replaced
1857:14c776dad920 1858:14747f24ad04
15 15
16 #ifdef HAVE_MAD 16 #ifdef HAVE_MAD
17 17
18 #include "MP3FileReader.h" 18 #include "MP3FileReader.h"
19 #include "base/ProgressReporter.h" 19 #include "base/ProgressReporter.h"
20 #include "base/Profiler.h"
20 21
21 #include "system/System.h" 22 #include "system/System.h"
22 23
23 #include <sys/types.h> 24 #include <sys/types.h>
24 #include <sys/stat.h> 25 #include <sys/stat.h>
171 } 172 }
172 } 173 }
173 174
174 MP3FileReader::~MP3FileReader() 175 MP3FileReader::~MP3FileReader()
175 { 176 {
177 Profiler profiler("MP3FileReader::~MP3FileReader");
178
176 if (m_decodeThread) { 179 if (m_decodeThread) {
177 m_cancelled = true; 180 m_cancelled = true;
178 m_decodeThread->wait(); 181 m_decodeThread->wait();
179 delete m_decodeThread; 182 delete m_decodeThread;
180 } 183 }
300 } 303 }
301 delete[] m_reader->m_sampleBuffer; 304 delete[] m_reader->m_sampleBuffer;
302 m_reader->m_sampleBuffer = nullptr; 305 m_reader->m_sampleBuffer = nullptr;
303 } 306 }
304 307
305 if (m_reader->isDecodeCacheInitialised()) m_reader->finishDecodeCache(); 308 if (m_reader->isDecodeCacheInitialised()) {
309 m_reader->finishDecodeCache();
310 }
306 311
307 m_reader->m_done = true; 312 m_reader->m_done = true;
308 m_reader->m_completion = 100; 313 m_reader->m_completion = 100;
309 314
310 m_reader->endSerialised(); 315 m_reader->endSerialised();
503 508
504 initialiseDecodeCache(); 509 initialiseDecodeCache();
505 510
506 if (m_cacheMode == CacheInTemporaryFile) { 511 if (m_cacheMode == CacheInTemporaryFile) {
507 // SVDEBUG << "MP3FileReader::accept: channel count " << m_channelCount << ", file rate " << m_fileRate << ", about to start serialised section" << endl; 512 // SVDEBUG << "MP3FileReader::accept: channel count " << m_channelCount << ", file rate " << m_fileRate << ", about to start serialised section" << endl;
508 startSerialised("MP3FileReader::Decode"); 513 startSerialised("MP3FileReader::Decode", &m_cancelled);
514 if (m_cancelled) {
515 return MAD_FLOW_STOP;
516 }
509 } 517 }
510 } 518 }
511 519
512 if (m_bitrateDenom > 0) { 520 if (m_bitrateDenom > 0) {
513 double bitrate = m_bitrateNum / m_bitrateDenom; 521 double bitrate = m_bitrateNum / m_bitrateDenom;