Mercurial > hg > svcore
comparison data/fileio/AudioFileReaderFactory.cpp @ 747:523e97d0f6eb
Merge from branch "coreaudio_tests"
author | Chris Cannam |
---|---|
date | Mon, 03 Sep 2012 11:06:50 +0100 |
parents | c10cb8782576 |
children | 02390a4c2abe |
comparison
equal
deleted
inserted
replaced
746:f5aeda36d5bd | 747:523e97d0f6eb |
---|---|
18 #include "WavFileReader.h" | 18 #include "WavFileReader.h" |
19 #include "ResamplingWavFileReader.h" | 19 #include "ResamplingWavFileReader.h" |
20 #include "OggVorbisFileReader.h" | 20 #include "OggVorbisFileReader.h" |
21 #include "MP3FileReader.h" | 21 #include "MP3FileReader.h" |
22 #include "QuickTimeFileReader.h" | 22 #include "QuickTimeFileReader.h" |
23 #include "CoreAudioFileReader.h" | |
23 | 24 |
24 #include <QString> | 25 #include <QString> |
25 #include <QFileInfo> | 26 #include <QFileInfo> |
26 #include <iostream> | 27 #include <iostream> |
27 | 28 |
39 OggVorbisFileReader::getSupportedExtensions(extensions); | 40 OggVorbisFileReader::getSupportedExtensions(extensions); |
40 #endif | 41 #endif |
41 #endif | 42 #endif |
42 #ifdef HAVE_QUICKTIME | 43 #ifdef HAVE_QUICKTIME |
43 QuickTimeFileReader::getSupportedExtensions(extensions); | 44 QuickTimeFileReader::getSupportedExtensions(extensions); |
45 #endif | |
46 #ifdef HAVE_COREAUDIO | |
47 CoreAudioFileReader::getSupportedExtensions(extensions); | |
44 #endif | 48 #endif |
45 | 49 |
46 QString rv; | 50 QString rv; |
47 for (std::set<QString>::const_iterator i = extensions.begin(); | 51 for (std::set<QString>::const_iterator i = extensions.begin(); |
48 i != extensions.end(); ++i) { | 52 i != extensions.end(); ++i) { |
71 AudioFileReaderFactory::create(FileSource source, size_t targetRate, bool threading, | 75 AudioFileReaderFactory::create(FileSource source, size_t targetRate, bool threading, |
72 ProgressReporter *reporter) | 76 ProgressReporter *reporter) |
73 { | 77 { |
74 QString err; | 78 QString err; |
75 | 79 |
76 // SVDEBUG << "AudioFileReaderFactory::createReader(\"" << source.getLocation() << "\"): Requested rate: " << targetRate << endl; | 80 SVDEBUG << "AudioFileReaderFactory::createReader(\"" << source.getLocation() << "\"): Requested rate: " << targetRate << endl; |
77 | 81 |
78 if (!source.isOK()) { | 82 if (!source.isOK()) { |
79 std::cerr << "AudioFileReaderFactory::createReader(\"" << source.getLocation() << "\": Failed to retrieve source (transmission error?): " << source.getErrorString() << std::endl; | 83 std::cerr << "AudioFileReaderFactory::createReader(\"" << source.getLocation() << "\": Failed to retrieve source (transmission error?): " << source.getErrorString() << std::endl; |
80 return 0; | 84 return 0; |
81 } | 85 } |
172 reader = 0; | 176 reader = 0; |
173 } | 177 } |
174 } | 178 } |
175 } | 179 } |
176 #endif | 180 #endif |
181 | |
182 #ifdef HAVE_COREAUDIO | |
183 if (!reader) { | |
184 if (CoreAudioFileReader::supports(source)) { | |
185 reader = new CoreAudioFileReader | |
186 (source, | |
187 threading ? | |
188 CoreAudioFileReader::DecodeThreaded : | |
189 CoreAudioFileReader::DecodeAtOnce, | |
190 CoreAudioFileReader::CacheInTemporaryFile, | |
191 targetRate, | |
192 reporter); | |
193 if (!reader->isOK()) { | |
194 delete reader; | |
195 reader = 0; | |
196 } | |
197 } | |
198 } | |
199 #endif | |
200 | |
177 | 201 |
178 // If none of the readers claimed to support this file extension, | 202 // If none of the readers claimed to support this file extension, |
179 // perhaps the extension is missing or misleading. Try again, | 203 // perhaps the extension is missing or misleading. Try again, |
180 // ignoring it. We have to be confident that the reader won't | 204 // ignoring it. We have to be confident that the reader won't |
181 // open just any old text file or whatever and pretend it's | 205 // open just any old text file or whatever and pretend it's |
262 reader = 0; | 286 reader = 0; |
263 } | 287 } |
264 } | 288 } |
265 #endif | 289 #endif |
266 | 290 |
291 #ifdef HAVE_COREAUDIO | |
292 | |
293 std::cerr << "AudioFileReaderFactory: HAVE_COREAUDIO" << std::endl; | |
294 | |
295 if (!reader) { | |
296 reader = new CoreAudioFileReader | |
297 (source, | |
298 threading ? | |
299 CoreAudioFileReader::DecodeThreaded : | |
300 CoreAudioFileReader::DecodeAtOnce, | |
301 CoreAudioFileReader::CacheInTemporaryFile, | |
302 targetRate, | |
303 reporter); | |
304 | |
305 if (!reader->isOK()) { | |
306 delete reader; | |
307 reader = 0; | |
308 } | |
309 } | |
310 #endif | |
311 | |
267 if (reader) { | 312 if (reader) { |
268 if (reader->isOK()) { | 313 if (reader->isOK()) { |
269 // std::cerr << "AudioFileReaderFactory: Reader is OK" << std::endl; | 314 std::cerr << "AudioFileReaderFactory: Reader is OK" << std::endl; |
270 return reader; | 315 return reader; |
271 } | 316 } |
272 std::cerr << "AudioFileReaderFactory: Preferred reader for " | 317 std::cerr << "AudioFileReaderFactory: Preferred reader for " |
273 << "url \"" << source.getLocation().toStdString() | 318 << "url \"" << source.getLocation().toStdString() |
274 << "\" (content type \"" | 319 << "\" (content type \"" |