MCPcopy Create free account
hub / github.com/audacity/audacity / UpdatePrefs

Method UpdatePrefs

src/toolbars/AudioSetupToolBar.cpp:233–333  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

231}
232
233void AudioSetupToolBar::UpdatePrefs()
234{
235 wxString desc;
236 const std::vector<DeviceSourceMap> &inMaps = DeviceManager::Instance()->GetInputDeviceMaps();
237 const std::vector<DeviceSourceMap> &outMaps = DeviceManager::Instance()->GetOutputDeviceMaps();
238
239 auto selectedHost = mHost.Get();
240 wxString oldHost = selectedHost ? *selectedHost : wxString{};
241
242 auto hostName = AudioIOHost.Read();
243
244 // if the prefs host name doesn't match the one displayed, it changed
245 // in another project's AudioSetupToolBar, so we need to repopulate everything.
246 if (oldHost != hostName)
247 // updates mHost and mOutput
248 FillHostDevices();
249
250 auto devName = AudioIORecordingDevice.Read();
251 auto sourceName = AudioIORecordingSource.Read();
252 if (sourceName.empty())
253 desc = devName;
254 else
255 desc = devName + wxT(": ") + sourceName;
256
257 if (mInput.Get() && *mInput.Get() != desc) {
258 if (mInput.Set(desc))
259 // updates mInputChannels
260 FillInputChannels();
261 else if (!mInput.Empty()) {
262 for (size_t i = 0; i < inMaps.size(); i++) {
263 if (inMaps[i].hostString == hostName &&
264 MakeDeviceSourceString(&inMaps[i]) == mInput.GetFirst()) {
265 // use the default. It should exist but check just in case, falling back on the 0 index.
266 DeviceSourceMap* defaultMap = DeviceManager::Instance()->GetDefaultInputDevice(inMaps[i].hostIndex);
267 if (defaultMap) {
268 mInput.Set(MakeDeviceSourceString(defaultMap));
269 SetDevices(defaultMap, nullptr);
270 }
271 else {
272 //use the first item (0th index) if we have no familiar devices
273 mInput.Set(0);
274 SetDevices(&inMaps[i], nullptr);
275 }
276 break;
277 }
278 }
279 }
280 }
281
282 devName = AudioIOPlaybackDevice.Read();
283 sourceName = AudioIOPlaybackSource.Read();
284 if (sourceName.empty())
285 desc = devName;
286 else
287 desc = devName + wxT(": ") + sourceName;
288
289 if (mOutput.Get() && *mOutput.Get() != desc) {
290 if (!mOutput.Set(desc) && !mOutput.Empty()) {

Callers

nothing calls this directly

Calls 12

MakeDeviceSourceStringFunction · 0.85
GetDefaultInputDeviceMethod · 0.80
InstanceClass · 0.50
GetMethod · 0.45
ReadMethod · 0.45
emptyMethod · 0.45
SetMethod · 0.45
EmptyMethod · 0.45
sizeMethod · 0.45
GetFirstMethod · 0.45
GetSmallIntegerIdMethod · 0.45
ReadWithDefaultMethod · 0.45

Tested by

no test coverage detected