]> git.sesse.net Git - nageru/blobdiff - mainwindow.cpp
Add the GPU memory metrics to the Grafana dashboard.
[nageru] / mainwindow.cpp
index bbafc25d05ecf275bba006d4e14fe58c96bc7b2d..839f1b359e1a9060fdb64a8cfdd942b0f42c26ea 100644 (file)
@@ -956,11 +956,13 @@ void MainWindow::audio_level_callback(float level_lufs, float peak_db, vector<Au
                set_peak_label(ui->peak_display, peak_db);
 
                // NOTE: Will be invisible when using multitrack audio.
-               ui->gainstaging_knob->blockSignals(true);
-               ui->gainstaging_knob->setValue(lrintf(bus_levels[0].gain_staging_db * 10.0f));
-               ui->gainstaging_knob->blockSignals(false);
-               ui->gainstaging_db_display->setText(
-                       QString::fromStdString(format_db(bus_levels[0].gain_staging_db, DB_WITH_SIGN)));
+               if (!bus_levels.empty()) {
+                       ui->gainstaging_knob->blockSignals(true);
+                       ui->gainstaging_knob->setValue(lrintf(bus_levels[0].gain_staging_db * 10.0f));
+                       ui->gainstaging_knob->blockSignals(false);
+                       ui->gainstaging_db_display->setText(
+                               QString::fromStdString(format_db(bus_levels[0].gain_staging_db, DB_WITH_SIGN)));
+               }
 
                ui->makeup_gain_knob->blockSignals(true);
                ui->makeup_gain_knob->setValue(lrintf(final_makeup_gain_db * 10.0f));
@@ -1468,7 +1470,9 @@ bool MainWindow::eventFilter(QObject *watched, QEvent *event)
                QApplication::restoreOverrideCursor();
                if (watched == previews[current_wb_pick_display]->display) {
                        const QMouseEvent *mouse_event = (QMouseEvent *)event;
-                       set_white_balance(current_wb_pick_display, mouse_event->x(), mouse_event->y());
+                       previews[current_wb_pick_display]->display->grab_white_balance(
+                               current_wb_pick_display,
+                               mouse_event->x(), mouse_event->y());
                } else {
                        // The user clicked on something else, give up.
                        // (The click goes through, which might not be ideal, but, yes.)
@@ -1494,34 +1498,6 @@ void MainWindow::closeEvent(QCloseEvent *event)
        event->accept();
 }
 
-namespace {
-
-double srgb_to_linear(double x)
-{
-       if (x < 0.04045) {
-               return x / 12.92;
-       } else {
-               return pow((x + 0.055) / 1.055, 2.4);
-       }
-}
-
-}  // namespace
-
-void MainWindow::set_white_balance(int channel_number, int x, int y)
-{
-       // Set the white balance to neutral for the grab. It's probably going to
-       // flicker a bit, but hopefully this display is not live anyway.
-       global_mixer->set_wb(Mixer::OUTPUT_INPUT0 + channel_number, 0.5, 0.5, 0.5);
-       previews[channel_number]->display->updateGL();
-       QRgb reference_color = previews[channel_number]->display->grabFrameBuffer().pixel(x, y);
-
-       double r = srgb_to_linear(qRed(reference_color) / 255.0);
-       double g = srgb_to_linear(qGreen(reference_color) / 255.0);
-       double b = srgb_to_linear(qBlue(reference_color) / 255.0);
-       global_mixer->set_wb(Mixer::OUTPUT_INPUT0 + channel_number, r, g, b);
-       previews[channel_number]->display->updateGL();
-}
-
 void MainWindow::audio_state_changed()
 {
        post_to_main_thread([this]{