aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Input/mad
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2009-09-12 14:33:49 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2009-09-12 14:33:49 +0000
commit8fbf582b60b6267463e6a3dc289b52e49fdc2f83 (patch)
tree9540a7b90f2b52ccb34104f2f89d4c1e22445a70 /src/plugins/Input/mad
parentc89ba4ee3ccca9a2f4b38d4b76ca666f94babbd4 (diff)
downloadqmmp-8fbf582b60b6267463e6a3dc289b52e49fdc2f83.tar.gz
qmmp-8fbf582b60b6267463e6a3dc289b52e49fdc2f83.tar.bz2
qmmp-8fbf582b60b6267463e6a3dc289b52e49fdc2f83.zip
prepare for gapless playback support
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1207 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Input/mad')
-rw-r--r--src/plugins/Input/mad/decoder_mad.cpp39
-rw-r--r--src/plugins/Input/mad/decoder_mad.h9
-rw-r--r--src/plugins/Input/mad/decodermadfactory.cpp4
-rw-r--r--src/plugins/Input/mad/decodermadfactory.h2
4 files changed, 28 insertions, 26 deletions
diff --git a/src/plugins/Input/mad/decoder_mad.cpp b/src/plugins/Input/mad/decoder_mad.cpp
index 572063ba2..bbfd43251 100644
--- a/src/plugins/Input/mad/decoder_mad.cpp
+++ b/src/plugins/Input/mad/decoder_mad.cpp
@@ -21,8 +21,8 @@
#define INPUT_BUFFER_SIZE (32*1024)
-DecoderMAD::DecoderMAD(QObject *parent, DecoderFactory *d, QIODevice *i, Output *o)
- : Decoder(parent, d, i, o)
+DecoderMAD::DecoderMAD(QIODevice *i)
+ : Decoder()
{
m_inited = false;
m_totalTime = 0.;
@@ -36,6 +36,7 @@ DecoderMAD::DecoderMAD(QObject *parent, DecoderFactory *d, QIODevice *i, Output
m_output_at = 0;
m_skip_frames = 0;
m_eof = false;
+ m_input = i;
}
DecoderMAD::~DecoderMAD()
@@ -62,7 +63,7 @@ bool DecoderMAD::initialize()
m_output_bytes = 0;
m_output_at = 0;
- if (!input())
+ if (!m_input)
{
qWarning("DecoderMAD: cannot initialize. No input.");
return FALSE;
@@ -71,20 +72,20 @@ bool DecoderMAD::initialize()
if (!m_input_buf)
m_input_buf = new char[INPUT_BUFFER_SIZE];
- if (!input()->isOpen())
+ if (!m_input->isOpen())
{
- if (!input()->open(QIODevice::ReadOnly))
+ if (!m_input->open(QIODevice::ReadOnly))
{
- qWarning("DecoderMAD: %s", qPrintable(input()->errorString ()));
+ qWarning("DecoderMAD: %s", qPrintable(m_input->errorString ()));
return FALSE;
}
}
- if (input()->isSequential ()) //for streams only
+ if (m_input->isSequential ()) //for streams only
{
- TagExtractor extractor(input());
+ TagExtractor extractor(m_input);
if(!extractor.id3v2tag().isEmpty())
- stateHandler()->dispatch(extractor.id3v2tag());
+ StateHandler::instance()->dispatch(extractor.id3v2tag());
}
mad_stream_init(&stream);
@@ -211,7 +212,7 @@ bool DecoderMAD::findHeader()
memmove (m_input_buf, stream.next_frame, remaining);
}
- m_input_bytes = input()->read(m_input_buf + remaining, INPUT_BUFFER_SIZE - remaining);
+ m_input_bytes = m_input->read(m_input_buf + remaining, INPUT_BUFFER_SIZE - remaining);
if (m_input_bytes <= 0)
break;
@@ -234,7 +235,7 @@ bool DecoderMAD::findHeader()
}
result = TRUE;
- if (input()->isSequential())
+ if (m_input->isSequential())
break;
count ++;
@@ -279,9 +280,9 @@ bool DecoderMAD::findHeader()
if (!result)
return FALSE;
- if (!is_vbr && !input()->isSequential())
+ if (!is_vbr && !m_input->isSequential())
{
- double time = (input()->size() * 8.0) / (header.bitrate);
+ double time = (m_input->size() * 8.0) / (header.bitrate);
double timefrac = (double)time - ((long)(time));
mad_timer_set(&duration, (long)time, (long)(timefrac*100), 100);
}
@@ -297,7 +298,7 @@ bool DecoderMAD::findHeader()
m_channels = MAD_NCHANNELS(&header);
m_bitrate = header.bitrate / 1000;
mad_header_finish(&header);
- input()->seek(0);
+ m_input->seek(0);
m_input_bytes = 0;
return TRUE;
}
@@ -314,7 +315,7 @@ int DecoderMAD::bitrate()
return int(m_bitrate);
}
-qint64 DecoderMAD::readAudio(char *data, qint64 size)
+qint64 DecoderMAD::read(char *data, qint64 size)
{
forever
{
@@ -358,12 +359,12 @@ qint64 DecoderMAD::readAudio(char *data, qint64 size)
return madOutput(data, size);
}
}
-void DecoderMAD::seekAudio(qint64 pos)
+void DecoderMAD::seek(qint64 pos)
{
if(m_totalTime > 0)
{
- qint64 seek_pos = qint64(pos * input()->size() / m_totalTime);
- input()->seek(seek_pos);
+ qint64 seek_pos = qint64(pos * m_input->size() / m_totalTime);
+ m_input->seek(seek_pos);
mad_frame_mute(&frame);
mad_synth_mute(&synth);
stream.error = MAD_ERROR_BUFLEN;
@@ -381,7 +382,7 @@ bool DecoderMAD::fillBuffer()
m_input_bytes = &m_input_buf[m_input_bytes] - (char *) stream.next_frame;
memmove(m_input_buf, stream.next_frame, m_input_bytes);
}
- int len = input()->read((char *) m_input_buf + m_input_bytes, INPUT_BUFFER_SIZE - m_input_bytes);
+ int len = m_input->read((char *) m_input_buf + m_input_bytes, INPUT_BUFFER_SIZE - m_input_bytes);
if (!len)
{
qDebug("DecoderMAD: end of file");
diff --git a/src/plugins/Input/mad/decoder_mad.h b/src/plugins/Input/mad/decoder_mad.h
index 8e66ac0c4..86369b4d9 100644
--- a/src/plugins/Input/mad/decoder_mad.h
+++ b/src/plugins/Input/mad/decoder_mad.h
@@ -7,6 +7,7 @@
#ifndef DECODER_MAD_H
#define DECODER_MAD_H
+class QIODevice;
class DecoderMAD;
#include <qmmp/decoder.h>
@@ -21,8 +22,7 @@ extern "C"
class DecoderMAD : public Decoder
{
public:
- DecoderMAD(QObject *parent = 0, DecoderFactory *d = 0,
- QIODevice *i = 0, Output *o = 0);
+ DecoderMAD(QIODevice *i);
virtual ~DecoderMAD();
// standard decoder API
@@ -31,8 +31,8 @@ public:
int bitrate();
private:
- qint64 readAudio(char *data, qint64 size);
- void seekAudio(qint64);
+ qint64 read(char *data, qint64 size);
+ void seek(qint64);
// helper functions
qint64 madOutput(char *data, qint64 size);
@@ -47,6 +47,7 @@ private:
uint m_bitrate;
long m_freq, m_len;
qint64 m_output_bytes, m_output_at;
+ QIODevice *m_input;
// file input buffer
char *m_input_buf;
diff --git a/src/plugins/Input/mad/decodermadfactory.cpp b/src/plugins/Input/mad/decodermadfactory.cpp
index d4d881cd8..47de2e828 100644
--- a/src/plugins/Input/mad/decodermadfactory.cpp
+++ b/src/plugins/Input/mad/decodermadfactory.cpp
@@ -94,9 +94,9 @@ const DecoderProperties DecoderMADFactory::properties() const
return properties;
}
-Decoder *DecoderMADFactory::create(QObject *parent, QIODevice *input, Output *output, const QString &)
+Decoder *DecoderMADFactory::create(QIODevice *input, const QString &)
{
- return new DecoderMAD(parent, this, input, output);
+ return new DecoderMAD(input);
}
QList<FileInfo *> DecoderMADFactory::createPlayList(const QString &fileName, bool useMetaData)
diff --git a/src/plugins/Input/mad/decodermadfactory.h b/src/plugins/Input/mad/decodermadfactory.h
index bd657514c..6107e56f0 100644
--- a/src/plugins/Input/mad/decodermadfactory.h
+++ b/src/plugins/Input/mad/decodermadfactory.h
@@ -43,7 +43,7 @@ public:
bool supports(const QString &source) const;
bool canDecode(QIODevice *input) const;
const DecoderProperties properties() const;
- Decoder *create(QObject *, QIODevice *, Output *, const QString &);
+ Decoder *create(QIODevice *, const QString &);
QList<FileInfo *> createPlayList(const QString &fileName, bool useMetaData);
MetaDataModel* createMetaDataModel(const QString &path, QObject *parent = 0);
void showSettings(QWidget *parent);