comparison 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
comparison
equal deleted inserted replaced
315:96ef9746c560 316:3a6725f285d6
16 #include "WavFileReader.h" 16 #include "WavFileReader.h"
17 17
18 #include <iostream> 18 #include <iostream>
19 19
20 #include <QMutexLocker> 20 #include <QMutexLocker>
21 21 #include <QFileInfo>
22 WavFileReader::WavFileReader(QString path, bool fileUpdating) : 22
23 WavFileReader::WavFileReader(RemoteFile source, bool fileUpdating) :
23 m_file(0), 24 m_file(0),
24 m_path(path), 25 m_source(source),
26 m_path(source.getLocalFilename()),
25 m_buffer(0), 27 m_buffer(0),
26 m_bufsiz(0), 28 m_bufsiz(0),
27 m_lastStart(0), 29 m_lastStart(0),
28 m_lastCount(0), 30 m_lastCount(0),
29 m_updating(fileUpdating) 31 m_updating(fileUpdating)
169 int count; 171 int count;
170 172
171 if (sf_command(0, SFC_GET_FORMAT_MAJOR_COUNT, &count, sizeof(count))) { 173 if (sf_command(0, SFC_GET_FORMAT_MAJOR_COUNT, &count, sizeof(count))) {
172 extensions.insert("wav"); 174 extensions.insert("wav");
173 extensions.insert("aiff"); 175 extensions.insert("aiff");
176 extensions.insert("aifc");
174 extensions.insert("aif"); 177 extensions.insert("aif");
175 return; 178 return;
176 } 179 }
177 180
178 SF_FORMAT_INFO info; 181 SF_FORMAT_INFO info;
179 for (int i = 0; i < count; ++i) { 182 for (int i = 0; i < count; ++i) {
180 info.format = i; 183 info.format = i;
181 if (!sf_command(0, SFC_GET_FORMAT_MAJOR, &info, sizeof(info))) { 184 if (!sf_command(0, SFC_GET_FORMAT_MAJOR, &info, sizeof(info))) {
182 extensions.insert(info.extension); 185 extensions.insert(QString(info.extension).toLower());
183 } 186 }
184 } 187 }
185 } 188 }
189
190 bool
191 WavFileReader::supportsExtension(QString extension)
192 {
193 std::set<QString> extensions;
194 getSupportedExtensions(extensions);
195 return (extensions.find(extension.toLower()) != extensions.end());
196 }
197
198 bool
199 WavFileReader::supportsContentType(QString type)
200 {
201 return (type == "audio/x-wav" ||
202 type == "audio/x-aiff" ||
203 type == "audio/basic");
204 }
205
206 bool
207 WavFileReader::supports(RemoteFile &source)
208 {
209 return (supportsExtension(source.getExtension()) ||
210 supportsContentType(source.getContentType()));
211 }
212
213