aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2008-09-12 13:38:37 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2008-09-12 13:38:37 +0000
commit07ae1ec8ca7452899b65b579e65fb1ad28764c58 (patch)
treecde844c7c82fb29c9860a974ac8af99d64751b31
parent1ceaa9a2f4394853914d95fe2b7aa3d4b44c786e (diff)
downloadqmmp-07ae1ec8ca7452899b65b579e65fb1ad28764c58.tar.gz
qmmp-07ae1ec8ca7452899b65b579e65fb1ad28764c58.tar.bz2
qmmp-07ae1ec8ca7452899b65b579e65fb1ad28764c58.zip
enabled effect plugin
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@549 90c681e8-e032-0410-971d-27865f9a5e38
-rw-r--r--src/plugins/Effect/srconverter/srconverter.cpp4
-rw-r--r--src/plugins/Effect/srconverter/srconverter.h8
-rw-r--r--src/plugins/Input/mad/decoder_mad.cpp2
-rw-r--r--src/plugins/Output/alsa/outputalsa.cpp5
-rw-r--r--src/plugins/Output/alsa/outputalsa.h5
-rw-r--r--src/qmmp/decoder.cpp17
-rw-r--r--src/qmmp/decoder.h7
-rw-r--r--src/qmmp/effect.cpp4
-rw-r--r--src/qmmp/effect.h6
-rw-r--r--src/qmmp/output.h2
-rw-r--r--src/qmmp/soundcore.cpp77
-rw-r--r--src/qmmp/soundcore.h2
12 files changed, 50 insertions, 89 deletions
diff --git a/src/plugins/Effect/srconverter/srconverter.cpp b/src/plugins/Effect/srconverter/srconverter.cpp
index 9d7937e7e..9cfd56361 100644
--- a/src/plugins/Effect/srconverter/srconverter.cpp
+++ b/src/plugins/Effect/srconverter/srconverter.cpp
@@ -97,7 +97,7 @@ const ulong SRConverter::process(char *in_data, const ulong size, char **out_dat
return wbytes;
}
-void SRConverter::configure(ulong freq, int chan, int res)
+void SRConverter::configure(quint32 freq, int chan, int res)
{
Effect::configure(freq, chan, res);
freeSRC();
@@ -114,7 +114,7 @@ void SRConverter::configure(ulong freq, int chan, int res)
}
}
-const ulong SRConverter::frequency()
+const quint32 SRConverter::sampleRate()
{
return m_overSamplingFs;
}
diff --git a/src/plugins/Effect/srconverter/srconverter.h b/src/plugins/Effect/srconverter/srconverter.h
index 3638383f9..f96079868 100644
--- a/src/plugins/Effect/srconverter/srconverter.h
+++ b/src/plugins/Effect/srconverter/srconverter.h
@@ -40,20 +40,20 @@ public:
virtual ~SRConverter();
const ulong process(char *in_data, const ulong size, char **out_data);
- void configure(ulong freq, int chan, int res);
- const ulong frequency();
+ void configure(quint32 freq, int chan, int res);
+ const quint32 sampleRate();
private:
void freeSRC();
SRC_STATE *m_src_state;
SRC_DATA m_src_data;
- int m_overSamplingFs;
+ quint32 m_overSamplingFs;
int m_srcError;
int m_converter_type;
bool m_isSrcAlloc;
float *m_srcIn, *m_srcOut;
short *m_wOut;
- ulong m_freq;
+ quint32 m_freq;
};
#endif
diff --git a/src/plugins/Input/mad/decoder_mad.cpp b/src/plugins/Input/mad/decoder_mad.cpp
index 98e437075..941dcee8b 100644
--- a/src/plugins/Input/mad/decoder_mad.cpp
+++ b/src/plugins/Input/mad/decoder_mad.cpp
@@ -67,7 +67,7 @@ DecoderMAD::~DecoderMAD()
bool DecoderMAD::initialize()
{
- bks = blockSize();
+ bks = Buffer::size();
inited = false;
user_stop = false;
diff --git a/src/plugins/Output/alsa/outputalsa.cpp b/src/plugins/Output/alsa/outputalsa.cpp
index 35e37b301..08ce660f8 100644
--- a/src/plugins/Output/alsa/outputalsa.cpp
+++ b/src/plugins/Output/alsa/outputalsa.cpp
@@ -40,8 +40,9 @@
OutputALSA::OutputALSA(QObject * parent, bool useVolume)
: Output(parent), m_inited(FALSE), m_pause(FALSE), m_play(FALSE),
m_userStop(FALSE), m_totalWritten(0), m_currentSeconds(-1),
- m_bps(-1), m_frequency(-1), m_channels(-1), m_precision(-1)
+ m_bps(-1), m_channels(-1), m_precision(-1)
{
+ m_frequency = 0;
QSettings settings(QDir::homePath()+"/.qmmp/qmmprc", QSettings::IniFormat);
QString dev_name = settings.value("ALSA/device","default").toString();
m_use_mmap = settings.value("ALSA/use_mmap", FALSE).toBool();
@@ -96,7 +97,7 @@ void OutputALSA::seek(long pos)
m_currentSeconds = -1;
}
-void OutputALSA::configure(qint64 freq, int chan, int prec)
+void OutputALSA::configure(quint32 freq, int chan, int prec)
{
// we need to configure
if (freq != m_frequency || chan != m_channels || prec != m_precision)
diff --git a/src/plugins/Output/alsa/outputalsa.h b/src/plugins/Output/alsa/outputalsa.h
index 333600b1d..7289a1ccd 100644
--- a/src/plugins/Output/alsa/outputalsa.h
+++ b/src/plugins/Output/alsa/outputalsa.h
@@ -42,7 +42,7 @@ public:
bool initialize();
bool isInitialized() const { return m_inited; }
void uninitialize();
- void configure(qint64, int, int);
+ void configure(quint32, int, int);
void stop();
void pause();
qint64 written();
@@ -62,7 +62,8 @@ private:
bool m_inited, m_pause, m_play, m_userStop;
long m_totalWritten, m_currentSeconds, m_bps;
- int m_rate, m_frequency, m_channels, m_precision;
+ int m_rate, m_channels, m_precision;
+ quint32 m_frequency;
//alsa
snd_pcm_t *pcm_handle;
char *pcm_name;
diff --git a/src/qmmp/decoder.cpp b/src/qmmp/decoder.cpp
index 525d33e0c..9d52ee019 100644
--- a/src/qmmp/decoder.cpp
+++ b/src/qmmp/decoder.cpp
@@ -34,10 +34,9 @@ Decoder::Decoder(QObject *parent, DecoderFactory *d, QIODevice *i, Output *o)
m_output->recycler()->clear();
int b[] = {0,0,0,0,0,0,0,0,0,0};
setEQ(b, 0);
- //qRegisterMetaType<DecoderState>("DecoderState");
qRegisterMetaType<Qmmp::State>("Qmmp::State");
blksize = Buffer::size();
- //m_effects = Effect::create(this);
+ m_effects = Effect::create(this);
QSettings settings(QDir::homePath()+"/.qmmp/qmmprc", QSettings::IniFormat);
m_useVolume = settings.value("Volume/software_volume", FALSE).toBool();
m_volL = settings.value("Volume/left", 80).toInt();
@@ -84,16 +83,6 @@ StateHandler *Decoder::stateHandler()
return m_handler;
}
-void Decoder::setBlockSize(unsigned int sz)
-{
- blksize = sz;
-}
-
-unsigned int Decoder::blockSize() const
-{
- return blksize;
-}
-
void Decoder::setEQ(int bands[10], int preamp)
{
set_preamp(0, 1.0 + 0.0932471 *preamp + 0.00279033 * preamp * preamp);
@@ -368,7 +357,7 @@ QList<DecoderFactory*> *Decoder::decoderFactories()
return factories;
}
-void Decoder::configure(qint64 srate, int chan, int bps)
+void Decoder::configure(quint32 srate, int chan, int bps)
{
Effect* effect = 0;
foreach(effect, m_effects)
@@ -382,7 +371,7 @@ void Decoder::configure(qint64 srate, int chan, int bps)
m_output->configure(srate, chan, bps);
}
-qint64 Decoder::produceSound(char *data, qint64 size, qint64 brate, int chan)
+qint64 Decoder::produceSound(char *data, qint64 size, quint32 brate, int chan)
{
ulong sz = size < blksize ? size : blksize;
diff --git a/src/qmmp/decoder.h b/src/qmmp/decoder.h
index 1e0a32d82..ec82ad096 100644
--- a/src/qmmp/decoder.h
+++ b/src/qmmp/decoder.h
@@ -52,9 +52,6 @@ public:
QWaitCondition *cond();
StateHandler *stateHandler();
- void setBlockSize(unsigned int sz);
- unsigned int blockSize() const;
-
void setEQ(int bands[10], int preamp);
void setEQEnabled(bool on);
@@ -81,8 +78,8 @@ signals:
//void stateChanged(const DecoderState&);
protected:
- void configure(qint64 srate, int chan, int bps);
- qint64 produceSound(char *data, qint64 size, qint64 brate, int chan);
+ void configure(quint32 srate, int chan, int bps);
+ qint64 produceSound(char *data, qint64 size, quint32 brate, int chan);
void finish();
private:
diff --git a/src/qmmp/effect.cpp b/src/qmmp/effect.cpp
index 5b498d4d6..9b279fab8 100644
--- a/src/qmmp/effect.cpp
+++ b/src/qmmp/effect.cpp
@@ -33,14 +33,14 @@ Effect::Effect(QObject *parent)
Effect::~Effect()
{}
-void Effect::configure(qint64 freq, int chan, int res)
+void Effect::configure(quint32 freq, int chan, int res)
{
m_freq = freq;
m_chan = chan;
m_res = res;
}
-const qint64 Effect::sampleRate()
+const quint32 Effect::sampleRate()
{
return m_freq;
}
diff --git a/src/qmmp/effect.h b/src/qmmp/effect.h
index 8eaabdd94..dede28f91 100644
--- a/src/qmmp/effect.h
+++ b/src/qmmp/effect.h
@@ -51,13 +51,13 @@ public:
//virtual bool process(char *in_data, char *out_data, const ulong maxsize, ulong &rbytes, ulong &wbytes) = 0;
- virtual void configure(qint64 freq, int chan, int res);
+ virtual void configure(quint32 freq, int chan, int res);
/*!
* Returns samplerate.
* This function should be reimplemented if subclass changes default samplerate.
*/
- virtual const qint64 sampleRate();
+ virtual const quint32 sampleRate();
/*!
* Returns channel number.
@@ -79,7 +79,7 @@ public:
static bool isEnabled(EffectFactory* factory);
private:
- ulong m_freq;
+ quint32 m_freq;
int m_chan;
int m_res;
};
diff --git a/src/qmmp/output.h b/src/qmmp/output.h
index 31057c05c..630b17539 100644
--- a/src/qmmp/output.h
+++ b/src/qmmp/output.h
@@ -37,7 +37,7 @@ public:
virtual bool isInitialized() const = 0;
virtual bool initialize() = 0;
virtual void uninitialize() = 0;
- virtual void configure(qint64, int, int) = 0;
+ virtual void configure(quint32, int, int) = 0;
virtual void pause() = 0;
virtual void stop() = 0;
virtual qint64 written() = 0;
diff --git a/src/qmmp/soundcore.cpp b/src/qmmp/soundcore.cpp
index cef20696c..76fc6db23 100644
--- a/src/qmmp/soundcore.cpp
+++ b/src/qmmp/soundcore.cpp
@@ -72,37 +72,14 @@ bool SoundCore::play(const QString &source)
return FALSE;
}
if (!m_output->initialize())
- return FALSE;
-
- m_decoder = Decoder::create(this, source, m_input, m_output);
- if (!m_decoder)
{
- qWarning("SoundCore: unsupported fileformat");
- m_block = FALSE;
- stop();
- setState(Qmmp::NormalError);
+ qWarning("SoundCore: unable to initialize output");
+ setState(Qmmp::FatalError);
return FALSE;
}
- qDebug ("ok");
- m_decoder->setBlockSize(globalBlockSize); //TODO remove
- StateHandler *handler = m_decoder->stateHandler();
- connect(handler, SIGNAL(elapsedChanged(qint64)), SIGNAL(elapsedChanged(qint64)));
- connect(handler, SIGNAL(bitrateChanged(int)), SIGNAL(bitrateChanged(int)));
- connect(handler, SIGNAL(frequencyChanged(int)), SIGNAL(frequencyChanged(int)));
- connect(handler, SIGNAL(precisionChanged(int)), SIGNAL(precisionChanged(int)));
- connect(handler, SIGNAL(channelsChanged(int)), SIGNAL(channelsChanged(int)));
- connect(handler, SIGNAL(metaDataChanged ()), SIGNAL(metaDataChanged ()));
- connect(handler, SIGNAL(stateChanged (Qmmp::State)), SLOT(setState(Qmmp::State)));
- connect(m_decoder, SIGNAL(finished()), SIGNAL(finished()));
+ m_source = source;
+ return decode();
- if (m_decoder->initialize())
- {
- m_output->start();
- m_decoder->start();
- return TRUE;
- }
- stop();
- return FALSE;
}
void SoundCore::stop()
@@ -319,43 +296,39 @@ void SoundCore::setState(Qmmp::State state)
}
}*/
-/*bool SoundCore::decode()
+bool SoundCore::decode()
{
- if (! m_decoder)
+ if (!m_input || !m_output)
+ return FALSE;
+ m_decoder = Decoder::create(this, m_source, m_input, m_output);
+ if (!m_decoder)
{
- m_block = TRUE;
- qDebug ("SoundCore: creating decoder");
- m_decoder = Decoder::create(this, m_source, m_input, m_output);
-
- if (! m_decoder)
- {
- qWarning("SoundCore: unsupported fileformat");
- m_block = FALSE;
- stop();
- //emit decoderStateChanged(DecoderState(DecoderState::Error));
- return FALSE;
- }
- qDebug ("ok");
- m_decoder->setBlockSize(globalBlockSize);
- connect(m_decoder, SIGNAL(stateChanged(const DecoderState&)),
- SIGNAL(decoderStateChanged(const DecoderState&)));
- setEQ(m_bands, m_preamp);
- setEQEnabled(m_useEQ);
+ qWarning("SoundCore: unsupported fileformat");
+ m_block = FALSE;
+ stop();
+ setState(Qmmp::NormalError);
+ return FALSE;
}
- qDebug("SoundCore: decoder was created successfully");
+ qDebug ("ok");
+ StateHandler *handler = m_decoder->stateHandler();
+ connect(handler, SIGNAL(elapsedChanged(qint64)), SIGNAL(elapsedChanged(qint64)));
+ connect(handler, SIGNAL(bitrateChanged(int)), SIGNAL(bitrateChanged(int)));
+ connect(handler, SIGNAL(frequencyChanged(int)), SIGNAL(frequencyChanged(int)));
+ connect(handler, SIGNAL(precisionChanged(int)), SIGNAL(precisionChanged(int)));
+ connect(handler, SIGNAL(channelsChanged(int)), SIGNAL(channelsChanged(int)));
+ connect(handler, SIGNAL(metaDataChanged ()), SIGNAL(metaDataChanged ()));
+ connect(handler, SIGNAL(stateChanged (Qmmp::State)), SLOT(setState(Qmmp::State)));
+ connect(m_decoder, SIGNAL(finished()), SIGNAL(finished()));
if (m_decoder->initialize())
{
m_output->start();
m_decoder->start();
- //m_error = NoError;
- m_block = FALSE;
return TRUE;
}
stop();
- m_block = FALSE;
return FALSE;
-}*/
+}
/*void SoundCore::showVisualization(QWidget *parent)
{
diff --git a/src/qmmp/soundcore.h b/src/qmmp/soundcore.h
index d585d9e53..c3d52469f 100644
--- a/src/qmmp/soundcore.h
+++ b/src/qmmp/soundcore.h
@@ -176,7 +176,7 @@ signals:
void finished();
private slots:
- //bool decode();
+ bool decode();
void setState(Qmmp::State);
private: