///Runs the wait for start dialog. Returns false if the user clicks stop while we are recording ///so that the high bool TimerRecordDialog::RunWaitDialog() { int updateResult = eProgressSuccess; if (m_DateTime_Start > wxDateTime::UNow()) updateResult = this->WaitForStart(); if (updateResult != eProgressSuccess) { // Don't proceed, but don't treat it as canceled recording. User just canceled waiting. return true; } else { // Record for specified time. AudacityProject* pProject = GetActiveProject(); pProject->OnRecord(); bool bIsRecording = true; wxString strMsg = _("Recording start") + (wxString)wxT(":\t\t") + GetDisplayDate(m_DateTime_Start) + wxT("\n") + _("Recording end") + wxT(":\t\t") + GetDisplayDate(m_DateTime_End) + wxT("\n") + _("Duration") + wxT(":\t\t") + m_TimeSpan_Duration.Format(); TimerProgressDialog progress(m_TimeSpan_Duration.GetMilliseconds().GetValue(), _("Audacity Timer Record Progress"), strMsg, pdlgHideCancelButton); // Make sure that start and end time are updated, so we always get the full // duration, even if there's some delay getting here. wxTimerEvent dummyTimerEvent; this->OnTimer(dummyTimerEvent); // Loop for progress display during recording. while (bIsRecording && (updateResult == eProgressSuccess)) { wxMilliSleep(kTimerInterval); updateResult = progress.Update(); bIsRecording = (wxDateTime::UNow() <= m_DateTime_End); // Call UNow() again for extra accuracy... } pProject->OnStop(); } // Let the caller handle cancellation or failure from recording progress. if (updateResult == eProgressCancelled || updateResult == eProgressFailed) return false; return true; }
ProgressResult TimerRecordDialog::WaitForStart() { // MY: The Waiting For Start dialog now shows what actions will occur after recording has completed wxString sPostAction = m_pTimerAfterCompleteChoiceCtrl->GetString(m_pTimerAfterCompleteChoiceCtrl->GetSelection()); // Two column layout. TimerProgressDialog::MessageTable columns(2); auto &column1 = columns[0]; auto &column2 = columns[1]; column1.push_back(_("Waiting to start recording at:")); column2.push_back(GetDisplayDate(m_DateTime_Start)); column1.push_back(_("Recording duration:")); column2.push_back(m_TimeSpan_Duration.Format()); column1.push_back(_("Scheduled to stop at:")); column2.push_back(GetDisplayDate(m_DateTime_End)); column1.push_back( {} ); column2.push_back( {} ); column1.push_back(_("Automatic Save enabled:")); column2.push_back((m_bAutoSaveEnabled ? _("Yes") : _("No"))); column1.push_back(_("Automatic Export enabled:")); column2.push_back((m_bAutoExportEnabled ? _("Yes") : _("No"))); column1.push_back(_("Action after Timer Recording:")); column2.push_back(sPostAction); wxDateTime startWait_DateTime = wxDateTime::UNow(); wxTimeSpan waitDuration = m_DateTime_Start - startWait_DateTime; TimerProgressDialog progress(waitDuration.GetMilliseconds().GetValue(), _("Audacity Timer Record - Waiting for Start"), columns, pdlgHideStopButton | pdlgConfirmStopCancel | pdlgHideElapsedTime, _("Recording will commence in:")); auto updateResult = ProgressResult::Success; bool bIsRecording = false; while (updateResult == ProgressResult::Success && !bIsRecording) { updateResult = progress.UpdateProgress(); wxMilliSleep(10); bIsRecording = (m_DateTime_Start <= wxDateTime::UNow()); } return updateResult; }
int TimerRecordDialog::WaitForStart() { wxString strMsg; /* i18n-hint: A time specification like "Sunday 28th October 2007 15:16:17 GMT" * but hopefully translated by wxwidgets will be inserted into this */ strMsg.Printf(_("Waiting to start recording at %s.\n"), GetDisplayDate(m_DateTime_Start).c_str()); wxDateTime startWait_DateTime = wxDateTime::UNow(); wxTimeSpan waitDuration = m_DateTime_Start - startWait_DateTime; TimerProgressDialog progress(waitDuration.GetMilliseconds().GetValue(), _("Audacity Timer Record - Waiting for Start"), strMsg, pdlgHideStopButton); int updateResult = eProgressSuccess; bool bIsRecording = false; while (updateResult == eProgressSuccess && !bIsRecording) { wxMilliSleep(10); updateResult = progress.Update(); bIsRecording = (m_DateTime_Start <= wxDateTime::UNow()); } return updateResult; }
bool TimerRecordDialog::WaitForStart() { wxString strMsg; /* i18n-hint: A time specification like "Sunday 28th October 2007 15:16:17 GMT" * but hopefully translated by wxwidgets will be inserted into this */ strMsg.Printf(_("Waiting to start recording at %s.\n"), GetDisplayDate(m_DateTime_Start).c_str()); ProgressDialog progress(_("Audacity Timer Record - Waiting for Start"), strMsg); wxDateTime startWait_DateTime = wxDateTime::UNow(); wxTimeSpan waitDuration = m_DateTime_Start - startWait_DateTime; bool bDidCancel = false; bool bIsRecording = false; wxTimeSpan done_TimeSpan; while (!bDidCancel && !bIsRecording) { wxMilliSleep(10); done_TimeSpan = wxDateTime::UNow() - startWait_DateTime; bDidCancel = !progress.Update(done_TimeSpan.GetSeconds(), waitDuration.GetSeconds()); bIsRecording = (m_DateTime_Start <= wxDateTime::UNow()); } return !bDidCancel; }
int TimerRecordDialog::WaitForStart() { // MY: The Waiting For Start dialog now shows what actions will occur after recording has completed wxString sPostAction = m_pTimerAfterCompleteChoiceCtrl->GetString(m_pTimerAfterCompleteChoiceCtrl->GetSelection()); /* i18n-hint: Time specifications like "Sunday 28th October 2007 15:16:17 GMT" * but hopefully translated by wxwidgets will be inserted into this */ wxString strMsg; strMsg.Printf(_("Waiting to start recording at:\t%s\n") + _("Recording duration:\t\t%s\n") + _("Scheduled to stop at:\t\t%s\n\n") + _("Automatic Save Enabled:\t\t%s\n") + _("Automatic Export Enabled:\t\t%s\n") + _("Post Timer Recording Action:\t%s"), GetDisplayDate(m_DateTime_Start).c_str(), m_TimeSpan_Duration.Format(), GetDisplayDate(m_DateTime_End).c_str(), (m_bAutoSaveEnabled ? _("Yes") : _("No")), (m_bAutoExportEnabled ? _("Yes") : _("No")), sPostAction); wxDateTime startWait_DateTime = wxDateTime::UNow(); wxTimeSpan waitDuration = m_DateTime_Start - startWait_DateTime; TimerProgressDialog progress(waitDuration.GetMilliseconds().GetValue(), _("Audacity Timer Record - Waiting for Start"), strMsg, pdlgHideStopButton | pdlgConfirmStopCancel | pdlgHideElapsedTime, _("Recording will commence in:")); int updateResult = eProgressSuccess; bool bIsRecording = false; while (updateResult == eProgressSuccess && !bIsRecording) { updateResult = progress.Update(); wxMilliSleep(10); bIsRecording = (m_DateTime_Start <= wxDateTime::UNow()); } return updateResult; }
void TimerRecordDialog::OnOK(wxCommandEvent& event) { m_timer.Stop(); // Don't need to keep updating m_DateTime_Start to prevent backdating. this->TransferDataFromWindow(); bool bDidCancel = false; if (m_DateTime_Start > wxDateTime::UNow()) bDidCancel = !this->WaitForStart(); if (!bDidCancel) { // Record for specified time. AudacityProject* pProject = GetActiveProject(); pProject->OnRecord(); bool bIsRecording = true; /* Although inaccurate, use the wxProgressDialog wxPD_ELAPSED_TIME | wxPD_REMAINING_TIME instead of calculating and presenting it. wxTimeSpan remaining_TimeSpan; wxString strNewMsg; */ wxString strMsg = _("Recording start") + (wxString)wxT(":\t\t") + GetDisplayDate(m_DateTime_Start) + wxT("\n") + _("Recording end") + wxT(":\t\t") + GetDisplayDate(m_DateTime_End) + wxT("\n") + _("Duration") + wxT(":\t\t") + m_TimeSpan_Duration.Format(); ProgressDialog progress( _("Audacity Timer Record Progress"), // const wxString& title, strMsg); // const wxString& message // Make sure that start and end time are updated, so we always get the full // duration, even if there's some delay getting here. wxTimerEvent dummyTimerEvent; this->OnTimer(dummyTimerEvent); wxDateTime dateTime_UNow; wxTimeSpan done_TimeSpan; while (bIsRecording && !bDidCancel) { // sit in this loop during the recording phase, i.e. from rec start to // recording end wxMilliSleep(kTimerInterval); dateTime_UNow = wxDateTime::UNow(); // get time now done_TimeSpan = dateTime_UNow - m_DateTime_Start; // work out how long we have been recording for // remaining_TimeSpan = m_DateTime_End - dateTime_UNow; // strNewMsg = strMsg + _("\nDone: ") + done_TimeSpan.Format() + _(" Remaining: ") + remaining_TimeSpan.Format(); bDidCancel = !progress.Update(done_TimeSpan.GetSeconds(), m_TimeSpan_Duration.GetSeconds()); // , strNewMsg); bIsRecording = (wxDateTime::UNow() <= m_DateTime_End); } pProject->OnStop(); } this->EndModal(wxID_OK); }
/// Runs the wait for start dialog. Returns -1 if the user clicks stop while we are recording /// or if the post recording actions fail. int TimerRecordDialog::RunWaitDialog() { AudacityProject* pProject = GetActiveProject(); auto updateResult = ProgressResult::Success; if (m_DateTime_Start > wxDateTime::UNow()) updateResult = this->WaitForStart(); if (updateResult != ProgressResult::Success) { // Don't proceed, but don't treat it as canceled recording. User just canceled waiting. return POST_TIMER_RECORD_CANCEL_WAIT; } else { // Record for specified time. pProject->OnRecord(*pProject); bool bIsRecording = true; wxString sPostAction = m_pTimerAfterCompleteChoiceCtrl->GetString(m_pTimerAfterCompleteChoiceCtrl->GetSelection()); // Two column layout. TimerProgressDialog::MessageTable columns(2); auto &column1 = columns[0]; auto &column2 = columns[1]; column1.push_back( _("Recording start:") ); column2.push_back( GetDisplayDate(m_DateTime_Start) ); column1.push_back( _("Duration:") ); column2.push_back( m_TimeSpan_Duration.Format() ); column1.push_back( _("Recording end:") ); column2.push_back( GetDisplayDate(m_DateTime_End) ); column1.push_back( {} ); column2.push_back( {} ); column1.push_back( _("Automatic Save enabled:") ); column2.push_back( (m_bAutoSaveEnabled ? _("Yes") : _("No")) ); column1.push_back( _("Automatic Export enabled:") ); column2.push_back( (m_bAutoExportEnabled ? _("Yes") : _("No")) ); column1.push_back( _("Action after Timer Recording:") ); column2.push_back( sPostAction ); TimerProgressDialog progress(m_TimeSpan_Duration.GetMilliseconds().GetValue(), _("Audacity Timer Record Progress"), columns, pdlgHideCancelButton | pdlgConfirmStopCancel); // Make sure that start and end time are updated, so we always get the full // duration, even if there's some delay getting here. wxTimerEvent dummyTimerEvent; this->OnTimer(dummyTimerEvent); // Loop for progress display during recording. while (bIsRecording && (updateResult == ProgressResult::Success)) { updateResult = progress.UpdateProgress(); wxMilliSleep(kTimerInterval); bIsRecording = (wxDateTime::UNow() <= m_DateTime_End); // Call UNow() again for extra accuracy... } } // Must do this AFTER the timer project dialog has been deleted to ensure the application // responds to the AUDIOIO events...see not about bug #334 in the ProgressDialog constructor. pProject->OnStop(*pProject); // Let the caller handle cancellation or failure from recording progress. if (updateResult == ProgressResult::Cancelled || updateResult == ProgressResult::Failed) return POST_TIMER_RECORD_CANCEL; return ExecutePostRecordActions((updateResult == ProgressResult::Stopped)); }