Mercurial > hg > svcore
comparison data/fileio/CodedAudioFileReader.cpp @ 285:20028c634494
* change some QStrings to std::strings etc
author | Chris Cannam |
---|---|
date | Thu, 09 Aug 2007 16:29:29 +0000 |
parents | 2268963dabd1 |
children | 92e8dbde73cd |
comparison
equal
deleted
inserted
replaced
284:41d64b873d87 | 285:20028c634494 |
---|---|
42 if (m_cacheFileWritePtr) sf_close(m_cacheFileWritePtr); | 42 if (m_cacheFileWritePtr) sf_close(m_cacheFileWritePtr); |
43 if (m_cacheFileReader) delete m_cacheFileReader; | 43 if (m_cacheFileReader) delete m_cacheFileReader; |
44 if (m_cacheWriteBuffer) delete[] m_cacheWriteBuffer; | 44 if (m_cacheWriteBuffer) delete[] m_cacheWriteBuffer; |
45 | 45 |
46 if (m_cacheFileName != "") { | 46 if (m_cacheFileName != "") { |
47 if (!QFile(m_cacheFileName).remove()) { | 47 if (!QFile(m_cacheFileName.c_str()).remove()) { |
48 std::cerr << "WARNING: CodedAudioFileReader::~CodedAudioFileReader: Failed to delete cache file \"" << m_cacheFileName.toStdString() << "\"" << std::endl; | 48 std::cerr << "WARNING: CodedAudioFileReader::~CodedAudioFileReader: Failed to delete cache file \"" << m_cacheFileName << "\"" << std::endl; |
49 } | 49 } |
50 } | 50 } |
51 } | 51 } |
52 | 52 |
53 void | 53 void |
61 m_cacheWriteBufferIndex = 0; | 61 m_cacheWriteBufferIndex = 0; |
62 | 62 |
63 try { | 63 try { |
64 QDir dir(TempDirectory::getInstance()->getPath()); | 64 QDir dir(TempDirectory::getInstance()->getPath()); |
65 m_cacheFileName = dir.filePath(QString("decoded_%1.wav") | 65 m_cacheFileName = dir.filePath(QString("decoded_%1.wav") |
66 .arg((intptr_t)this)); | 66 .arg((intptr_t)this)).toStdString(); |
67 | 67 |
68 SF_INFO fileInfo; | 68 SF_INFO fileInfo; |
69 fileInfo.samplerate = m_sampleRate; | 69 fileInfo.samplerate = m_sampleRate; |
70 fileInfo.channels = m_channelCount; | 70 fileInfo.channels = m_channelCount; |
71 fileInfo.format = SF_FORMAT_WAV | SF_FORMAT_FLOAT; | 71 fileInfo.format = SF_FORMAT_WAV | SF_FORMAT_FLOAT; |
72 | 72 |
73 m_cacheFileWritePtr = sf_open(m_cacheFileName.toLocal8Bit(), | 73 m_cacheFileWritePtr = sf_open(m_cacheFileName.c_str(), |
74 SFM_WRITE, &fileInfo); | 74 SFM_WRITE, &fileInfo); |
75 | 75 |
76 if (m_cacheFileWritePtr) { | 76 if (m_cacheFileWritePtr) { |
77 | 77 |
78 //!!! really want to do this now only if we're in a | 78 //!!! really want to do this now only if we're in a |
81 //information here | 81 //information here |
82 | 82 |
83 m_cacheFileReader = new WavFileReader(m_cacheFileName); | 83 m_cacheFileReader = new WavFileReader(m_cacheFileName); |
84 | 84 |
85 if (!m_cacheFileReader->isOK()) { | 85 if (!m_cacheFileReader->isOK()) { |
86 std::cerr << "ERROR: CodedAudioFileReader::initialiseDecodeCache: Failed to construct WAV file reader for temporary file: " << m_cacheFileReader->getError().toStdString() << std::endl; | 86 std::cerr << "ERROR: CodedAudioFileReader::initialiseDecodeCache: Failed to construct WAV file reader for temporary file: " << m_cacheFileReader->getError() << std::endl; |
87 delete m_cacheFileReader; | 87 delete m_cacheFileReader; |
88 m_cacheFileReader = 0; | 88 m_cacheFileReader = 0; |
89 m_cacheMode = CacheInMemory; | 89 m_cacheMode = CacheInMemory; |
90 sf_close(m_cacheFileWritePtr); | 90 sf_close(m_cacheFileWritePtr); |
91 } | 91 } |
92 } else { | 92 } else { |
93 std::cerr << "CodedAudioFileReader::initialiseDecodeCache: failed to open cache file \"" << m_cacheFileName.toStdString() << "\" (" << m_channelCount << " channels, sample rate " << m_sampleRate << " for writing, falling back to in-memory cache" << std::endl; | 93 std::cerr << "CodedAudioFileReader::initialiseDecodeCache: failed to open cache file \"" << m_cacheFileName << "\" (" << m_channelCount << " channels, sample rate " << m_sampleRate << " for writing, falling back to in-memory cache" << std::endl; |
94 m_cacheMode = CacheInMemory; | 94 m_cacheMode = CacheInMemory; |
95 } | 95 } |
96 | 96 |
97 } catch (DirectoryCreationFailed f) { | 97 } catch (DirectoryCreationFailed f) { |
98 std::cerr << "CodedAudioFileReader::initialiseDecodeCache: failed to create temporary directory! Falling back to in-memory cache" << std::endl; | 98 std::cerr << "CodedAudioFileReader::initialiseDecodeCache: failed to create temporary directory! Falling back to in-memory cache" << std::endl; |
179 m_cacheFileReader->updateFrameCount(); | 179 m_cacheFileReader->updateFrameCount(); |
180 /* | 180 /* |
181 m_cacheFileReader = new WavFileReader(m_cacheFileName); | 181 m_cacheFileReader = new WavFileReader(m_cacheFileName); |
182 | 182 |
183 if (!m_cacheFileReader->isOK()) { | 183 if (!m_cacheFileReader->isOK()) { |
184 std::cerr << "ERROR: CodedAudioFileReader::finishDecodeCache: Failed to construct WAV file reader for temporary file: " << m_cacheFileReader->getError().toStdString() << std::endl; | 184 std::cerr << "ERROR: CodedAudioFileReader::finishDecodeCache: Failed to construct WAV file reader for temporary file: " << m_cacheFileReader->getError() << std::endl; |
185 delete m_cacheFileReader; | 185 delete m_cacheFileReader; |
186 m_cacheFileReader = 0; | 186 m_cacheFileReader = 0; |
187 }*/ | 187 }*/ |
188 | 188 |
189 break; | 189 break; |