diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2008-11-20 12:00:54 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2008-11-20 12:00:54 +0000 |
| commit | 7ad1d35d38aed36e5c42803d7d35aa38ee3cc800 (patch) | |
| tree | e1041457fe1c8545927ade9eed14683c9f680cfe | |
| parent | a030a982fc4194e81b21a36c1fb0a505f8e2e28b (diff) | |
| download | qmmp-7ad1d35d38aed36e5c42803d7d35aa38ee3cc800.tar.gz qmmp-7ad1d35d38aed36e5c42803d7d35aa38ee3cc800.tar.bz2 qmmp-7ad1d35d38aed36e5c42803d7d35aa38ee3cc800.zip | |
make visualization independent of the software volume level
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@623 90c681e8-e032-0410-971d-27865f9a5e38
| -rw-r--r-- | src/qmmp/decoder.cpp | 20 | ||||
| -rw-r--r-- | src/qmmp/decoder.h | 1 | ||||
| -rw-r--r-- | src/qmmp/output.cpp | 23 | ||||
| -rw-r--r-- | src/qmmp/output.h | 1 |
4 files changed, 22 insertions, 23 deletions
diff --git a/src/qmmp/decoder.cpp b/src/qmmp/decoder.cpp index 7c33cc112..02f07211f 100644 --- a/src/qmmp/decoder.cpp +++ b/src/qmmp/decoder.cpp @@ -19,7 +19,6 @@ #include "visual.h" #include "decoderfactory.h" #include "streamreader.h" -#include "volumecontrol.h" extern "C" { @@ -141,7 +140,6 @@ qint64 Decoder::produceSound(char *data, qint64 size, quint32 brate, int chan) } iir((void*) data, sz, chan); } - changeVolume(data, sz, chan); char *out_data = data; char *prev_data = data; qint64 w = sz; @@ -188,24 +186,6 @@ void Decoder::finish() emit playbackFinished(); } -void Decoder::changeVolume(char *data, qint64 size, int chan) -{ - if (!SoftwareVolume::instance()) - return; - if (chan > 1) - for (qint64 i = 0; i < size/2; i+=2) - { - ((short*)data)[i]*= SoftwareVolume::instance()->left()/256.0; - ((short*)data)[i+1]*= SoftwareVolume::instance()->right()/256.0; - } - else - { - int l = qMax(SoftwareVolume::instance()->left(), SoftwareVolume::instance()->right()); - for (qint64 i = 0; i < size/2; i++) - ((short*)data)[i]*= l/256.0; - } -} - // static methods QList<DecoderFactory*> *Decoder::m_factories = 0; QStringList Decoder::m_files; diff --git a/src/qmmp/decoder.h b/src/qmmp/decoder.h index 479b87ef6..1e4d56481 100644 --- a/src/qmmp/decoder.h +++ b/src/qmmp/decoder.h @@ -87,7 +87,6 @@ protected slots: private: void init(); - void changeVolume(char *data, qint64 size, int chan); static void checkFactories(); DecoderFactory *m_factory; diff --git a/src/qmmp/output.cpp b/src/qmmp/output.cpp index 6626be6ce..ded4c6e28 100644 --- a/src/qmmp/output.cpp +++ b/src/qmmp/output.cpp @@ -13,6 +13,7 @@ #include "constants.h" #include "buffer.h" #include "output.h" +#include "volumecontrol.h" #include <stdio.h> @@ -155,8 +156,7 @@ void Output::run() if (!b) { b = recycler()->next(); - dispatchVisual(b, m_totalWritten, m_channels, m_precision); - if (b->rate) + if (b && b->rate) m_kbps = b->rate; } @@ -165,6 +165,8 @@ void Output::run() mutex()->unlock(); if (b) { + dispatchVisual(b, m_totalWritten, m_channels, m_precision); + changeVolume(b->data, b->nbytes, m_channels); if ((l = writeAudio(b->data, b->nbytes)) > 0) m_totalWritten += b->nbytes; else @@ -201,6 +203,23 @@ void Output::status() } } +void Output::changeVolume(uchar *data, qint64 size, int chan) +{ + if (!SoftwareVolume::instance()) + return; + if (chan > 1) + for (qint64 i = 0; i < size/2; i+=2) + { + ((short*)data)[i]*= SoftwareVolume::instance()->left()/100.0; + ((short*)data)[i+1]*= SoftwareVolume::instance()->right()/100.0; + } + else + { + int l = qMax(SoftwareVolume::instance()->left(), SoftwareVolume::instance()->right()); + for (qint64 i = 0; i < size/2; i++) + ((short*)data)[i]*= l/100.0; + } +} // static methods diff --git a/src/qmmp/output.h b/src/qmmp/output.h index 389c29695..07b9d7f67 100644 --- a/src/qmmp/output.h +++ b/src/qmmp/output.h @@ -70,6 +70,7 @@ protected: private: void run(); //thread run function void status(); + void changeVolume(uchar *data, qint64 size, int chan); QMutex m_mutex; Recycler m_recycler; StateHandler *m_handler; |
