mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-15 07:40:23 +02:00
Use enum class ProgressResult, don't interconvert with int or bool
This commit is contained in:
parent
5036583549
commit
aa0d55ac83
@ -162,7 +162,7 @@ static void RemoveDependencies(AudacityProject *project,
|
||||
ProgressDialog progress
|
||||
(_("Removing Dependencies"),
|
||||
_("Copying audio data into project..."));
|
||||
int updateResult = eProgressSuccess;
|
||||
auto updateResult = ProgressResult::Success;
|
||||
|
||||
// Hash aliasedFiles based on their full paths and
|
||||
// count total number of bytes to process.
|
||||
@ -209,7 +209,7 @@ static void RemoveDependencies(AudacityProject *project,
|
||||
// Update the progress bar
|
||||
completedBytes += SAMPLE_SIZE(format) * len;
|
||||
updateResult = progress.Update(completedBytes, totalBytesToProcess);
|
||||
if (updateResult != eProgressSuccess)
|
||||
if (updateResult != ProgressResult::Success)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -6316,7 +6316,7 @@ class ASAProgress final : public SAProgress {
|
||||
(is_audio[1] ? AUDIO_WORK_UNIT : MIDI_WORK_UNIT) * f;
|
||||
}
|
||||
int updateResult = mProgress->Update((int)(work), (int)(mTotalWork));
|
||||
return (updateResult == eProgressSuccess);
|
||||
return (updateResult == ProgressResult::Success);
|
||||
}
|
||||
bool set_matrix_progress(int cells) override {
|
||||
mCellCount += cells;
|
||||
@ -6325,7 +6325,7 @@ class ASAProgress final : public SAProgress {
|
||||
(is_audio[1] ? AUDIO_WORK_UNIT : MIDI_WORK_UNIT) * mFrames[1];
|
||||
work += mCellCount * MATRIX_WORK_UNIT;
|
||||
int updateResult = mProgress->Update((int)(work), (int)(mTotalWork));
|
||||
return (updateResult == eProgressSuccess);
|
||||
return (updateResult == ProgressResult::Success);
|
||||
}
|
||||
bool set_smoothing_progress(int i) override {
|
||||
iterations = i;
|
||||
@ -6335,7 +6335,7 @@ class ASAProgress final : public SAProgress {
|
||||
MATRIX_WORK_UNIT * mFrames[0] * mFrames[1];
|
||||
work += i * wxMax(mFrames[0], mFrames[1]) * SMOOTHING_WORK_UNIT;
|
||||
int updateResult = mProgress->Update((int)(work), (int)(mTotalWork));
|
||||
return (updateResult == eProgressSuccess);
|
||||
return (updateResult == ProgressResult::Success);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -166,12 +166,12 @@ void MixAndRender(TrackList *tracks, TrackFactory *trackFactory,
|
||||
|
||||
::wxSafeYield();
|
||||
|
||||
int updateResult = eProgressSuccess;
|
||||
auto updateResult = ProgressResult::Success;
|
||||
{
|
||||
ProgressDialog progress(_("Mix and Render"),
|
||||
_("Mixing and rendering tracks"));
|
||||
|
||||
while (updateResult == eProgressSuccess) {
|
||||
while (updateResult == ProgressResult::Success) {
|
||||
auto blockLen = mixer.Process(maxBlockLen);
|
||||
|
||||
if (blockLen == 0)
|
||||
@ -196,7 +196,7 @@ void MixAndRender(TrackList *tracks, TrackFactory *trackFactory,
|
||||
mixLeft->Flush();
|
||||
if (!mono)
|
||||
mixRight->Flush();
|
||||
if (updateResult == eProgressCancelled || updateResult == eProgressFailed)
|
||||
if (updateResult == ProgressResult::Cancelled || updateResult == ProgressResult::Failed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -980,8 +980,8 @@ void PluginRegistrationDialog::OnOK(wxCommandEvent & WXUNUSED(evt))
|
||||
if (item.state == STATE_Enabled && item.plugs[0]->GetPluginType() == PluginTypeStub)
|
||||
{
|
||||
last3 = last3.AfterFirst(wxT('\n')) + item.path + wxT("\n");
|
||||
int status = progress.Update(++i, enableCount, wxString::Format(_("Enabling effect:\n\n%s"), last3.c_str()));
|
||||
if (!status)
|
||||
auto status = progress.Update(++i, enableCount, wxString::Format(_("Enabling effect:\n\n%s"), last3.c_str()));
|
||||
if (status == ProgressResult::Cancelled)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -505,12 +505,12 @@ int TimerRecordDialog::RunWaitDialog()
|
||||
{
|
||||
AudacityProject* pProject = GetActiveProject();
|
||||
|
||||
int updateResult = eProgressSuccess;
|
||||
auto updateResult = ProgressResult::Success;
|
||||
|
||||
if (m_DateTime_Start > wxDateTime::UNow())
|
||||
updateResult = this->WaitForStart();
|
||||
|
||||
if (updateResult != eProgressSuccess) {
|
||||
if (updateResult != ProgressResult::Success) {
|
||||
// Don't proceed, but don't treat it as canceled recording. User just canceled waiting.
|
||||
return POST_TIMER_RECORD_CANCEL_WAIT;
|
||||
} else {
|
||||
@ -552,7 +552,7 @@ int TimerRecordDialog::RunWaitDialog()
|
||||
this->OnTimer(dummyTimerEvent);
|
||||
|
||||
// Loop for progress display during recording.
|
||||
while (bIsRecording && (updateResult == eProgressSuccess)) {
|
||||
while (bIsRecording && (updateResult == ProgressResult::Success)) {
|
||||
updateResult = progress.Update();
|
||||
wxMilliSleep(kTimerInterval);
|
||||
bIsRecording = (wxDateTime::UNow() <= m_DateTime_End); // Call UNow() again for extra accuracy...
|
||||
@ -564,10 +564,10 @@ int TimerRecordDialog::RunWaitDialog()
|
||||
pProject->OnStop();
|
||||
|
||||
// Let the caller handle cancellation or failure from recording progress.
|
||||
if (updateResult == eProgressCancelled || updateResult == eProgressFailed)
|
||||
if (updateResult == ProgressResult::Cancelled || updateResult == ProgressResult::Failed)
|
||||
return POST_TIMER_RECORD_CANCEL;
|
||||
|
||||
return ExecutePostRecordActions((updateResult == eProgressStopped));
|
||||
return ExecutePostRecordActions((updateResult == ProgressResult::Stopped));
|
||||
}
|
||||
|
||||
int TimerRecordDialog::ExecutePostRecordActions(bool bWasStopped) {
|
||||
@ -675,8 +675,8 @@ int TimerRecordDialog::ExecutePostRecordActions(bool bWasStopped) {
|
||||
// Lets show a warning dialog telling the user what is about to happen.
|
||||
// If the user no longer wants to carry out this action then they can click
|
||||
// Cancel and we will do POST_TIMER_RECORD_NOTHING instead.
|
||||
int iDelayOutcome = PreActionDelay(iPostRecordAction, (TimerRecordCompletedActions)eActionFlags);
|
||||
if (iDelayOutcome != eProgressSuccess) {
|
||||
auto iDelayOutcome = PreActionDelay(iPostRecordAction, (TimerRecordCompletedActions)eActionFlags);
|
||||
if (iDelayOutcome != ProgressResult::Success) {
|
||||
// Cancel the action!
|
||||
iPostRecordAction = POST_TIMER_RECORD_NOTHING;
|
||||
// Set this to true to avoid any chance of the temp files being deleted
|
||||
@ -993,7 +993,7 @@ void TimerRecordDialog::UpdateEnd()
|
||||
m_pTimeTextCtrl_End->SetValue(wxDateTime_to_AudacityTime(m_DateTime_End));
|
||||
}
|
||||
|
||||
int TimerRecordDialog::WaitForStart()
|
||||
ProgressResult TimerRecordDialog::WaitForStart()
|
||||
{
|
||||
// MY: The Waiting For Start dialog now shows what actions will occur after recording has completed
|
||||
wxString sPostAction = m_pTimerAfterCompleteChoiceCtrl->GetString(m_pTimerAfterCompleteChoiceCtrl->GetSelection());
|
||||
@ -1026,9 +1026,9 @@ int TimerRecordDialog::WaitForStart()
|
||||
pdlgHideStopButton | pdlgConfirmStopCancel | pdlgHideElapsedTime,
|
||||
_("Recording will commence in:"));
|
||||
|
||||
int updateResult = eProgressSuccess;
|
||||
auto updateResult = ProgressResult::Success;
|
||||
bool bIsRecording = false;
|
||||
while (updateResult == eProgressSuccess && !bIsRecording)
|
||||
while (updateResult == ProgressResult::Success && !bIsRecording)
|
||||
{
|
||||
updateResult = progress.Update();
|
||||
wxMilliSleep(10);
|
||||
@ -1037,7 +1037,7 @@ int TimerRecordDialog::WaitForStart()
|
||||
return updateResult;
|
||||
}
|
||||
|
||||
int TimerRecordDialog::PreActionDelay(int iActionIndex, TimerRecordCompletedActions eCompletedActions)
|
||||
ProgressResult TimerRecordDialog::PreActionDelay(int iActionIndex, TimerRecordCompletedActions eCompletedActions)
|
||||
{
|
||||
wxString sAction = m_pTimerAfterCompleteChoiceCtrl->GetString(iActionIndex);
|
||||
wxString sCountdownLabel;
|
||||
@ -1068,9 +1068,9 @@ int TimerRecordDialog::PreActionDelay(int iActionIndex, TimerRecordCompletedActi
|
||||
pdlgHideStopButton | pdlgHideElapsedTime,
|
||||
sCountdownLabel);
|
||||
|
||||
int iUpdateResult = eProgressSuccess;
|
||||
auto iUpdateResult = ProgressResult::Success;
|
||||
bool bIsTime = false;
|
||||
while (iUpdateResult == eProgressSuccess && !bIsTime)
|
||||
while (iUpdateResult == ProgressResult::Success && !bIsTime)
|
||||
{
|
||||
iUpdateResult = dlgAction.Update();
|
||||
wxMilliSleep(10);
|
||||
|
@ -81,7 +81,7 @@ private:
|
||||
bool TransferDataFromWindow();
|
||||
void UpdateDuration(); // Update m_TimeSpan_Duration and ctrl based on m_DateTime_Start and m_DateTime_End.
|
||||
void UpdateEnd(); // Update m_DateTime_End and ctrls based on m_DateTime_Start and m_TimeSpan_Duration.
|
||||
int WaitForStart();
|
||||
ProgressResult WaitForStart();
|
||||
|
||||
// Timer Recording Automation Control Events
|
||||
void OnAutoSavePathButton_Click(wxCommandEvent& event);
|
||||
@ -99,7 +99,7 @@ private:
|
||||
TimerRecordPathCtrl *NewPathControl(wxWindow *wParent, const int iID, const wxString &sCaption, const wxString &sValue);
|
||||
|
||||
int ExecutePostRecordActions(bool bWasStopped);
|
||||
int PreActionDelay(int iActionIndex, TimerRecordCompletedActions eCompletedActions);
|
||||
ProgressResult PreActionDelay(int iActionIndex, TimerRecordCompletedActions eCompletedActions);
|
||||
|
||||
private:
|
||||
wxDateTime m_DateTime_Start;
|
||||
|
@ -1843,11 +1843,11 @@ bool WaveClip::Resample(int rate, ProgressDialog *progress)
|
||||
|
||||
if (progress)
|
||||
{
|
||||
int updateResult = progress->Update(
|
||||
auto updateResult = progress->Update(
|
||||
pos.as_long_long(),
|
||||
numSamples.as_long_long()
|
||||
);
|
||||
error = (updateResult != eProgressSuccess);
|
||||
error = (updateResult != ProgressResult::Success);
|
||||
if (error)
|
||||
{
|
||||
break;
|
||||
|
@ -1977,26 +1977,26 @@ void Effect::IncludeNotSelectedPreviewTracks(bool includeNotSelected)
|
||||
|
||||
bool Effect::TotalProgress(double frac)
|
||||
{
|
||||
int updateResult = (mProgress ?
|
||||
auto updateResult = (mProgress ?
|
||||
mProgress->Update(frac) :
|
||||
eProgressSuccess);
|
||||
return (updateResult != eProgressSuccess);
|
||||
ProgressResult::Success);
|
||||
return (updateResult != ProgressResult::Success);
|
||||
}
|
||||
|
||||
bool Effect::TrackProgress(int whichTrack, double frac, const wxString &msg)
|
||||
{
|
||||
int updateResult = (mProgress ?
|
||||
auto updateResult = (mProgress ?
|
||||
mProgress->Update(whichTrack + frac, (double) mNumTracks, msg) :
|
||||
eProgressSuccess);
|
||||
return (updateResult != eProgressSuccess);
|
||||
ProgressResult::Success);
|
||||
return (updateResult != ProgressResult::Success);
|
||||
}
|
||||
|
||||
bool Effect::TrackGroupProgress(int whichGroup, double frac, const wxString &msg)
|
||||
{
|
||||
int updateResult = (mProgress ?
|
||||
auto updateResult = (mProgress ?
|
||||
mProgress->Update(whichGroup + frac, (double) mNumGroups, msg) :
|
||||
eProgressSuccess);
|
||||
return (updateResult != eProgressSuccess);
|
||||
ProgressResult::Success);
|
||||
return (updateResult != ProgressResult::Success);
|
||||
}
|
||||
|
||||
void Effect::GetSamples(
|
||||
@ -2614,7 +2614,7 @@ void Effect::Preview(bool dryOnly)
|
||||
mT0, t1, options);
|
||||
|
||||
if (token) {
|
||||
int previewing = eProgressSuccess;
|
||||
auto previewing = ProgressResult::Success;
|
||||
// The progress dialog must be deleted before stopping the stream
|
||||
// to allow events to flow to the app during StopStream processing.
|
||||
// The progress dialog blocks these events.
|
||||
@ -2622,7 +2622,7 @@ void Effect::Preview(bool dryOnly)
|
||||
ProgressDialog progress
|
||||
(GetName(), _("Previewing"), pdlgHideCancelButton);
|
||||
|
||||
while (gAudioIO->IsStreamActive(token) && previewing == eProgressSuccess) {
|
||||
while (gAudioIO->IsStreamActive(token) && previewing == ProgressResult::Success) {
|
||||
::wxMilliSleep(100);
|
||||
previewing = progress.Update(gAudioIO->GetStreamTime() - mT0, t1 - mT0);
|
||||
}
|
||||
|
@ -822,14 +822,12 @@ bool Exporter::CheckMix()
|
||||
|
||||
bool Exporter::ExportTracks()
|
||||
{
|
||||
int success;
|
||||
|
||||
// Keep original in case of failure
|
||||
if (mActualName != mFilename) {
|
||||
::wxRenameFile(mActualName.GetFullPath(), mFilename.GetFullPath());
|
||||
}
|
||||
|
||||
success = mPlugins[mFormat]->Export(mProject,
|
||||
auto success = mPlugins[mFormat]->Export(mProject,
|
||||
mChannels,
|
||||
mActualName.GetFullPath(),
|
||||
mSelectedOnly,
|
||||
@ -841,7 +839,7 @@ bool Exporter::ExportTracks()
|
||||
|
||||
if (mActualName != mFilename) {
|
||||
// Remove backup
|
||||
if (success == eProgressSuccess || success == eProgressStopped) {
|
||||
if (success == ProgressResult::Success || success == ProgressResult::Stopped) {
|
||||
::wxRemoveFile(mFilename.GetFullPath());
|
||||
}
|
||||
else {
|
||||
@ -851,7 +849,7 @@ bool Exporter::ExportTracks()
|
||||
}
|
||||
}
|
||||
|
||||
return (success == eProgressSuccess || success == eProgressStopped);
|
||||
return (success == ProgressResult::Success || success == ProgressResult::Stopped);
|
||||
}
|
||||
|
||||
void Exporter::CreateUserPaneCallback(wxWindow *parent, wxUIntPtr userdata)
|
||||
|
@ -33,6 +33,7 @@ class MixerSpec;
|
||||
class TimeTrack;
|
||||
class Mixer;
|
||||
class WaveTrackConstArray;
|
||||
enum class ProgressResult : unsigned;
|
||||
|
||||
class AUDACITY_DLL_API FormatInfo
|
||||
{
|
||||
@ -108,7 +109,7 @@ public:
|
||||
* libsndfile export plug-in, but with subformat set to 0, 1, and 2
|
||||
* respectively.
|
||||
*/
|
||||
virtual int Export(AudacityProject *project,
|
||||
virtual ProgressResult Export(AudacityProject *project,
|
||||
unsigned channels,
|
||||
const wxString &fName,
|
||||
bool selectedOnly,
|
||||
|
@ -284,7 +284,7 @@ public:
|
||||
// Required
|
||||
wxWindow *OptionsCreate(wxWindow *parent, int format);
|
||||
|
||||
int Export(AudacityProject *project,
|
||||
ProgressResult Export(AudacityProject *project,
|
||||
unsigned channels,
|
||||
const wxString &fName,
|
||||
bool selectedOnly,
|
||||
@ -306,7 +306,7 @@ ExportCL::ExportCL()
|
||||
SetDescription(_("(external program)"),0);
|
||||
}
|
||||
|
||||
int ExportCL::Export(AudacityProject *project,
|
||||
ProgressResult ExportCL::Export(AudacityProject *project,
|
||||
unsigned channels,
|
||||
const wxString &fName,
|
||||
bool selectionOnly,
|
||||
@ -368,7 +368,7 @@ int ExportCL::Export(AudacityProject *project,
|
||||
process.Detach();
|
||||
process.CloseOutput();
|
||||
|
||||
return false;
|
||||
return ProgressResult::Cancelled;
|
||||
}
|
||||
|
||||
// Turn off logging to prevent broken pipe messages
|
||||
@ -432,7 +432,7 @@ int ExportCL::Export(AudacityProject *project,
|
||||
|
||||
size_t numBytes = 0;
|
||||
samplePtr mixed = NULL;
|
||||
int updateResult = eProgressSuccess;
|
||||
auto updateResult = ProgressResult::Success;
|
||||
|
||||
{
|
||||
// Prepare the progress display
|
||||
@ -442,7 +442,7 @@ int ExportCL::Export(AudacityProject *project,
|
||||
_("Exporting the entire project using command-line encoder"));
|
||||
|
||||
// Start piping the mixed data to the command
|
||||
while (updateResult == eProgressSuccess && process.IsActive() && os->IsOk()) {
|
||||
while (updateResult == ProgressResult::Success && process.IsActive() && os->IsOk()) {
|
||||
// Capture any stdout and stderr from the command
|
||||
Drain(process.GetInputStream(), &output);
|
||||
Drain(process.GetErrorStream(), &output);
|
||||
|
@ -140,7 +140,7 @@ public:
|
||||
///\param metadata tags to write into file
|
||||
///\param subformat index of export type
|
||||
///\return true if export succeded
|
||||
int Export(AudacityProject *project,
|
||||
ProgressResult Export(AudacityProject *project,
|
||||
unsigned channels,
|
||||
const wxString &fName,
|
||||
bool selectedOnly,
|
||||
@ -823,12 +823,12 @@ bool ExportFFmpeg::EncodeAudioFrame(int16_t *pFrame, size_t frameSize)
|
||||
}
|
||||
|
||||
|
||||
int ExportFFmpeg::Export(AudacityProject *project,
|
||||
ProgressResult ExportFFmpeg::Export(AudacityProject *project,
|
||||
unsigned channels, const wxString &fName,
|
||||
bool selectionOnly, double t0, double t1, MixerSpec *mixerSpec, const Tags *metadata, int subformat)
|
||||
{
|
||||
if (!CheckFFmpegPresence())
|
||||
return false;
|
||||
return ProgressResult::Cancelled;
|
||||
mChannels = channels;
|
||||
// subformat index may not correspond directly to fmts[] index, convert it
|
||||
mSubFormat = AdjustFormatIndex(subformat);
|
||||
@ -840,20 +840,22 @@ int ExportFFmpeg::Export(AudacityProject *project,
|
||||
channels,
|
||||
ExportFFmpegOptions::fmts[mSubFormat].maxchannels),
|
||||
_("Error"));
|
||||
return false;
|
||||
return ProgressResult::Cancelled;
|
||||
}
|
||||
mName = fName;
|
||||
const TrackList *tracks = project->GetTracks();
|
||||
bool ret = true;
|
||||
|
||||
if (mSubFormat >= FMT_LAST) return false;
|
||||
if (mSubFormat >= FMT_LAST)
|
||||
return ProgressResult::Cancelled;
|
||||
|
||||
wxString shortname(ExportFFmpegOptions::fmts[mSubFormat].shortname);
|
||||
if (mSubFormat == FMT_OTHER)
|
||||
shortname = gPrefs->Read(wxT("/FileFormats/FFmpegFormat"),wxT("matroska"));
|
||||
ret = Init(shortname.mb_str(),project, metadata, subformat);
|
||||
|
||||
if (!ret) return false;
|
||||
if (!ret)
|
||||
return ProgressResult::Cancelled;
|
||||
|
||||
int pcmBufferSize = 1024;
|
||||
const WaveTrackConstArray waveTracks =
|
||||
@ -864,14 +866,14 @@ int ExportFFmpeg::Export(AudacityProject *project,
|
||||
channels, pcmBufferSize, true,
|
||||
mSampleRate, int16Sample, true, mixerSpec);
|
||||
|
||||
int updateResult = eProgressSuccess;
|
||||
auto updateResult = ProgressResult::Success;
|
||||
{
|
||||
ProgressDialog progress(wxFileName(fName).GetName(),
|
||||
selectionOnly ?
|
||||
wxString::Format(_("Exporting selected audio as %s"), ExportFFmpegOptions::fmts[mSubFormat].description) :
|
||||
wxString::Format(_("Exporting entire file as %s"), ExportFFmpegOptions::fmts[mSubFormat].description));
|
||||
|
||||
while (updateResult == eProgressSuccess) {
|
||||
while (updateResult == ProgressResult::Success) {
|
||||
auto pcmNumSamples = mixer->Process(pcmBufferSize);
|
||||
|
||||
if (pcmNumSamples == 0)
|
||||
|
@ -182,7 +182,7 @@ public:
|
||||
// Required
|
||||
|
||||
wxWindow *OptionsCreate(wxWindow *parent, int format);
|
||||
int Export(AudacityProject *project,
|
||||
ProgressResult Export(AudacityProject *project,
|
||||
unsigned channels,
|
||||
const wxString &fName,
|
||||
bool selectedOnly,
|
||||
@ -212,7 +212,7 @@ ExportFLAC::ExportFLAC()
|
||||
SetDescription(_("FLAC Files"),0);
|
||||
}
|
||||
|
||||
int ExportFLAC::Export(AudacityProject *project,
|
||||
ProgressResult ExportFLAC::Export(AudacityProject *project,
|
||||
unsigned numChannels,
|
||||
const wxString &fName,
|
||||
bool selectionOnly,
|
||||
@ -226,7 +226,7 @@ int ExportFLAC::Export(AudacityProject *project,
|
||||
const TrackList *tracks = project->GetTracks();
|
||||
|
||||
wxLogNull logNo; // temporarily disable wxWidgets error messages
|
||||
int updateResult = eProgressSuccess;
|
||||
auto updateResult = ProgressResult::Success;
|
||||
|
||||
int levelPref;
|
||||
gPrefs->Read(wxT("/FileFormats/FLACLevel"), &levelPref, 5);
|
||||
@ -244,7 +244,7 @@ int ExportFLAC::Export(AudacityProject *project,
|
||||
|
||||
// See note in GetMetadata() about a bug in libflac++ 1.1.2
|
||||
if (!GetMetadata(project, metadata)) {
|
||||
return false;
|
||||
return ProgressResult::Cancelled;
|
||||
}
|
||||
|
||||
if (mMetadata) {
|
||||
@ -286,7 +286,7 @@ int ExportFLAC::Export(AudacityProject *project,
|
||||
wxFFile f; // will be closed when it goes out of scope
|
||||
if (!f.Open(fName, wxT("w+b"))) {
|
||||
wxMessageBox(wxString::Format(_("FLAC export couldn't open %s"), fName.c_str()));
|
||||
return false;
|
||||
return ProgressResult::Cancelled;
|
||||
}
|
||||
|
||||
// Even though there is an init() method that takes a filename, use the one that
|
||||
@ -295,7 +295,7 @@ int ExportFLAC::Export(AudacityProject *project,
|
||||
int status = encoder.init(f.fp());
|
||||
if (status != FLAC__STREAM_ENCODER_INIT_STATUS_OK) {
|
||||
wxMessageBox(wxString::Format(_("FLAC encoder failed to initialize\nStatus: %d"), status));
|
||||
return false;
|
||||
return ProgressResult::Cancelled;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -323,7 +323,7 @@ int ExportFLAC::Export(AudacityProject *project,
|
||||
_("Exporting the selected audio as FLAC") :
|
||||
_("Exporting the entire project as FLAC"));
|
||||
|
||||
while (updateResult == eProgressSuccess) {
|
||||
while (updateResult == ProgressResult::Success) {
|
||||
auto samplesThisRun = mixer->Process(SAMPLES_PER_RUN);
|
||||
if (samplesThisRun == 0) { //stop encoding
|
||||
break;
|
||||
|
@ -173,7 +173,7 @@ public:
|
||||
// Required
|
||||
|
||||
wxWindow *OptionsCreate(wxWindow *parent, int format);
|
||||
int Export(AudacityProject *project,
|
||||
ProgressResult Export(AudacityProject *project,
|
||||
unsigned channels,
|
||||
const wxString &fName,
|
||||
bool selectedOnly,
|
||||
@ -203,7 +203,7 @@ ExportMP2::ExportMP2()
|
||||
SetDescription(_("MP2 Files"),0);
|
||||
}
|
||||
|
||||
int ExportMP2::Export(AudacityProject *project,
|
||||
ProgressResult ExportMP2::Export(AudacityProject *project,
|
||||
unsigned channels, const wxString &fName,
|
||||
bool selectionOnly, double t0, double t1, MixerSpec *mixerSpec, const Tags *metadata,
|
||||
int WXUNUSED(subformat))
|
||||
@ -228,7 +228,7 @@ int ExportMP2::Export(AudacityProject *project,
|
||||
wxMessageBox(_("Cannot export MP2 with this sample rate and bit rate"),
|
||||
_("Error"), wxICON_STOP);
|
||||
twolame_close(&encodeOptions);
|
||||
return false;
|
||||
return ProgressResult::Cancelled;
|
||||
}
|
||||
|
||||
// Put ID3 tags at beginning of file
|
||||
@ -239,7 +239,7 @@ int ExportMP2::Export(AudacityProject *project,
|
||||
if (!outFile.IsOpened()) {
|
||||
wxMessageBox(_("Unable to open target file for writing"));
|
||||
twolame_close(&encodeOptions);
|
||||
return false;
|
||||
return ProgressResult::Cancelled;
|
||||
}
|
||||
|
||||
char *id3buffer = NULL;
|
||||
@ -260,7 +260,7 @@ int ExportMP2::Export(AudacityProject *project,
|
||||
|
||||
const WaveTrackConstArray waveTracks =
|
||||
tracks->GetWaveTrackConstArray(selectionOnly, false);
|
||||
int updateResult = eProgressSuccess;
|
||||
auto updateResult = ProgressResult::Success;
|
||||
{
|
||||
auto mixer = CreateMixer(waveTracks,
|
||||
tracks->GetTimeTrack(),
|
||||
@ -273,7 +273,7 @@ int ExportMP2::Export(AudacityProject *project,
|
||||
wxString::Format(_("Exporting selected audio at %ld kbps"), bitrate) :
|
||||
wxString::Format(_("Exporting entire file at %ld kbps"), bitrate));
|
||||
|
||||
while (updateResult == eProgressSuccess) {
|
||||
while (updateResult == ProgressResult::Success) {
|
||||
auto pcmNumSamples = mixer->Process(pcmBufferSize);
|
||||
|
||||
if (pcmNumSamples == 0)
|
||||
|
@ -1602,7 +1602,7 @@ public:
|
||||
// Required
|
||||
|
||||
wxWindow *OptionsCreate(wxWindow *parent, int format);
|
||||
int Export(AudacityProject *project,
|
||||
ProgressResult Export(AudacityProject *project,
|
||||
unsigned channels,
|
||||
const wxString &fName,
|
||||
bool selectedOnly,
|
||||
@ -1662,7 +1662,7 @@ int ExportMP3::SetNumExportChannels()
|
||||
}
|
||||
|
||||
|
||||
int ExportMP3::Export(AudacityProject *project,
|
||||
ProgressResult ExportMP3::Export(AudacityProject *project,
|
||||
unsigned channels,
|
||||
const wxString &fName,
|
||||
bool selectionOnly,
|
||||
@ -1693,7 +1693,7 @@ int ExportMP3::Export(AudacityProject *project,
|
||||
gPrefs->Write(wxT("/MP3/MP3LibPath"), wxString(wxT("")));
|
||||
gPrefs->Flush();
|
||||
|
||||
return false;
|
||||
return ProgressResult::Cancelled;
|
||||
}
|
||||
|
||||
if (!exporter.ValidLibraryLoaded()) {
|
||||
@ -1701,7 +1701,7 @@ int ExportMP3::Export(AudacityProject *project,
|
||||
gPrefs->Write(wxT("/MP3/MP3LibPath"), wxString(wxT("")));
|
||||
gPrefs->Flush();
|
||||
|
||||
return false;
|
||||
return ProgressResult::Cancelled;
|
||||
}
|
||||
#endif // DISABLE_DYNAMIC_LOADING_LAME
|
||||
|
||||
@ -1764,7 +1764,7 @@ int ExportMP3::Export(AudacityProject *project,
|
||||
(rate < lowrate) || (rate > highrate)) {
|
||||
rate = AskResample(bitrate, rate, lowrate, highrate);
|
||||
if (rate == 0) {
|
||||
return false;
|
||||
return ProgressResult::Cancelled;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1782,7 +1782,7 @@ int ExportMP3::Export(AudacityProject *project,
|
||||
auto inSamples = exporter.InitializeStream(channels, rate);
|
||||
if (((int)inSamples) < 0) {
|
||||
wxMessageBox(_("Unable to initialize MP3 stream"));
|
||||
return false;
|
||||
return ProgressResult::Cancelled;
|
||||
}
|
||||
|
||||
// Put ID3 tags at beginning of file
|
||||
@ -1793,7 +1793,7 @@ int ExportMP3::Export(AudacityProject *project,
|
||||
wxFFile outFile(fName, wxT("w+b"));
|
||||
if (!outFile.IsOpened()) {
|
||||
wxMessageBox(_("Unable to open target file for writing"));
|
||||
return false;
|
||||
return ProgressResult::Cancelled;
|
||||
}
|
||||
|
||||
char *id3buffer = NULL;
|
||||
@ -1805,7 +1805,7 @@ int ExportMP3::Export(AudacityProject *project,
|
||||
}
|
||||
|
||||
wxFileOffset pos = outFile.Tell();
|
||||
int updateResult = eProgressSuccess;
|
||||
auto updateResult = ProgressResult::Success;
|
||||
long bytes;
|
||||
|
||||
int bufferSize = exporter.GetOutBufferSize();
|
||||
@ -1843,7 +1843,7 @@ int ExportMP3::Export(AudacityProject *project,
|
||||
|
||||
ProgressDialog progress(wxFileName(fName).GetName(), title);
|
||||
|
||||
while (updateResult == eProgressSuccess) {
|
||||
while (updateResult == ProgressResult::Success) {
|
||||
auto blockLen = mixer->Process(inSamples);
|
||||
|
||||
if (blockLen == 0) {
|
||||
|
@ -566,7 +566,7 @@ void ExportMultiple::OnExport(wxCommandEvent& WXUNUSED(event))
|
||||
}
|
||||
|
||||
// bool overwrite = mOverwrite->GetValue();
|
||||
int ok;
|
||||
ProgressResult ok;
|
||||
mExported.Empty();
|
||||
|
||||
if (mLabel->GetValue()) {
|
||||
@ -584,10 +584,10 @@ void ExportMultiple::OnExport(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxString msg;
|
||||
msg.Printf(
|
||||
ok == eProgressSuccess ? _("Successfully exported the following %lld file(s).")
|
||||
: (ok == eProgressFailed ? _("Something went wrong after exporting the following %lld file(s).")
|
||||
: (ok == eProgressCancelled ? _("Export canceled after exporting the following %lld file(s).")
|
||||
: (ok == eProgressStopped ? _("Export stopped after exporting the following %lld file(s).")
|
||||
ok == ProgressResult::Success ? _("Successfully exported the following %lld file(s).")
|
||||
: (ok == ProgressResult::Failed ? _("Something went wrong after exporting the following %lld file(s).")
|
||||
: (ok == ProgressResult::Cancelled ? _("Export canceled after exporting the following %lld file(s).")
|
||||
: (ok == ProgressResult::Stopped ? _("Export stopped after exporting the following %lld file(s).")
|
||||
: _("Something went really wrong after exporting the following %lld file(s).")
|
||||
)
|
||||
)
|
||||
@ -606,7 +606,7 @@ void ExportMultiple::OnExport(wxCommandEvent& WXUNUSED(event))
|
||||
450,400);
|
||||
}
|
||||
|
||||
if (ok == eProgressSuccess || ok == eProgressStopped) {
|
||||
if (ok == ProgressResult::Success || ok == ProgressResult::Stopped) {
|
||||
EndModal(1);
|
||||
}
|
||||
}
|
||||
@ -637,7 +637,7 @@ bool ExportMultiple::DirOk()
|
||||
}
|
||||
|
||||
// TODO: JKC July2016: Merge labels/tracks duplicated export code.
|
||||
int ExportMultiple::ExportMultipleByLabel(bool byName,
|
||||
ProgressResult ExportMultiple::ExportMultipleByLabel(bool byName,
|
||||
const wxString &prefix, bool addNumber)
|
||||
{
|
||||
wxASSERT(mProject);
|
||||
@ -732,7 +732,7 @@ int ExportMultiple::ExportMultipleByLabel(bool byName,
|
||||
setting.filetags.SetTag(TAG_TRACK, l+1);
|
||||
// let the user have a crack at editing it, exit if cancelled
|
||||
if( !setting.filetags.ShowEditDialog(mProject, _("Edit Metadata Tags"), tagsPrompt) )
|
||||
return false;
|
||||
return ProgressResult::Cancelled;
|
||||
}
|
||||
|
||||
/* add the settings to the array of settings to be used for export */
|
||||
@ -741,7 +741,7 @@ int ExportMultiple::ExportMultipleByLabel(bool byName,
|
||||
l++; // next label, count up one
|
||||
}
|
||||
|
||||
int ok = eProgressSuccess; // did it work?
|
||||
auto ok = ProgressResult::Success; // did it work?
|
||||
int count = 0; // count the number of sucessful runs
|
||||
ExportKit activeSetting; // pointer to the settings in use for this export
|
||||
/* Go round again and do the exporting (so this run is slow but
|
||||
@ -755,7 +755,7 @@ int ExportMultiple::ExportMultipleByLabel(bool byName,
|
||||
|
||||
// Export it
|
||||
ok = DoExport(channels, activeSetting.destfile, false, activeSetting.t0, activeSetting.t1, activeSetting.filetags);
|
||||
if (ok != eProgressSuccess && ok != eProgressStopped) {
|
||||
if (ok != ProgressResult::Success && ok != ProgressResult::Stopped) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -763,14 +763,14 @@ int ExportMultiple::ExportMultipleByLabel(bool byName,
|
||||
return ok;
|
||||
}
|
||||
|
||||
int ExportMultiple::ExportMultipleByTrack(bool byName,
|
||||
ProgressResult ExportMultiple::ExportMultipleByTrack(bool byName,
|
||||
const wxString &prefix, bool addNumber)
|
||||
{
|
||||
wxASSERT(mProject);
|
||||
bool tagsPrompt = mProject->GetShowId3Dialog();
|
||||
Track *tr, *tr2;
|
||||
int l = 0; // track counter
|
||||
int ok = eProgressSuccess;
|
||||
auto ok = ProgressResult::Success;
|
||||
wxArrayString otherNames;
|
||||
std::vector<Track*> selected; /**< Array of pointers to the tracks which were
|
||||
selected when we started */
|
||||
@ -874,7 +874,7 @@ int ExportMultiple::ExportMultipleByTrack(bool byName,
|
||||
setting.filetags.SetTag(TAG_TRACK, l+1);
|
||||
// let the user have a crack at editing it, exit if cancelled
|
||||
if (!setting.filetags.ShowEditDialog(mProject,_("Edit Metadata Tags"), tagsPrompt))
|
||||
return false;
|
||||
return ProgressResult::Cancelled;
|
||||
}
|
||||
/* add the settings to the array of settings to be used for export */
|
||||
exportSettings.Add(setting);
|
||||
@ -924,7 +924,7 @@ int ExportMultiple::ExportMultipleByTrack(bool byName,
|
||||
}
|
||||
|
||||
// Stop if an error occurred
|
||||
if (ok != eProgressSuccess && ok != eProgressStopped) {
|
||||
if (ok != ProgressResult::Success && ok != ProgressResult::Stopped) {
|
||||
break;
|
||||
}
|
||||
// increment export counter
|
||||
@ -939,7 +939,7 @@ int ExportMultiple::ExportMultipleByTrack(bool byName,
|
||||
return ok ;
|
||||
}
|
||||
|
||||
int ExportMultiple::DoExport(unsigned channels,
|
||||
ProgressResult ExportMultiple::DoExport(unsigned channels,
|
||||
const wxFileName &inName,
|
||||
bool selectedOnly,
|
||||
double t0,
|
||||
@ -956,7 +956,7 @@ int ExportMultiple::DoExport(unsigned channels,
|
||||
if (mOverwrite->GetValue()) {
|
||||
// Make sure we don't overwrite (corrupt) alias files
|
||||
if (!mProject->GetDirManager()->EnsureSafeFilename(inName)) {
|
||||
return false;
|
||||
return ProgressResult::Cancelled;
|
||||
}
|
||||
name = inName;
|
||||
}
|
||||
@ -971,7 +971,7 @@ int ExportMultiple::DoExport(unsigned channels,
|
||||
|
||||
// Call the format export routine
|
||||
const wxString fullPath{name.GetFullPath()};
|
||||
int success = mPlugins[mPluginIndex]->Export(mProject,
|
||||
auto success = mPlugins[mPluginIndex]->Export(mProject,
|
||||
channels,
|
||||
fullPath,
|
||||
selectedOnly,
|
||||
@ -981,7 +981,7 @@ int ExportMultiple::DoExport(unsigned channels,
|
||||
&tags,
|
||||
mSubFormatIndex);
|
||||
|
||||
if (success == eProgressSuccess || success == eProgressStopped) {
|
||||
if (success == ProgressResult::Success || success == ProgressResult::Stopped) {
|
||||
mExported.Add(fullPath);
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ private:
|
||||
* labels that define them (true), or just numbered (false).
|
||||
* @param prefix The string used to prefix the file number if files are being
|
||||
* numbered rather than named */
|
||||
int ExportMultipleByLabel(bool byName, const wxString &prefix, bool addNumber);
|
||||
ProgressResult ExportMultipleByLabel(bool byName, const wxString &prefix, bool addNumber);
|
||||
|
||||
/** \brief Export each track in the project to a separate file
|
||||
*
|
||||
@ -62,7 +62,7 @@ private:
|
||||
* (true), or just numbered (false).
|
||||
* @param prefix The string used to prefix the file number if files are being
|
||||
* numbered rather than named */
|
||||
int ExportMultipleByTrack(bool byName, const wxString &prefix, bool addNumber);
|
||||
ProgressResult ExportMultipleByTrack(bool byName, const wxString &prefix, bool addNumber);
|
||||
|
||||
/** Export one file of an export multiple set
|
||||
*
|
||||
@ -74,7 +74,7 @@ private:
|
||||
* @param t1 End time for export
|
||||
* @param tags Metadata to include in the file (if possible).
|
||||
*/
|
||||
int DoExport(unsigned channels,
|
||||
ProgressResult DoExport(unsigned channels,
|
||||
const wxFileName &name,
|
||||
bool selectedOnly,
|
||||
double t0,
|
||||
|
@ -132,7 +132,7 @@ public:
|
||||
// Required
|
||||
wxWindow *OptionsCreate(wxWindow *parent, int format) override;
|
||||
|
||||
int Export(AudacityProject *project,
|
||||
ProgressResult Export(AudacityProject *project,
|
||||
unsigned channels,
|
||||
const wxString &fName,
|
||||
bool selectedOnly,
|
||||
@ -158,7 +158,7 @@ ExportOGG::ExportOGG()
|
||||
SetDescription(_("Ogg Vorbis Files"),0);
|
||||
}
|
||||
|
||||
int ExportOGG::Export(AudacityProject *project,
|
||||
ProgressResult ExportOGG::Export(AudacityProject *project,
|
||||
unsigned numChannels,
|
||||
const wxString &fName,
|
||||
bool selectionOnly,
|
||||
@ -173,14 +173,14 @@ int ExportOGG::Export(AudacityProject *project,
|
||||
double quality = (gPrefs->Read(wxT("/FileFormats/OggExportQuality"), 50)/(float)100.0);
|
||||
|
||||
wxLogNull logNo; // temporarily disable wxWidgets error messages
|
||||
int updateResult = eProgressSuccess;
|
||||
auto updateResult = ProgressResult::Success;
|
||||
int eos = 0;
|
||||
|
||||
FileIO outFile(fName, FileIO::Output);
|
||||
|
||||
if (!outFile.IsOpened()) {
|
||||
wxMessageBox(_("Unable to open target file for writing"));
|
||||
return false;
|
||||
return ProgressResult::Cancelled;
|
||||
}
|
||||
|
||||
// All the Ogg and Vorbis encoding data
|
||||
@ -199,7 +199,7 @@ int ExportOGG::Export(AudacityProject *project,
|
||||
|
||||
// Retrieve tags
|
||||
if (!FillComment(project, &comment, metadata)) {
|
||||
return false;
|
||||
return ProgressResult::Cancelled;
|
||||
}
|
||||
|
||||
// Set up analysis state and auxiliary encoding storage
|
||||
@ -253,7 +253,7 @@ int ExportOGG::Export(AudacityProject *project,
|
||||
_("Exporting the selected audio as Ogg Vorbis") :
|
||||
_("Exporting the entire project as Ogg Vorbis"));
|
||||
|
||||
while (updateResult == eProgressSuccess && !eos) {
|
||||
while (updateResult == ProgressResult::Success && !eos) {
|
||||
float **vorbis_buffer = vorbis_analysis_buffer(&dsp, SAMPLES_PER_RUN);
|
||||
auto samplesThisRun = mixer->Process(SAMPLES_PER_RUN);
|
||||
|
||||
|
@ -313,7 +313,7 @@ public:
|
||||
// Required
|
||||
|
||||
wxWindow *OptionsCreate(wxWindow *parent, int format);
|
||||
int Export(AudacityProject *project,
|
||||
ProgressResult Export(AudacityProject *project,
|
||||
unsigned channels,
|
||||
const wxString &fName,
|
||||
bool selectedOnly,
|
||||
@ -384,7 +384,7 @@ ExportPCM::ExportPCM()
|
||||
* @param subformat Control whether we are doing a "preset" export to a popular
|
||||
* file type, or giving the user full control over libsndfile.
|
||||
*/
|
||||
int ExportPCM::Export(AudacityProject *project,
|
||||
ProgressResult ExportPCM::Export(AudacityProject *project,
|
||||
unsigned numChannels,
|
||||
const wxString &fName,
|
||||
bool selectionOnly,
|
||||
@ -407,7 +407,7 @@ int ExportPCM::Export(AudacityProject *project,
|
||||
sf_format = kFormats[subformat].format;
|
||||
}
|
||||
|
||||
int updateResult = eProgressSuccess;
|
||||
auto updateResult = ProgressResult::Success;
|
||||
{
|
||||
wxFile f; // will be closed when it goes out of scope
|
||||
SFFile sf; // wraps f
|
||||
@ -436,7 +436,7 @@ int ExportPCM::Export(AudacityProject *project,
|
||||
info.format = (info.format & SF_FORMAT_TYPEMASK);
|
||||
if (!sf_format_check(&info)) {
|
||||
wxMessageBox(_("Cannot export audio in this format."));
|
||||
return false;
|
||||
return ProgressResult::Cancelled;
|
||||
}
|
||||
|
||||
if (f.Open(fName, wxFile::write)) {
|
||||
@ -451,7 +451,7 @@ int ExportPCM::Export(AudacityProject *project,
|
||||
if (!sf) {
|
||||
wxMessageBox(wxString::Format(_("Cannot export audio to %s"),
|
||||
fName.c_str()));
|
||||
return false;
|
||||
return ProgressResult::Cancelled;
|
||||
}
|
||||
// Retrieve tags if not given a set
|
||||
if (metadata == NULL)
|
||||
@ -462,7 +462,7 @@ int ExportPCM::Export(AudacityProject *project,
|
||||
if ((sf_format & SF_FORMAT_TYPEMASK) != SF_FORMAT_WAV &&
|
||||
(sf_format & SF_FORMAT_TYPEMASK) != SF_FORMAT_WAVEX) {
|
||||
if (!AddStrings(project, sf.get(), metadata, sf_format)) {
|
||||
return false;
|
||||
return ProgressResult::Cancelled;
|
||||
}
|
||||
}
|
||||
|
||||
@ -491,7 +491,7 @@ int ExportPCM::Export(AudacityProject *project,
|
||||
wxString::Format(_("Exporting the entire project as %s"),
|
||||
formatStr.c_str()));
|
||||
|
||||
while (updateResult == eProgressSuccess) {
|
||||
while (updateResult == ProgressResult::Success) {
|
||||
sf_count_t samplesWritten;
|
||||
auto numSamples = mixer->Process(maxBlockLen);
|
||||
|
||||
@ -526,7 +526,7 @@ int ExportPCM::Export(AudacityProject *project,
|
||||
if ((sf_format & SF_FORMAT_TYPEMASK) == SF_FORMAT_WAV ||
|
||||
(sf_format & SF_FORMAT_TYPEMASK) == SF_FORMAT_WAVEX) {
|
||||
if (!AddStrings(project, sf.get(), metadata, sf_format)) {
|
||||
return false;
|
||||
return ProgressResult::Cancelled;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -517,11 +517,9 @@ bool Importer::Import(const wxString &fName,
|
||||
else
|
||||
inFile->SetStreamUsage(0,TRUE);
|
||||
|
||||
int res;
|
||||
auto res = inFile->Import(trackFactory, tracks, tags);
|
||||
|
||||
res = inFile->Import(trackFactory, tracks, tags);
|
||||
|
||||
if (res == eProgressSuccess || res == eProgressStopped)
|
||||
if (res == ProgressResult::Success || res == ProgressResult::Stopped)
|
||||
{
|
||||
// LOF ("list-of-files") has different semantics
|
||||
if (extension.IsSameAs(wxT("lof"), false))
|
||||
@ -538,7 +536,7 @@ bool Importer::Import(const wxString &fName,
|
||||
}
|
||||
}
|
||||
|
||||
if (res == eProgressCancelled || res == eProgressFailed)
|
||||
if (res == ProgressResult::Cancelled || res == ProgressResult::Failed)
|
||||
{
|
||||
pProj->mbBusyImporting = false;
|
||||
return false;
|
||||
|
@ -208,7 +208,7 @@ public:
|
||||
|
||||
///! Imports audio
|
||||
///\return import status (see Import.cpp)
|
||||
int Import(TrackFactory *trackFactory, TrackHolders &outTracks,
|
||||
ProgressResult Import(TrackFactory *trackFactory, TrackHolders &outTracks,
|
||||
Tags *tags) override;
|
||||
|
||||
///! Reads next audio frame
|
||||
@ -223,8 +223,7 @@ public:
|
||||
|
||||
///! Writes decoded data into WaveTracks. Called by DecodeFrame
|
||||
///\param sc - stream context
|
||||
///\return 0 on success, 1 on error or interruption
|
||||
int WriteData(streamContext *sc);
|
||||
ProgressResult WriteData(streamContext *sc);
|
||||
|
||||
///! Writes extracted metadata to tags object
|
||||
///\param avf - file context
|
||||
@ -467,7 +466,7 @@ auto FFmpegImportFileHandle::GetFileUncompressedBytes() -> ByteCount
|
||||
return 0;
|
||||
}
|
||||
|
||||
int FFmpegImportFileHandle::Import(TrackFactory *trackFactory,
|
||||
ProgressResult FFmpegImportFileHandle::Import(TrackFactory *trackFactory,
|
||||
TrackHolders &outTracks,
|
||||
Tags *tags)
|
||||
{
|
||||
@ -572,7 +571,7 @@ int FFmpegImportFileHandle::Import(TrackFactory *trackFactory,
|
||||
}
|
||||
// This is the heart of the importing process
|
||||
// The result of Import() to be returend. It will be something other than zero if user canceled or some error appears.
|
||||
int res = eProgressSuccess;
|
||||
auto res = ProgressResult::Success;
|
||||
|
||||
#ifdef EXPERIMENTAL_OD_FFMPEG
|
||||
mUsingOD = false;
|
||||
@ -623,27 +622,27 @@ int FFmpegImportFileHandle::Import(TrackFactory *trackFactory,
|
||||
sc->m_stream->codec->channels * mNumStreams
|
||||
).as_long_long()
|
||||
);
|
||||
if (res != eProgressSuccess)
|
||||
if (res != ProgressResult::Success)
|
||||
break;
|
||||
}
|
||||
}
|
||||
tasks.push_back(std::move(odTask));
|
||||
}
|
||||
//Now we add the tasks and let them run, or DELETE them if the user cancelled
|
||||
if (res == eProgressSuccess)
|
||||
if (res == ProgressResult::Success)
|
||||
for (int i = 0; i < (int)tasks.size(); i++)
|
||||
ODManager::Instance()->AddNewTask(std::move(tasks[i]));
|
||||
} else {
|
||||
#endif
|
||||
|
||||
// Read next frame.
|
||||
for (streamContext *sc; (sc = ReadNextFrame()) != NULL && (res == eProgressSuccess);)
|
||||
for (streamContext *sc; (sc = ReadNextFrame()) != NULL && (res == ProgressResult::Success);)
|
||||
{
|
||||
// ReadNextFrame returns 1 if stream is not to be imported
|
||||
if (sc != (streamContext*)1)
|
||||
{
|
||||
// Decode frame until it is not possible to decode any further
|
||||
while (sc->m_pktRemainingSiz > 0 && (res == eProgressSuccess || res == eProgressStopped))
|
||||
while (sc->m_pktRemainingSiz > 0 && (res == ProgressResult::Success || res == ProgressResult::Stopped))
|
||||
{
|
||||
if (DecodeFrame(sc,false) < 0)
|
||||
break;
|
||||
@ -659,7 +658,7 @@ int FFmpegImportFileHandle::Import(TrackFactory *trackFactory,
|
||||
}
|
||||
|
||||
// Flush the decoders.
|
||||
if ((mNumStreams != 0) && (res == eProgressSuccess || res == eProgressStopped))
|
||||
if ((mNumStreams != 0) && (res == ProgressResult::Success || res == ProgressResult::Stopped))
|
||||
{
|
||||
for (int i = 0; i < mNumStreams; i++)
|
||||
{
|
||||
@ -678,7 +677,7 @@ int FFmpegImportFileHandle::Import(TrackFactory *trackFactory,
|
||||
#endif //EXPERIMENTAL_OD_FFMPEG
|
||||
|
||||
// Something bad happened - destroy everything!
|
||||
if (res == eProgressCancelled || res == eProgressFailed)
|
||||
if (res == ProgressResult::Cancelled || res == ProgressResult::Failed)
|
||||
return res;
|
||||
//else if (res == 2), we just stop the decoding as if the file has ended
|
||||
|
||||
@ -712,7 +711,7 @@ int FFmpegImportFileHandle::DecodeFrame(streamContext *sc, bool flushing)
|
||||
return import_ffmpeg_decode_frame(sc, flushing);
|
||||
}
|
||||
|
||||
int FFmpegImportFileHandle::WriteData(streamContext *sc)
|
||||
ProgressResult FFmpegImportFileHandle::WriteData(streamContext *sc)
|
||||
{
|
||||
// Find the stream index in mScs array
|
||||
int streamid = -1;
|
||||
@ -729,7 +728,7 @@ int FFmpegImportFileHandle::WriteData(streamContext *sc)
|
||||
// Stream is not found. This should not really happen
|
||||
if (streamid == -1)
|
||||
{
|
||||
return 1;
|
||||
return ProgressResult::Success;
|
||||
}
|
||||
|
||||
// Allocate the buffer to store audio.
|
||||
@ -785,7 +784,7 @@ int FFmpegImportFileHandle::WriteData(streamContext *sc)
|
||||
free(tmp[chn]);
|
||||
}
|
||||
free(tmp);
|
||||
return 1;
|
||||
return ProgressResult::Success;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -806,7 +805,7 @@ int FFmpegImportFileHandle::WriteData(streamContext *sc)
|
||||
free(tmp);
|
||||
|
||||
// Try to update the progress indicator (and see if user wants to cancel)
|
||||
int updateResult = eProgressSuccess;
|
||||
auto updateResult = ProgressResult::Success;
|
||||
int64_t filesize = avio_size(mFormatContext->pb);
|
||||
// PTS (presentation time) is the proper way of getting current position
|
||||
if (sc->m_pkt->pts != int64_t(AV_NOPTS_VALUE) && mFormatContext->duration != int64_t(AV_NOPTS_VALUE))
|
||||
|
@ -154,7 +154,7 @@ public:
|
||||
|
||||
wxString GetFileDescription() override;
|
||||
ByteCount GetFileUncompressedBytes() override;
|
||||
int Import(TrackFactory *trackFactory, TrackHolders &outTracks,
|
||||
ProgressResult Import(TrackFactory *trackFactory, TrackHolders &outTracks,
|
||||
Tags *tags) override;
|
||||
|
||||
wxInt32 GetStreamCount() override { return 1; }
|
||||
@ -178,7 +178,7 @@ private:
|
||||
FLAC__uint64 mNumSamples;
|
||||
FLAC__uint64 mSamplesDone;
|
||||
bool mStreamInfoDone;
|
||||
int mUpdateResult;
|
||||
ProgressResult mUpdateResult;
|
||||
TrackHolders mChannels;
|
||||
movable_ptr<ODDecodeFlacTask> mDecoderTask;
|
||||
};
|
||||
@ -277,7 +277,7 @@ FLAC__StreamDecoderWriteStatus MyFLACFile::write_callback(const FLAC__Frame *fra
|
||||
mFile->mSamplesDone += frame->header.blocksize;
|
||||
|
||||
mFile->mUpdateResult = mFile->mProgress->Update((wxULongLong_t) mFile->mSamplesDone, mFile->mNumSamples != 0 ? (wxULongLong_t)mFile->mNumSamples : 1);
|
||||
if (mFile->mUpdateResult != eProgressSuccess)
|
||||
if (mFile->mUpdateResult != ProgressResult::Success)
|
||||
{
|
||||
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
|
||||
}
|
||||
@ -345,7 +345,7 @@ FLACImportFileHandle::FLACImportFileHandle(const wxString & name)
|
||||
: ImportFileHandle(name),
|
||||
mSamplesDone(0),
|
||||
mStreamInfoDone(false),
|
||||
mUpdateResult(eProgressSuccess)
|
||||
mUpdateResult(ProgressResult::Success)
|
||||
{
|
||||
mFormat = (sampleFormat)
|
||||
gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleFormat"), floatSample);
|
||||
@ -439,7 +439,7 @@ auto FLACImportFileHandle::GetFileUncompressedBytes() -> ByteCount
|
||||
}
|
||||
|
||||
|
||||
int FLACImportFileHandle::Import(TrackFactory *trackFactory,
|
||||
ProgressResult FLACImportFileHandle::Import(TrackFactory *trackFactory,
|
||||
TrackHolders &outTracks,
|
||||
Tags *tags)
|
||||
{
|
||||
@ -507,7 +507,7 @@ int FLACImportFileHandle::Import(TrackFactory *trackFactory,
|
||||
i.as_long_long(),
|
||||
fileTotalFrames.as_long_long()
|
||||
);
|
||||
if (mUpdateResult != eProgressSuccess)
|
||||
if (mUpdateResult != ProgressResult::Success)
|
||||
break;
|
||||
}
|
||||
|
||||
@ -529,7 +529,7 @@ int FLACImportFileHandle::Import(TrackFactory *trackFactory,
|
||||
//END OD
|
||||
|
||||
|
||||
if (mUpdateResult == eProgressFailed || mUpdateResult == eProgressCancelled) {
|
||||
if (mUpdateResult == ProgressResult::Failed || mUpdateResult == ProgressResult::Cancelled) {
|
||||
return mUpdateResult;
|
||||
}
|
||||
|
||||
|
@ -1088,7 +1088,7 @@ GStreamerImportFileHandle::Import(TrackFactory *trackFactory,
|
||||
{
|
||||
wxMessageBox(wxT("File doesn't contain any audio streams."),
|
||||
wxT("GStreamer Importer"));
|
||||
return eProgressFailed;
|
||||
return ProgressResult::Failed;
|
||||
}
|
||||
|
||||
// Get the ball rolling...
|
||||
@ -1097,7 +1097,7 @@ GStreamerImportFileHandle::Import(TrackFactory *trackFactory,
|
||||
{
|
||||
wxMessageBox(wxT("Unable to import file, state change failed."),
|
||||
wxT("GStreamer Importer"));
|
||||
return eProgressFailed;
|
||||
return ProgressResult::Failed;
|
||||
}
|
||||
|
||||
// Get the duration of the stream
|
||||
@ -1106,8 +1106,8 @@ GStreamerImportFileHandle::Import(TrackFactory *trackFactory,
|
||||
|
||||
// Handle bus messages and update progress while files is importing
|
||||
bool success = true;
|
||||
int updateResult = eProgressSuccess;
|
||||
while (ProcessBusMessage(success) && success && updateResult == eProgressSuccess)
|
||||
int updateResult = ProgressResult::Success;
|
||||
while (ProcessBusMessage(success) && success && updateResult == ProgressResult::Success)
|
||||
{
|
||||
gint64 position;
|
||||
|
||||
@ -1123,7 +1123,7 @@ GStreamerImportFileHandle::Import(TrackFactory *trackFactory,
|
||||
gst_element_set_state(mPipeline.get(), GST_STATE_NULL);
|
||||
|
||||
// Something bad happened
|
||||
if (!success || updateResult == eProgressFailed || updateResult == eProgressCancelled)
|
||||
if (!success || updateResult == ProgressResult::Failed || updateResult == ProgressResult::Cancelled)
|
||||
{
|
||||
return updateResult;
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ public:
|
||||
|
||||
wxString GetFileDescription() override;
|
||||
ByteCount GetFileUncompressedBytes() override;
|
||||
int Import(TrackFactory *trackFactory, TrackHolders &outTracks,
|
||||
ProgressResult Import(TrackFactory *trackFactory, TrackHolders &outTracks,
|
||||
Tags *tags) override;
|
||||
|
||||
wxInt32 GetStreamCount() override { return 1; }
|
||||
@ -232,7 +232,7 @@ auto LOFImportFileHandle::GetFileUncompressedBytes() -> ByteCount
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LOFImportFileHandle::Import(TrackFactory * WXUNUSED(trackFactory), TrackHolders &outTracks,
|
||||
ProgressResult LOFImportFileHandle::Import(TrackFactory * WXUNUSED(trackFactory), TrackHolders &outTracks,
|
||||
Tags * WXUNUSED(tags))
|
||||
{
|
||||
outTracks.clear();
|
||||
@ -242,7 +242,7 @@ int LOFImportFileHandle::Import(TrackFactory * WXUNUSED(trackFactory), TrackHold
|
||||
if(mTextFile->Eof())
|
||||
{
|
||||
mTextFile->Close();
|
||||
return eProgressFailed;
|
||||
return ProgressResult::Failed;
|
||||
}
|
||||
|
||||
wxString line = mTextFile->GetFirstLine();
|
||||
@ -262,9 +262,9 @@ int LOFImportFileHandle::Import(TrackFactory * WXUNUSED(trackFactory), TrackHold
|
||||
|
||||
// exited ok
|
||||
if(mTextFile->Close())
|
||||
return eProgressSuccess;
|
||||
return ProgressResult::Success;
|
||||
|
||||
return eProgressFailed;
|
||||
return ProgressResult::Failed;
|
||||
}
|
||||
|
||||
static int CountNumTracks(AudacityProject *proj)
|
||||
|
@ -100,7 +100,7 @@ struct private_data {
|
||||
TrackHolders channels;
|
||||
ProgressDialog *progress;
|
||||
unsigned numChannels;
|
||||
int updateResult;
|
||||
ProgressResult updateResult;
|
||||
bool id3checked;
|
||||
bool eof; /* having supplied both underlying file and guard pad data */
|
||||
};
|
||||
@ -133,7 +133,7 @@ public:
|
||||
|
||||
wxString GetFileDescription() override;
|
||||
ByteCount GetFileUncompressedBytes() override;
|
||||
int Import(TrackFactory *trackFactory, TrackHolders &outTracks,
|
||||
ProgressResult Import(TrackFactory *trackFactory, TrackHolders &outTracks,
|
||||
Tags *tags) override;
|
||||
|
||||
wxInt32 GetStreamCount() override { return 1; }
|
||||
@ -208,7 +208,7 @@ auto MP3ImportFileHandle::GetFileUncompressedBytes() -> ByteCount
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MP3ImportFileHandle::Import(TrackFactory *trackFactory, TrackHolders &outTracks,
|
||||
ProgressResult MP3ImportFileHandle::Import(TrackFactory *trackFactory, TrackHolders &outTracks,
|
||||
Tags *tags)
|
||||
{
|
||||
outTracks.clear();
|
||||
@ -221,7 +221,7 @@ int MP3ImportFileHandle::Import(TrackFactory *trackFactory, TrackHolders &outTra
|
||||
mPrivateData.inputBuffer = new unsigned char [INPUT_BUFFER_SIZE];
|
||||
mPrivateData.inputBufferFill = 0;
|
||||
mPrivateData.progress = mProgress.get();
|
||||
mPrivateData.updateResult= eProgressSuccess;
|
||||
mPrivateData.updateResult= ProgressResult::Success;
|
||||
mPrivateData.id3checked = false;
|
||||
mPrivateData.numChannels = 0;
|
||||
mPrivateData.trackFactory= trackFactory;
|
||||
@ -233,8 +233,8 @@ int MP3ImportFileHandle::Import(TrackFactory *trackFactory, TrackHolders &outTra
|
||||
|
||||
bool res = (mad_decoder_run(&mDecoder, MAD_DECODER_MODE_SYNC) == 0) &&
|
||||
(mPrivateData.numChannels > 0) &&
|
||||
!(mPrivateData.updateResult == eProgressCancelled) &&
|
||||
!(mPrivateData.updateResult == eProgressFailed);
|
||||
!(mPrivateData.updateResult == ProgressResult::Cancelled) &&
|
||||
!(mPrivateData.updateResult == ProgressResult::Failed);
|
||||
|
||||
mad_decoder_finish(&mDecoder);
|
||||
|
||||
@ -406,7 +406,7 @@ enum mad_flow input_cb(void *_data, struct mad_stream *stream)
|
||||
data->updateResult = data->progress->Update((wxULongLong_t)data->file->Tell(),
|
||||
(wxULongLong_t)data->file->Length() != 0 ?
|
||||
(wxULongLong_t)data->file->Length() : 1);
|
||||
if(data->updateResult != eProgressSuccess)
|
||||
if(data->updateResult != ProgressResult::Success)
|
||||
return MAD_FLOW_STOP;
|
||||
|
||||
if (data->eof) {
|
||||
|
@ -124,7 +124,7 @@ public:
|
||||
|
||||
wxString GetFileDescription() override;
|
||||
ByteCount GetFileUncompressedBytes() override;
|
||||
int Import(TrackFactory *trackFactory, TrackHolders &outTracks,
|
||||
ProgressResult Import(TrackFactory *trackFactory, TrackHolders &outTracks,
|
||||
Tags *tags) override;
|
||||
|
||||
wxInt32 GetStreamCount() override
|
||||
@ -229,7 +229,7 @@ auto OggImportFileHandle::GetFileUncompressedBytes() -> ByteCount
|
||||
return 0;
|
||||
}
|
||||
|
||||
int OggImportFileHandle::Import(TrackFactory *trackFactory, TrackHolders &outTracks,
|
||||
ProgressResult OggImportFileHandle::Import(TrackFactory *trackFactory, TrackHolders &outTracks,
|
||||
Tags *tags)
|
||||
{
|
||||
outTracks.clear();
|
||||
@ -300,7 +300,7 @@ int OggImportFileHandle::Import(TrackFactory *trackFactory, TrackHolders &outTra
|
||||
endian = 1; // big endian
|
||||
|
||||
/* number of samples currently in each channel's buffer */
|
||||
int updateResult = eProgressSuccess;
|
||||
auto updateResult = ProgressResult::Success;
|
||||
long bytesRead = 0;
|
||||
long samplesRead = 0;
|
||||
int bitstream = 0;
|
||||
@ -361,15 +361,15 @@ int OggImportFileHandle::Import(TrackFactory *trackFactory, TrackHolders &outTra
|
||||
samplesSinceLastCallback -= SAMPLES_PER_CALLBACK;
|
||||
|
||||
}
|
||||
} while (updateResult == eProgressSuccess && bytesRead != 0);
|
||||
} while (updateResult == ProgressResult::Success && bytesRead != 0);
|
||||
|
||||
delete[]mainBuffer;
|
||||
|
||||
int res = updateResult;
|
||||
auto res = updateResult;
|
||||
if (bytesRead < 0)
|
||||
res = eProgressFailed;
|
||||
res = ProgressResult::Failed;
|
||||
|
||||
if (res == eProgressFailed || res == eProgressCancelled) {
|
||||
if (res == ProgressResult::Failed || res == ProgressResult::Cancelled) {
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ public:
|
||||
|
||||
wxString GetFileDescription() override;
|
||||
ByteCount GetFileUncompressedBytes() override;
|
||||
int Import(TrackFactory *trackFactory, TrackHolders &outTracks,
|
||||
ProgressResult Import(TrackFactory *trackFactory, TrackHolders &outTracks,
|
||||
Tags *tags) override;
|
||||
|
||||
wxInt32 GetStreamCount() override { return 1; }
|
||||
@ -324,7 +324,7 @@ How do you want to import the current file(s)?"), oldCopyPref == wxT("copy") ? _
|
||||
return oldCopyPref;
|
||||
}
|
||||
|
||||
int PCMImportFileHandle::Import(TrackFactory *trackFactory,
|
||||
ProgressResult PCMImportFileHandle::Import(TrackFactory *trackFactory,
|
||||
TrackHolders &outTracks,
|
||||
Tags *tags)
|
||||
{
|
||||
@ -336,7 +336,7 @@ int PCMImportFileHandle::Import(TrackFactory *trackFactory,
|
||||
wxString copyEdit = AskCopyOrEdit();
|
||||
|
||||
if (copyEdit == wxT("cancel"))
|
||||
return eProgressCancelled;
|
||||
return ProgressResult::Cancelled;
|
||||
|
||||
// Fall back to "copy" if it doesn't match anything else, since it is safer
|
||||
bool doEdit = false;
|
||||
@ -372,7 +372,7 @@ int PCMImportFileHandle::Import(TrackFactory *trackFactory,
|
||||
auto fileTotalFrames =
|
||||
(sampleCount)mInfo.frames; // convert from sf_count_t
|
||||
auto maxBlockSize = channels.begin()->get()->GetMaxBlockSize();
|
||||
int updateResult = false;
|
||||
auto updateResult = ProgressResult::Cancelled;
|
||||
|
||||
// If the format is not seekable, we must use 'copy' mode,
|
||||
// because 'edit' mode depends on the ability to seek to an
|
||||
@ -405,7 +405,7 @@ int PCMImportFileHandle::Import(TrackFactory *trackFactory,
|
||||
fileTotalFrames.as_long_long()
|
||||
);
|
||||
updateCounter = 0;
|
||||
if (updateResult != eProgressSuccess)
|
||||
if (updateResult != ProgressResult::Success)
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -443,13 +443,13 @@ int PCMImportFileHandle::Import(TrackFactory *trackFactory,
|
||||
// PRL: guard against excessive memory buffer allocation in case of many channels
|
||||
using type = decltype(maxBlockSize);
|
||||
if (mInfo.channels < 1)
|
||||
return eProgressFailed;
|
||||
return ProgressResult::Failed;
|
||||
auto maxBlock = std::min(maxBlockSize,
|
||||
std::numeric_limits<type>::max() /
|
||||
(mInfo.channels * SAMPLE_SIZE(mFormat))
|
||||
);
|
||||
if (maxBlock < 1)
|
||||
return eProgressFailed;
|
||||
return ProgressResult::Failed;
|
||||
|
||||
SampleBuffer srcbuffer;
|
||||
wxASSERT(mInfo.channels >= 0);
|
||||
@ -457,7 +457,7 @@ int PCMImportFileHandle::Import(TrackFactory *trackFactory,
|
||||
{
|
||||
maxBlock /= 2;
|
||||
if (maxBlock < 1)
|
||||
return eProgressFailed;
|
||||
return ProgressResult::Failed;
|
||||
}
|
||||
|
||||
SampleBuffer buffer(maxBlock, mFormat);
|
||||
@ -497,13 +497,13 @@ int PCMImportFileHandle::Import(TrackFactory *trackFactory,
|
||||
framescompleted.as_long_long(),
|
||||
fileTotalFrames.as_long_long()
|
||||
);
|
||||
if (updateResult != eProgressSuccess)
|
||||
if (updateResult != ProgressResult::Success)
|
||||
break;
|
||||
|
||||
} while (block > 0);
|
||||
}
|
||||
|
||||
if (updateResult == eProgressFailed || updateResult == eProgressCancelled) {
|
||||
if (updateResult == ProgressResult::Failed || updateResult == ProgressResult::Cancelled) {
|
||||
return updateResult;
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,7 @@ public:
|
||||
// do the actual import, creating whatever tracks are necessary with
|
||||
// the TrackFactory and calling the progress callback every iteration
|
||||
// through the importing loop
|
||||
virtual int Import(TrackFactory *trackFactory, TrackHolders &outTracks,
|
||||
virtual ProgressResult Import(TrackFactory *trackFactory, TrackHolders &outTracks,
|
||||
Tags *tags) = 0;
|
||||
|
||||
// Return number of elements in stream list
|
||||
|
@ -157,7 +157,7 @@ class QTImportFileHandle final : public ImportFileHandle
|
||||
{
|
||||
}
|
||||
|
||||
int Import(TrackFactory *trackFactory,
|
||||
ProgressResult Import(TrackFactory *trackFactory,
|
||||
TrackHolders &outTracks,
|
||||
Tags *tags) override;
|
||||
|
||||
@ -229,7 +229,7 @@ auto QTImportFileHandle::GetFileUncompressedBytes() -> ByteCount
|
||||
return 0;
|
||||
}
|
||||
|
||||
int QTImportFileHandle::Import(TrackFactory *trackFactory,
|
||||
ProgressResult QTImportFileHandle::Import(TrackFactory *trackFactory,
|
||||
TrackHolders &outTracks,
|
||||
Tags *tags)
|
||||
{
|
||||
@ -237,7 +237,7 @@ int QTImportFileHandle::Import(TrackFactory *trackFactory,
|
||||
|
||||
OSErr err = noErr;
|
||||
MovieAudioExtractionRef maer = NULL;
|
||||
int updateResult = eProgressSuccess;
|
||||
auto updateResult = ProgressResult::Success;
|
||||
auto totSamples =
|
||||
(sampleCount) GetMovieDuration(mMovie); // convert from TimeValue
|
||||
decltype(totSamples) numSamples = 0;
|
||||
@ -372,9 +372,9 @@ int QTImportFileHandle::Import(TrackFactory *trackFactory,
|
||||
if (numFrames == 0 || flags & kQTMovieAudioExtractionComplete) {
|
||||
break;
|
||||
}
|
||||
} while (updateResult == eProgressSuccess);
|
||||
} while (updateResult == ProgressResult::Success);
|
||||
|
||||
res = (updateResult == eProgressSuccess && err == noErr);
|
||||
res = (updateResult == ProgressResult::Success && err == noErr);
|
||||
|
||||
if (res) {
|
||||
for (const auto &channel: channels) {
|
||||
@ -403,7 +403,7 @@ int QTImportFileHandle::Import(TrackFactory *trackFactory,
|
||||
MovieAudioExtractionEnd(maer);
|
||||
}
|
||||
|
||||
return (res ? eProgressSuccess : eProgressFailed);
|
||||
return (res ? ProgressResult::Success : ProgressResult::Failed);
|
||||
}
|
||||
|
||||
static const struct
|
||||
|
@ -102,7 +102,7 @@ void ImportRaw(wxWindow *parent, const wxString &fileName,
|
||||
double rate = 44100.0;
|
||||
double percent = 100.0;
|
||||
TrackHolders channels;
|
||||
int updateResult = eProgressSuccess;
|
||||
auto updateResult = ProgressResult::Success;
|
||||
|
||||
{
|
||||
SF_INFO sndInfo;
|
||||
@ -255,7 +255,7 @@ void ImportRaw(wxWindow *parent, const wxString &fileName,
|
||||
// This is not supposed to happen, sndfile.h says result is always
|
||||
// a count, not an invalid value for error
|
||||
wxASSERT(false);
|
||||
updateResult = eProgressFailed;
|
||||
updateResult = ProgressResult::Failed;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -282,13 +282,13 @@ void ImportRaw(wxWindow *parent, const wxString &fileName,
|
||||
framescompleted.as_long_long(),
|
||||
totalFrames.as_long_long()
|
||||
);
|
||||
if (updateResult != eProgressSuccess)
|
||||
if (updateResult != ProgressResult::Success)
|
||||
break;
|
||||
|
||||
} while (block > 0 && framescompleted < totalFrames);
|
||||
}
|
||||
|
||||
if (updateResult == eProgressFailed || updateResult == eProgressCancelled) {
|
||||
if (updateResult == ProgressResult::Failed || updateResult == ProgressResult::Cancelled) {
|
||||
// It's a shame we can't return proper error code
|
||||
return;
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ FLAC__StreamDecoderWriteStatus ODFLACFile::write_callback(const FLAC__Frame *fra
|
||||
|
||||
// mDecoder->mUpdateResult = mDecoder->mProgress->Update((wxULongLong_t) mDecoder->mSamplesDone, mDecoder->mNumSamples != 0 ? (wxULongLong_t)mDecoder->mNumSamples : 1);
|
||||
/*
|
||||
if (mDecoder->mUpdateResult != eProgressSuccess)
|
||||
if (mDecoder->mUpdateResult != ProgressResult::Success)
|
||||
{
|
||||
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
|
||||
}
|
||||
|
@ -1268,16 +1268,16 @@ bool ProgressDialog::Create(const wxString & title,
|
||||
//
|
||||
// Update the time and, optionally, the message
|
||||
//
|
||||
int ProgressDialog::Update(int value, const wxString & message)
|
||||
ProgressResult ProgressDialog::Update(int value, const wxString & message)
|
||||
{
|
||||
if (mCancel)
|
||||
{
|
||||
// for compatibility with old Update, that returned false on cancel
|
||||
return eProgressCancelled;
|
||||
return ProgressResult::Cancelled;
|
||||
}
|
||||
else if (mStop)
|
||||
{
|
||||
return eProgressStopped;
|
||||
return ProgressResult::Stopped;
|
||||
}
|
||||
|
||||
wxLongLong_t now = wxGetLocalTimeMillis().GetValue();
|
||||
@ -1285,7 +1285,7 @@ int ProgressDialog::Update(int value, const wxString & message)
|
||||
|
||||
if (elapsed < 500)
|
||||
{
|
||||
return eProgressSuccess;
|
||||
return ProgressResult::Success;
|
||||
}
|
||||
|
||||
if (mIsTransparent)
|
||||
@ -1355,13 +1355,13 @@ int ProgressDialog::Update(int value, const wxString & message)
|
||||
mYieldTimer = now;
|
||||
}
|
||||
|
||||
return eProgressSuccess;
|
||||
return ProgressResult::Success;
|
||||
}
|
||||
|
||||
//
|
||||
// Update the time and, optionally, the message
|
||||
//
|
||||
int ProgressDialog::Update(double current, const wxString & message)
|
||||
ProgressResult ProgressDialog::Update(double current, const wxString & message)
|
||||
{
|
||||
return Update((int)(current * 1000), message);
|
||||
}
|
||||
@ -1369,7 +1369,7 @@ int ProgressDialog::Update(double current, const wxString & message)
|
||||
//
|
||||
// Update the time and, optionally, the message
|
||||
//
|
||||
int ProgressDialog::Update(wxULongLong_t current, wxULongLong_t total, const wxString & message)
|
||||
ProgressResult ProgressDialog::Update(wxULongLong_t current, wxULongLong_t total, const wxString & message)
|
||||
{
|
||||
if (total != 0)
|
||||
{
|
||||
@ -1384,7 +1384,7 @@ int ProgressDialog::Update(wxULongLong_t current, wxULongLong_t total, const wxS
|
||||
//
|
||||
// Update the time and, optionally, the message
|
||||
//
|
||||
int ProgressDialog::Update(wxLongLong current, wxLongLong total, const wxString & message)
|
||||
ProgressResult ProgressDialog::Update(wxLongLong current, wxLongLong total, const wxString & message)
|
||||
{
|
||||
if (total.GetValue() != 0)
|
||||
{
|
||||
@ -1399,7 +1399,7 @@ int ProgressDialog::Update(wxLongLong current, wxLongLong total, const wxString
|
||||
//
|
||||
// Update the time and, optionally, the message
|
||||
//
|
||||
int ProgressDialog::Update(wxLongLong_t current, wxLongLong_t total, const wxString & message)
|
||||
ProgressResult ProgressDialog::Update(wxLongLong_t current, wxLongLong_t total, const wxString & message)
|
||||
{
|
||||
if (total != 0)
|
||||
{
|
||||
@ -1414,7 +1414,7 @@ int ProgressDialog::Update(wxLongLong_t current, wxLongLong_t total, const wxStr
|
||||
//
|
||||
// Update the time and, optionally, the message
|
||||
//
|
||||
int ProgressDialog::Update(int current, int total, const wxString & message)
|
||||
ProgressResult ProgressDialog::Update(int current, int total, const wxString & message)
|
||||
{
|
||||
if (total != 0)
|
||||
{
|
||||
@ -1429,7 +1429,7 @@ int ProgressDialog::Update(int current, int total, const wxString & message)
|
||||
//
|
||||
// Update the time and, optionally, the message
|
||||
//
|
||||
int ProgressDialog::Update(double current, double total, const wxString & message)
|
||||
ProgressResult ProgressDialog::Update(double current, double total, const wxString & message)
|
||||
{
|
||||
if (total != 0)
|
||||
{
|
||||
@ -1597,16 +1597,16 @@ TimerProgressDialog::TimerProgressDialog(const wxLongLong_t duration,
|
||||
mDuration = duration;
|
||||
}
|
||||
|
||||
int TimerProgressDialog::Update(const wxString & message /*= wxEmptyString*/)
|
||||
ProgressResult TimerProgressDialog::Update(const wxString & message /*= wxEmptyString*/)
|
||||
{
|
||||
if (mCancel)
|
||||
{
|
||||
// for compatibility with old Update, that returned false on cancel
|
||||
return eProgressCancelled;
|
||||
return ProgressResult::Cancelled;
|
||||
}
|
||||
else if (mStop)
|
||||
{
|
||||
return eProgressStopped;
|
||||
return ProgressResult::Stopped;
|
||||
}
|
||||
|
||||
wxLongLong_t now = wxGetLocalTimeMillis().GetValue();
|
||||
@ -1614,7 +1614,7 @@ int TimerProgressDialog::Update(const wxString & message /*= wxEmptyString*/)
|
||||
|
||||
if (elapsed < 500)
|
||||
{
|
||||
return eProgressSuccess;
|
||||
return ProgressResult::Success;
|
||||
}
|
||||
|
||||
if (mIsTransparent)
|
||||
@ -1678,14 +1678,14 @@ int TimerProgressDialog::Update(const wxString & message /*= wxEmptyString*/)
|
||||
wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI | wxEVT_CATEGORY_USER_INPUT | wxEVT_CATEGORY_TIMER);
|
||||
|
||||
// MY: Added this after the YieldFor to check we haven't changed the outcome based on buttons pressed...
|
||||
int iReturn = eProgressSuccess;
|
||||
auto iReturn = ProgressResult::Success;
|
||||
if (mCancel)
|
||||
{
|
||||
iReturn = eProgressCancelled;
|
||||
iReturn = ProgressResult::Cancelled;
|
||||
}
|
||||
else if (mStop)
|
||||
{
|
||||
iReturn = eProgressStopped;
|
||||
iReturn = ProgressResult::Stopped;
|
||||
}
|
||||
return iReturn;
|
||||
}
|
||||
|
@ -30,12 +30,12 @@
|
||||
|
||||
#include "wxPanelWrapper.h"
|
||||
|
||||
enum
|
||||
enum class ProgressResult : unsigned
|
||||
{
|
||||
eProgressCancelled = 0, //<! User says that whatever is happening is undesirable and shouldn't have happened at all
|
||||
eProgressSuccess, //<! User says nothing, everything works fine, continue doing whatever we're doing
|
||||
eProgressFailed, //<! Something has gone wrong, we should stop and cancel everything we did
|
||||
eProgressStopped //<! Nothing is wrong, but user says we should stop now and leave things as they are now
|
||||
Cancelled = 0, //<! User says that whatever is happening is undesirable and shouldn't have happened at all
|
||||
Success, //<! User says nothing, everything works fine, continue doing whatever we're doing
|
||||
Failed, //<! Something has gone wrong, we should stop and cancel everything we did
|
||||
Stopped //<! Nothing is wrong, but user says we should stop now and leave things as they are now
|
||||
};
|
||||
|
||||
enum ProgressDialogFlags
|
||||
@ -69,13 +69,13 @@ public:
|
||||
int flags = pdlgDefaultFlags,
|
||||
const wxString & sRemainingLabelText = wxEmptyString);
|
||||
|
||||
int Update(int value, const wxString & message = wxEmptyString);
|
||||
int Update(double current, const wxString & message = wxEmptyString);
|
||||
int Update(double current, double total, const wxString & message = wxEmptyString);
|
||||
int Update(wxULongLong_t current, wxULongLong_t total, const wxString & message = wxEmptyString);
|
||||
int Update(wxLongLong current, wxLongLong total, const wxString & message = wxEmptyString);
|
||||
int Update(wxLongLong_t current, wxLongLong_t total, const wxString & message = wxEmptyString);
|
||||
int Update(int current, int total, const wxString & message = wxEmptyString);
|
||||
ProgressResult Update(int value, const wxString & message = wxEmptyString);
|
||||
ProgressResult Update(double current, const wxString & message = wxEmptyString);
|
||||
ProgressResult Update(double current, double total, const wxString & message = wxEmptyString);
|
||||
ProgressResult Update(wxULongLong_t current, wxULongLong_t total, const wxString & message = wxEmptyString);
|
||||
ProgressResult Update(wxLongLong current, wxLongLong total, const wxString & message = wxEmptyString);
|
||||
ProgressResult Update(wxLongLong_t current, wxLongLong_t total, const wxString & message = wxEmptyString);
|
||||
ProgressResult Update(int current, int total, const wxString & message = wxEmptyString);
|
||||
void SetMessage(const wxString & message);
|
||||
|
||||
// 'ETB' character to indicate a new column in the message text.
|
||||
@ -137,7 +137,7 @@ public:
|
||||
const wxString & message = wxEmptyString,
|
||||
int flags = pdlgDefaultFlags,
|
||||
const wxString & sRemainingLabelText = wxEmptyString);
|
||||
int Update(const wxString & message = wxEmptyString);
|
||||
ProgressResult Update(const wxString & message = wxEmptyString);
|
||||
|
||||
protected:
|
||||
wxLongLong_t mDuration;
|
||||
|
Loading…
x
Reference in New Issue
Block a user