]> git.sesse.net Git - nageru/blob - main.cpp
Let settings follow buses when editing the mapping.
[nageru] / main.cpp
1 extern "C" {
2 #include <libavformat/avformat.h>
3 }
4 #include <stdbool.h>
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <sys/mman.h>
8 #include <epoxy/gl.h>
9
10 #include <QApplication>
11 #include <QCoreApplication>
12 #include <QGL>
13 #include <QSize>
14 #include <QSurfaceFormat>
15
16 #include "context.h"
17 #include "flags.h"
18 #include "image_input.h"
19 #include "mainwindow.h"
20 #include "mixer.h"
21
22 int main(int argc, char *argv[])
23 {
24         parse_flags(argc, argv);
25
26         if (global_flags.va_display.empty() ||
27             global_flags.va_display[0] != '/') {
28                 // We normally use EGL for zerocopy, but if we use VA against DRM
29                 // instead of against X11, we turn it off, and then don't need EGL.
30                 setenv("QT_XCB_GL_INTEGRATION", "xcb_egl", 0);
31         }
32         setlinebuf(stdout);
33         av_register_all();
34
35         QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true);
36         QApplication app(argc, argv);
37
38         QSurfaceFormat fmt;
39         fmt.setDepthBufferSize(0);
40         fmt.setStencilBufferSize(0);
41         fmt.setProfile(QSurfaceFormat::CoreProfile);
42         fmt.setMajorVersion(3);
43         fmt.setMinorVersion(1);
44
45         // Turn off vsync, since Qt generally gives us at most frame rate
46         // (display frequency) / (number of QGLWidgets active).
47         fmt.setSwapInterval(0);
48
49         QSurfaceFormat::setDefaultFormat(fmt);
50
51         QGLFormat::setDefaultFormat(QGLFormat::fromSurfaceFormat(fmt));
52
53         global_share_widget = new QGLWidget();
54
55         MainWindow mainWindow;
56         mainWindow.resize(QSize(1500, 850));
57         mainWindow.show();
58
59         app.installEventFilter(&mainWindow);  // For white balance color picking.
60
61         // Even on an otherwise unloaded system, it would seem writing the recording
62         // to disk (potentially terabytes of data as time goes by) causes Nageru
63         // to be pushed out of RAM. If we have the right privileges, simply lock us
64         // into memory for better realtime behavior.
65         if (mlockall(MCL_CURRENT | MCL_FUTURE) == -1) {
66                 perror("mlockall()");
67                 fprintf(stderr, "Failed to lock Nageru into RAM. You probably want to\n");
68                 fprintf(stderr, "increase \"memlock\" for your user in limits.conf\n");
69                 fprintf(stderr, "for better realtime behavior.\n");
70                 uses_mlock = false;
71         } else {
72                 uses_mlock = true;
73         }
74
75         int rc = app.exec();
76         global_mixer->quit();
77         mainWindow.mixer_shutting_down();
78         delete global_mixer;
79         ImageInput::shutdown_updaters();
80         return rc;
81 }