#include <memory>
+#include <QTimer>
+
using namespace bmusb;
using namespace std;
using namespace std::chrono;
DelayAnalyzer::DelayAnalyzer()
: ui(new Ui::DelayAnalyzer),
- devices(global_audio_mixer->get_devices(AudioMixer::HOLD_NO_DEVICES))
+ devices(global_audio_mixer->get_devices(AudioMixer::HOLD_NO_DEVICES)),
+ grab_timeout(new QTimer(this))
{
ui->setupUi(this);
connect(ui->grab_btn, &QPushButton::clicked, this, &DelayAnalyzer::grab_clicked);
bind(&DelayAnalyzer::channel_selected, this, ui->channel_combo_1));
connect(ui->channel_combo_2, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
bind(&DelayAnalyzer::channel_selected, this, ui->channel_combo_2));
+ connect(grab_timeout, &QTimer::timeout, bind(&DelayAnalyzer::grab_timed_out, this));
for (const auto &spec_and_info : devices) {
QString label(QString::fromStdString(spec_and_info.second.display_name));
void DelayAnalyzer::grab_clicked()
{
grabbing = true;
+ grab_timeout->setSingleShot(true);
+ grab_timeout->start(milliseconds(2000));
clip1.clear();
clip2.clear();
ui->peak_display_1->reset_base();
if (clip1.get_length_seconds_after_base(base) >= 1.0 &&
clip2.get_length_seconds_after_base(base) >= 1.0) {
+ post_to_main_thread([this] {
+ grab_timeout->stop();
+ });
grabbing = false;
}
}
+
+void DelayAnalyzer::grab_timed_out()
+{
+ grabbing = false;
+ ui->delay_estimate_label->setText("Could not capture audio (timed out).");
+}