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