From: Simon A. Eugster Date: Wed, 8 Dec 2010 17:49:33 +0000 (+0000) Subject: Abstract Scopes: X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=2d1cdc69906a9f6e96928f53fb9a6cc17134792c;p=kdenlive Abstract Scopes: * Debug messages improved * New pen added * Abstract Audio Scope: Debugging switch added * Abstract Audio Scope: Keep track of number of new data such that the renderer function knows whether it is called due to new data or simply because the view or parameters have changed svn path=/trunk/kdenlive/; revision=5152 --- diff --git a/src/abstractscopewidget.cpp b/src/abstractscopewidget.cpp index 9c3bc416..af113407 100644 --- a/src/abstractscopewidget.cpp +++ b/src/abstractscopewidget.cpp @@ -33,12 +33,13 @@ const QColor light(250, 238, 226, 255); const QColor dark(40, 40, 39, 255); const QColor dark2(25, 25, 23, 255); -const QPen AbstractScopeWidget::penThick(QBrush(QColor(250, 250, 250)), 2, Qt::SolidLine); -const QPen AbstractScopeWidget::penThin(QBrush(QColor(250, 250, 250)), 1, Qt::SolidLine); -const QPen AbstractScopeWidget::penLight(QBrush(QColor(200, 200, 250, 150)), 1, Qt::SolidLine); +const QPen AbstractScopeWidget::penThick(QBrush(QColor(250, 250, 250)), 2, Qt::SolidLine); +const QPen AbstractScopeWidget::penThin(QBrush(QColor(250, 250, 250)), 1, Qt::SolidLine); +const QPen AbstractScopeWidget::penLight(QBrush(QColor(200, 200, 250, 150)), 1, Qt::SolidLine); const QPen AbstractScopeWidget::penLightDots(QBrush(QColor(200, 200, 250, 150)), 1, Qt::DotLine); -const QPen AbstractScopeWidget::penDark(QBrush(QColor(0, 0, 20, 250)), 1, Qt::SolidLine); -const QPen AbstractScopeWidget::penDarkDots(QBrush(QColor(0, 0, 20, 250)), 1, Qt::DotLine); +const QPen AbstractScopeWidget::penLighter(QBrush(QColor(225, 225, 250, 225)), 1, Qt::SolidLine); +const QPen AbstractScopeWidget::penDark(QBrush(QColor(0, 0, 20, 250)), 1, Qt::SolidLine); +const QPen AbstractScopeWidget::penDarkDots(QBrush(QColor(0, 0, 20, 250)), 1, Qt::DotLine); const QString AbstractScopeWidget::directions[] = {"North", "Northeast", "East", "Southeast"}; @@ -499,7 +500,7 @@ void AbstractScopeWidget::slotRenderZoneUpdated() m_newBackgroundFrames.fetchAndAddRelaxed(1); #ifdef DEBUG_ASW - qDebug() << "Monitor incoming at " << widgetName() << ". New frames total HUD/Scope/Background: " << m_newHUDFrames + qDebug() << "Data incoming at " << widgetName() << ". New frames total HUD/Scope/Background: " << m_newHUDFrames << "/" << m_newScopeFrames << "/" << m_newBackgroundFrames; #endif diff --git a/src/abstractscopewidget.h b/src/abstractscopewidget.h index c1a77118..8188c16f 100644 --- a/src/abstractscopewidget.h +++ b/src/abstractscopewidget.h @@ -58,6 +58,8 @@ class AbstractScopeWidget : public QWidget Q_OBJECT public: + /** trackMouse enables mouse tracking; The variables m_mousePos and m_mouseWithinWidget will be set + if mouse tracking is enabled. See also signalMousePositionChanged(). */ AbstractScopeWidget(bool trackMouse = false, QWidget *parent = 0); virtual ~AbstractScopeWidget(); // Must be virtual because of inheritance, to avoid memory leaks @@ -84,6 +86,7 @@ public: static const QPen penThin; static const QPen penLight; static const QPen penLightDots; + static const QPen penLighter; static const QPen penDark; static const QPen penDarkDots; @@ -206,7 +209,8 @@ signals: void signalBackgroundRenderingFinished(uint mseconds, uint accelerationFactor); /** For the mouse position itself see m_mousePos. - To check whether the mouse has leaved the widget, see m_mouseWithinWidget. */ + To check whether the mouse has leaved the widget, see m_mouseWithinWidget. + This signal is typically connected to forceUpdateHUD(). */ void signalMousePositionChanged(); /** Do we need the renderer to send its frames to us? */ diff --git a/src/audioscopes/abstractaudioscopewidget.cpp b/src/audioscopes/abstractaudioscopewidget.cpp index 71a6263c..272accdd 100644 --- a/src/audioscopes/abstractaudioscopewidget.cpp +++ b/src/audioscopes/abstractaudioscopewidget.cpp @@ -20,21 +20,35 @@ #include #include +// Uncomment for debugging +//#define DEBUG_AASW + +#ifdef DEBUG_AASW +#include +#endif + AbstractAudioScopeWidget::AbstractAudioScopeWidget(bool trackMouse, QWidget *parent) : AbstractScopeWidget(trackMouse, parent), m_audioFrame(), m_freq(0), m_nChannels(0), - m_nSamples(0) + m_nSamples(0), + m_newData(0) { } -void AbstractAudioScopeWidget::slotReceiveAudio(const QVector& sampleData, int freq, int num_channels, int num_samples) +void AbstractAudioScopeWidget::slotReceiveAudio(const QVector &sampleData, int freq, int num_channels, int num_samples) { +#ifdef DEBUG_AASW + qDebug() << "Received audio for " << widgetName() << "."; +#endif m_audioFrame = sampleData; m_freq = freq; m_nChannels = num_channels; m_nSamples = num_samples; + + m_newData.fetchAndAddAcquire(1); + AbstractScopeWidget::slotRenderZoneUpdated(); } @@ -42,5 +56,11 @@ AbstractAudioScopeWidget::~AbstractAudioScopeWidget() {} QImage AbstractAudioScopeWidget::renderScope(uint accelerationFactor) { - return renderAudioScope(accelerationFactor, m_audioFrame, m_freq, m_nChannels, m_nSamples); + int newData = m_newData.fetchAndStoreAcquire(0); + + return renderAudioScope(accelerationFactor, m_audioFrame, m_freq, m_nChannels, m_nSamples, newData); } + +#ifdef DEBUG_AASW +#undef DEBUG_AASW +#endif diff --git a/src/audioscopes/abstractaudioscopewidget.h b/src/audioscopes/abstractaudioscopewidget.h index d8c262dc..58a9bfba 100644 --- a/src/audioscopes/abstractaudioscopewidget.h +++ b/src/audioscopes/abstractaudioscopewidget.h @@ -38,13 +38,15 @@ protected: when calculation has finished, to allow multi-threading. accelerationFactor hints how much faster than usual the calculation should be accomplished, if possible. */ virtual QImage renderAudioScope(uint accelerationFactor, - const QVector audioFrame, const int freq, const int num_channels, const int num_samples) = 0; + const QVector audioFrame, const int freq, const int num_channels, const int num_samples, + const int newData) = 0; private: QVector m_audioFrame; int m_freq; int m_nChannels; int m_nSamples; + QAtomicInt m_newData; private slots: void slotReceiveAudio(const QVector& sampleData, int freq, int num_channels, int num_samples);