diff data/fileio/AudioFileReaderFactory.cpp @ 1583:c8fad3c14a2b bqaudiostream

Start wiring in BQAudioStream stuff
author Chris Cannam
date Thu, 06 Dec 2018 12:50:28 +0000
parents 1c9bbbb6116a
children f8e3dcbafb4d
line wrap: on
line diff
--- a/data/fileio/AudioFileReaderFactory.cpp	Wed Nov 14 15:46:35 2018 +0000
+++ b/data/fileio/AudioFileReaderFactory.cpp	Thu Dec 06 12:50:28 2018 +0000
@@ -17,9 +17,8 @@
 
 #include "WavFileReader.h"
 #include "DecodingWavFileReader.h"
-#include "OggVorbisFileReader.h"
 #include "MP3FileReader.h"
-#include "CoreAudioFileReader.h"
+#include "BQAFileReader.h"
 #include "AudioFileSizeEstimator.h"
 
 #include "base/StorageAdviser.h"
@@ -28,26 +27,21 @@
 #include <QFileInfo>
 #include <iostream>
 
+using namespace std;
+
 QString
 AudioFileReaderFactory::getKnownExtensions()
 {
-    std::set<QString> extensions;
+    set<QString> extensions;
 
     WavFileReader::getSupportedExtensions(extensions);
 #ifdef HAVE_MAD
     MP3FileReader::getSupportedExtensions(extensions);
 #endif
-#ifdef HAVE_OGGZ
-#ifdef HAVE_FISHSOUND
-    OggVorbisFileReader::getSupportedExtensions(extensions);
-#endif
-#endif
-#ifdef HAVE_COREAUDIO
-    CoreAudioFileReader::getSupportedExtensions(extensions);
-#endif
+    BQAFileReader::getSupportedExtensions(extensions);
 
     QString rv;
-    for (std::set<QString>::const_iterator i = extensions.begin();
+    for (set<QString>::const_iterator i = extensions.begin();
          i != extensions.end(); ++i) {
         if (i != extensions.begin()) rv += " ";
         rv += "*." + *i;
@@ -126,27 +120,41 @@
             SVDEBUG << "AudioFileReaderFactory: Source not officially handled by any reader, trying again with each reader in turn"
                     << endl;
         }
-    
-#ifdef HAVE_OGGZ
-#ifdef HAVE_FISHSOUND
-        // If we have the "real" Ogg reader, use that first. Otherwise
-        // the WavFileReader will likely accept Ogg files (as
-        // libsndfile supports them) but it has no ability to return
-        // file metadata, so we get a slightly less useful result.
-        if (anyReader || OggVorbisFileReader::supports(source)) {
 
-            reader = new OggVorbisFileReader
-                (source, decodeMode, cacheMode, targetRate, normalised, reporter);
+#ifdef HAVE_MAD
+        if (anyReader || MP3FileReader::supports(source)) {
+
+            MP3FileReader::GaplessMode gapless =
+                params.gaplessMode == GaplessMode::Gapless ?
+                MP3FileReader::GaplessMode::Gapless :
+                MP3FileReader::GaplessMode::Gappy;
+            
+            reader = new MP3FileReader
+                (source, decodeMode, cacheMode, gapless,
+                 targetRate, normalised, reporter);
 
             if (reader->isOK()) {
-                SVDEBUG << "AudioFileReaderFactory: Ogg file reader is OK, returning it" << endl;
+                SVDEBUG << "AudioFileReaderFactory: MP3 file reader is OK, returning it" << endl;
                 return reader;
             } else {
                 delete reader;
             }
         }
 #endif
-#endif
+
+        if (anyReader || BQAFileReader::supports(source)) {
+
+            reader = new BQAFileReader
+                (source, decodeMode, cacheMode, 
+                 targetRate, normalised, reporter);
+
+            if (reader->isOK()) {
+                SVDEBUG << "AudioFileReaderFactory: BQA reader is OK, returning it" << endl;
+                return reader;
+            } else {
+                delete reader;
+            }
+        }
 
         if (anyReader || WavFileReader::supports(source)) {
 
@@ -178,43 +186,6 @@
                 delete reader;
             }
         }
-
-#ifdef HAVE_MAD
-        if (anyReader || MP3FileReader::supports(source)) {
-
-            MP3FileReader::GaplessMode gapless =
-                params.gaplessMode == GaplessMode::Gapless ?
-                MP3FileReader::GaplessMode::Gapless :
-                MP3FileReader::GaplessMode::Gappy;
-            
-            reader = new MP3FileReader
-                (source, decodeMode, cacheMode, gapless,
-                 targetRate, normalised, reporter);
-
-            if (reader->isOK()) {
-                SVDEBUG << "AudioFileReaderFactory: MP3 file reader is OK, returning it" << endl;
-                return reader;
-            } else {
-                delete reader;
-            }
-        }
-#endif
-
-#ifdef HAVE_COREAUDIO
-        if (anyReader || CoreAudioFileReader::supports(source)) {
-
-            reader = new CoreAudioFileReader
-                (source, decodeMode, cacheMode, targetRate, normalised, reporter);
-
-            if (reader->isOK()) {
-                SVDEBUG << "AudioFileReaderFactory: CoreAudio reader is OK, returning it" << endl;
-                return reader;
-            } else {
-                delete reader;
-            }
-        }
-#endif
-
     }
     
     SVCERR << "AudioFileReaderFactory::Failed to create a reader for "