mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-17 16:40:07 +02:00
Settings objects used in AudioIOBase...
... Giving many examples of use of Settings objects. Many other rewrites like this should be made to eliminate as many direct uses of gPrefs as we can. Don't rely on long distance coincidences of literals for paths or defaults. For each of several paths like /AudioIO/Host, all uses of that path are replaced with use of a global Settings object defined in one place, in AudioIOBase. The object also gives the benefit of caching the last-read or written value. Other users of those preferences must then include "AudioIOBase.h" to make the dependency explicit at compile time. It should be checked that no other mentions of those paths remain in the source, and that there was no unintended change in default values. This also inverts dependency of AudioIOBase on RecordingPrefs, which is GUI for changing some of these settings.
This commit is contained in:
parent
5fef82dccf
commit
8c04ed3990
@ -923,8 +923,8 @@ void AudioIO::Init()
|
||||
int i = getRecordDevIndex();
|
||||
const PaDeviceInfo *info = Pa_GetDeviceInfo(i);
|
||||
if (info) {
|
||||
gPrefs->Write(wxT("/AudioIO/RecordingDevice"), DeviceName(info));
|
||||
gPrefs->Write(wxT("/AudioIO/Host"), HostName(info));
|
||||
AudioIORecordingDevice.Write(DeviceName(info));
|
||||
AudioIOHost.Write(HostName(info));
|
||||
}
|
||||
}
|
||||
|
||||
@ -932,8 +932,8 @@ void AudioIO::Init()
|
||||
int i = getPlayDevIndex();
|
||||
const PaDeviceInfo *info = Pa_GetDeviceInfo(i);
|
||||
if (info) {
|
||||
gPrefs->Write(wxT("/AudioIO/PlaybackDevice"), DeviceName(info));
|
||||
gPrefs->Write(wxT("/AudioIO/Host"), HostName(info));
|
||||
AudioIOPlaybackDevice.Write(DeviceName(info));
|
||||
AudioIOHost.Write(HostName(info));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1277,8 +1277,7 @@ bool AudioIO::StartPortAudioStream(const AudioIOStartStreamOptions &options,
|
||||
PaStreamParameters playbackParameters{};
|
||||
PaStreamParameters captureParameters{};
|
||||
|
||||
double latencyDuration = DEFAULT_LATENCY_DURATION;
|
||||
gPrefs->Read(wxT("/AudioIO/LatencyDuration"), &latencyDuration);
|
||||
auto latencyDuration = AudioIOLatencyDuration.Read();
|
||||
|
||||
if( numPlaybackChannels > 0)
|
||||
{
|
||||
@ -1446,9 +1445,8 @@ void AudioIO::StartMonitoring( const AudioIOStartStreamOptions &options )
|
||||
return;
|
||||
|
||||
bool success;
|
||||
long captureChannels;
|
||||
auto captureFormat = QualityPrefs::SampleFormatChoice();
|
||||
gPrefs->Read(wxT("/AudioIO/RecordChannels"), &captureChannels, 2L);
|
||||
auto captureChannels = AudioIORecordChannels.Read();
|
||||
gPrefs->Read(wxT("/AudioIO/SWPlaythrough"), &mSoftwarePlaythrough, false);
|
||||
int playbackChannels = 0;
|
||||
|
||||
@ -1526,7 +1524,7 @@ int AudioIO::StartStream(const TransportTracks &tracks,
|
||||
#ifdef __WXGTK__
|
||||
// Detect whether ALSA is the chosen host, and do the various involved MIDI
|
||||
// timing compensations only then.
|
||||
mUsingAlsa = (gPrefs->Read(wxT("/AudioIO/Host"), wxT("")) == "ALSA");
|
||||
mUsingAlsa = (AudioIOHost.Read() == L"ALSA");
|
||||
#endif
|
||||
|
||||
gPrefs->Read(wxT("/AudioIO/SWPlaythrough"), &mSoftwarePlaythrough, false);
|
||||
@ -1556,9 +1554,7 @@ int AudioIO::StartStream(const TransportTracks &tracks,
|
||||
mRecordingSchedule = {};
|
||||
mRecordingSchedule.mPreRoll = preRoll;
|
||||
mRecordingSchedule.mLatencyCorrection =
|
||||
(gPrefs->ReadDouble(wxT("/AudioIO/LatencyCorrection"),
|
||||
DEFAULT_LATENCY_CORRECTION))
|
||||
/ 1000.0;
|
||||
AudioIOLatencyCorrection.Read() / 1000.0;
|
||||
mRecordingSchedule.mDuration = t1 - t0;
|
||||
if (options.pCrossfadeData)
|
||||
mRecordingSchedule.mCrossfadeData.swap( *options.pCrossfadeData );
|
||||
@ -2191,8 +2187,7 @@ void AudioIO::StopStream()
|
||||
// PortAudio callback can use the information that we are stopping to fade
|
||||
// out the audio. Give PortAudio callback a chance to do so.
|
||||
mAudioThreadFillBuffersLoopRunning = false;
|
||||
long latency;
|
||||
gPrefs->Read( wxT("/AudioIO/LatencyDuration"), &latency, DEFAULT_LATENCY_DURATION );
|
||||
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
|
||||
// there will be a click.
|
||||
|
@ -18,7 +18,6 @@ Paul Licameli split from AudioIO.cpp
|
||||
#include <wx/txtstrm.h>
|
||||
|
||||
#include "Prefs.h"
|
||||
#include "prefs/RecordingPrefs.h"
|
||||
#include "widgets/MeterPanelBase.h"
|
||||
|
||||
#if USE_PORTMIXER
|
||||
@ -185,7 +184,8 @@ void AudioIOBase::HandleDeviceChange()
|
||||
playbackParameters.suggestedLatency =
|
||||
Pa_GetDeviceInfo(playDeviceNum)->defaultLowOutputLatency;
|
||||
else
|
||||
playbackParameters.suggestedLatency = DEFAULT_LATENCY_CORRECTION/1000.0;
|
||||
playbackParameters.suggestedLatency =
|
||||
AudioIOLatencyCorrection.GetDefault()/1000.0;
|
||||
|
||||
PaStreamParameters captureParameters;
|
||||
|
||||
@ -197,7 +197,8 @@ void AudioIOBase::HandleDeviceChange()
|
||||
captureParameters.suggestedLatency =
|
||||
Pa_GetDeviceInfo(recDeviceNum)->defaultLowInputLatency;
|
||||
else
|
||||
captureParameters.suggestedLatency = DEFAULT_LATENCY_CORRECTION/1000.0;
|
||||
captureParameters.suggestedLatency =
|
||||
AudioIOLatencyCorrection.GetDefault()/1000.0;
|
||||
|
||||
// try opening for record and playback
|
||||
// Not really doing I/O so pass nullptr for the callback function
|
||||
@ -257,8 +258,7 @@ void AudioIOBase::HandleDeviceChange()
|
||||
|
||||
// Set input source
|
||||
#if USE_PORTMIXER
|
||||
int sourceIndex;
|
||||
if (gPrefs->Read(wxT("/AudioIO/RecordingSourceIndex"), &sourceIndex)) {
|
||||
auto sourceIndex = AudioIORecordingSourceIndex.Read(); // defaults to -1
|
||||
if (sourceIndex >= 0) {
|
||||
//the current index of our source may be different because the stream
|
||||
//is a combination of two devices, so update it.
|
||||
@ -266,7 +266,6 @@ void AudioIOBase::HandleDeviceChange()
|
||||
if (sourceIndex >= 0)
|
||||
SetMixer(sourceIndex);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Determine mixer capabilities - if it doesn't support control of output
|
||||
@ -471,10 +470,9 @@ std::vector<long> AudioIOBase::GetSupportedCaptureRates(int devIndex, double rat
|
||||
return supported;
|
||||
}
|
||||
|
||||
double latencyDuration = DEFAULT_LATENCY_DURATION;
|
||||
long recordChannels = 1;
|
||||
gPrefs->Read(wxT("/AudioIO/LatencyDuration"), &latencyDuration);
|
||||
gPrefs->Read(wxT("/AudioIO/RecordChannels"), &recordChannels);
|
||||
auto latencyDuration = AudioIOLatencyDuration.Read();
|
||||
// Why not defaulting to 2 as elsewhere?
|
||||
auto recordChannels = AudioIORecordChannels.ReadWithDefault(1);
|
||||
|
||||
// LLL: Remove when a proper method of determining actual supported
|
||||
// DirectSound rate is devised.
|
||||
@ -583,7 +581,7 @@ int AudioIOBase::GetOptimalSupportedSampleRate()
|
||||
int AudioIOBase::getRecordSourceIndex(PxMixer *portMixer)
|
||||
{
|
||||
int i;
|
||||
wxString sourceName = gPrefs->Read(wxT("/AudioIO/RecordingSource"), wxT(""));
|
||||
auto sourceName = AudioIORecordingSource.Read();
|
||||
int numSources = Px_GetNumInputSources(portMixer);
|
||||
for (i = 0; i < numSources; i++) {
|
||||
if (sourceName == wxString(wxSafeConvertMB2WX(Px_GetInputSourceName(portMixer, i))))
|
||||
@ -598,11 +596,9 @@ int AudioIOBase::getPlayDevIndex(const wxString &devNameArg)
|
||||
wxString devName(devNameArg);
|
||||
// if we don't get given a device, look up the preferences
|
||||
if (devName.empty())
|
||||
{
|
||||
devName = gPrefs->Read(wxT("/AudioIO/PlaybackDevice"), wxT(""));
|
||||
}
|
||||
devName = AudioIOPlaybackDevice.Read();
|
||||
|
||||
wxString hostName = gPrefs->Read(wxT("/AudioIO/Host"), wxT(""));
|
||||
auto hostName = AudioIOHost.Read();
|
||||
PaHostApiIndex hostCnt = Pa_GetHostApiCount();
|
||||
PaHostApiIndex hostNum;
|
||||
for (hostNum = 0; hostNum < hostCnt; hostNum++)
|
||||
@ -655,11 +651,9 @@ int AudioIOBase::getRecordDevIndex(const wxString &devNameArg)
|
||||
wxString devName(devNameArg);
|
||||
// if we don't get given a device, look up the preferences
|
||||
if (devName.empty())
|
||||
{
|
||||
devName = gPrefs->Read(wxT("/AudioIO/RecordingDevice"), wxT(""));
|
||||
}
|
||||
devName = AudioIORecordingDevice.Read();
|
||||
|
||||
wxString hostName = gPrefs->Read(wxT("/AudioIO/Host"), wxT(""));
|
||||
auto hostName = AudioIOHost.Read();
|
||||
PaHostApiIndex hostCnt = Pa_GetHostApiCount();
|
||||
PaHostApiIndex hostNum;
|
||||
for (hostNum = 0; hostNum < hostCnt; hostNum++)
|
||||
@ -732,8 +726,8 @@ wxString AudioIOBase::GetDeviceInfo()
|
||||
s << XO("Default recording device number: %d\n").Format( recDeviceNum );
|
||||
s << XO("Default playback device number: %d\n").Format( playDeviceNum);
|
||||
|
||||
wxString recDevice = gPrefs->Read(wxT("/AudioIO/RecordingDevice"), wxT(""));
|
||||
wxString playDevice = gPrefs->Read(wxT("/AudioIO/PlaybackDevice"), wxT(""));
|
||||
auto recDevice = AudioIORecordingDevice.Read();
|
||||
auto playDevice = AudioIOPlaybackDevice.Read();
|
||||
int j;
|
||||
|
||||
// This gets info on all available audio devices (input and output)
|
||||
@ -840,9 +834,9 @@ wxString AudioIOBase::GetDeviceInfo()
|
||||
playbackParameters.suggestedLatency =
|
||||
Pa_GetDeviceInfo(playDeviceNum)->defaultLowOutputLatency;
|
||||
}
|
||||
else{
|
||||
playbackParameters.suggestedLatency = DEFAULT_LATENCY_CORRECTION/1000.0;
|
||||
}
|
||||
else
|
||||
playbackParameters.suggestedLatency =
|
||||
AudioIOLatencyCorrection.GetDefault()/1000.0;
|
||||
|
||||
PaStreamParameters captureParameters;
|
||||
|
||||
@ -853,9 +847,10 @@ wxString AudioIOBase::GetDeviceInfo()
|
||||
if (Pa_GetDeviceInfo(recDeviceNum)){
|
||||
captureParameters.suggestedLatency =
|
||||
Pa_GetDeviceInfo(recDeviceNum)->defaultLowInputLatency;
|
||||
}else{
|
||||
captureParameters.suggestedLatency = DEFAULT_LATENCY_CORRECTION/1000.0;
|
||||
}
|
||||
else
|
||||
captureParameters.suggestedLatency =
|
||||
AudioIOLatencyCorrection.GetDefault()/1000.0;
|
||||
|
||||
// Not really doing I/O so pass nullptr for the callback function
|
||||
error = Pa_OpenStream(&stream,
|
||||
@ -1060,3 +1055,20 @@ wxString AudioIOBase::GetMidiDeviceInfo()
|
||||
return o.GetString();
|
||||
}
|
||||
#endif
|
||||
|
||||
StringSetting AudioIOHost{
|
||||
L"/AudioIO/Host", L"" };
|
||||
DoubleSetting AudioIOLatencyCorrection{
|
||||
L"/AudioIO/LatencyCorrection", -130.0 };
|
||||
DoubleSetting AudioIOLatencyDuration{
|
||||
L"/AudioIO/LatencyDuration", 100.0 };
|
||||
StringSetting AudioIOPlaybackDevice{
|
||||
L"/AudioIO/PlaybackDevice", L"" };
|
||||
IntSetting AudioIORecordChannels{
|
||||
L"/AudioIO/RecordChannels", 2 };
|
||||
StringSetting AudioIORecordingDevice{
|
||||
L"/AudioIO/RecordingDevice", L"" };
|
||||
StringSetting AudioIORecordingSource{
|
||||
L"/AudioIO/RecordingSource", L"" };
|
||||
IntSetting AudioIORecordingSourceIndex{
|
||||
L"/AudioIO/RecordingSourceIndex", -1 };
|
||||
|
@ -338,3 +338,14 @@ protected:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#include "Prefs.h"
|
||||
|
||||
extern AUDACITY_DLL_API StringSetting AudioIOHost;
|
||||
extern AUDACITY_DLL_API DoubleSetting AudioIOLatencyCorrection;
|
||||
extern AUDACITY_DLL_API DoubleSetting AudioIOLatencyDuration;
|
||||
extern AUDACITY_DLL_API StringSetting AudioIOPlaybackDevice;
|
||||
extern AUDACITY_DLL_API IntSetting AudioIORecordChannels;
|
||||
extern AUDACITY_DLL_API StringSetting AudioIORecordingDevice;
|
||||
extern AUDACITY_DLL_API StringSetting AudioIORecordingSource;
|
||||
extern AUDACITY_DLL_API IntSetting AudioIORecordingSourceIndex;
|
||||
|
@ -389,8 +389,7 @@ WaveTrackArray ProjectAudioManager::ChooseExistingRecordingTracks(
|
||||
AudacityProject &proj, bool selectedOnly, double targetRate)
|
||||
{
|
||||
auto p = &proj;
|
||||
size_t recordingChannels =
|
||||
std::max(0L, gPrefs->Read(wxT("/AudioIO/RecordChannels"), 2));
|
||||
size_t recordingChannels = std::max(0, AudioIORecordChannels.Read());
|
||||
bool strictRules = (recordingChannels <= 2);
|
||||
|
||||
// Iterate over all wave tracks, or over selected wave tracks only.
|
||||
@ -665,7 +664,7 @@ bool ProjectAudioManager::DoRecord(AudacityProject &project,
|
||||
auto &trackList = TrackList::Get( *p );
|
||||
auto numTracks = trackList.Leaders< const WaveTrack >().size();
|
||||
|
||||
auto recordingChannels = std::max(1L, gPrefs->Read(wxT("/AudioIO/RecordChannels"), 2));
|
||||
auto recordingChannels = std::max(1, AudioIORecordChannels.Read());
|
||||
|
||||
gPrefs->Read(wxT("/GUI/TrackNames/RecordingNameCustom"), &recordingNameCustom, false);
|
||||
gPrefs->Read(wxT("/GUI/TrackNames/TrackNumber"), &useTrackNumber, false);
|
||||
|
@ -1053,9 +1053,8 @@ int ProjectManager::GetEstimatedRecordingMinsLeftOnDisk(long lCaptureChannels) {
|
||||
|
||||
// Obtain the current settings
|
||||
auto oCaptureFormat = QualityPrefs::SampleFormatChoice();
|
||||
if (lCaptureChannels == 0) {
|
||||
gPrefs->Read(wxT("/AudioIO/RecordChannels"), &lCaptureChannels, 2L);
|
||||
}
|
||||
if (lCaptureChannels == 0)
|
||||
lCaptureChannels = AudioIORecordChannels.Read();
|
||||
|
||||
// Find out how much free space we have on disk
|
||||
wxLongLong lFreeSpace = ProjectFileIO::Get( project ).GetFreeDiskSpace();
|
||||
|
@ -529,8 +529,8 @@ void OnPunchAndRoll(const CommandContext &context)
|
||||
auto tracks =
|
||||
ProjectAudioManager::ChooseExistingRecordingTracks(project, true, rateOfSelected);
|
||||
if (tracks.empty()) {
|
||||
int recordingChannels =
|
||||
std::max(0L, gPrefs->Read(wxT("/AudioIO/RecordChannels"), 2));
|
||||
auto recordingChannels =
|
||||
std::max(0, AudioIORecordChannels.Read());
|
||||
auto message =
|
||||
(recordingChannels == 1)
|
||||
? XO("Please select in a mono track.")
|
||||
|
@ -24,6 +24,7 @@ other settings.
|
||||
|
||||
|
||||
#include "DevicePrefs.h"
|
||||
#include "AudioIOBase.h"
|
||||
|
||||
#include "RecordingPrefs.h"
|
||||
|
||||
@ -84,10 +85,10 @@ void DevicePrefs::Populate()
|
||||
GetNamesAndLabels();
|
||||
|
||||
// Get current setting for devices
|
||||
mPlayDevice = gPrefs->Read(wxT("/AudioIO/PlaybackDevice"), wxT(""));
|
||||
mRecordDevice = gPrefs->Read(wxT("/AudioIO/RecordingDevice"), wxT(""));
|
||||
mRecordSource = gPrefs->Read(wxT("/AudioIO/RecordingSource"), wxT(""));
|
||||
mRecordChannels = gPrefs->Read(wxT("/AudioIO/RecordChannels"), 2L);
|
||||
mPlayDevice = AudioIOPlaybackDevice.Read();
|
||||
mRecordDevice = AudioIORecordingDevice.Read();
|
||||
mRecordSource = AudioIORecordingSource.Read();
|
||||
mRecordChannels = AudioIORecordChannels.Read();
|
||||
|
||||
//------------------------- Main section --------------------
|
||||
// Now construct the GUI itself.
|
||||
@ -137,7 +138,7 @@ void DevicePrefs::PopulateOrExchange(ShuttleGui & S)
|
||||
S.Id(HostID);
|
||||
mHost = S.TieChoice( XXO("&Host:"),
|
||||
{
|
||||
wxT("/AudioIO/Host"),
|
||||
AudioIOHost,
|
||||
{ ByColumns, mHostNames, mHostLabels }
|
||||
}
|
||||
);
|
||||
@ -190,17 +191,14 @@ void DevicePrefs::PopulateOrExchange(ShuttleGui & S)
|
||||
w = S
|
||||
.NameSuffix(XO("milliseconds"))
|
||||
.TieNumericTextBox(XXO("&Buffer length:"),
|
||||
{wxT("/AudioIO/LatencyDuration"),
|
||||
DEFAULT_LATENCY_DURATION},
|
||||
AudioIOLatencyDuration,
|
||||
9);
|
||||
S.AddUnits(XO("milliseconds"));
|
||||
|
||||
w = S
|
||||
.NameSuffix(XO("milliseconds"))
|
||||
.TieNumericTextBox(XXO("&Latency compensation:"),
|
||||
{wxT("/AudioIO/LatencyCorrection"),
|
||||
DEFAULT_LATENCY_CORRECTION},
|
||||
9);
|
||||
AudioIOLatencyCorrection, 9);
|
||||
S.AddUnits(XO("milliseconds"));
|
||||
}
|
||||
S.EndThreeColumn();
|
||||
@ -396,28 +394,21 @@ bool DevicePrefs::Commit()
|
||||
map = (DeviceSourceMap *) mPlay->GetClientData(
|
||||
mPlay->GetSelection());
|
||||
}
|
||||
if (map) {
|
||||
gPrefs->Write(wxT("/AudioIO/PlaybackDevice"), map->deviceString);
|
||||
}
|
||||
if (map)
|
||||
AudioIOPlaybackDevice.Write(map->deviceString);
|
||||
|
||||
map = NULL;
|
||||
if (mRecord->GetCount() > 0) {
|
||||
map = (DeviceSourceMap *) mRecord->GetClientData(mRecord->GetSelection());
|
||||
}
|
||||
if (map) {
|
||||
gPrefs->Write(wxT("/AudioIO/RecordingDevice"),
|
||||
map->deviceString);
|
||||
gPrefs->Write(wxT("/AudioIO/RecordingSourceIndex"),
|
||||
map->sourceIndex);
|
||||
if (map->totalSources >= 1) {
|
||||
gPrefs->Write(wxT("/AudioIO/RecordingSource"),
|
||||
map->sourceString);
|
||||
} else {
|
||||
gPrefs->Write(wxT("/AudioIO/RecordingSource"),
|
||||
wxT(""));
|
||||
}
|
||||
gPrefs->Write(wxT("/AudioIO/RecordChannels"),
|
||||
mChannels->GetSelection() + 1);
|
||||
AudioIORecordingDevice.Write(map->deviceString);
|
||||
AudioIORecordingSourceIndex.Write(map->sourceIndex);
|
||||
if (map->totalSources >= 1)
|
||||
AudioIORecordingSource.Write(map->sourceString);
|
||||
else
|
||||
AudioIORecordingSource.Reset();
|
||||
AudioIORecordChannels.Write(mChannels->GetSelection() + 1);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
|
||||
#include "RecordingPrefs.h"
|
||||
#include "AudioIOBase.h"
|
||||
|
||||
#include <wx/defs.h>
|
||||
#include <wx/textctrl.h>
|
||||
@ -269,11 +270,8 @@ bool RecordingPrefs::Commit()
|
||||
ShuttleGui S(this, eIsSavingToPrefs);
|
||||
PopulateOrExchange(S);
|
||||
|
||||
double latencyDuration = DEFAULT_LATENCY_DURATION;
|
||||
gPrefs->Read(wxT("/AudioIO/LatencyDuration"), &latencyDuration);
|
||||
if (latencyDuration < 0) {
|
||||
gPrefs->Write(wxT("/AudioIO/LatencyDuration"), DEFAULT_LATENCY_DURATION);
|
||||
}
|
||||
if (AudioIOLatencyDuration.Read() < 0)
|
||||
AudioIOLatencyDuration.Reset();
|
||||
|
||||
#ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
|
||||
double targetpeak, deltapeak;
|
||||
|
@ -30,9 +30,6 @@ class ShuttleGui;
|
||||
|
||||
#define RECORDING_PREFS_PLUGIN_SYMBOL ComponentInterfaceSymbol{ XO("Recording") }
|
||||
|
||||
#define DEFAULT_LATENCY_DURATION 100.0
|
||||
#define DEFAULT_LATENCY_CORRECTION -130.0
|
||||
|
||||
#define AUDIO_PRE_ROLL_KEY (wxT("/AudioIO/PreRoll"))
|
||||
#define DEFAULT_PRE_ROLL_SECONDS 5.0
|
||||
|
||||
|
@ -237,9 +237,6 @@ void DeviceToolBar::OnCaptureKey(wxCommandEvent &event)
|
||||
|
||||
void DeviceToolBar::UpdatePrefs()
|
||||
{
|
||||
wxString hostName;
|
||||
wxString devName;
|
||||
wxString sourceName;
|
||||
wxString desc;
|
||||
const std::vector<DeviceSourceMap> &inMaps = DeviceManager::Instance()->GetInputDeviceMaps();
|
||||
const std::vector<DeviceSourceMap> &outMaps = DeviceManager::Instance()->GetOutputDeviceMaps();
|
||||
@ -248,15 +245,15 @@ void DeviceToolBar::UpdatePrefs()
|
||||
int hostSelectionIndex = mHost->GetSelection();
|
||||
wxString oldHost = hostSelectionIndex >= 0 ? mHost->GetString(hostSelectionIndex) :
|
||||
wxT("");
|
||||
hostName = gPrefs->Read(wxT("/AudioIO/Host"), wxT(""));
|
||||
auto hostName = AudioIOHost.Read();
|
||||
|
||||
// if the prefs host name doesn't match the one displayed, it changed
|
||||
// in another project's DeviceToolBar, so we need to repopulate everything.
|
||||
if (oldHost != hostName)
|
||||
FillHostDevices();
|
||||
|
||||
devName = gPrefs->Read(wxT("/AudioIO/RecordingDevice"), wxT(""));
|
||||
sourceName = gPrefs->Read(wxT("/AudioIO/RecordingSource"), wxT(""));
|
||||
auto devName = AudioIORecordingDevice.Read();
|
||||
auto sourceName = AudioIORecordingSource.Read();
|
||||
if (sourceName.empty())
|
||||
desc = devName;
|
||||
else
|
||||
@ -285,7 +282,7 @@ void DeviceToolBar::UpdatePrefs()
|
||||
}
|
||||
}
|
||||
|
||||
devName = gPrefs->Read(wxT("/AudioIO/PlaybackDevice"), wxT(""));
|
||||
devName = AudioIOPlaybackDevice.Read();
|
||||
sourceName = gPrefs->Read(wxT("/AudioIO/PlaybackSource"), wxT(""));
|
||||
if (sourceName.empty())
|
||||
desc = devName;
|
||||
@ -315,9 +312,9 @@ void DeviceToolBar::UpdatePrefs()
|
||||
}
|
||||
}
|
||||
|
||||
long oldChannels, newChannels;
|
||||
long oldChannels;
|
||||
oldChannels = mInputChannels->GetSelection() + 1;
|
||||
gPrefs->Read(wxT("/AudioIO/RecordChannels"), &newChannels, 0);
|
||||
auto newChannels = AudioIORecordChannels.ReadWithDefault(0);
|
||||
if (newChannels > 0 && oldChannels != newChannels)
|
||||
mInputChannels->SetSelection(newChannels - 1);
|
||||
|
||||
@ -432,7 +429,7 @@ void DeviceToolBar::FillHostDevices()
|
||||
const std::vector<DeviceSourceMap> &outMaps = DeviceManager::Instance()->GetOutputDeviceMaps();
|
||||
|
||||
//read what is in the prefs
|
||||
wxString host = gPrefs->Read(wxT("/AudioIO/Host"), wxT(""));
|
||||
auto host = AudioIOHost.Read();
|
||||
int foundHostIndex = -1;
|
||||
|
||||
// if the host is not in the hosts combo then we rescanned.
|
||||
@ -482,7 +479,7 @@ void DeviceToolBar::FillHostDevices()
|
||||
mInput->Append(MakeDeviceSourceString(&device));
|
||||
if (host.empty()) {
|
||||
host = device.hostString;
|
||||
gPrefs->Write(wxT("/AudioIO/Host"), host);
|
||||
AudioIOHost.Write(host);
|
||||
mHost->SetStringSelection(host);
|
||||
}
|
||||
}
|
||||
@ -496,7 +493,7 @@ void DeviceToolBar::FillHostDevices()
|
||||
mOutput->Append(MakeDeviceSourceString(&device));
|
||||
if (host.empty()) {
|
||||
host = device.hostString;
|
||||
gPrefs->Write(wxT("/AudioIO/Host"), host);
|
||||
AudioIOHost.Write(host);
|
||||
gPrefs->Flush();
|
||||
mHost->SetStringSelection(host);
|
||||
}
|
||||
@ -512,12 +509,12 @@ void DeviceToolBar::FillHostDevices()
|
||||
void DeviceToolBar::FillInputChannels()
|
||||
{
|
||||
const std::vector<DeviceSourceMap> &inMaps = DeviceManager::Instance()->GetInputDeviceMaps();
|
||||
wxString host = gPrefs->Read(wxT("/AudioIO/Host"), wxT(""));
|
||||
wxString device = gPrefs->Read(wxT("/AudioIO/RecordingDevice"), wxT(""));
|
||||
wxString source = gPrefs->Read(wxT("/AudioIO/RecordingSource"), wxT(""));
|
||||
long oldChannels = 2, newChannels;
|
||||
auto host = AudioIOHost.Read();
|
||||
auto device = AudioIORecordingDevice.Read();
|
||||
auto source = AudioIORecordingSource.Read();
|
||||
long newChannels;
|
||||
|
||||
gPrefs->Read(wxT("/AudioIO/RecordChannels"), &oldChannels);
|
||||
auto oldChannels = AudioIORecordChannels.Read();
|
||||
mInputChannels->Clear();
|
||||
for (auto & dev: inMaps) {
|
||||
if (source == dev.sourceString &&
|
||||
@ -546,7 +543,7 @@ void DeviceToolBar::FillInputChannels()
|
||||
if (newChannels >= 1) {
|
||||
mInputChannels->SetSelection(newChannels - 1);
|
||||
}
|
||||
gPrefs->Write(wxT("/AudioIO/RecordChannels"), newChannels);
|
||||
AudioIORecordChannels.Write(newChannels);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -568,7 +565,7 @@ int DeviceToolBar::ChangeHost()
|
||||
int hostSelectionIndex;
|
||||
hostSelectionIndex = mHost->GetSelection();
|
||||
|
||||
wxString oldHost = gPrefs->Read(wxT("/AudioIO/Host"), wxT(""));
|
||||
auto oldHost = AudioIOHost.Read();
|
||||
wxString newHost = hostSelectionIndex >= 0 ? mHost->GetString(hostSelectionIndex) :
|
||||
oldHost;
|
||||
|
||||
@ -576,7 +573,7 @@ int DeviceToolBar::ChangeHost()
|
||||
return 0;
|
||||
|
||||
//change the host and switch to correct devices.
|
||||
gPrefs->Write(wxT("/AudioIO/Host"), newHost);
|
||||
AudioIOHost.Write(newHost);
|
||||
gPrefs->Flush();
|
||||
|
||||
// populate the devices
|
||||
@ -588,20 +585,19 @@ int DeviceToolBar::ChangeHost()
|
||||
void DeviceToolBar::SetDevices(const DeviceSourceMap *in, const DeviceSourceMap *out)
|
||||
{
|
||||
if (in) {
|
||||
gPrefs->Write(wxT("/AudioIO/RecordingDevice"), in->deviceString);
|
||||
gPrefs->Write(wxT("/AudioIO/RecordingSourceIndex"), in->sourceIndex);
|
||||
if (in->totalSources >= 1) {
|
||||
gPrefs->Write(wxT("/AudioIO/RecordingSource"), in->sourceString);
|
||||
} else {
|
||||
gPrefs->Write(wxT("/AudioIO/RecordingSource"), wxT(""));
|
||||
}
|
||||
AudioIORecordingDevice.Write(in->deviceString);
|
||||
AudioIORecordingSourceIndex.Write(in->sourceIndex);
|
||||
if (in->totalSources >= 1)
|
||||
AudioIORecordingSource.Write(in->sourceString);
|
||||
else
|
||||
AudioIORecordingSource.Reset();
|
||||
gPrefs->Flush();
|
||||
|
||||
FillInputChannels();
|
||||
}
|
||||
|
||||
if (out) {
|
||||
gPrefs->Write(wxT("/AudioIO/PlaybackDevice"), out->deviceString);
|
||||
AudioIOPlaybackDevice.Write(out->deviceString);
|
||||
if (out->totalSources >= 1) {
|
||||
gPrefs->Write(wxT("/AudioIO/PlaybackSource"), out->sourceString);
|
||||
} else {
|
||||
@ -618,7 +614,7 @@ void DeviceToolBar::ChangeDevice(bool isInput)
|
||||
size_t i;
|
||||
|
||||
int selectionIndex = combo->GetSelection();
|
||||
wxString host = gPrefs->Read(wxT("/AudioIO/Host"), wxT(""));
|
||||
auto host = AudioIOHost.Read();
|
||||
const std::vector<DeviceSourceMap> &maps = isInput ? DeviceManager::Instance()->GetInputDeviceMaps()
|
||||
: DeviceManager::Instance()->GetOutputDeviceMaps();
|
||||
|
||||
@ -652,7 +648,7 @@ void DeviceToolBar::OnChoice(wxCommandEvent &event)
|
||||
} else if (eventObject == mInputChannels) {
|
||||
int channelsSelectionIndex = mInputChannels->GetSelection();
|
||||
if (channelsSelectionIndex >= 0)
|
||||
gPrefs->Write(wxT("/AudioIO/RecordChannels"),channelsSelectionIndex + 1);
|
||||
AudioIORecordChannels.Write(channelsSelectionIndex + 1);
|
||||
} else if (eventObject == mInput) {
|
||||
ChangeDevice(true);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user