1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-25 08:38:39 +02:00

A few changes not using Maybe

This commit is contained in:
Paul Licameli 2016-02-18 12:43:02 -05:00
parent 62361c32f4
commit e3e10f1fc1
2 changed files with 24 additions and 32 deletions

View File

@ -317,7 +317,7 @@ void QuitAudacity(bool bForce)
AudacityProject::DeleteAllProjectsDeleteLock(); AudacityProject::DeleteAllProjectsDeleteLock();
//remove our logger //remove our logger
delete wxLog::SetActiveTarget(NULL); std::unique_ptr<wxLog>{ wxLog::SetActiveTarget(NULL) }; // DELETE
if (bForce) if (bForce)
{ {
@ -1147,7 +1147,7 @@ bool AudacityApp::OnInit()
// Ensure we have an event loop during initialization // Ensure we have an event loop during initialization
wxEventLoopGuarantor eventLoop; wxEventLoopGuarantor eventLoop;
delete wxLog::SetActiveTarget(new AudacityLogger); std::unique_ptr < wxLog > { wxLog::SetActiveTarget(new AudacityLogger) }; // DELETE
mLocale = NULL; mLocale = NULL;

View File

@ -1343,72 +1343,67 @@ bool AudioIO::StartPortAudioStream(double sampleRate,
mNumPlaybackChannels = numPlaybackChannels; mNumPlaybackChannels = numPlaybackChannels;
mNumCaptureChannels = numCaptureChannels; mNumCaptureChannels = numCaptureChannels;
PaStreamParameters *playbackParameters = NULL; bool usePlayback = false, useCapture = false;
PaStreamParameters *captureParameters = NULL; PaStreamParameters playbackParameters{};
PaStreamParameters captureParameters{};
double latencyDuration = DEFAULT_LATENCY_DURATION; double latencyDuration = DEFAULT_LATENCY_DURATION;
gPrefs->Read(wxT("/AudioIO/LatencyDuration"), &latencyDuration); gPrefs->Read(wxT("/AudioIO/LatencyDuration"), &latencyDuration);
if( numPlaybackChannels > 0) if( numPlaybackChannels > 0)
{ {
playbackParameters = new PaStreamParameters; usePlayback = true;
// this sets the device index to whatever is "right" based on preferences, // this sets the device index to whatever is "right" based on preferences,
// then defaults // then defaults
playbackParameters->device = getPlayDevIndex(); playbackParameters.device = getPlayDevIndex();
const PaDeviceInfo *playbackDeviceInfo; const PaDeviceInfo *playbackDeviceInfo;
playbackDeviceInfo = Pa_GetDeviceInfo( playbackParameters->device ); playbackDeviceInfo = Pa_GetDeviceInfo( playbackParameters.device );
if( playbackDeviceInfo == NULL ) if( playbackDeviceInfo == NULL )
{
delete playbackParameters;
return false; return false;
}
// regardless of source formats, we always mix to float // regardless of source formats, we always mix to float
playbackParameters->sampleFormat = paFloat32; playbackParameters.sampleFormat = paFloat32;
playbackParameters->hostApiSpecificStreamInfo = NULL; playbackParameters.hostApiSpecificStreamInfo = NULL;
playbackParameters->channelCount = mNumPlaybackChannels; playbackParameters.channelCount = mNumPlaybackChannels;
if (mSoftwarePlaythrough) if (mSoftwarePlaythrough)
playbackParameters->suggestedLatency = playbackParameters.suggestedLatency =
playbackDeviceInfo->defaultLowOutputLatency; playbackDeviceInfo->defaultLowOutputLatency;
else else
playbackParameters->suggestedLatency = latencyDuration/1000.0; playbackParameters.suggestedLatency = latencyDuration/1000.0;
mOutputMeter = mOwningProject->GetPlaybackMeter(); mOutputMeter = mOwningProject->GetPlaybackMeter();
} }
if( numCaptureChannels > 0) if( numCaptureChannels > 0)
{ {
useCapture = true;
mCaptureFormat = captureFormat; mCaptureFormat = captureFormat;
captureParameters = new PaStreamParameters;
const PaDeviceInfo *captureDeviceInfo; const PaDeviceInfo *captureDeviceInfo;
// retrieve the index of the device set in the prefs, or a sensible // retrieve the index of the device set in the prefs, or a sensible
// default if it isn't set/valid // default if it isn't set/valid
captureParameters->device = getRecordDevIndex(); captureParameters.device = getRecordDevIndex();
captureDeviceInfo = Pa_GetDeviceInfo( captureParameters->device ); captureDeviceInfo = Pa_GetDeviceInfo( captureParameters.device );
if( captureDeviceInfo == NULL ) if( captureDeviceInfo == NULL )
{
delete captureParameters;
delete playbackParameters;
return false; return false;
}
captureParameters->sampleFormat = captureParameters.sampleFormat =
AudacityToPortAudioSampleFormat(mCaptureFormat); AudacityToPortAudioSampleFormat(mCaptureFormat);
captureParameters->hostApiSpecificStreamInfo = NULL; captureParameters.hostApiSpecificStreamInfo = NULL;
captureParameters->channelCount = mNumCaptureChannels; captureParameters.channelCount = mNumCaptureChannels;
if (mSoftwarePlaythrough) if (mSoftwarePlaythrough)
captureParameters->suggestedLatency = captureParameters.suggestedLatency =
captureDeviceInfo->defaultHighInputLatency; captureDeviceInfo->defaultHighInputLatency;
else else
captureParameters->suggestedLatency = latencyDuration/1000.0; captureParameters.suggestedLatency = latencyDuration/1000.0;
mInputMeter = mOwningProject->GetCaptureMeter(); mInputMeter = mOwningProject->GetCaptureMeter();
} }
@ -1429,7 +1424,8 @@ bool AudioIO::StartPortAudioStream(double sampleRate,
#endif #endif
#endif #endif
mLastPaError = Pa_OpenStream( &mPortStreamV19, mLastPaError = Pa_OpenStream( &mPortStreamV19,
captureParameters, playbackParameters, useCapture ? &captureParameters : NULL,
usePlayback ? &playbackParameters : NULL,
mRate, paFramesPerBufferUnspecified, mRate, paFramesPerBufferUnspecified,
paNoFlag, paNoFlag,
audacityAudioCallback, NULL ); audacityAudioCallback, NULL );
@ -1457,10 +1453,6 @@ bool AudioIO::StartPortAudioStream(double sampleRate,
} }
#endif #endif
// these may be null, but deleting a null pointer should never crash.
delete captureParameters;
delete playbackParameters;
return (mLastPaError == paNoError); return (mLastPaError == paNoError);
} }