aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Input/wavpack
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2008-10-12 19:48:39 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2008-10-12 19:48:39 +0000
commite48a196c880d9f92804c6e1e3ea5631ae2017dd1 (patch)
tree6767f170f669cdfaea23e469050c05ad1f6c67ca /src/plugins/Input/wavpack
parent0a74e1c0e3781afe041ba9acc361461cc3ebda82 (diff)
downloadqmmp-e48a196c880d9f92804c6e1e3ea5631ae2017dd1.tar.gz
qmmp-e48a196c880d9f92804c6e1e3ea5631ae2017dd1.tar.bz2
qmmp-e48a196c880d9f92804c6e1e3ea5631ae2017dd1.zip
enabled all input plugins
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@581 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Input/wavpack')
-rw-r--r--src/plugins/Input/wavpack/decoder_wavpack.cpp44
-rw-r--r--src/plugins/Input/wavpack/decoder_wavpack.h11
-rw-r--r--src/plugins/Input/wavpack/decoderwavpackfactory.cpp38
-rw-r--r--src/plugins/Input/wavpack/decoderwavpackfactory.h6
4 files changed, 43 insertions, 56 deletions
diff --git a/src/plugins/Input/wavpack/decoder_wavpack.cpp b/src/plugins/Input/wavpack/decoder_wavpack.cpp
index 8e03f4e1d..d4b28c473 100644
--- a/src/plugins/Input/wavpack/decoder_wavpack.cpp
+++ b/src/plugins/Input/wavpack/decoder_wavpack.cpp
@@ -34,9 +34,10 @@
// Decoder class
-DecoderWavPack::DecoderWavPack(QObject *parent, DecoderFactory *d, QIODevice *i, Output *o)
- : Decoder(parent, d, i, o)
+DecoderWavPack::DecoderWavPack(QObject *parent, DecoderFactory *d, Output *o, const QString &path)
+ : Decoder(parent, d, o)
{
+ m_path = path;
m_inited = FALSE;
m_user_stop = FALSE;
m_output_buf = 0;
@@ -108,7 +109,7 @@ void DecoderWavPack::flush(bool final)
bool DecoderWavPack::initialize()
{
- m_bks = blockSize();
+ m_bks = Buffer::size();
m_inited = m_user_stop = m_done = m_finish = FALSE;
m_freq = m_bitrate = 0;
m_chan = 0;
@@ -116,50 +117,39 @@ bool DecoderWavPack::initialize()
m_seekTime = -1.0;
m_totalTime = 0.0;
-
- if (! input())
- {
- error("DecoderWavPack: cannot initialize. No input.");
-
- return FALSE;
- }
-
if (! m_output_buf)
m_output_buf = new char[globalBufferSize];
m_output_at = 0;
m_output_bytes = 0;
- QString filename = qobject_cast<QFile*>(input())->fileName ();
- input()->close();
-
char err [80];
- m_context = WavpackOpenFileInput (filename.toLocal8Bit(), err,
+ m_context = WavpackOpenFileInput (m_path.toLocal8Bit(), err,
OPEN_WVC | OPEN_TAGS, 0);
if(!m_context)
{
- error(QString("DecoderWavPack: error: %1").arg(err));
+ qWarning("DecoderWavPack: error: %s", err);
return FALSE;
}
m_chan = WavpackGetNumChannels(m_context);
m_freq = WavpackGetSampleRate (m_context);
m_bps = WavpackGetBitsPerSample (m_context);
- configure(m_freq, m_chan, m_bps, int(WavpackGetAverageBitrate(m_context, m_chan)/1000));
+ configure(m_freq, m_chan, m_bps);
m_totalTime = (int) WavpackGetNumSamples(m_context)/m_freq;
m_inited = TRUE;
qDebug("DecoderWavPack: initialize succes");
return TRUE;
}
-double DecoderWavPack::lengthInSeconds()
+qint64 DecoderWavPack::lengthInSeconds()
{
- if (! m_inited)
+ if (!m_inited)
return 0;
return m_totalTime;
}
-void DecoderWavPack::seek(double pos)
+void DecoderWavPack::seek(qint64 pos)
{
m_seekTime = pos;
}
@@ -186,14 +176,12 @@ void DecoderWavPack::run()
int16_t *out = new int16_t[globalBufferSize * m_chan / m_chan / 4];
uint32_t samples = 0;
- if (! m_inited)
+ if (!m_inited)
{
mutex()->unlock();
-
return;
}
mutex()->unlock();
- dispatch(DecoderState::Decoding);
while (! m_done && ! m_finish)
{
@@ -253,9 +241,8 @@ void DecoderWavPack::run()
}
else
{
- // error in read
- error("DecoderWavPack: Error while decoding stream, File appears to be "
- "corrupted");
+ // error while reading
+ qWarning("DecoderWavPack: Error while decoding stream, file appears to be corrupted");
m_finish = TRUE;
}
mutex()->unlock();
@@ -267,11 +254,8 @@ void DecoderWavPack::run()
delete[] out;
if (m_finish)
- dispatch(DecoderState::Finished);
- else if (m_user_stop)
- dispatch(DecoderState::Stopped);
+ finish();
mutex()->unlock();
-
deinit();
}
diff --git a/src/plugins/Input/wavpack/decoder_wavpack.h b/src/plugins/Input/wavpack/decoder_wavpack.h
index eb3402160..36f5fc4f8 100644
--- a/src/plugins/Input/wavpack/decoder_wavpack.h
+++ b/src/plugins/Input/wavpack/decoder_wavpack.h
@@ -31,13 +31,13 @@ extern "C"{
class DecoderWavPack : public Decoder
{
public:
- DecoderWavPack(QObject *, DecoderFactory *, QIODevice *, Output *);
+ DecoderWavPack(QObject *, DecoderFactory *, Output *, const QString &);
virtual ~DecoderWavPack();
// Standard Decoder API
bool initialize();
- double lengthInSeconds();
- void seek(double);
+ qint64 lengthInSeconds();
+ void seek(qint64);
void stop();
private:
@@ -53,14 +53,15 @@ private:
// output buffer
char *m_output_buf;
- ulong m_output_bytes, m_output_at;
+ qint64 m_output_bytes, m_output_at;
unsigned int m_bks; //block size
bool m_done, m_finish;
long m_freq, m_bitrate;
int m_chan;
unsigned long m_output_size;
- double m_totalTime, m_seekTime;
+ qint64 m_totalTime, m_seekTime;
+ QString m_path;
};
diff --git a/src/plugins/Input/wavpack/decoderwavpackfactory.cpp b/src/plugins/Input/wavpack/decoderwavpackfactory.cpp
index 145000c25..114cd5366 100644
--- a/src/plugins/Input/wavpack/decoderwavpackfactory.cpp
+++ b/src/plugins/Input/wavpack/decoderwavpackfactory.cpp
@@ -51,47 +51,49 @@ const DecoderProperties DecoderWavPackFactory::properties() const
//properties.contentType = ;
properties.hasAbout = TRUE;
properties.hasSettings = FALSE;
+ properties.noInput = TRUE;
+ properties.protocols = "file";
return properties;
}
Decoder *DecoderWavPackFactory::create(QObject *parent, QIODevice *input,
- Output *output)
+ Output *output, const QString &path)
{
- return new DecoderWavPack(parent, this, input, output);
+ Q_UNUSED(input);
+ return new DecoderWavPack(parent, this, output, path);
}
-FileTag *DecoderWavPackFactory::createTag(const QString &source)
+QList<FileInfo *> DecoderWavPackFactory::createPlayList(const QString &fileName)
{
- FileTag *ftag = new FileTag();
-
+ QList <FileInfo*> list;
char err[80];
- WavpackContext *ctx = WavpackOpenFileInput (source.toLocal8Bit(), err,
+ WavpackContext *ctx = WavpackOpenFileInput (fileName.toLocal8Bit(), err,
OPEN_WVC | OPEN_TAGS, 0);
-
if(!ctx)
{
qWarning("DecoderWavPackFactory: error: %s", err);
- return ftag;
+ return list;
}
-
+ FileInfo *info = new FileInfo(fileName);
char value[200];
WavpackGetTagItem (ctx, "Album", value, sizeof(value));
- ftag->setValue(FileTag::ALBUM, QString::fromUtf8(value));
+ info->setMetaData(Qmmp::ALBUM, QString::fromUtf8(value));
WavpackGetTagItem (ctx, "Artist", value, sizeof(value));
- ftag->setValue(FileTag::ARTIST, QString::fromUtf8(value));
+ info->setMetaData(Qmmp::ARTIST, QString::fromUtf8(value));
WavpackGetTagItem (ctx, "Comment", value, sizeof(value));
- ftag->setValue(FileTag::COMMENT, QString::fromUtf8(value));
+ info->setMetaData(Qmmp::COMMENT, QString::fromUtf8(value));
WavpackGetTagItem (ctx, "Genre", value, sizeof(value));
- ftag->setValue(FileTag::GENRE, QString::fromUtf8(value));
+ info->setMetaData(Qmmp::GENRE, QString::fromUtf8(value));
WavpackGetTagItem (ctx, "Title", value, sizeof(value));
- ftag->setValue(FileTag::TITLE, QString::fromUtf8(value));
+ info->setMetaData(Qmmp::TITLE, QString::fromUtf8(value));
WavpackGetTagItem (ctx, "Year", value, sizeof(value));
- ftag->setValue(FileTag::YEAR, QString::fromUtf8(value).toInt());
+ info->setMetaData(Qmmp::YEAR, QString::fromUtf8(value).toInt());
WavpackGetTagItem (ctx, "Track", value, sizeof(value));
- ftag->setValue(FileTag::TRACK, QString::fromUtf8(value).toInt());
- ftag->setValue(FileTag::LENGTH, (int) WavpackGetNumSamples(ctx)/WavpackGetSampleRate(ctx));
+ info->setMetaData(Qmmp::TRACK, QString::fromUtf8(value).toInt());
+ info->setLength((int) WavpackGetNumSamples(ctx)/WavpackGetSampleRate(ctx));
WavpackCloseFile (ctx);
- return ftag;
+ list << info;
+ return list;
}
QObject* DecoderWavPackFactory::showDetails(QWidget *parent, const QString &path)
diff --git a/src/plugins/Input/wavpack/decoderwavpackfactory.h b/src/plugins/Input/wavpack/decoderwavpackfactory.h
index f3e2f5e22..1213dd92a 100644
--- a/src/plugins/Input/wavpack/decoderwavpackfactory.h
+++ b/src/plugins/Input/wavpack/decoderwavpackfactory.h
@@ -28,7 +28,7 @@
#include <qmmp/decoder.h>
#include <qmmp/output.h>
#include <qmmp/decoderfactory.h>
-#include <qmmp/filetag.h>
+#include <qmmp/fileinfo.h>
class DecoderWavPackFactory : public QObject,
@@ -41,8 +41,8 @@ public:
bool supports(const QString &source) const;
bool canDecode(QIODevice *input) const;
const DecoderProperties properties() const;
- Decoder *create(QObject *, QIODevice *, Output *);
- FileTag *createTag(const QString &source);
+ Decoder *create(QObject *, QIODevice *, Output *, const QString &);
+ QList<FileInfo *> createPlayList(const QString &fileName);
QObject* showDetails(QWidget *parent, const QString &path);
void showSettings(QWidget *parent);
void showAbout(QWidget *parent);