X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=mainwindow.cpp;h=fec26f22fbf19544e4cf9dc921a3a002a696dbe6;hb=21bd3592c1a692463abd321047c2c612f91cc2ad;hp=9ed7d3e4ca7a3ea97cb084b5bb53a7d1077fb4c6;hpb=a67460db8ba2c3c50e75866fa85091fbebdc7386;p=nageru diff --git a/mainwindow.cpp b/mainwindow.cpp index 9ed7d3e..fec26f2 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -30,6 +31,7 @@ class QResizeEvent; using namespace std; +using namespace std::chrono; using namespace std::placeholders; Q_DECLARE_METATYPE(std::string); @@ -121,6 +123,8 @@ MainWindow::MainWindow() qRegisterMetaType>("std::vector"); connect(ui->me_live, &GLWidget::transition_names_updated, this, &MainWindow::set_transition_names); qRegisterMetaType("Mixer::Output"); + + last_audio_level_callback = steady_clock::now() - seconds(1); } void MainWindow::resizeEvent(QResizeEvent* event) @@ -311,13 +315,11 @@ void MainWindow::audio_level_callback(float level_lufs, float peak_db, float glo float gain_staging_db, float final_makeup_gain_db, float correlation) { - timespec now; - clock_gettime(CLOCK_MONOTONIC, &now); + steady_clock::time_point now = steady_clock::now(); // The meters are somewhat inefficient to update. Only update them // every 100 ms or so (we get updates every 5–20 ms). - double last_update_age = now.tv_sec - last_audio_level_callback.tv_sec + - 1e-9 * (now.tv_nsec - last_audio_level_callback.tv_nsec); + double last_update_age = duration(now - last_audio_level_callback).count(); if (last_update_age < 0.100) { return; }