| 433 | } |
| 434 | |
| 435 | void DevicePrefs::OnDevice(wxCommandEvent & WXUNUSED(event)) |
| 436 | { |
| 437 | int ndx = mRecord->GetCurrentSelection(); |
| 438 | if (ndx == wxNOT_FOUND) { |
| 439 | ndx = 0; |
| 440 | } |
| 441 | |
| 442 | int sel = mChannels->GetSelection(); |
| 443 | int cnt = 0; |
| 444 | |
| 445 | DeviceSourceMap *inMap = (DeviceSourceMap *) mRecord->GetClientData(ndx); |
| 446 | if (inMap != NULL) { |
| 447 | cnt = inMap->numChannels; |
| 448 | } |
| 449 | |
| 450 | if (sel != wxNOT_FOUND) { |
| 451 | mRecordChannels = sel + 1; |
| 452 | } |
| 453 | |
| 454 | mChannels->Clear(); |
| 455 | |
| 456 | // Mimic old behavior |
| 457 | if (cnt <= 0) { |
| 458 | cnt = 16; |
| 459 | } |
| 460 | |
| 461 | // Place an artificial limit on the number of channels to prevent an |
| 462 | // outrageous number. I don't know if this is really necessary, but |
| 463 | // it doesn't hurt. |
| 464 | if (cnt > 256) { |
| 465 | cnt = 256; |
| 466 | } |
| 467 | |
| 468 | wxArrayStringEx channelnames; |
| 469 | |
| 470 | // Channel counts, mono, stereo etc... |
| 471 | for (int i = 0; i < cnt; i++) { |
| 472 | wxString name; |
| 473 | |
| 474 | if (i == 0) { |
| 475 | name = _("1 (Mono)"); |
| 476 | } |
| 477 | else if (i == 1) { |
| 478 | name = _("2 (Stereo)"); |
| 479 | } |
| 480 | else { |
| 481 | name = wxString::Format(wxT("%d"), i + 1); |
| 482 | } |
| 483 | |
| 484 | channelnames.push_back(name); |
| 485 | int index = mChannels->Append(name); |
| 486 | if (i == mRecordChannels - 1) { |
| 487 | mChannels->SetSelection(index); |
| 488 | } |
| 489 | } |
| 490 | |
| 491 | if (mChannels->GetCount() && mChannels->GetCurrentSelection() == wxNOT_FOUND) { |
| 492 | mChannels->SetSelection(0); |
nothing calls this directly
no test coverage detected