return input_mapping;
}
+void AudioMixer::set_extra_devices(const set<DeviceSpec> &devices)
+{
+ lock_guard<timed_mutex> lock(audio_mutex);
+ extra_devices = devices;
+ for (unsigned card_index = 0; card_index < MAX_ALSA_CARDS; ++card_index) {
+ const DeviceSpec device_spec{InputSourceType::ALSA_INPUT, card_index};
+ start_or_stop_alsa_capture(device_spec);
+ }
+}
+
unsigned AudioMixer::num_buses() const
{
lock_guard<timed_mutex> lock(audio_mutex);
assert(device_spec.type == InputSourceType::ALSA_INPUT);
AudioDevice *device = find_audio_device(device_spec);
bool previously_held = alsa_pool.device_is_held(device_spec.index);
- bool should_be_held = !device->interesting_channels.empty();
+ bool should_be_held = !device->interesting_channels.empty() || extra_devices.count(device_spec);
if (should_be_held) {
alsa_pool.hold_device(device_spec.index);
} else {
MappingMode get_mapping_mode() const;
InputMapping get_input_mapping() const;
+ // See extra_devices.
+ void set_extra_devices(const std::set<DeviceSpec> &devices);
+
unsigned num_buses() const;
void set_locut_cutoff(float cutoff_hz)
std::unique_ptr<BusMetrics[]> bus_metrics; // One for each bus in <input_mapping>.
DelayAnalyzerInterface *delay_analyzer = nullptr;
+
+ // A set of devices (potentially empty) that should be kept open even
+ // if they're not used in any bus. This allows the delay analyzer to
+ // make sure a given ALSA device is opened to tap into its data, even if
+ // there is no bus using it. (Non-ALSA devices are allowed to be here,
+ // but won't do anything.)
+ std::set<DeviceSpec> extra_devices;
};
extern AudioMixer *global_audio_mixer;
ui->peak_display_2->reset_base();
ui->peak_display_1->audio_clip_updated();
ui->peak_display_2->audio_clip_updated();
+
+ set<DeviceSpec> devices;
+ devices.insert(get_selected_device(ui->card_combo_1));
+ devices.insert(get_selected_device(ui->card_combo_2));
+ global_audio_mixer->set_extra_devices(devices);
}
void DelayAnalyzer::card_selected(QComboBox *card_combo, int selected_index)
clip2.get_length_seconds_after_base(base) >= 1.0) {
post_to_main_thread([this] {
grab_timeout->stop();
+ global_audio_mixer->set_extra_devices({}); // Put on another thread so that we don't get recursive locking.
});
grabbing = false;
void DelayAnalyzer::grab_timed_out()
{
grabbing = false;
+ global_audio_mixer->set_extra_devices({});
ui->delay_estimate_label->setText("Could not capture audio (timed out).");
}