aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/CMakeLists.txt3
-rw-r--r--lib/decoder.cpp2
-rw-r--r--lib/lib.pro31
-rw-r--r--lib/output.cpp36
-rw-r--r--lib/output.h17
-rw-r--r--lib/qmmp/Output/alsa/outputalsa.cpp3
-rw-r--r--lib/qmmp/Output/jack/outputjack.cpp4
-rw-r--r--lib/qmmp/Output/oss/outputoss.cpp4
-rw-r--r--lib/soundcore.cpp2
-rw-r--r--lib/soundcore.h6
-rw-r--r--lib/visual.cpp53
-rw-r--r--lib/visual.h (renamed from lib/visualization.h)40
-rw-r--r--src/mainvisual.cpp44
-rw-r--r--src/mainvisual.h28
14 files changed, 150 insertions, 123 deletions
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index ce8cba005..3996c47fa 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -17,6 +17,7 @@ ADD_DEFINITIONS(-DQT_THREAD)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
SET(libqmmp_SRCS
+ visual.cpp
recycler.cpp
decoder.cpp
output.cpp
@@ -30,7 +31,7 @@ SET(libqmmp_SRCS
)
SET(libqmmp_MOC_HDRS
- visualization.h
+ visual.h
recycler.h
buffer.h
constants.h
diff --git a/lib/decoder.cpp b/lib/decoder.cpp
index be8821535..d3beda1a1 100644
--- a/lib/decoder.cpp
+++ b/lib/decoder.cpp
@@ -13,7 +13,7 @@
#include "constants.h"
#include "buffer.h"
#include "output.h"
-#include "visualization.h"
+#include "visual.h"
#include "decoderfactory.h"
#include "streamreader.h"
extern "C"{
diff --git a/lib/lib.pro b/lib/lib.pro
index 0df692ccd..54e3f0363 100644
--- a/lib/lib.pro
+++ b/lib/lib.pro
@@ -15,9 +15,9 @@ HEADERS += recycler.h \
equ\iir.h \
decoderfactory.h \
soundcore.h \
- visualization.h \
streamreader.h \
- downloader.h
+ downloader.h \
+ visual.h
SOURCES += recycler.cpp \
decoder.cpp \
output.cpp \
@@ -27,7 +27,8 @@ SOURCES += recycler.cpp \
soundcore.cpp \
streamreader.cpp \
downloader.cpp \
- filetag.cpp
+ filetag.cpp \
+ visual.cpp
TARGET = qmmp
CONFIG += release \
@@ -39,20 +40,20 @@ link_pkgconfig
TEMPLATE = lib
PKGCONFIG += libcurl
-isEmpty (LIB_DIR){
-LIB_DIR = /lib
+isEmpty(LIB_DIR){
+ LIB_DIR = /lib
}
-unix{
-LINE1 = $$sprintf(echo \"%1ifndef CONFIG_H\" > ./config.h, $$LITERAL_HASH)
-LINE2 = $$sprintf(echo \"%1define CONFIG_H\" >> ./config.h, $$LITERAL_HASH)
-LINE3 = $$sprintf(echo \"%1define LIB_DIR \\\"%2\\\"\" >> ./config.h, $$LITERAL_HASH, $$LIB_DIR)
-LINE4 = $$sprintf(echo \"%1endif\" >> ./config.h, $$LITERAL_HASH)
-system($$LINE1)
-system($$LINE2)
-system($$LINE3)
-system($$LINE4)
-QMAKE_CLEAN += ./config.h
+unix {
+ LINE1 = $$sprintf(echo \"%1ifndef CONFIG_H\" > ./config.h, $$LITERAL_HASH)
+ LINE2 = $$sprintf(echo \"%1define CONFIG_H\" >> ./config.h, $$LITERAL_HASH)
+ LINE3 = $$sprintf(echo \"%1define LIB_DIR \\\"%2\\\"\" >> ./config.h, $$LITERAL_HASH, $$LIB_DIR)
+ LINE4 = $$sprintf(echo \"%1endif\" >> ./config.h, $$LITERAL_HASH)
+ system($$LINE1)
+ system($$LINE2)
+ system($$LINE3)
+ system($$LINE4)
+ QMAKE_CLEAN += ./config.h
}
target.path = $$LIB_DIR
diff --git a/lib/output.cpp b/lib/output.cpp
index 285fa98c5..fbbe1c0e4 100644
--- a/lib/output.cpp
+++ b/lib/output.cpp
@@ -12,7 +12,6 @@
#include "constants.h"
#include "output.h"
-#include "visualization.h"
#include <stdio.h>
@@ -131,18 +130,18 @@ void Output::error ( const QString &e )
}
-void Output::addVisual ( Visualization *v )
+void Output::addVisual ( Visual *v )
{
- if ( visuals.indexOf ( v ) == -1 )
+ if (visuals.indexOf (v) == -1)
{
- visuals.append ( v );
+ visuals.append (v);
}
}
-void Output::removeVisual ( Visualization *v )
+void Output::removeVisual (Visual *v)
{
- visuals.removeAll ( v );
+ visuals.removeAll (v);
}
void Output::dispatchVisual ( Buffer *buffer, unsigned long written,
@@ -150,8 +149,8 @@ void Output::dispatchVisual ( Buffer *buffer, unsigned long written,
{
if ( ! buffer || !visuals.size())
return;
- Visualization *visual = 0;
- foreach (visual , visuals );
+ Visual* visual = 0;
+ foreach (visual , visuals);
{
visual->mutex()->lock ();
visual->add ( buffer, written, chan, prec );
@@ -160,20 +159,21 @@ void Output::dispatchVisual ( Buffer *buffer, unsigned long written,
}
-void Output::prepareVisuals()
+void Output::clearVisuals()
{
- //Visual *visual = visuals.first();
- /*while (visual) {
- visual->mutex()->lock();
- visual->prepare();
- visual->mutex()->unlock();
-
- visual = visuals.next();
- }*/
+ Visual *visual = 0;
+ foreach (visual, visuals );
+ {
+ visual->mutex()->lock ();
+ visual->clear();
+ visual->mutex()->unlock();
+ }
}
void Output::dispatch(OutputState::Type st)
{
+ if(st == OutputState::Stopped)
+ clearVisuals();
emit stateChanged ( OutputState(st) );
}
@@ -184,6 +184,8 @@ void Output::dispatch(long s, unsigned long w, int b, int f, int p, int c)
void Output::dispatch ( const OutputState &st )
{
+ if(st.type() == OutputState::Stopped)
+ clearVisuals();
emit stateChanged ( st );
}
diff --git a/lib/output.h b/lib/output.h
index 57bee8c9d..c87bd2420 100644
--- a/lib/output.h
+++ b/lib/output.h
@@ -5,8 +5,8 @@
// warranty, or liability of any kind.
//
-#ifndef __output_h
-#define __output_h
+#ifndef OUTPUT_H
+#define OUTPUT_H
class Output;
@@ -15,7 +15,8 @@ class Output;
#include <QEvent>
#include <QList>
#include <QIODevice>
-#include <outputfactory.h>
+#include "visual.h"
+#include "outputfactory.h"
#include "recycler.h"
@@ -153,8 +154,8 @@ public:
return &r;
}
- void addVisual(Visualization *);
- void removeVisual(Visualization *);
+ void addVisual(Visual*);
+ void removeVisual(Visual*);
QMutex *mutex()
{
@@ -198,14 +199,14 @@ protected:
void dispatchVolume(int L, int R);
void error(const QString &e);
void dispatchVisual(Buffer *, unsigned long, int, int);
- void prepareVisuals();
+ void clearVisuals();
private:
QMutex mtx;
Recycler r;
- QList<Visualization *> visuals;
+ QList<Visual*> visuals;
VolumeType m_vol;
};
-#endif // __output_h
+#endif // OUTPUT_H
diff --git a/lib/qmmp/Output/alsa/outputalsa.cpp b/lib/qmmp/Output/alsa/outputalsa.cpp
index 8b694f4ce..5ee44c314 100644
--- a/lib/qmmp/Output/alsa/outputalsa.cpp
+++ b/lib/qmmp/Output/alsa/outputalsa.cpp
@@ -32,7 +32,7 @@
#include "outputalsa.h"
#include "constants.h"
#include "buffer.h"
-#include "visualization.h"
+#include "visual.h"
OutputALSA::OutputALSA(QObject * parent)
: Output(parent, Output::Custom), m_inited(FALSE), m_pause(FALSE), m_play(FALSE),
@@ -172,7 +172,6 @@ void OutputALSA::configure(long freq, int chan, int prec, int brate)
qWarning("OutputALSA: Error setting HW params.");
return;
}
- prepareVisuals();
}
}
diff --git a/lib/qmmp/Output/jack/outputjack.cpp b/lib/qmmp/Output/jack/outputjack.cpp
index 221968372..7c3c0a32c 100644
--- a/lib/qmmp/Output/jack/outputjack.cpp
+++ b/lib/qmmp/Output/jack/outputjack.cpp
@@ -7,7 +7,7 @@
#include "outputjack.h"
#include "constants.h"
#include "buffer.h"
-#include "visualization.h"
+#include "visual.h"
#include <stdio.h>
#include <string.h>
@@ -75,8 +75,6 @@ void OutputJACK::configure(long freq, int chan, int prec, int brate)
else
m_configure = TRUE;
-
- prepareVisuals();
qDebug("OutputJACK: configure end");
}
diff --git a/lib/qmmp/Output/oss/outputoss.cpp b/lib/qmmp/Output/oss/outputoss.cpp
index 37953b84e..60936bd10 100644
--- a/lib/qmmp/Output/oss/outputoss.cpp
+++ b/lib/qmmp/Output/oss/outputoss.cpp
@@ -24,7 +24,7 @@
#include "outputoss.h"
#include "constants.h"
#include "buffer.h"
-#include "visualization.h"
+#include "visual.h"
#include <stdio.h>
#include <string.h>
@@ -155,8 +155,6 @@ void OutputOSS::configure(long freq, int chan, int prec, int rate)
}
m_rate = rate;
-
- prepareVisuals();
}
diff --git a/lib/soundcore.cpp b/lib/soundcore.cpp
index 4b4d9a6fb..d5aa0435d 100644
--- a/lib/soundcore.cpp
+++ b/lib/soundcore.cpp
@@ -289,7 +289,7 @@ void SoundCore::updateConfig()
stop();
}
-void SoundCore::addVisualization(Visualization *visual)
+void SoundCore::addVisualization(Visual *visual)
{
m_vis = visual;
}
diff --git a/lib/soundcore.h b/lib/soundcore.h
index c1c3a3be5..13e8b97c6 100644
--- a/lib/soundcore.h
+++ b/lib/soundcore.h
@@ -26,7 +26,7 @@
#include "decoder.h"
#include "output.h"
-#include "visualization.h"
+#include "visual.h"
/**
@author Ilya Kotov <forkotov02@hotmail.ru>
@@ -136,7 +136,7 @@ public:
/*!
* adds visualization
*/
- void addVisualization(Visualization *visual);
+ void addVisualization(Visual *visual);
signals:
@@ -174,7 +174,7 @@ private:
bool m_block;
int m_preamp;
int m_bands[10];
- Visualization *m_vis;
+ Visual *m_vis;
QString m_source;
};
diff --git a/lib/visual.cpp b/lib/visual.cpp
new file mode 100644
index 000000000..8c03bd65d
--- /dev/null
+++ b/lib/visual.cpp
@@ -0,0 +1,53 @@
+/***************************************************************************
+ * Copyright (C) 2006 by Ilya Kotov *
+ * forkotov02@hotmail.ru *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "visual.h"
+
+
+Visual::Visual()
+{}
+
+Visual::~Visual()
+{}
+
+Decoder *Visual::decoder() const
+{
+ return m_decoder;
+}
+
+void Visual::setDecoder(Decoder *decoder)
+{
+ m_decoder = decoder;
+}
+
+Output *Visual::output() const
+{
+ return m_output;
+}
+
+void Visual::setOutput(Output *output)
+{
+ m_output = output;
+}
+
+QMutex *Visual::mutex()
+{
+ return &m_mutex;
+}
diff --git a/lib/visualization.h b/lib/visual.h
index e484606c2..cc28efb34 100644
--- a/lib/visualization.h
+++ b/lib/visual.h
@@ -17,8 +17,8 @@
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
-#ifndef VISUALIZATION_H
-#define VISUALIZATION_H
+#ifndef VISUAL_H
+#define VISUAL_H
/**
@author Ilya Kotov <forkotov02@hotmail.ru>
@@ -30,39 +30,21 @@ class Buffer;
class Decoder;
class Output;
-class Visualization
+class Visual
{
public:
- Visualization() {};
+ Visual();
- virtual ~Visualization() {};
+ virtual ~Visual();
virtual void add(Buffer *, unsigned long, int, int) = 0;
- virtual void prepare() = 0;
-
- Decoder *decoder() const
- {
- return m_decoder;
- }
- void setDecoder(Decoder *decoder)
- {
- m_decoder = decoder;
- }
-
- Output *output() const
- {
- return m_output;
- }
- void setOutput(Output *output)
- {
- m_output = output;
- }
-
- QMutex *mutex()
- {
- return &m_mutex;
- }
+ virtual void clear() = 0;
+ Decoder *decoder() const;
+ void setDecoder(Decoder *decoder);
+ Output *output() const;
+ void setOutput(Output *output);
+ QMutex *mutex();
private:
Decoder *m_decoder;
diff --git a/src/mainvisual.cpp b/src/mainvisual.cpp
index 77e0d3554..65bd287a1 100644
--- a/src/mainvisual.cpp
+++ b/src/mainvisual.cpp
@@ -44,10 +44,9 @@ MainVisual *MainVisual::getPointer()
return pointer;
}
-MainVisual::MainVisual ( QWidget *parent)
- : QWidget ( parent ), m_vis ( 0 ), m_playing ( FALSE ), m_fps ( 20 )
+MainVisual::MainVisual (QWidget *parent)
+ : QWidget (parent), m_vis (0), m_playing (FALSE)
{
- m_transparent = FALSE;
m_draw = TRUE;
m_skin = Skin::getPointer();
connect(m_skin, SIGNAL(skinChanged()), this, SLOT(updateSettings()));
@@ -90,10 +89,13 @@ void MainVisual::setVisual (VisualBase *newvis)
}
}
-void MainVisual::prepare()
+void MainVisual::clear()
{
while (!m_nodes.isEmpty())
delete m_nodes.takeFirst();
+ if (m_vis)
+ m_vis->clear();
+ update();
}
void MainVisual::add ( Buffer *b, unsigned long w, int c, int p )
@@ -138,7 +140,7 @@ void MainVisual::timeout()
{
VisualNode *node = 0;
- if ( /*playing &&*/ output() )
+ if ( /*playing &&*/ output())
{
//output()->mutex()->lock ();
//long olat = output()->latency();
@@ -166,9 +168,8 @@ void MainVisual::timeout()
node = prev;
}
- bool stop = TRUE;
- if ( m_vis )
- stop = m_vis->process ( node );
+ if (m_vis)
+ m_vis->process ( node );
delete node;
if ( m_vis )
@@ -230,11 +231,6 @@ void MainVisual::mousePressEvent (QMouseEvent *e)
void MainVisual::drawBackGround()
{
m_bg = QPixmap (75,20);
- if (m_transparent)
- {
- m_bg.fill(Qt::transparent);
- return;
- }
QPainter painter(&m_bg);
for (int x = 0; x < 75; x += 2)
{
@@ -438,11 +434,7 @@ Analyzer::Analyzer()
: m_analyzerBarWidth ( 4 ), m_fps ( 20 )
{
m_size = QSize(75,20);
- for ( int i = 0; i< 75; ++i )
- {
- m_intern_vis_data[i] = 0;
- m_peaks[i] = 0;
- }
+ clear();
m_skin = Skin::getPointer();
double peaks_speed[] = { 0.05, 0.1, 0.2, 0.4, 0.8 };
@@ -462,6 +454,15 @@ Analyzer::Analyzer()
Analyzer::~Analyzer()
{}
+void Analyzer::clear()
+{
+ for ( int i = 0; i< 75; ++i )
+ {
+ m_intern_vis_data[i] = 0;
+ m_peaks[i] = 0;
+ }
+}
+
bool Analyzer::process ( VisualNode *node )
{
static fft_state *state = 0;
@@ -573,9 +574,14 @@ void Analyzer::draw ( QPainter *p)
Scope::Scope()
{
+ clear();
+ m_skin = Skin::getPointer();
+}
+
+void Scope::clear()
+{
for (int i = 0; i< 75; ++i)
m_intern_vis_data[i] = 7;
- m_skin = Skin::getPointer();
}
Scope::~Scope()
diff --git a/src/mainvisual.h b/src/mainvisual.h
index 8490929e2..d31b1c73a 100644
--- a/src/mainvisual.h
+++ b/src/mainvisual.h
@@ -22,7 +22,7 @@
#include <QWidget>
#include <QResizeEvent>
-#include <visualization.h>
+#include <visual.h>
#include <constants.h>
#include "logscale.h"
@@ -59,7 +59,8 @@ class VisualBase
{
public:
virtual ~VisualBase()
- {}
+ {};
+ virtual void clear() = 0;
virtual bool process(VisualNode *node) = 0;
virtual void draw(QPainter *) = 0;
virtual const QString name() = 0;
@@ -67,7 +68,7 @@ public:
class Skin;
-class MainVisual : public QWidget, public Visualization
+class MainVisual : public QWidget, public Visual
{
Q_OBJECT
@@ -77,27 +78,12 @@ public:
static MainVisual *getPointer();
- VisualBase *visual() const
- {
- return m_vis;
- }
void setVisual( VisualBase *newvis );
void add(Buffer *, unsigned long, int, int);
- void prepare();
-
- void configChanged(QSettings &settings);
-
+ void clear();
void paintEvent( QPaintEvent * );
- static QStringList visuals();
-
- void setFrameRate( int newfps );
- int frameRate() const
- {
- return m_fps;
- }
-
protected:
virtual void hideEvent (QHideEvent *);
virtual void showEvent (QShowEvent *);
@@ -120,8 +106,6 @@ private:
QList <VisualNode*> m_nodes;
QTimer *m_timer;
bool m_playing;
- int m_fps;
- bool m_transparent;
bool m_draw;
Skin *m_skin;
//menu and actions
@@ -142,6 +126,7 @@ public:
Analyzer();
virtual ~Analyzer();
+ void clear();
bool process(VisualNode *node);
void draw(QPainter *p);
const QString name()
@@ -168,6 +153,7 @@ public:
Scope();
virtual ~Scope();
+ void clear();
bool process(VisualNode *node);
void draw(QPainter *p);
const QString name()