Improve the use of separate threads for each module

FramePropertiesDock now copies an instance of the CalypFrame that
is always kept valid until updated
This commit is contained in:
2021-05-29 03:14:15 +01:00
parent 48907ef614
commit cea720f8e9
6 changed files with 31 additions and 38 deletions
+2 -2
View File
@@ -48,7 +48,7 @@ CalypAppModuleIf::CalypAppModuleIf( QObject* parent, QAction* action, CalypModul
}
}
void CalypAppModuleIf::update()
void CalypAppModuleIf::update( bool isPlaying )
{
if( m_pcDisplaySubWindow )
{
@@ -56,7 +56,7 @@ void CalypAppModuleIf::update()
}
else
{
apply();
apply( isPlaying );
}
}
+3 -2
View File
@@ -30,13 +30,14 @@
#include <cstdio>
#include <iostream>
#include "config.h"
#ifdef CALYP_THREADED_MODULES
#include <QThread>
#endif
#include "CommonDefs.h"
#include "ModuleHandleDock.h"
#include "config.h"
#include "lib/CalypFrame.h"
#include "lib/CalypModuleIf.h"
#include "lib/CalypStream.h"
@@ -105,7 +106,7 @@ public:
CalypModuleIf* getModule() { return m_pcModule; }
unsigned int getModuleRequirements() { return m_pcModule->m_uiModuleRequirements; }
ClpString moduleInfo() { return m_pcModule->moduleInfo(); }
void update();
void update( bool isPlaying );
bool apply( bool isPlaying = false, bool disableThreads = false );
bool isRunning();
void show();
+2 -1
View File
@@ -703,6 +703,7 @@ bool VideoSubWindow::hasRunningModule()
void VideoSubWindow::setFillWindow( bool bFlag )
{
m_pcVideoInfo->setBusyWindow( bFlag );
m_pcVideoInfo->repaint();
}
void VideoSubWindow::setCurrFrame( CalypFrame* pcCurrFrame )
@@ -731,7 +732,7 @@ void VideoSubWindow::refreshFrameOperation()
}
for( int i = 0; i < m_apcCurrentModule.size(); i++ )
{
m_apcCurrentModule.at( i )->update();
m_apcCurrentModule.at( i )->update( m_bIsPlaying );
}
}
+17 -27
View File
@@ -28,12 +28,12 @@
#include <QtGui>
#include <cmath>
#include "lib/CalypStream.h"
FramePropertiesDock::FramePropertiesDock( QWidget* parent, bool* pbMainPlaySwitch )
: QWidget( parent ), m_pbIsPlaying( pbMainPlaySwitch )
: QWidget( parent ), m_pbIsPlaying( pbMainPlaySwitch ), m_bHasFrame( false )
{
// -------------- Variables definition --------------
m_pcFrame = NULL;
m_pcSelectedFrame = NULL;
m_iLastFrameType = -1;
// Histogram area -----------------------------------------------------
@@ -278,13 +278,8 @@ QSize FramePropertiesDock::sizeHint() const
void FramePropertiesDock::reset()
{
m_pcFrame = NULL;
m_bHasFrame = false;
m_cSelectionArea = QRect();
if( m_pcSelectedFrame )
{
delete m_pcSelectedFrame;
m_pcSelectedFrame = NULL;
}
m_iLastFrameType = -1;
@@ -364,35 +359,30 @@ void FramePropertiesDock::setFrame( CalypFrame* pcFrame )
}
}
setEnabled( true );
if( m_pcFrame || !( *m_pbIsPlaying ) )
if( pcFrame && !( *m_pbIsPlaying ) )
{
m_pcFrame = pcFrame;
m_bHasFrame = true;
m_cFrame = CalypFrame( pcFrame );
updateDataHistogram();
}
}
void FramePropertiesDock::setSelection( const QRect& selectionArea )
{
if( m_pcFrame )
if( m_bHasFrame )
{
bool bSelectionChanged = !( selectionArea.size() == m_cSelectionArea.size() );
m_cSelectionArea = selectionArea;
if( selectionArea.isValid() )
{
m_cSelectionArea = selectionArea;
histogramWidget->stopHistogramComputation();
/*
* Allocate a new image for the selection
* or just copy information
* Crop selection from frame
*/
if( bSelectionChanged )
{
if( m_pcSelectedFrame )
{
delete m_pcSelectedFrame;
}
m_pcSelectedFrame = new CalypFrame( m_pcFrame, selectionArea.x(), selectionArea.y(), selectionArea.width(),
selectionArea.height() );
m_cSelectedFrame = CalypFrame( m_cFrame, selectionArea.x(), selectionArea.y(), selectionArea.width(),
selectionArea.height() );
}
updateDataHistogram();
selectionImageButton->click();
@@ -409,13 +399,13 @@ void FramePropertiesDock::setSelection( const QRect& selectionArea )
void FramePropertiesDock::updateDataHistogram()
{
if( m_pcFrame && isVisible() )
if( m_bHasFrame && isVisible() )
{
if( !*m_pbIsPlaying )
{
if( m_pcSelectedFrame )
if( m_cSelectionArea.isValid() )
{
m_pcSelectedFrame->copyFrom( m_pcFrame, m_cSelectionArea.x(), m_cSelectionArea.y() );
m_cSelectedFrame = CalypFrame( m_cFrame, m_cSelectionArea.x(), m_cSelectionArea.y(), m_cSelectionArea.width(), m_cSelectionArea.height() );
fullImageButton->show();
selectionImageButton->show();
}
@@ -424,7 +414,7 @@ void FramePropertiesDock::updateDataHistogram()
fullImageButton->hide();
selectionImageButton->hide();
}
histogramWidget->updateData( m_pcFrame, m_pcSelectedFrame );
histogramWidget->updateData( &m_cFrame, m_cSelectionArea.isValid() ? &m_cSelectedFrame : nullptr );
}
else
{
@@ -523,7 +513,7 @@ void FramePropertiesDock::slotRefreshOptions( int range )
void FramePropertiesDock::slotHistogramComputationFailed()
{
m_pcFrame = NULL;
m_bHasFrame = false;
}
void FramePropertiesDock::slotChannelChanged( int index )
+5 -4
View File
@@ -31,7 +31,8 @@
#include "HistogramWidget.h"
#include "config.h"
#include "lib/CalypFrame.h"
#include "lib/CalypStream.h"
class CalypStream;
class FramePropertiesDock : public QWidget
{
@@ -48,10 +49,10 @@ public:
void stopHistogram();
private:
CalypFrame* m_pcFrame;
CalypFrame* m_pcSelectedFrame;
CalypFrame m_cFrame;
CalypFrame m_cSelectedFrame;
int m_iLastFrameType;
bool m_bHasFrame;
bool* m_pbIsPlaying;
QComboBox* channelCB;
+2 -2
View File
@@ -53,8 +53,8 @@ public:
void setup( CalypFrame* frame )
{
m_pcFrame = frame;
// run();
start();
run();
//start();
}
void run()
{