]> git.sesse.net Git - kdenlive/commitdiff
Abstract Scopes:
authorSimon A. Eugster <simon.eu@gmail.com>
Wed, 8 Dec 2010 17:49:33 +0000 (17:49 +0000)
committerSimon A. Eugster <simon.eu@gmail.com>
Wed, 8 Dec 2010 17:49:33 +0000 (17:49 +0000)
* 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

src/abstractscopewidget.cpp
src/abstractscopewidget.h
src/audioscopes/abstractaudioscopewidget.cpp
src/audioscopes/abstractaudioscopewidget.h

index 9c3bc416cc63b0f6c58f82f89b55b673a7418f99..af113407bc175cb144e6479fb26e21194eedad5d 100644 (file)
@@ -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
 
index c1a771181c7c33a58bf815a237685e1dddce3d15..8188c16f5be498bafe8606bcc339f8a42b23dd91 100644 (file)
@@ -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? */
index 71a6263c7b8c789f90ace89d33c5a317478340d5..272accdde42cd465abbc4f8121b2f5f65b4ed83d 100644 (file)
 #include <QMouseEvent>
 #include <QPainter>
 
+// Uncomment for debugging
+//#define DEBUG_AASW
+
+#ifdef DEBUG_AASW
+#include <QDebug>
+#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<int16_t>sampleData, int freq, int num_channels, int num_samples)
+void AbstractAudioScopeWidget::slotReceiveAudio(const QVector<int16_t> &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
index d8c262dc22ba98c2793d17e05c0f4c54d8dea6fe..58a9bfbacd28302de95c13209655a0aaad378c4b 100644 (file)
@@ -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<int16_t> audioFrame, const int freq, const int num_channels, const int num_samples) = 0;
+                               const QVector<int16_t> audioFrame, const int freq, const int num_channels, const int num_samples,
+                               const int newData) = 0;
 
 private:
     QVector<int16_t> m_audioFrame;
     int m_freq;
     int m_nChannels;
     int m_nSamples;
+    QAtomicInt m_newData;
 
 private slots:
     void slotReceiveAudio(const QVector<int16_t>& sampleData, int freq, int num_channels, int num_samples);