comparison data/fileio/AudioFileReaderFactory.cpp @ 440:5746c559af15

* Merge revisions 1131 to 1201 from sv-rdf-import branch
author Chris Cannam
date Thu, 18 Sep 2008 12:33:30 +0000
parents 183ee2a55fc7
children 029dd9e5cc29 1c8898816fd0
comparison
equal deleted inserted replaced
439:beb2948baa77 440:5746c559af15
102 ResamplingWavFileReader::ResampleThreaded : 102 ResamplingWavFileReader::ResampleThreaded :
103 ResamplingWavFileReader::ResampleAtOnce, 103 ResamplingWavFileReader::ResampleAtOnce,
104 ResamplingWavFileReader::CacheInTemporaryFile, 104 ResamplingWavFileReader::CacheInTemporaryFile,
105 targetRate, 105 targetRate,
106 reporter); 106 reporter);
107 if (!reader->isOK()) {
108 delete reader;
109 reader = 0;
110 }
107 } 111 }
108 } 112 }
109 113
110 #ifdef HAVE_OGGZ 114 #ifdef HAVE_OGGZ
111 #ifdef HAVE_FISHSOUND 115 #ifdef HAVE_FISHSOUND
117 OggVorbisFileReader::DecodeThreaded : 121 OggVorbisFileReader::DecodeThreaded :
118 OggVorbisFileReader::DecodeAtOnce, 122 OggVorbisFileReader::DecodeAtOnce,
119 OggVorbisFileReader::CacheInTemporaryFile, 123 OggVorbisFileReader::CacheInTemporaryFile,
120 targetRate, 124 targetRate,
121 reporter); 125 reporter);
126 if (!reader->isOK()) {
127 delete reader;
128 reader = 0;
129 }
122 } 130 }
123 } 131 }
124 #endif 132 #endif
125 #endif 133 #endif
126 134
133 MP3FileReader::DecodeThreaded : 141 MP3FileReader::DecodeThreaded :
134 MP3FileReader::DecodeAtOnce, 142 MP3FileReader::DecodeAtOnce,
135 MP3FileReader::CacheInTemporaryFile, 143 MP3FileReader::CacheInTemporaryFile,
136 targetRate, 144 targetRate,
137 reporter); 145 reporter);
146 if (!reader->isOK()) {
147 delete reader;
148 reader = 0;
149 }
138 } 150 }
139 } 151 }
140 #endif 152 #endif
141 153
142 #ifdef HAVE_QUICKTIME 154 #ifdef HAVE_QUICKTIME
148 QuickTimeFileReader::DecodeThreaded : 160 QuickTimeFileReader::DecodeThreaded :
149 QuickTimeFileReader::DecodeAtOnce, 161 QuickTimeFileReader::DecodeAtOnce,
150 QuickTimeFileReader::CacheInTemporaryFile, 162 QuickTimeFileReader::CacheInTemporaryFile,
151 targetRate, 163 targetRate,
152 reporter); 164 reporter);
165 if (!reader->isOK()) {
166 delete reader;
167 reader = 0;
168 }
169 }
170 }
171 #endif
172
173 // If none of the readers claimed to support this file extension,
174 // perhaps the extension is missing or misleading. Try again,
175 // ignoring it. We have to be confident that the reader won't
176 // open just any old text file or whatever and pretend it's
177 // succeeded
178
179 if (!reader) {
180
181 reader = new WavFileReader(source);
182
183 if (targetRate != 0 &&
184 reader->isOK() &&
185 reader->getSampleRate() != targetRate) {
186
187 std::cerr << "AudioFileReaderFactory::createReader: WAV file rate: " << reader->getSampleRate() << ", creating resampling reader" << std::endl;
188
189 delete reader;
190 reader = new ResamplingWavFileReader
191 (source,
192 threading ?
193 ResamplingWavFileReader::ResampleThreaded :
194 ResamplingWavFileReader::ResampleAtOnce,
195 ResamplingWavFileReader::CacheInTemporaryFile,
196 targetRate,
197 reporter);
198 }
199
200 if (!reader->isOK()) {
201 delete reader;
202 reader = 0;
203 }
204 }
205
206 #ifdef HAVE_OGGZ
207 #ifdef HAVE_FISHSOUND
208 if (!reader) {
209 reader = new OggVorbisFileReader
210 (source,
211 threading ?
212 OggVorbisFileReader::DecodeThreaded :
213 OggVorbisFileReader::DecodeAtOnce,
214 OggVorbisFileReader::CacheInTemporaryFile,
215 targetRate,
216 reporter);
217
218 if (!reader->isOK()) {
219 delete reader;
220 reader = 0;
221 }
222 }
223 #endif
224 #endif
225
226 #ifdef HAVE_MAD
227 if (!reader) {
228 reader = new MP3FileReader
229 (source,
230 threading ?
231 MP3FileReader::DecodeThreaded :
232 MP3FileReader::DecodeAtOnce,
233 MP3FileReader::CacheInTemporaryFile,
234 targetRate,
235 reporter);
236
237 if (!reader->isOK()) {
238 delete reader;
239 reader = 0;
240 }
241 }
242 #endif
243
244 #ifdef HAVE_QUICKTIME
245 if (!reader) {
246 reader = new QuickTimeFileReader
247 (source,
248 threading ?
249 QuickTimeFileReader::DecodeThreaded :
250 QuickTimeFileReader::DecodeAtOnce,
251 QuickTimeFileReader::CacheInTemporaryFile,
252 targetRate,
253 reporter);
254
255 if (!reader->isOK()) {
256 delete reader;
257 reader = 0;
153 } 258 }
154 } 259 }
155 #endif 260 #endif
156 261
157 if (reader) { 262 if (reader) {