1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-24 08:28:04 +02:00

Remove whitespace only changes

Signed-off-by: Emily Mabrey <emabrey@tenacityaudio.org>
This commit is contained in:
Emily Mabrey 2021-08-10 18:49:56 -04:00
parent d4a560f6f3
commit d7695f3c91
No known key found for this signature in database
GPG Key ID: 6F4EF47256A1B7DC
3 changed files with 92 additions and 91 deletions

View File

@ -18,8 +18,8 @@
********************************************************************//**
\class AudioIoCallback
\brief AudioIoCallback is a class that implements the callback required
by PortAudio. The callback needs to be responsive, has no GUI, and
\brief AudioIoCallback is a class that implements the callback required
by PortAudio. The callback needs to be responsive, has no GUI, and
copies data into and out of the sound card buffers. It also sends data
to the meters.
@ -408,7 +408,7 @@ callbacks for these events.
*//****************************************************************//**
\class AudioIOStartStreamOptions
\brief struct holding stream options, including a pointer to the
\brief struct holding stream options, including a pointer to the
time warp info and AudioIOListener and whether the playback is looped.
*//*******************************************************************/
@ -961,7 +961,7 @@ AudioIO::AudioIO()
wxASSERT(false);
}
// This ASSERT because of casting in the callback
// This ASSERT because of casting in the callback
// functions where we cast a tempFloats buffer to a (short*) buffer.
// We have to ASSERT in the GUI thread, if we are to see it properly.
wxASSERT( sizeof( short ) <= sizeof( float ));
@ -986,8 +986,7 @@ AudioIO::AudioIO()
#ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
mAILAActive = false;
#endif
mStreamToken = 0;
mStreamToken = 0;
mLastPaError = paNoError;
@ -1004,18 +1003,18 @@ AudioIO::AudioIO()
PaError err = Pa_Initialize();
if (err != paNoError) {
auto errStr = XO("Could not find any audio devices.\n");
errStr += XO("You will not be able to play or record audio.\n\n");
const wxString paErrStr = LAT1CTOWX(Pa_GetErrorText(err));
if (!paErrStr.empty())
errStr += XO("Error: %s").Format(paErrStr);
// XXX: we are in libaudacity, popping up dialogs not allowed! A
// long-term solution will probably involve exceptions
AudacityMessageBox(
errStr,
XO("Error Initializing Audio"),
wxICON_ERROR | wxOK);
if (err != paNoError) {
auto errStr = XO("Could not find any audio devices.\n");
errStr += XO("You will not be able to play or record audio.\n\n");
const wxString paErrStr = LAT1CTOWX(Pa_GetErrorText(err));
if (!paErrStr.empty())
errStr += XO("Error: %s").Format(paErrStr);
// XXX: we are in libaudacity, popping up dialogs not allowed! A
// long-term solution will probably involve exceptions
AudacityMessageBox(
errStr,
XO("Error Initializing Audio"),
wxICON_ERROR|wxOK);
// Since PortAudio is not initialized, all calls to PortAudio
// functions will fail. This will give reasonable behavior, since
@ -1026,19 +1025,19 @@ AudioIO::AudioIO()
#ifdef EXPERIMENTAL_MIDI_OUT
PmError pmErr = Pm_Initialize();
if (pmErr != pmNoError) {
auto errStr =
XO("There was an error initializing the midi i/o layer.\n");
errStr += XO("You will not be able to play midi.\n\n");
const wxString pmErrStr = LAT1CTOWX(Pm_GetErrorText(pmErr));
if (!pmErrStr.empty())
errStr += XO("Error: %s").Format(pmErrStr);
// XXX: we are in libaudacity, popping up dialogs not allowed! A
// long-term solution will probably involve exceptions
AudacityMessageBox(
errStr,
XO("Error Initializing Midi"),
wxICON_ERROR | wxOK);
if (pmErr != pmNoError) {
auto errStr =
XO("There was an error initializing the midi i/o layer.\n");
errStr += XO("You will not be able to play midi.\n\n");
const wxString pmErrStr = LAT1CTOWX(Pm_GetErrorText(pmErr));
if (!pmErrStr.empty())
errStr += XO("Error: %s").Format(pmErrStr);
// XXX: we are in libaudacity, popping up dialogs not allowed! A
// long-term solution will probably involve exceptions
AudacityMessageBox(
errStr,
XO("Error Initializing Midi"),
wxICON_ERROR|wxOK);
// Same logic for PortMidi as described above for PortAudio
}
@ -1253,13 +1252,13 @@ bool AudioIO::StartPortAudioStream(const AudioIOStartStreamOptions &options,
mRate = GetBestRate(numCaptureChannels > 0, numPlaybackChannels > 0, sampleRate);
// July 2016 (Carsten and Uwe)
// BUG 193: Tell PortAudio sound card will handle 24 bit (under DirectSound) using
// BUG 193: Tell PortAudio sound card will handle 24 bit (under DirectSound) using
// userData.
int captureFormat_saved = captureFormat;
// Special case: Our 24-bit sample format is different from PortAudio's
// 3-byte packed format. So just make PortAudio return float samples,
// since we need float values anyway to apply the gain.
// ANSWER-ME: So we *never* actually handle 24-bit?! This causes mCapture to
// ANSWER-ME: So we *never* actually handle 24-bit?! This causes mCapture to
// be set to floatSample below.
// JKC: YES that's right. Internally Audacity uses float, and float has space for
// 24 bits as well as exponent. Actual 24 bit would require packing and
@ -1358,7 +1357,7 @@ bool AudioIO::StartPortAudioStream(const AudioIOStartStreamOptions &options,
#endif
// July 2016 (Carsten and Uwe)
// BUG 193: Possibly tell portAudio to use 24 bit with DirectSound.
// BUG 193: Possibly tell portAudio to use 24 bit with DirectSound.
int userData = 24;
int* lpUserData = (captureFormat_saved == int24Sample) ? &userData : NULL;
@ -1473,7 +1472,7 @@ void AudioIO::StartMonitoring( const AudioIOStartStreamOptions &options )
// FIXME: TRAP_ERR PaErrorCode 'noted' but not reported in StartMonitoring.
// Now start the PortAudio stream!
// TODO: ? Factor out and reuse error reporting code from end of
// TODO: ? Factor out and reuse error reporting code from end of
// AudioIO::StartStream?
mLastPaError = Pa_StartStream( mPortStreamV19 );
@ -1706,7 +1705,7 @@ int AudioIO::StartStream(const TransportTracks &tracks,
mPlaybackMixers[ii]->Reposition( time );
mPlaybackSchedule.RealTimeInit( time );
}
// Now that we are done with SetTrackTime():
mTimeQueue.mLastTime = mPlaybackSchedule.GetTrackTime();
if (mTimeQueue.mData)
@ -1857,7 +1856,7 @@ bool AudioIO::AllocateBuffers(
// more frequent polling of the mouse
playbackTime =
lrint(options.pScrubbingOptions->delay * mRate) / mRate;
wxASSERT( playbackTime >= 0 );
mPlaybackSamplesToCopy = playbackTime * mRate;
@ -2005,7 +2004,7 @@ bool AudioIO::AllocateBuffers(
}
}
} while(!bDone);
success = true;
return true;
}
@ -2179,7 +2178,7 @@ void AudioIO::StopStream()
// Re-enable system sleep
wxPowerResource::Release(wxPOWER_RESOURCE_SCREEN);
#endif
if( mAudioThreadFillBuffersLoopRunning)
{
// PortAudio callback can use the information that we are stopping to fade
@ -2187,7 +2186,7 @@ void AudioIO::StopStream()
mAudioThreadFillBuffersLoopRunning = false;
auto latency = static_cast<long>(AudioIOLatencyDuration.Read());
// If we can gracefully fade out in 200ms, with the faded-out play buffers making it through
// the sound card, then do so. If we can't, don't wait around. Just stop quickly and accept
// the sound card, then do so. If we can't, don't wait around. Just stop quickly and accept
// there will be a click.
if( mbMicroFades && (latency < 150 ))
wxMilliSleep( latency + 50);
@ -2305,7 +2304,7 @@ void AudioIO::StopStream()
#endif
auto pListener = GetListener();
// If there's no token, we were just monitoring, so we can
// skip this next part...
if (mStreamToken > 0) {
@ -2373,7 +2372,7 @@ void AudioIO::StopStream()
} );
}
if (!mLostCaptureIntervals.empty())
{
// This scope may combine many splittings of wave tracks
@ -2427,7 +2426,7 @@ void AudioIO::StopStream()
e.SetInt(false);
wxTheApp->ProcessEvent(e);
}
if (mNumCaptureChannels > 0)
{
wxCommandEvent e(wasMonitoring ? EVT_AUDIOIO_MONITOR : EVT_AUDIOIO_CAPTURE);
@ -2820,7 +2819,7 @@ void AudioIO::FillBuffers()
// wxASSERT(put == frames);
// but we can't assert in this thread
wxUnusedVar(put);
}
}
}
available -= frames;
@ -3274,7 +3273,7 @@ void AudioIoCallback::GetNextEvent()
if (mNextEvent) {
mNextEventTime = (mNextIsNoteOn ? mNextEvent->time :
mNextEvent->get_end_time()) + nextOffset;;
}
}
if (mNextEventTime > (mPlaybackSchedule.mT1 + midiLoopOffset)){ // terminate playback at mT1
mNextEvent = &gAllNotesOff;
mNextEventTime = mPlaybackSchedule.mT1 + midiLoopOffset - ALG_EPS;
@ -3824,7 +3823,7 @@ bool AudioIoCallback::FillOutputBuffers(
return false;
if( !outputBuffer )
return false;
if(numPlaybackChannels <= 0)
if(numPlaybackChannels <= 0)
return false;
float *outputFloats = (float *)outputBuffer;
@ -3855,7 +3854,7 @@ bool AudioIoCallback::FillOutputBuffers(
// The drop and dropQuickly booleans are so named for historical reasons.
// JKC: The original code attempted to be faster by doing nothing on silenced audio.
// This, IMHO, is 'premature optimisation'. Instead clearer and cleaner code would
// simply use a gain of 0.0 for silent audio and go on through to the stage of
// simply use a gain of 0.0 for silent audio and go on through to the stage of
// applying that 0.0 gain to the data mixed into the buffer.
// Then (and only then) we would have if needed fast paths for:
// - Applying a uniform gain of 0.0.
@ -3900,7 +3899,7 @@ bool AudioIoCallback::FillOutputBuffers(
if (dropQuickly) {
len = mPlaybackBuffers[t]->Discard(toGet);
// keep going here.
// keep going here.
// we may still need to issue a paComplete.
} else {
const auto ptrToSample = (samplePtr)bufHelper.get()->tempBufs[chanCnt];
@ -4000,7 +3999,7 @@ void AudioIoCallback::UpdateTimePosition(unsigned long framesPerBuffer)
// Copy from PortAudio to our input buffers.
//
void AudioIoCallback::FillInputBuffers(
const void *inputBuffer,
const void *inputBuffer,
unsigned long framesPerBuffer,
const PaStreamCallbackFlags statusFlags,
float * tempFloats
@ -4071,10 +4070,10 @@ void AudioIoCallback::FillInputBuffers(
wxPrintf(wxT("lost %d samples\n"), (int)(framesPerBuffer - len));
}
if (len <= 0)
if (len <= 0)
return;
// We have an ASSERT in the AudioIO constructor to alert us to
// We have an ASSERT in the AudioIO constructor to alert us to
// possible issues with the (short*) cast. We'd have a problem if
// sizeof(short) > sizeof(float) since our buffers are sized for floats.
for(unsigned t = 0; t < numCaptureChannels; t++) {
@ -4111,7 +4110,7 @@ void AudioIoCallback::FillInputBuffers(
} // switch
// JKC: mCaptureFormat must be for samples with sizeof(float) or
// fewer bytes (because tempFloats is sized for floats). All
// fewer bytes (because tempFloats is sized for floats). All
// formats are 2 or 4 bytes, so we are OK.
const auto put =
mCaptureBuffers[t]->Put(
@ -4157,7 +4156,7 @@ void OldCodeToCalculateLatency()
// return true, IFF we have fully handled the callback.
// Prime the output buffer with 0's, optionally adding in the playthrough.
void AudioIoCallback::DoPlaythrough(
const void *inputBuffer,
const void *inputBuffer,
void *outputBuffer,
unsigned long framesPerBuffer,
float *outputMeterFloats
@ -4194,7 +4193,7 @@ void AudioIoCallback::DoPlaythrough(
// Also computes rms
void AudioIoCallback::SendVuInputMeterData(
float *inputSamples,
unsigned long framesPerBuffer
unsigned long framesPerBuffer
)
{
const auto numCaptureChannels = mNumCaptureChannels;
@ -4235,7 +4234,7 @@ void AudioIoCallback::SendVuOutputMeterData(
return;
if( mOutputMeter->IsMeterDisabled() )
return;
if( !outputMeterFloats)
if( !outputMeterFloats)
return;
// Get here if playback meter is live
@ -4289,7 +4288,7 @@ unsigned AudioIoCallback::CountSoloingTracks(){
// TODO: Consider making the two Track status functions into functions of
// WaveTrack.
// true IFF the track should be silent.
// true IFF the track should be silent.
// The track may not yet be silent, since it may still be
// fading out.
bool AudioIoCallback::TrackShouldBeSilent( const WaveTrack &wt )
@ -4320,8 +4319,8 @@ bool AudioIoCallback::AllTracksAlreadySilent()
const bool dropAllQuickly = std::all_of(
mPlaybackTracks.begin(), mPlaybackTracks.end(),
[&]( const std::shared_ptr< WaveTrack > &vt )
{ return
TrackShouldBeSilent( *vt ) &&
{ return
TrackShouldBeSilent( *vt ) &&
TrackHasBeenFadedOut( *vt ); }
);
return dropAllQuickly;
@ -4351,9 +4350,9 @@ int AudioIoCallback::AudioCallback(const void *inputBuffer, void *outputBuffer,
// but it does nothing unless we have EXPERIMENTAL_MIDI_OUT
// TODO: Possibly rename variables to make it clearer which ones are MIDI specific
// and which ones affect all audio.
ComputeMidiTimings(
timeInfo,
framesPerBuffer
ComputeMidiTimings(
timeInfo,
framesPerBuffer
);
#ifndef USE_MIDI_THREAD
if (mMidiStream)
@ -4369,10 +4368,10 @@ int AudioIoCallback::AudioCallback(const void *inputBuffer, void *outputBuffer,
float *tempFloats = (float *)alloca(framesPerBuffer*sizeof(float)*
MAX(numCaptureChannels,numPlaybackChannels));
bool bVolEmulationActive =
bool bVolEmulationActive =
(outputBuffer && mEmulateMixerOutputVol && mMixerOutputVol != 1.0);
// outputMeterFloats is the scratch pad for the output meter.
// we can often reuse the existing outputBuffer and save on allocating
// outputMeterFloats is the scratch pad for the output meter.
// we can often reuse the existing outputBuffer and save on allocating
// something new.
float *outputMeterFloats = bVolEmulationActive ?
(float *)alloca(framesPerBuffer*numPlaybackChannels * sizeof(float)) :
@ -4397,10 +4396,10 @@ int AudioIoCallback::AudioCallback(const void *inputBuffer, void *outputBuffer,
// This function may queue up a pause or resume.
// TODO this is a bit dodgy as it toggles the Pause, and
// relies on an idle event to have handled that, so could
// relies on an idle event to have handled that, so could
// queue up multiple toggle requests and so do nothing.
// Eventually it will sort itself out by random luck, but
// the net effect is a delay in starting/stopping sound activated
// the net effect is a delay in starting/stopping sound activated
// recording.
CheckSoundActivatedRecordingLevel(
inputSamples,
@ -4411,7 +4410,7 @@ int AudioIoCallback::AudioCallback(const void *inputBuffer, void *outputBuffer,
// Initialise output buffer to zero or to playthrough data.
// Initialise output meter values.
DoPlaythrough(
inputBuffer,
inputBuffer,
outputBuffer,
framesPerBuffer,
outputMeterFloats);
@ -4433,7 +4432,7 @@ int AudioIoCallback::AudioCallback(const void *inputBuffer, void *outputBuffer,
// To capture input into track (sound from microphone)
FillInputBuffers(
inputBuffer,
inputBuffer,
framesPerBuffer,
statusFlags,
tempFloats);
@ -4508,7 +4507,7 @@ void AudioIoCallback::CallbackCheckCompletion(
done = mPlaybackSchedule.PlayingAtSpeed()
// some leftover length allowed in this case
|| (mPlaybackSchedule.PlayingStraight() && len == 0);
if(!done)
if(!done)
return;
#ifdef EXPERIMENTAL_MIDI_OUT

View File

@ -11,6 +11,9 @@ Paul Licameli split from AudioIO.h
#ifndef __AUDACITY_AUDIO_IO_BASE__
#define __AUDACITY_AUDIO_IO_BASE__
#include <cfloat>
#include <functional>
#include <vector>
@ -35,7 +38,7 @@ class BoundedEnvelope;
// Windows build needs complete type for parameter of wxWeakRef
// class MeterPanelBase;
#include "widgets/MeterPanelBase.h"
using PRCrossfadeData = std::vector< std::vector<float>>;
using PRCrossfadeData = std::vector< std::vector < float > >;
#define BAD_STREAM_TIME (-DBL_MAX)

View File

@ -10,35 +10,34 @@ class AudioIOBufferHelper
private:
unsigned int numPlaybackChannels;
unsigned long framesPerBuffer;
unsigned int numPlaybackChannels;
unsigned long framesPerBuffer;
public:
WaveTrack** chans;
float** tempBufs;
WaveTrack** chans;
float** tempBufs;
AudioIOBufferHelper(const unsigned int numPlaybackChannels, const unsigned long framesPerBuffer) {
this->numPlaybackChannels = numPlaybackChannels;
this->framesPerBuffer = framesPerBuffer;
AudioIOBufferHelper(const unsigned int numPlaybackChannels, const unsigned long framesPerBuffer) {
this->numPlaybackChannels = numPlaybackChannels;
this->framesPerBuffer = framesPerBuffer;
this->chans = safenew WaveTrack * [numPlaybackChannels];
this->tempBufs = safenew float* [numPlaybackChannels];
this->chans = safenew WaveTrack * [numPlaybackChannels];
this->tempBufs = safenew float* [numPlaybackChannels];
tempBufs[0] = safenew float[(size_t)numPlaybackChannels * framesPerBuffer];
memset(tempBufs[0], 0, (size_t)numPlaybackChannels * (size_t)framesPerBuffer * sizeof(float));
tempBufs[0] = safenew float[(size_t)numPlaybackChannels * framesPerBuffer];
memset(tempBufs[0], 0, (size_t)numPlaybackChannels * (size_t)framesPerBuffer * sizeof(float));
for (unsigned int c = 1; c < numPlaybackChannels; c++) {
tempBufs[c] = tempBufs[c - 1] + framesPerBuffer;
}
}
for (unsigned int c = 1; c < numPlaybackChannels; c++) {
tempBufs[c] = tempBufs[c - 1] + framesPerBuffer;
}
}
~AudioIOBufferHelper() {
delete[] tempBufs[0];
delete[] tempBufs;
delete[] chans;
}
~AudioIOBufferHelper() {
delete[] tempBufs[0];
delete[] tempBufs;
delete[] chans;
}
};
#endif