228{
229 outTracks.clear();
230
231 wxASSERT(
mFile->IsOpened());
232
234
235
236
238
239 int i = -1;
241 {
242 ++i;
243
244
246 {
247
248
249 continue;
250 }
251
253
254 link.resize(vi->channels);
255
256 for (auto &channel : link)
257
259 }
260
261
262#define CODEC_TRANSFER_SIZE 4096u
263
264
265
266#define SAMPLES_PER_CALLBACK 100000
267
269 long bytesRead = 0;
270 {
272
273
274
275 int testvar = 1, endian;
276 if (*(char *)&testvar)
277 endian = 0;
278 else
279 endian = 1;
280
281
282 long samplesRead = 0;
283 int bitstream = 0;
284 int samplesSinceLastCallback = 0;
285
286
287
288
289
290
292
293 do {
294
295 bytesRead = ov_read(
mVorbisFile.get(), (
char *)mainBuffer.get(),
297 endian,
298 2,
299 1,
300 &bitstream);
301
302 if (bytesRead == OV_HOLE) {
304 wxLogError(
wxT(
"Ogg Vorbis importer: file %s is malformed, ov_read() reported a hole"),
305 ff.GetFullName());
306
307
308
309
310 continue;
311 }
312 else if (bytesRead < 0) {
313
314
315 wxLogError(
wxT(
"Ogg Vorbis importer: ov_read() returned error %i"),
316 bytesRead);
317 break;
318 }
319
320 samplesRead = bytesRead /
mVorbisFile->vi[bitstream].channels /
sizeof(short);
321
322
324 std::advance(iter, bitstream);
326 {
327 auto iter2 = iter->begin();
328 for (
int c = 0; c <
mVorbisFile->vi[bitstream].channels; ++iter2, ++c)
329 iter2->get()->Append((char *)(mainBuffer.get() + c),
331 samplesRead,
334 }
335
336 samplesSinceLastCallback += samplesRead;
341 }
343 }
344
345 auto res = updateResult;
346 if (bytesRead < 0)
347 res = ProgressResult::Failed;
348
350 return res;
351 }
352
354 {
355 for (auto &channel : link)
356 channel->Flush();
357 outTracks.push_back(std::move(link));
358 }
359
360
363 for (
int c = 0; c <
mVorbisFile->vc[0].comments; c++) {
365 wxString
name = comment.BeforeFirst(
wxT(
'='));
366 wxString value = comment.AfterFirst(
wxT(
'='));
368 long val;
369 if (value.length() == 4 && value.ToLong(&val)) {
371 }
372 }
374 }
375 }
376
377 return res;
378}
const TranslatableString name
#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...
std::unique_ptr< ProgressDialog > mProgress
std::shared_ptr< WaveTrack > NewWaveTrack(WaveTrackFactory &trackFactory, sampleFormat effectiveFormat, double rate)
Build a wave track with appropriate format, which will not be narrower than the specified one.
std::list< NewChannelGroup > mChannels