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

Method Process

modules/import-export/mod-cl/ExportCL.cpp:643–746  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

641}
642
643ExportResult CLExportProcessor::Process(ExportProcessorDelegate& delegate)
644{
645 delegate.SetStatusString(context.status);
646 auto& process = *context.process;
647 auto exportResult = ExportResult::Success;
648 {
649 size_t numBytes = 0;
650 constSamplePtr mixed = nullptr;
651
652 wxOutputStream *os = process.GetOutputStream();
653 auto closeIt = finally ( [&] {
654 // Should make the process die, before propagating any exception
655 process.CloseOutput();
656 } );
657
658 // Start piping the mixed data to the command
659 while (exportResult == ExportResult::Success && process.IsActive() && os->IsOk()) {
660 // Capture any stdout and stderr from the command
661 Drain(process.GetInputStream(), &context.output);
662 Drain(process.GetErrorStream(), &context.output);
663
664 // Need to mix another block
665 if (numBytes == 0) {
666 auto numSamples = context.mixer->Process();
667 if (numSamples == 0)
668 break;
669
670 mixed = context.mixer->GetBuffer();
671 numBytes = numSamples * context.channels;
672
673 // Byte-swapping is necessary on big-endian machines, since
674 // WAV files are little-endian
675#if wxBYTE_ORDER == wxBIG_ENDIAN
676 auto buffer = (const float *) mixed;
677 for (int i = 0; i < numBytes; i++) {
678 buffer[i] = wxUINT32_SWAP_ON_BE(buffer[i]);
679 }
680#endif
681 numBytes *= SAMPLE_SIZE(floatSample);
682 }
683
684 // Don't write too much at once...pipes may not be able to handle it
685 size_t bytes = wxMin(numBytes, 4096);
686 numBytes -= bytes;
687
688 while (bytes > 0) {
689 os->Write(mixed, bytes);
690 if (!os->IsOk()) {
691 exportResult = ExportResult::Error;
692 break;
693 }
694 bytes -= os->LastWrite();
695 mixed += os->LastWrite();
696 }
697
698 if(exportResult == ExportResult::Success)
699 exportResult = ExportPluginHelpers::UpdateProgress(
700 delegate, *context.mixer, context.t0, context.t1);

Callers

nothing calls this directly

Calls 15

finallyFunction · 0.85
DrainFunction · 0.85
YieldFunction · 0.85
CallAfterFunction · 0.85
moveFunction · 0.85
GetStatusMethod · 0.80
AddTextWindowMethod · 0.80
AddSpacerMethod · 0.80
GetSizerMethod · 0.80
wxSizeClass · 0.50
SetStatusStringMethod · 0.45
IsActiveMethod · 0.45

Tested by

no test coverage detected