diff data/fileio/AudioFileReaderFactory.cpp @ 665:029dd9e5cc29 coreaudio_tests

tests for using coreaudio to read files in 64-bit mac osx
author luisf
date Thu, 18 Nov 2010 11:40:38 +0000
parents 5746c559af15
children c10cb8782576
line wrap: on
line diff
--- a/data/fileio/AudioFileReaderFactory.cpp	Fri Mar 12 15:06:38 2010 +0000
+++ b/data/fileio/AudioFileReaderFactory.cpp	Thu Nov 18 11:40:38 2010 +0000
@@ -20,6 +20,7 @@
 #include "OggVorbisFileReader.h"
 #include "MP3FileReader.h"
 #include "QuickTimeFileReader.h"
+#include "CoreAudioFileReader.h"
 
 #include <QString>
 #include <QFileInfo>
@@ -42,6 +43,9 @@
 #ifdef HAVE_QUICKTIME
     QuickTimeFileReader::getSupportedExtensions(extensions);
 #endif
+#ifdef HAVE_COREAUDIO
+    CoreAudioFileReader::getSupportedExtensions(extensions);
+#endif
 
     QString rv;
     for (std::set<QString>::const_iterator i = extensions.begin();
@@ -73,7 +77,7 @@
 {
     QString err;
 
-//    std::cerr << "AudioFileReaderFactory::createReader(\"" << source.getLocation().toStdString() << "\"): Requested rate: " << targetRate << std::endl;
+    std::cerr << "AudioFileReaderFactory::createReader(\"" << source.getLocation().toStdString() << "\"): Requested rate: " << targetRate << std::endl;
 
     if (!source.isOK() || !source.isAvailable()) {
         std::cerr << "AudioFileReaderFactory::createReader(\"" << source.getLocation().toStdString() << "\": Source unavailable" << std::endl;
@@ -170,6 +174,26 @@
     }
 #endif
 
+#ifdef HAVE_COREAUDIO
+    if (!reader) {
+        if (CoreAudioFileReader::supports(source)) {
+            reader = new CoreAudioFileReader
+                (source,
+                 threading ?
+                 CoreAudioFileReader::DecodeThreaded :
+                 CoreAudioFileReader::DecodeAtOnce,
+                 CoreAudioFileReader::CacheInTemporaryFile,
+                 targetRate,
+                 reporter);
+            if (!reader->isOK()) {
+                delete reader;
+                reader = 0;
+            }
+        }
+    }
+#endif
+
+
     // If none of the readers claimed to support this file extension,
     // perhaps the extension is missing or misleading.  Try again,
     // ignoring it.  We have to be confident that the reader won't
@@ -259,9 +283,30 @@
     }
 #endif
 
+#ifdef HAVE_COREAUDIO
+
+    std::cerr << "AudioFileReaderFactory: HAVE_COREAUDIO" << std::endl;
+
+    if (!reader) {
+        reader = new CoreAudioFileReader
+            (source,
+             threading ?
+             CoreAudioFileReader::DecodeThreaded :
+             CoreAudioFileReader::DecodeAtOnce,
+             CoreAudioFileReader::CacheInTemporaryFile,
+             targetRate,
+             reporter);
+
+        if (!reader->isOK()) {
+            delete reader;
+            reader = 0;
+        }
+    }
+#endif
+
     if (reader) {
         if (reader->isOK()) {
-//            std::cerr << "AudioFileReaderFactory: Reader is OK" << std::endl;
+            std::cerr << "AudioFileReaderFactory: Reader is OK" << std::endl;
             return reader;
         }
         std::cerr << "AudioFileReaderFactory: Preferred reader for "