209{
211
212 outTracks.clear();
213
214 wxASSERT(
mFile->IsOpened());
215
216
217
219
221 {
222
224 {
225
226
228 continue;
229 }
230
232
233
235
237 }
238
239
240#define CODEC_TRANSFER_SIZE 4096u
241
242
243
244#define SAMPLES_PER_CALLBACK 100000
245
246 long bytesRead = 0;
247 {
249
250
251
252 int testvar = 1, endian;
253 if (*(char *)&testvar)
254 endian = 0;
255 else
256 endian = 1;
257
258
259 long samplesRead = 0;
260 int bitstream = 0;
261 int samplesSinceLastCallback = 0;
262
263
264
265
266
267
269
270 do {
271
272 bytesRead = ov_read(
mVorbisFile.get(), (
char *)mainBuffer.get(),
274 endian,
275 2,
276 1,
277 &bitstream);
278
279 if (bytesRead == OV_HOLE) {
281 wxLogError(
wxT(
"Ogg Vorbis importer: file %s is malformed, ov_read() reported a hole"),
282 ff.GetFullName());
283
284
285
286
287 continue;
288 }
289 else if (bytesRead < 0) {
290
291
292 wxLogError(
wxT(
"Ogg Vorbis importer: ov_read() returned error %i"),
293 bytesRead);
294 break;
295 }
296
297 samplesRead = bytesRead /
mVorbisFile->vi[bitstream].channels /
sizeof(short);
298
300 {
301
302 unsigned chn = 0;
304 {
305 channel.AppendBuffer(
306 (char *)(mainBuffer.get() + chn),
307 int16Sample,
308 samplesRead,
309 mVorbisFile->vi[bitstream].channels,
310 int16Sample
311 );
312 ++chn;
313 });
314 }
315
316 samplesSinceLastCallback += samplesRead;
318 const auto timeTotal = ov_time_total(
mVorbisFile.get(), bitstream);
319 if(timeTotal > 0)
322 }
324 }
325
326 if (bytesRead < 0)
327 {
329 return;
330 }
331
333 {
335 return;
336 }
337
339 {
341 }
343
344
347 for (
int c = 0; c <
mVorbisFile->vc[0].comments; c++) {
349 wxString
name = comment.BeforeFirst(
wxT(
'='));
350 wxString value = comment.AfterFirst(
wxT(
'='));
352 long val;
353 if (value.length() == 4 && value.ToLong(&val)) {
355 }
356 }
358 }
359 }
360
364}
#define SAMPLES_PER_CALLBACK
#define CODEC_TRANSFER_SIZE
This simplifies arrays of arrays, each array separately allocated with NEW[] But it might be better t...
bool IsStopped() const noexcept
FilePath GetFilename() const override
bool IsCancelled() const noexcept
virtual void OnImportResult(ImportResult result)=0
Used to report on import result for file handle passed as argument to OnImportFileOpened.
virtual void OnImportProgress(double progress)=0
static void ForEachChannel(TrackList &trackList, const std::function< void(WaveChannel &)> &op)
Iterates over channels in each wave track from the list.
static void FinalizeImport(TrackHolders &outTracks, const std::vector< std::shared_ptr< WaveTrack > > &importedStreams)
Flushes the given channels and moves them to outTracks.
std::vector< TrackListHolder > mStreams
TrackListHolder CreateMany(size_t nChannels)
Creates tracks with project's default rate and format and the given number of channels.