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 *trackFactory,
236 vi->channels,
238 vi->rate));
239 }
240
241
242#define CODEC_TRANSFER_SIZE 4096u
243
244
245
246#define SAMPLES_PER_CALLBACK 100000
247
248 long bytesRead = 0;
249 {
251
252
253
254 int testvar = 1, endian;
255 if (*(char *)&testvar)
256 endian = 0;
257 else
258 endian = 1;
259
260
261 long samplesRead = 0;
262 int bitstream = 0;
263 int samplesSinceLastCallback = 0;
264
265
266
267
268
269
271
272 do {
273
274 bytesRead = ov_read(
mVorbisFile.get(), (
char *)mainBuffer.get(),
276 endian,
277 2,
278 1,
279 &bitstream);
280
281 if (bytesRead == OV_HOLE) {
283 wxLogError(
wxT(
"Ogg Vorbis importer: file %s is malformed, ov_read() reported a hole"),
284 ff.GetFullName());
285
286
287
288
289 continue;
290 }
291 else if (bytesRead < 0) {
292
293
294 wxLogError(
wxT(
"Ogg Vorbis importer: ov_read() returned error %i"),
295 bytesRead);
296 break;
297 }
298
299 samplesRead = bytesRead /
mVorbisFile->vi[bitstream].channels /
sizeof(short);
300
302 {
303
304 unsigned chn = 0;
306 {
307 channel.AppendBuffer(
308 (char *)(mainBuffer.get() + chn),
309 int16Sample,
310 samplesRead,
311 mVorbisFile->vi[bitstream].channels,
312 int16Sample
313 );
314 ++chn;
315 });
316 }
317
318 samplesSinceLastCallback += samplesRead;
320 const auto timeTotal = ov_time_total(
mVorbisFile.get(), bitstream);
321 if(timeTotal > 0)
324 }
326 }
327
328 if (bytesRead < 0)
329 {
331 return;
332 }
333
335 {
337 return;
338 }
339
341
342
345 for (
int c = 0; c <
mVorbisFile->vc[0].comments; c++) {
347 wxString
name = comment.BeforeFirst(
wxT(
'='));
348 wxString value = comment.AfterFirst(
wxT(
'='));
350 long val;
351 if (value.length() == 4 && value.ToLong(&val)) {
353 }
354 }
356 }
357 }
358
362}
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...
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 std::shared_ptr< WaveTrack > NewWaveTrack(WaveTrackFactory &trackFactory, unsigned nChannels, sampleFormat effectiveFormat, double rate)
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< WaveTrack::Holder > mStreams