MCPcopy Create free account
hub / github.com/audacity/audacity / Process

Method Process

modules/import-export/mod-flac/ExportFLAC.cpp:414–475  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

412}
413
414ExportResult FLACExportProcessor::Process(ExportProcessorDelegate& delegate)
415{
416 delegate.SetStatusString(context.status);
417
418 auto exportResult = ExportResult::Success;
419
420 auto cleanup2 = finally( [&] {
421 if (exportResult == ExportResult::Cancelled || exportResult == ExportResult::Error) {
422#ifndef LEGACY_FLAC
423 context.f.Detach(); // libflac closes the file
424#endif
425 context.encoder.finish();
426 }
427 } );
428
429 ArraysOf<FLAC__int32> tmpsmplbuf{ context.numChannels, SAMPLES_PER_RUN, true };
430
431 while (exportResult == ExportResult::Success) {
432 auto samplesThisRun = context.mixer->Process();
433 if (samplesThisRun == 0) //stop encoding
434 break;
435
436 for (size_t i = 0; i < context.numChannels; i++) {
437 auto mixed = context.mixer->GetBuffer(i);
438 if (context.format == int24Sample) {
439 for (decltype(samplesThisRun) j = 0; j < samplesThisRun; j++) {
440 tmpsmplbuf[i][j] = ((const int *)mixed)[j];
441 }
442 }
443 else {
444 for (decltype(samplesThisRun) j = 0; j < samplesThisRun; j++) {
445 tmpsmplbuf[i][j] = ((const short *)mixed)[j];
446 }
447 }
448 }
449 if (! context.encoder.process(
450 reinterpret_cast<FLAC__int32**>( tmpsmplbuf.get() ),
451 samplesThisRun) ) {
452 // TODO: more precise message
453 throw ExportDiskFullError(context.fName);
454 }
455 exportResult = ExportPluginHelpers::UpdateProgress(
456 delegate, *context.mixer, context.t0, context.t1);
457 }
458
459 if (exportResult != ExportResult::Cancelled && exportResult != ExportResult::Error) {
460#ifndef LEGACY_FLAC
461 context.f.Detach(); // libflac closes the file
462#endif
463 if (!context.encoder.finish())
464 {
465 return ExportResult::Error;
466 }
467#ifdef LEGACY_FLAC
468 if (!context.f.Flush() || !context.f.Close())
469 {
470 return ExportResult::Error;
471 }

Callers

nothing calls this directly

Calls 9

finallyFunction · 0.85
SetStatusStringMethod · 0.45
DetachMethod · 0.45
finishMethod · 0.45
GetBufferMethod · 0.45
processMethod · 0.45
getMethod · 0.45
FlushMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected