annotate data/fileio/AudioFileReaderFactory.cpp @ 183:146eb9e35baa

* Improve output from Profiler class and make it incur less (no) overhead in release builds with NO_TIMING defined * Fix a lock contention issue in spectrogram * Marginal optimisations elsewhere
author Chris Cannam
date Tue, 10 Oct 2006 14:51:17 +0000
parents c03ec31005e1
children 91fdc752e540
rev   line source
Chris@148 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@148 2
Chris@148 3 /*
Chris@148 4 Sonic Visualiser
Chris@148 5 An audio file viewer and annotation editor.
Chris@148 6 Centre for Digital Music, Queen Mary, University of London.
Chris@148 7 This file copyright 2006 Chris Cannam.
Chris@148 8
Chris@148 9 This program is free software; you can redistribute it and/or
Chris@148 10 modify it under the terms of the GNU General Public License as
Chris@148 11 published by the Free Software Foundation; either version 2 of the
Chris@148 12 License, or (at your option) any later version. See the file
Chris@148 13 COPYING included with this distribution for more information.
Chris@148 14 */
Chris@148 15
Chris@148 16 #include "AudioFileReaderFactory.h"
Chris@148 17
Chris@148 18 #include "WavFileReader.h"
Chris@148 19 #include "OggVorbisFileReader.h"
Chris@148 20 #include "MP3FileReader.h"
Chris@148 21
Chris@148 22 #include <QString>
Chris@148 23
Chris@148 24 QString
Chris@148 25 AudioFileReaderFactory::getKnownExtensions()
Chris@148 26 {
Chris@157 27 std::set<QString> extensions;
Chris@157 28
Chris@157 29 WavFileReader::getSupportedExtensions(extensions);
Chris@148 30 #ifdef HAVE_MAD
Chris@157 31 MP3FileReader::getSupportedExtensions(extensions);
Chris@148 32 #endif
Chris@148 33 #ifdef HAVE_OGGZ
Chris@148 34 #ifdef HAVE_FISHSOUND
Chris@157 35 OggVorbisFileReader::getSupportedExtensions(extensions);
Chris@148 36 #endif
Chris@148 37 #endif
Chris@157 38
Chris@157 39 QString rv;
Chris@157 40 for (std::set<QString>::const_iterator i = extensions.begin();
Chris@157 41 i != extensions.end(); ++i) {
Chris@157 42 if (i != extensions.begin()) rv += " ";
Chris@157 43 rv += "*." + *i;
Chris@157 44 }
Chris@157 45
Chris@157 46 return rv;
Chris@148 47 }
Chris@148 48
Chris@148 49 AudioFileReader *
Chris@148 50 AudioFileReaderFactory::createReader(QString path)
Chris@148 51 {
Chris@148 52 QString err;
Chris@148 53
Chris@148 54 AudioFileReader *reader = 0;
Chris@148 55
Chris@148 56 reader = new WavFileReader(path);
Chris@148 57 if (reader->isOK()) return reader;
Chris@148 58 if (reader->getError() != "") err = reader->getError();
Chris@148 59 delete reader;
Chris@148 60
Chris@148 61 #ifdef HAVE_OGGZ
Chris@148 62 #ifdef HAVE_FISHSOUND
Chris@148 63 reader = new OggVorbisFileReader(path, true,
Chris@148 64 OggVorbisFileReader::CacheInTemporaryFile);
Chris@148 65 if (reader->isOK()) return reader;
Chris@148 66 if (reader->getError() != "") err = reader->getError();
Chris@148 67 delete reader;
Chris@148 68 #endif
Chris@148 69 #endif
Chris@148 70
Chris@148 71 #ifdef HAVE_MAD
Chris@148 72 reader = new MP3FileReader(path, true,
Chris@148 73 MP3FileReader::CacheInTemporaryFile);
Chris@148 74 if (reader->isOK()) return reader;
Chris@148 75 if (reader->getError() != "") err = reader->getError();
Chris@148 76 delete reader;
Chris@148 77 #endif
Chris@148 78
Chris@148 79 return 0;
Chris@148 80 }
Chris@148 81