diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | lib/decoder.cpp | 2 | ||||
| -rw-r--r-- | lib/lib.pro | 31 | ||||
| -rw-r--r-- | lib/output.cpp | 36 | ||||
| -rw-r--r-- | lib/output.h | 17 | ||||
| -rw-r--r-- | lib/qmmp/Output/alsa/outputalsa.cpp | 3 | ||||
| -rw-r--r-- | lib/qmmp/Output/jack/outputjack.cpp | 4 | ||||
| -rw-r--r-- | lib/qmmp/Output/oss/outputoss.cpp | 4 | ||||
| -rw-r--r-- | lib/soundcore.cpp | 2 | ||||
| -rw-r--r-- | lib/soundcore.h | 6 | ||||
| -rw-r--r-- | lib/visual.cpp | 53 | ||||
| -rw-r--r-- | lib/visual.h (renamed from lib/visualization.h) | 40 |
12 files changed, 118 insertions, 83 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; |
