mirror of
https://github.com/cookiengineer/audacity
synced 2026-04-25 23:44:13 +02:00
Bug 1402, rewrite logic for the display of hours and minutes and ensure we use one routine for this.
This commit is contained in:
@@ -4654,43 +4654,12 @@ void AudacityProject::OnTimer(wxTimerEvent& WXUNUSED(event))
|
|||||||
if (GetAudioIOToken() > 0 && gAudioIO->GetNumCaptureChannels() > 0) {
|
if (GetAudioIOToken() > 0 && gAudioIO->GetNumCaptureChannels() > 0) {
|
||||||
wxLongLong freeSpace = mDirManager->GetFreeDiskSpace();
|
wxLongLong freeSpace = mDirManager->GetFreeDiskSpace();
|
||||||
if (freeSpace >= 0) {
|
if (freeSpace >= 0) {
|
||||||
wxString msg;
|
wxString sMessage;
|
||||||
double recTime;
|
|
||||||
int recMins;
|
|
||||||
// JKC: Bug 50: Use preferences to get actual sample format.
|
|
||||||
// However there is a slight performance impact due to Bug 1436
|
|
||||||
// So have left the old code in that gets the size (in RAM) but
|
|
||||||
// #ifdeffed out.
|
|
||||||
#if 1
|
|
||||||
sampleFormat oCaptureFormat = (sampleFormat)
|
|
||||||
gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleFormat"), floatSample);
|
|
||||||
#else
|
|
||||||
sampleFormat oCaptureFormat = gAudioIO->GetCaptureFormat();
|
|
||||||
#endif
|
|
||||||
double bytesOnDiskPerSample = SAMPLE_SIZE_DISK(oCaptureFormat);
|
|
||||||
recTime = freeSpace.GetHi() * 4294967296.0 + freeSpace.GetLo();
|
|
||||||
recTime /= bytesOnDiskPerSample;
|
|
||||||
// note size on disk (=3 for 24-bit) not in memory (=4 for 24-bit)
|
|
||||||
recTime /= gAudioIO->GetNumCaptureChannels();
|
|
||||||
recTime /= GetRate();
|
|
||||||
recMins = (int)(recTime / 60.0);
|
|
||||||
|
|
||||||
if (recMins >= 120)
|
int iRecordingMins = GetEstimatedRecordingMinsLeftOnDisk(gAudioIO->GetNumCaptureChannels());
|
||||||
msg.Printf(_("Disk space remains for recording %d hours and %d minutes."),
|
sMessage.Printf(_("Disk space remains for recording %s"), GetHoursMinsString(iRecordingMins));
|
||||||
recMins/60, recMins%60);
|
|
||||||
else if (recMins >= 60)
|
|
||||||
msg.Printf(_("Disk space remains for recording 1 hour and %d minutes."),
|
|
||||||
recMins-60);
|
|
||||||
else if (recMins > 3)
|
|
||||||
msg.Printf(_("Disk space remains for recording %d minutes."),
|
|
||||||
recMins);
|
|
||||||
else if (recTime >= 2)
|
|
||||||
msg.Printf(_("Disk space remains for recording %d seconds."),
|
|
||||||
(int)recTime);
|
|
||||||
else
|
|
||||||
msg.Printf(_("Out of disk space"));
|
|
||||||
|
|
||||||
mStatusBar->SetStatusText(msg, mainStatusBarField);
|
mStatusBar->SetStatusText(sMessage, mainStatusBarField);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(ODManager::IsInstanceCreated())
|
else if(ODManager::IsInstanceCreated())
|
||||||
@@ -5528,7 +5497,7 @@ bool AudacityProject::SaveFromTimerRecording(wxFileName fnFile) {
|
|||||||
return bSuccess;
|
return bSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
// MY: Does the project have any tracks?
|
// Does the project have any tracks?
|
||||||
bool AudacityProject::ProjectHasTracks() {
|
bool AudacityProject::ProjectHasTracks() {
|
||||||
// These two lines test for an 'empty' project.
|
// These two lines test for an 'empty' project.
|
||||||
// of course it could still have a history at this stage.
|
// of course it could still have a history at this stage.
|
||||||
@@ -5537,20 +5506,43 @@ bool AudacityProject::ProjectHasTracks() {
|
|||||||
return bHasTracks;
|
return bHasTracks;
|
||||||
}
|
}
|
||||||
|
|
||||||
// MY: This routine will give an estimate of how many
|
wxString AudacityProject::GetHoursMinsString(int iMinutes)
|
||||||
|
{
|
||||||
|
|
||||||
|
wxString sFormatted = wxEmptyString;
|
||||||
|
wxString sHours = wxEmptyString;
|
||||||
|
wxString sMins = wxEmptyString;
|
||||||
|
|
||||||
|
if (iMinutes < 1) {
|
||||||
|
// Less than a minute...
|
||||||
|
sFormatted = _("Less than 1 minute");
|
||||||
|
return sFormatted;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate
|
||||||
|
int iHours = iMinutes / 60;
|
||||||
|
int iMins = iMinutes % 60;
|
||||||
|
|
||||||
|
// Use wxPLURAL to get strings
|
||||||
|
sHours = wxPLURAL("hour", "hours", iHours);
|
||||||
|
sMins = wxPLURAL("minute", "minutes", iMins);
|
||||||
|
|
||||||
|
sFormatted.Printf(_("%d %s and %d %s."), iHours, sHours, iMins, sMins);
|
||||||
|
return sFormatted;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This routine will give an estimate of how many
|
||||||
// minutes of recording time we have available.
|
// minutes of recording time we have available.
|
||||||
// This is called from TimerRecordDialog::OnOK() to allow
|
|
||||||
// the user to resolve a potential disk space issue before
|
|
||||||
// Timer Recording starts.
|
|
||||||
// The calculations made are based on the user's current
|
// The calculations made are based on the user's current
|
||||||
// preferences.
|
// preferences.
|
||||||
int AudacityProject::GetEstimatedRecordingMinsLeftOnDisk() {
|
int AudacityProject::GetEstimatedRecordingMinsLeftOnDisk(long lCaptureChannels) {
|
||||||
|
|
||||||
// Obtain the current settings
|
// Obtain the current settings
|
||||||
sampleFormat oCaptureFormat = (sampleFormat)
|
sampleFormat oCaptureFormat = (sampleFormat)
|
||||||
gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleFormat"), floatSample);
|
gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleFormat"), floatSample);
|
||||||
long lCaptureChannels;
|
if (lCaptureChannels == 0) {
|
||||||
gPrefs->Read(wxT("/AudioIO/RecordChannels"), &lCaptureChannels, 2L);
|
gPrefs->Read(wxT("/AudioIO/RecordChannels"), &lCaptureChannels, 2L);
|
||||||
|
}
|
||||||
|
|
||||||
// Find out how much free space we have on disk
|
// Find out how much free space we have on disk
|
||||||
wxLongLong lFreeSpace = mDirManager->GetFreeDiskSpace();
|
wxLongLong lFreeSpace = mDirManager->GetFreeDiskSpace();
|
||||||
@@ -5567,7 +5559,7 @@ int AudacityProject::GetEstimatedRecordingMinsLeftOnDisk() {
|
|||||||
dRecTime /= GetRate();
|
dRecTime /= GetRate();
|
||||||
|
|
||||||
// Convert to minutes before returning
|
// Convert to minutes before returning
|
||||||
int iRecMins = (int)(dRecTime / 60.0);
|
int iRecMins = (int)round(dRecTime / 60.0);
|
||||||
return iRecMins;
|
return iRecMins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -291,7 +291,9 @@ class AUDACITY_DLL_API AudacityProject final : public wxFrame,
|
|||||||
bool ProjectHasTracks();
|
bool ProjectHasTracks();
|
||||||
|
|
||||||
// Routine to estimate how many minutes of recording time are left on disk
|
// Routine to estimate how many minutes of recording time are left on disk
|
||||||
int GetEstimatedRecordingMinsLeftOnDisk();
|
int GetEstimatedRecordingMinsLeftOnDisk(long lCaptureChannels = 0);
|
||||||
|
// Converts number of minutes to human readable format
|
||||||
|
wxString GetHoursMinsString(int iMinutes);
|
||||||
|
|
||||||
#include "Menus.h"
|
#include "Menus.h"
|
||||||
|
|
||||||
|
|||||||
@@ -356,43 +356,6 @@ void TimerRecordDialog::OnHelpButtonClick(wxCommandEvent& WXUNUSED(event))
|
|||||||
HelpSystem::ShowHelpDialog(this, wxT("Timer_Record"), true);
|
HelpSystem::ShowHelpDialog(this, wxT("Timer_Record"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString TimerRecordDialog::GetHoursMinsString(int iMinutes) {
|
|
||||||
|
|
||||||
wxString sFormatted = "";
|
|
||||||
wxString sHours = "";
|
|
||||||
wxString sMins = "";
|
|
||||||
|
|
||||||
if (iMinutes < 1) {
|
|
||||||
// Less than a minute...
|
|
||||||
sFormatted = _("Less than 1 minute");
|
|
||||||
return sFormatted;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calculate
|
|
||||||
int iHours = iMinutes / 60;
|
|
||||||
int iMins = iMinutes % 60;
|
|
||||||
|
|
||||||
// Format the hours
|
|
||||||
if (iHours == 1) {
|
|
||||||
sHours = _("1 hour and ");
|
|
||||||
}
|
|
||||||
else if (iHours > 1) {
|
|
||||||
sHours.Printf(_("%d hours and"), iHours);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Format the minutes
|
|
||||||
if (iMins == 1) {
|
|
||||||
sMins = _("1 minute");
|
|
||||||
}
|
|
||||||
else if (iMins > 1) {
|
|
||||||
sMins.Printf(_("%d minutes"), iMins);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Build the string
|
|
||||||
sFormatted.Printf("%s %s", sHours, sMins);
|
|
||||||
return sFormatted;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TimerRecordDialog::OnOK(wxCommandEvent& WXUNUSED(event))
|
void TimerRecordDialog::OnOK(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
this->TransferDataFromWindow();
|
this->TransferDataFromWindow();
|
||||||
@@ -440,9 +403,9 @@ void TimerRecordDialog::OnOK(wxCommandEvent& WXUNUSED(event))
|
|||||||
|
|
||||||
// Format the strings
|
// Format the strings
|
||||||
wxString sRemainingTime = "";
|
wxString sRemainingTime = "";
|
||||||
sRemainingTime = GetHoursMinsString(iMinsLeft);
|
sRemainingTime = pProject->GetHoursMinsString(iMinsLeft);
|
||||||
wxString sPlannedTime = "";
|
wxString sPlannedTime = "";
|
||||||
sPlannedTime = GetHoursMinsString(iMinsRecording);
|
sPlannedTime = pProject->GetHoursMinsString(iMinsRecording);
|
||||||
|
|
||||||
// Create the message string
|
// Create the message string
|
||||||
wxString sMessage = "";
|
wxString sMessage = "";
|
||||||
|
|||||||
@@ -101,8 +101,6 @@ private:
|
|||||||
int ExecutePostRecordActions(bool bWasStopped);
|
int ExecutePostRecordActions(bool bWasStopped);
|
||||||
int PreActionDelay(int iActionIndex, TimerRecordCompletedActions eCompletedActions);
|
int PreActionDelay(int iActionIndex, TimerRecordCompletedActions eCompletedActions);
|
||||||
|
|
||||||
wxString GetHoursMinsString(int iMinutes);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxDateTime m_DateTime_Start;
|
wxDateTime m_DateTime_Start;
|
||||||
wxDateTime m_DateTime_End;
|
wxDateTime m_DateTime_End;
|
||||||
|
|||||||
Reference in New Issue
Block a user