: ui(new Ui::InputMappingDialog),
mapping(global_mixer->get_audio_mixer()->get_input_mapping()),
old_mapping(mapping),
- card_names(global_mixer->get_audio_mixer()->get_names())
+ devices(global_mixer->get_audio_mixer()->get_devices())
{
ui->setupUi(this);
ui->table->setSelectionBehavior(QAbstractItemView::SelectRows);
// Card choices.
QComboBox *card_combo = new QComboBox;
+ unsigned current_index = 0;
card_combo->addItem(QString("(none) "));
- for (const string &name : card_names) {
- card_combo->addItem(QString::fromStdString(name + " "));
- }
- switch (bus.device.type) {
- case InputSourceType::SILENCE:
- card_combo->setCurrentIndex(0);
- break;
- case InputSourceType::CAPTURE_CARD:
- card_combo->setCurrentIndex(mapping.buses[row].device.index + 1);
- break;
- default:
- assert(false);
+ for (const auto &spec_and_info : devices) {
+ ++current_index;
+ card_combo->addItem(
+ QString::fromStdString(spec_and_info.second.name + " "),
+ qulonglong(DeviceSpec_to_key(spec_and_info.first)));
+ if (bus.device == spec_and_info.first) {
+ card_combo->setCurrentIndex(current_index);
+ }
}
connect(card_combo, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
- bind(&InputMappingDialog::card_selected, this, row, _1));
+ bind(&InputMappingDialog::card_selected, this, card_combo, row, _1));
ui->table->setCellWidget(row, 1, card_combo);
setup_channel_choices_from_bus(row, bus);
for (unsigned channel = 0; channel < 2; ++channel) {
QComboBox *channel_combo = new QComboBox;
channel_combo->addItem(QString("(none)"));
- if (bus.device.type == InputSourceType::CAPTURE_CARD) {
- for (unsigned source = 0; source < 8; ++source) { // TODO: Ask the card about number of channels, and names.
+ if (bus.device.type == InputSourceType::CAPTURE_CARD ||
+ bus.device.type == InputSourceType::ALSA_INPUT) {
+ auto device_it = devices.find(bus.device);
+ assert(device_it != devices.end());
+ unsigned num_device_channels = device_it->second.num_channels;
+ for (unsigned source = 0; source < num_device_channels; ++source) {
char buf[256];
snprintf(buf, sizeof(buf), "Channel %u ", source + 1);
channel_combo->addItem(QString(buf));
mapping.buses[row].name = ui->table->item(row, column)->text().toStdString();
}
-void InputMappingDialog::card_selected(unsigned row, int index)
+void InputMappingDialog::card_selected(QComboBox *card_combo, unsigned row, int index)
{
- if (index == 0) {
- mapping.buses[row].device.type = InputSourceType::SILENCE;
- } else {
- mapping.buses[row].device.type = InputSourceType::CAPTURE_CARD;
- mapping.buses[row].device.index = index - 1;
- }
+ uint64_t key = card_combo->itemData(index).toULongLong();
+ mapping.buses[row].device = key_to_DeviceSpec(key);
setup_channel_choices_from_bus(row, mapping.buses[row]);
}