From 101b3ee8cd324ee57f66789214f1b5084e37b722 Mon Sep 17 00:00:00 2001 From: James Crook Date: Tue, 5 Jul 2016 15:14:27 +0100 Subject: [PATCH] Bug 50 - Calculation of "disk space remains for recording (time)" incorrect when recording in 24 bit quality There is a very slight performance cost in using the sample-format set in preferences that does not seem to matter in practice. That's because the status message is updated infrequently, not every screen refresh, and the actual cost per look up is small. See http://bugzilla.audacityteam.org/show_bug.cgi?id=1436 for information on slow reading of preferences. --- src/Project.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Project.cpp b/src/Project.cpp index 89bb501a7..5939399bd 100644 --- a/src/Project.cpp +++ b/src/Project.cpp @@ -4533,9 +4533,19 @@ void AudacityProject::OnTimer(wxTimerEvent& WXUNUSED(event)) wxString msg; 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 /= SAMPLE_SIZE_DISK(gAudioIO->GetCaptureFormat()); + recTime /= bytesOnDiskPerSample; // note size on disk (=3 for 24-bit) not in memory (=4 for 24-bit) recTime /= gAudioIO->GetNumCaptureChannels(); recTime /= GetRate(); @@ -5429,8 +5439,9 @@ int AudacityProject::GetEstimatedRecordingMinsLeftOnDisk() { // Calculate the remaining time double dRecTime = 0.0; + double bytesOnDiskPerSample = SAMPLE_SIZE_DISK(oCaptureFormat); dRecTime = lFreeSpace.GetHi() * 4294967296.0 + lFreeSpace.GetLo(); - dRecTime /= SAMPLE_SIZE_DISK(oCaptureFormat); + dRecTime /= bytesOnDiskPerSample; dRecTime /= lCaptureChannels; dRecTime /= GetRate();