]> git.sesse.net Git - nageru/blobdiff - nageru/input_mapping_dialog.cpp
Make number of cards flexible at runtime.
[nageru] / nageru / input_mapping_dialog.cpp
index b4565152a4af01b290941025633e7224b8c4d4dd..831d4873468f488283b6e8d0546982264606efd4 100644 (file)
 using namespace std;
 using namespace std::placeholders;
 
+namespace {
+
+bool uses_device(const InputMapping &mapping, DeviceSpec device)
+{
+       for (const InputMapping::Bus &bus : mapping.buses) {
+               if (bus.device == device) {
+                       return true;
+               }
+       }
+       return false;
+}
+
+}  // namespace
+
 InputMappingDialog::InputMappingDialog()
        : ui(new Ui::InputMappingDialog),
          mapping(global_audio_mixer->get_input_mapping()),
@@ -113,6 +127,15 @@ void InputMappingDialog::fill_row_from_bus(unsigned row, const InputMapping::Bus
                        } else if (state == ALSAPool::Device::State::DEAD) {
                                label += " (dead)";
                        }
+               } else if (!global_audio_mixer->get_active(spec_and_info.first)) {
+                       // Should nominally be skipped, but if we used it before it went away,
+                       // we'll need to allow the user to still see it.
+                       if (uses_device(mapping, spec_and_info.first) ||
+                           uses_device(old_mapping, spec_and_info.first)) {
+                               label += " (dead)";
+                       } else {
+                               continue;
+                       }
                }
                ++current_index;
                if (unsigned(card_combo->count()) > current_index) {
@@ -148,8 +171,7 @@ void InputMappingDialog::setup_channel_choices_from_bus(unsigned row, const Inpu
                QComboBox *channel_combo = new QComboBox;
                channel_combo->addItem(QString("(none)"));
                if (bus.device.type == InputSourceType::CAPTURE_CARD ||
-                   bus.device.type == InputSourceType::ALSA_INPUT ||
-                   bus.device.type == InputSourceType::FFMPEG_VIDEO_INPUT) {
+                   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;