summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0614cde)
raw | patch | inline | side by side (parent: 0614cde)
author | Manisha Agrawal <manisha.agrawal@ti.com> | |
Thu, 9 Jun 2016 21:03:25 +0000 (16:03 -0500) | ||
committer | Manisha Agrawal <manisha.agrawal@ti.com> | |
Thu, 9 Jun 2016 21:03:25 +0000 (16:03 -0500) |
Mutex is used rather using global variables to prevent simultaneous
access to drm resource by loopback and main thread.
access to drm resource by loopback and main thread.
mainwindow.cpp | patch | blob | history |
diff --git a/mainwindow.cpp b/mainwindow.cpp
index ceb5383c9e0d4e1c17d49a2487de44ecced72942..b82fdd0454d59da8c50f3131ca597fd6c0ba1a13 100644 (file)
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QThread>
+#include <QMutex>
#include "loopback.h"
#include <stdio.h>
};
MyThread* loopback;
-bool processing_frame = 1;
-bool pause_process = 0;
+QMutex drm_resource;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
/* Making the background color black solves the problem */
ui->frame->setStyleSheet("background-color:black;");
ui->frame->show();
-
+
ui->frame_pip->setGeometry(25, 25, status.display_xres/3, status.display_yres/3);
ui->capture->setGeometry(status.display_xres/2 - 210,
status.display_yres - 50,
/* While changing the drm display properties, make sure loopback thread */
/* isn't running thereby accessing drm properties simultaneously, and */
/* hence can cause system crash */
- QThread* thread = QThread::currentThread();
- pause_process = 1;
- while(processing_frame){
- QThread::msleep(1);
- }
+ drm_resource.lock();
- /* Raise current thread priority to change the drm properties for display */
- thread->setPriority(QThread::HighestPriority);
if (status.num_cams==2){
+ //switch the main camera by toggleing the main_cam value.
status.main_cam = !status.main_cam;
set_plane_properties();
}
- pause_process = 0;
+
+ drm_resource.unlock();
}
void MainWindow::on_pip_clicked()
{
- QThread* thread = QThread::currentThread();
-
- /* While changing the drm display properties, make sure loopback thread */
- /* isn't running thereby accessing drm properties simultaneously, and */
+ /* While changing the drm display properties, make sure loopback thread */
+ /* isn't running thereby accessing drm properties simultaneously, and */
/* hence can cause system crash */
- pause_process = 1;
- while(processing_frame){
- QThread::msleep(1);
- }
-
- /* Raise current thread priority to change the drm properties for display */
- thread->setPriority(QThread::HighestPriority);
+ drm_resource.lock();
if (status.num_cams==1) {
status.pip=false;
status.pip=true;
status.num_cams = 2;
}
- pause_process = 0;
+
+ drm_resource.unlock();
}
void MainWindow::on_exit_clicked()
void MyThread::run() {
while(status.exit == false) {
- processing_frame = 1;
-
- while(pause_process){
- msleep(1);
- }
-
+ drm_resource.lock();
process_frame();
-
- processing_frame = 0;
+ drm_resource.unlock();
msleep(1);
}
end_streaming();