| 321 | } |
| 322 | |
| 323 | void DevicePrefs::OnHost(wxCommandEvent & e) |
| 324 | { |
| 325 | // Bail if we have no hosts |
| 326 | if (mHostNames.size() < 1) |
| 327 | return; |
| 328 | |
| 329 | // Find the index for the host API selected |
| 330 | int index = -1; |
| 331 | auto apiName = mHostLabels[mHost->GetCurrentSelection()]; |
| 332 | int nHosts = Pa_GetHostApiCount(); |
| 333 | for (int i = 0; i < nHosts; ++i) { |
| 334 | wxString name = wxSafeConvertMB2WX(Pa_GetHostApiInfo(i)->name); |
| 335 | if (name == apiName) { |
| 336 | index = i; |
| 337 | break; |
| 338 | } |
| 339 | } |
| 340 | // We should always find the host! |
| 341 | if (index < 0) { |
| 342 | wxLogDebug(wxT("DevicePrefs::OnHost(): API index not found")); |
| 343 | return; |
| 344 | } |
| 345 | |
| 346 | int nDevices = Pa_GetDeviceCount(); |
| 347 | |
| 348 | // FIXME: TRAP_ERR PaErrorCode not handled. nDevices can be negative number. |
| 349 | if (nDevices == 0) { |
| 350 | mHost->Clear(); |
| 351 | mHost->Append(_("No audio interfaces"), (void *) NULL); |
| 352 | mHost->SetSelection(0); |
| 353 | } |
| 354 | |
| 355 | const std::vector<DeviceSourceMap> &inMaps = DeviceManager::Instance()->GetInputDeviceMaps(); |
| 356 | const std::vector<DeviceSourceMap> &outMaps = DeviceManager::Instance()->GetOutputDeviceMaps(); |
| 357 | |
| 358 | wxArrayString playnames; |
| 359 | wxArrayString recordnames; |
| 360 | size_t i; |
| 361 | int devindex; /* temp variable to hold the numeric ID of each device in turn */ |
| 362 | wxString device; |
| 363 | wxString recDevice; |
| 364 | |
| 365 | recDevice = mRecordDevice; |
| 366 | if (!this->mRecordSource.empty()) |
| 367 | recDevice += wxT(": ") + mRecordSource; |
| 368 | |
| 369 | mRecord->Clear(); |
| 370 | for (i = 0; i < inMaps.size(); i++) { |
| 371 | if (index == inMaps[i].hostIndex) { |
| 372 | device = MakeDeviceSourceString(&inMaps[i]); |
| 373 | devindex = mRecord->Append(device); |
| 374 | // We need to const cast here because SetClientData is a wx function |
| 375 | // It is okay because the original variable is non-const. |
| 376 | mRecord->SetClientData(devindex, const_cast<DeviceSourceMap *>(&inMaps[i])); |
| 377 | if (device == recDevice) { /* if this is the default device, select it */ |
| 378 | mRecord->SetSelection(devindex); |
| 379 | } |
| 380 | } |
nothing calls this directly
no test coverage detected