Mercurial > hg > svcore
diff data/fileio/WavFileReader.cpp @ 316:3a6725f285d6
* Make RemoteFile far more pervasive, and use it for local files as well
so that we can handle both transparently. Make it shallow copy with
reference counting, so it can be used by value without having to worry
about the cache file lifetime. Use RemoteFile for MainWindow file-open
functions, etc
author | Chris Cannam |
---|---|
date | Thu, 18 Oct 2007 15:31:20 +0000 |
parents | 92e8dbde73cd |
children | c324d410b096 |
line wrap: on
line diff
--- a/data/fileio/WavFileReader.cpp Thu Oct 18 10:24:26 2007 +0000 +++ b/data/fileio/WavFileReader.cpp Thu Oct 18 15:31:20 2007 +0000 @@ -18,10 +18,12 @@ #include <iostream> #include <QMutexLocker> +#include <QFileInfo> -WavFileReader::WavFileReader(QString path, bool fileUpdating) : +WavFileReader::WavFileReader(RemoteFile source, bool fileUpdating) : m_file(0), - m_path(path), + m_source(source), + m_path(source.getLocalFilename()), m_buffer(0), m_bufsiz(0), m_lastStart(0), @@ -171,6 +173,7 @@ if (sf_command(0, SFC_GET_FORMAT_MAJOR_COUNT, &count, sizeof(count))) { extensions.insert("wav"); extensions.insert("aiff"); + extensions.insert("aifc"); extensions.insert("aif"); return; } @@ -179,7 +182,32 @@ for (int i = 0; i < count; ++i) { info.format = i; if (!sf_command(0, SFC_GET_FORMAT_MAJOR, &info, sizeof(info))) { - extensions.insert(info.extension); + extensions.insert(QString(info.extension).toLower()); } } } + +bool +WavFileReader::supportsExtension(QString extension) +{ + std::set<QString> extensions; + getSupportedExtensions(extensions); + return (extensions.find(extension.toLower()) != extensions.end()); +} + +bool +WavFileReader::supportsContentType(QString type) +{ + return (type == "audio/x-wav" || + type == "audio/x-aiff" || + type == "audio/basic"); +} + +bool +WavFileReader::supports(RemoteFile &source) +{ + return (supportsExtension(source.getExtension()) || + supportsContentType(source.getContentType())); +} + +