| 231 | } |
| 232 | |
| 233 | void 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()) { |
nothing calls this directly
no test coverage detected