aboutsummaryrefslogtreecommitdiff
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
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
-rw-r--r--src/plugins/Input/CMakeLists.txt10
-rw-r--r--src/plugins/Input/Input.pro8
-rw-r--r--src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp83
-rw-r--r--src/plugins/Input/ffmpeg/decoder_ffmpeg.h34
-rw-r--r--src/plugins/Input/ffmpeg/decoderffmpegfactory.cpp43
-rw-r--r--src/plugins/Input/ffmpeg/decoderffmpegfactory.h8
-rw-r--r--src/plugins/Input/modplug/decoder_modplug.cpp58
-rw-r--r--src/plugins/Input/modplug/decoder_modplug.h9
-rw-r--r--src/plugins/Input/modplug/decodermodplugfactory.cpp32
-rw-r--r--src/plugins/Input/modplug/decodermodplugfactory.h6
-rw-r--r--src/plugins/Input/mpc/decoder_mpc.cpp84
-rw-r--r--src/plugins/Input/mpc/decoder_mpc.h20
-rw-r--r--src/plugins/Input/mpc/decodermpcfactory.cpp30
-rw-r--r--src/plugins/Input/mpc/decodermpcfactory.h6
-rw-r--r--src/plugins/Input/sndfile/decoder_sndfile.cpp71
-rw-r--r--src/plugins/Input/sndfile/decoder_sndfile.h11
-rw-r--r--src/plugins/Input/sndfile/decodersndfilefactory.cpp26
-rw-r--r--src/plugins/Input/sndfile/decodersndfilefactory.h6
-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
-rw-r--r--src/qmmp/decoder.cpp30
-rw-r--r--src/qmmp/decoder.h2
24 files changed, 293 insertions, 383 deletions
diff --git a/src/plugins/Input/CMakeLists.txt b/src/plugins/Input/CMakeLists.txt
index 977aaf93f..80fe7d9d0 100644
--- a/src/plugins/Input/CMakeLists.txt
+++ b/src/plugins/Input/CMakeLists.txt
@@ -26,23 +26,23 @@ add_subdirectory(vorbis)
ENDIF(USE_VORBIS AND TAGLIB_FOUND)
IF(USE_FFMPEG)
-#add_subdirectory(ffmpeg)
+add_subdirectory(ffmpeg)
ENDIF(USE_FFMPEG)
IF(USE_MPC AND TAGLIB_FOUND)
-#add_subdirectory(mpc)
+add_subdirectory(mpc)
ENDIF(USE_MPC AND TAGLIB_FOUND)
IF(USE_SNDFILE)
-#add_subdirectory(sndfile)
+add_subdirectory(sndfile)
ENDIF(USE_SNDFILE)
IF(USE_WAVPACK)
-#add_subdirectory(wavpack)
+add_subdirectory(wavpack)
ENDIF(USE_WAVPACK)
IF(USE_MODPLUG)
-#add_subdirectory(modplug)
+add_subdirectory(modplug)
ENDIF(USE_MODPLUG)
IF(USE_CUE)
diff --git a/src/plugins/Input/Input.pro b/src/plugins/Input/Input.pro
index 129253a84..c4197bfaa 100644
--- a/src/plugins/Input/Input.pro
+++ b/src/plugins/Input/Input.pro
@@ -1,17 +1,17 @@
include(../../../qmmp.pri)
-SUBDIRS += mad vorbis cue # sndfile wavpack
+SUBDIRS += mad vorbis cue sndfile wavpack
TEMPLATE = subdirs
contains(CONFIG, MODPLUG_PLUGIN){
-# SUBDIRS += modplug
+ SUBDIRS += modplug
message(***************************)
message(* Modplug plugin enabled *)
message(***************************)
}
contains(CONFIG, MUSEPACK_PLUGIN){
-# SUBDIRS += mpc
+ SUBDIRS += mpc
message(***************************)
message(* Musepack plugin enabled *)
message(***************************)
@@ -25,7 +25,7 @@ contains(CONFIG, FLAC_PLUGIN){
}
contains(CONFIG, FFMPEG_PLUGIN){
-# SUBDIRS += ffmpeg
+ SUBDIRS += ffmpeg
message(*************************)
message(* FFMPEG plugin enabled *)
message(*************************)
diff --git a/src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp b/src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp
index 274e05160..c1b5ac2e2 100644
--- a/src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp
+++ b/src/plugins/Input/ffmpeg/decoder_ffmpeg.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2006 by Ilya Kotov *
+ * Copyright (C) 2006-2008 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -30,18 +30,17 @@
// Decoder class
-DecoderFFmpeg::DecoderFFmpeg(QObject *parent, DecoderFactory *d, QIODevice *i, Output *o)
- : Decoder(parent, d, i, o)
+DecoderFFmpeg::DecoderFFmpeg(QObject *parent, DecoderFactory *d, Output *o, const QString &path)
+ : Decoder(parent, d, o)
{
inited = FALSE;
user_stop = FALSE;
- stat = 0;
output_buf = 0;
output_bytes = 0;
output_at = 0;
bks = 0;
done = FALSE;
- finish = FALSE;
+ m_finish = FALSE;
freq = 0;
bitrate = 0;
seekTime = -1.0;
@@ -50,6 +49,7 @@ DecoderFFmpeg::DecoderFFmpeg(QObject *parent, DecoderFactory *d, QIODevice *i, O
output_size = 0;
ic = 0;
wma_outbuf = 0;
+ m_path = path;
}
@@ -80,11 +80,11 @@ void DecoderFFmpeg::flush(bool final)
{
ulong min = final ? 0 : bks;
- while ((! done && ! finish) && output_bytes > min)
+ while ((! done && ! m_finish) && output_bytes > min)
{
output()->recycler()->mutex()->lock ();
- while ((! done && ! finish) && output()->recycler()->full())
+ while ((! done && ! m_finish) && output()->recycler()->full())
{
mutex()->unlock();
@@ -94,7 +94,7 @@ void DecoderFFmpeg::flush(bool final)
done = user_stop;
}
- if (user_stop || finish)
+ if (user_stop || m_finish)
{
inited = FALSE;
done = TRUE;
@@ -118,47 +118,25 @@ void DecoderFFmpeg::flush(bool final)
bool DecoderFFmpeg::initialize()
{
- bks = blockSize();
- inited = user_stop = done = finish = FALSE;
+ bks = Buffer::size();
+ inited = user_stop = done = m_finish = FALSE;
freq = bitrate = 0;
- stat = chan = 0;
+ chan = 0;
output_size = 0;
seekTime = -1.0;
totalTime = 0.0;
-
- if (! input())
- {
- error("DecoderFFmpeg: cannot initialize. No input.");
-
- return FALSE;
- }
-
- if (! output_buf)
+ if (!output_buf)
output_buf = new char[globalBufferSize];
output_at = 0;
output_bytes = 0;
- if (! input())
- {
- error("DecoderFFmpeg: cannot initialize. No input.");
-
- return FALSE;
- }
-
- if (! output_buf)
- output_buf = new char[globalBufferSize];
- output_at = 0;
- output_bytes = 0;
-
- QString filename = qobject_cast<QFile*>(input())->fileName ();
- input()->close();
avcodec_init();
avcodec_register_all();
av_register_all();
AVCodec *codec;
- if (av_open_input_file(&ic, filename.toLocal8Bit(), NULL,0, NULL) < 0)
+ if (av_open_input_file(&ic, m_path.toLocal8Bit(), NULL,0, NULL) < 0)
{
qDebug("DecoderFFmpeg: cannot open input file");
return FALSE;
@@ -179,7 +157,7 @@ bool DecoderFFmpeg::initialize()
totalTime = ic->duration/AV_TIME_BASE;
- configure(c->sample_rate, c->channels, 16, c->bit_rate);
+ configure(c->sample_rate, c->channels, 16);
bitrate = c->bit_rate;
chan = c->channels;
@@ -190,7 +168,7 @@ bool DecoderFFmpeg::initialize()
}
-double DecoderFFmpeg::lengthInSeconds()
+qint64 DecoderFFmpeg::lengthInSeconds()
{
if (! inited)
return 0;
@@ -199,7 +177,7 @@ double DecoderFFmpeg::lengthInSeconds()
}
-void DecoderFFmpeg::seek(double pos)
+void DecoderFFmpeg::seek(qint64 pos)
{
seekTime = pos;
}
@@ -207,9 +185,9 @@ void DecoderFFmpeg::seek(double pos)
void DecoderFFmpeg::deinit()
{
- inited = user_stop = done = finish = FALSE;
+ inited = user_stop = done = m_finish = FALSE;
freq = bitrate = 0;
- stat = chan = 0;
+ chan = 0;
output_size = 0;
}
@@ -229,13 +207,9 @@ void DecoderFFmpeg::run()
return;
}
- stat = DecoderState::Decoding;
mutex()->unlock();
- {
- dispatch(DecoderState ((DecoderState::Type) stat));
- }
- while (! done && ! finish)
+ while (!done && !m_finish)
{
mutex()->lock ();
// decode
@@ -254,7 +228,7 @@ void DecoderFFmpeg::run()
int l = 0;
if (av_read_frame(ic, &pkt) < 0)
{
- finish = TRUE;
+ m_finish = TRUE;
goto end;
}
size = pkt.size;
@@ -277,7 +251,7 @@ void DecoderFFmpeg::run()
}
bitrate = c->bit_rate/1024;
end:
- if (finish)
+ if (m_finish)
{
flush(TRUE);
@@ -298,7 +272,7 @@ end:
done = TRUE;
if (! user_stop)
{
- finish = TRUE;
+ m_finish = TRUE;
}
}
@@ -307,18 +281,9 @@ end:
}
mutex()->lock ();
-
- if (finish)
- stat = DecoderState::Finished;
- else if (user_stop)
- stat = DecoderState::Stopped;
-
+ if (m_finish)
+ finish();
mutex()->unlock();
-
- {
- dispatch(DecoderState ((DecoderState::Type) stat));
- }
-
deinit();
}
diff --git a/src/plugins/Input/ffmpeg/decoder_ffmpeg.h b/src/plugins/Input/ffmpeg/decoder_ffmpeg.h
index 37265e31f..9e85c9089 100644
--- a/src/plugins/Input/ffmpeg/decoder_ffmpeg.h
+++ b/src/plugins/Input/ffmpeg/decoder_ffmpeg.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2006 by Ilya Kotov *
+ * Copyright (C) 2006-2008 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -22,7 +22,9 @@
#define __decoder_ffmeg_h
extern "C"{
-#if defined HAVE_FFMPEG_AVFORMAT_H
+#if defined HAVE_FFMPEG_LIBAVFORMAT_AVFORMAT_H
+#include <ffmpeg/libavformat/avformat.h>
+#elif defined HAVE_FFMPEG_AVFORMAT_H
#include <ffmpeg/avformat.h>
#elif defined HAVE_LIBAVFORMAT_AVFORMAT_H
#include <libavformat/avformat.h>
@@ -30,7 +32,9 @@ extern "C"{
#include <avformat.h>
#endif
-#if defined HAVE_FFMPEG_AVCODEC_H
+#if defined HAVE_FFMPEG_LIBAVCODEC_AVCODEC_H
+#include <ffmpeg/libavcodec/avcodec.h>
+#elif defined HAVE_FFMPEG_AVCODEC_H
#include <ffmpeg/avcodec.h>
#elif defined HAVE_LIBAVCODEC_AVCODEC_H
#include <libavcodec/avcodec.h>
@@ -43,22 +47,15 @@ extern "C"{
class DecoderFFmpeg : public Decoder
{
public:
- DecoderFFmpeg(QObject *, DecoderFactory *, QIODevice *, Output *);
+ DecoderFFmpeg(QObject *, DecoderFactory *, Output *, const QString &);
virtual ~DecoderFFmpeg();
// Standard Decoder API
bool initialize();
- double lengthInSeconds();
- void seek(double);
+ qint64 lengthInSeconds();
+ void seek(qint64);
void stop();
- // Equalizer
- bool isEQSupported() const { return FALSE; }
- void setEQEnabled(bool) { ; }
- void setEQGain(int) { ; }
- void setEQBands(int[10]) { ; }
-
-
private:
// thread run function
void run();
@@ -66,13 +63,11 @@ private:
void flush(bool = FALSE);
void deinit();
void ffmpeg_out(int size);
-
bool inited, user_stop;
- int stat;
// output buffer
char *output_buf;
- ulong output_bytes, output_at;
+ qint64 output_bytes, output_at;
AVFormatContext *ic;
AVCodecContext *c;
@@ -80,11 +75,12 @@ private:
uint8_t *wma_outbuf;
unsigned int bks;
- bool done, finish;
+ bool done, m_finish;
long freq, bitrate;
int chan;
- unsigned long output_size;
- double totalTime, seekTime;
+ qint64 output_size;
+ qint64 totalTime, seekTime;
+ QString m_path;
};
diff --git a/src/plugins/Input/ffmpeg/decoderffmpegfactory.cpp b/src/plugins/Input/ffmpeg/decoderffmpegfactory.cpp
index 3598cebbc..41a968634 100644
--- a/src/plugins/Input/ffmpeg/decoderffmpegfactory.cpp
+++ b/src/plugins/Input/ffmpeg/decoderffmpegfactory.cpp
@@ -21,7 +21,9 @@
#include <QtGui>
extern "C"{
-#if defined HAVE_FFMPEG_AVFORMAT_H
+#if defined HAVE_FFMPEG_LIBAVFORMAT_AVFORMAT_H
+#include <ffmpeg/libavformat/avformat.h>
+#elif defined HAVE_FFMPEG_AVFORMAT_H
#include <ffmpeg/avformat.h>
#elif defined HAVE_LIBAVFORMAT_AVFORMAT_H
#include <libavformat/avformat.h>
@@ -29,7 +31,9 @@ extern "C"{
#include <avformat.h>
#endif
-#if defined HAVE_FFMPEG_AVCODEC_H
+#if defined HAVE_FFMPEG_LIBAVCODEC_AVCODEC_H
+#include <ffmpeg/libavcodec/avcodec.h>
+#elif defined HAVE_FFMPEG_AVCODEC_H
#include <ffmpeg/avcodec.h>
#elif defined HAVE_LIBAVCODEC_AVCODEC_H
#include <libavcodec/avcodec.h>
@@ -65,36 +69,41 @@ const DecoderProperties DecoderFFmpegFactory::properties() const
//properties.contentType = "";
properties.hasAbout = TRUE;
properties.hasSettings = FALSE;
+ properties.noInput = TRUE;
+ properties.protocols = "file";
return properties;
}
Decoder *DecoderFFmpegFactory::create(QObject *parent, QIODevice *input,
- Output *output)
+ Output *output, const QString &path)
{
- return new DecoderFFmpeg(parent, this, input, output);
+ Q_UNUSED(input);
+ return new DecoderFFmpeg(parent, this, output, path);
}
-FileTag *DecoderFFmpegFactory::createTag(const QString &source)
+QList<FileInfo *> DecoderFFmpegFactory::createPlayList(const QString &fileName)
{
- FileTag *ftag = new FileTag();
+ QList <FileInfo*> list;
avcodec_init();
avcodec_register_all();
av_register_all();
AVFormatContext *in;
- if (av_open_input_file(&in, source.toLocal8Bit(), NULL,0, NULL) < 0)
- return ftag;
+ if (av_open_input_file(&in, fileName.toLocal8Bit(), NULL,0, NULL) < 0)
+ return list;
+ FileInfo *info = new FileInfo(fileName);
av_find_stream_info(in);
- ftag->setValue(FileTag::ALBUM, QString::fromUtf8(in->album).trimmed());
- ftag->setValue(FileTag::ARTIST, QString::fromUtf8(in->author).trimmed());
- ftag->setValue(FileTag::COMMENT, QString::fromUtf8(in->comment).trimmed());
- ftag->setValue(FileTag::GENRE, QString::fromUtf8(in->genre).trimmed());
- ftag->setValue(FileTag::TITLE, QString::fromUtf8(in->title).trimmed());
- ftag->setValue(FileTag::YEAR, in->year);
- ftag->setValue(FileTag::TRACK, in->track);
- ftag->setValue(FileTag::LENGTH ,int(in->duration/AV_TIME_BASE));
+ info->setMetaData(Qmmp::ALBUM, QString::fromUtf8(in->album).trimmed());
+ info->setMetaData(Qmmp::ARTIST, QString::fromUtf8(in->author).trimmed());
+ info->setMetaData(Qmmp::COMMENT, QString::fromUtf8(in->comment).trimmed());
+ info->setMetaData(Qmmp::GENRE, QString::fromUtf8(in->genre).trimmed());
+ info->setMetaData(Qmmp::TITLE, QString::fromUtf8(in->title).trimmed());
+ info->setMetaData(Qmmp::YEAR, in->year);
+ info->setMetaData(Qmmp::TRACK, in->track);
+ info->setLength(in->duration/AV_TIME_BASE);
av_close_input_file(in);
- return ftag;
+ list << info;
+ return list;
}
QObject* DecoderFFmpegFactory::showDetails(QWidget *parent, const QString &path)
diff --git a/src/plugins/Input/ffmpeg/decoderffmpegfactory.h b/src/plugins/Input/ffmpeg/decoderffmpegfactory.h
index 6f24fed94..c8bb2ef62 100644
--- a/src/plugins/Input/ffmpeg/decoderffmpegfactory.h
+++ b/src/plugins/Input/ffmpeg/decoderffmpegfactory.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2006 by Ilya Kotov *
+ * Copyright (C) 2006-2008 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -28,7 +28,7 @@
#include <qmmp/decoder.h>
#include <qmmp/output.h>
#include <qmmp/decoderfactory.h>
-#include <qmmp/filetag.h>
+#include <qmmp/fileinfo.h>
@@ -43,8 +43,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);
diff --git a/src/plugins/Input/modplug/decoder_modplug.cpp b/src/plugins/Input/modplug/decoder_modplug.cpp
index ea0d18f64..6321f56b7 100644
--- a/src/plugins/Input/modplug/decoder_modplug.cpp
+++ b/src/plugins/Input/modplug/decoder_modplug.cpp
@@ -47,9 +47,10 @@
DecoderModPlug* DecoderModPlug::m_instance = 0;
-DecoderModPlug::DecoderModPlug(QObject *parent, DecoderFactory *d, QIODevice *i, Output *o)
- : Decoder(parent, d, i, o)
+DecoderModPlug::DecoderModPlug(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;
@@ -125,7 +126,7 @@ void DecoderModPlug::flush(bool final)
bool DecoderModPlug::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;
@@ -133,29 +134,25 @@ bool DecoderModPlug::initialize()
m_seekTime = -1.0;
m_totalTime = 0.0;
-
- if (! input())
- {
- error("DecoderModPlug: 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 ();
ArchiveReader reader(this);
- if (reader.isSupported(filename))
+ if (reader.isSupported(m_path))
+ m_input_buf = reader.unpack(m_path);
+ else
{
- input()->close();
- m_input_buf = reader.unpack(filename);
+ QFile file(m_path);
+ if (!file.open(QIODevice::ReadOnly))
+ {
+ qWarning("DecoderModPlug: error: %s", qPrintable(file.errorString ()));
+ return FALSE;
+ }
+ m_input_buf = file.readAll();
+ file.close();
}
- else
- m_input_buf = input()->readAll();
-
if (m_input_buf.isEmpty())
{
qWarning("DecoderModPlug: error reading moplug file");
@@ -172,13 +169,13 @@ bool DecoderModPlug::initialize()
return FALSE;
}*/
- m_totalTime = (int) m_soundFile->GetSongTime();
- configure(m_freq, m_chan, m_bps, m_bitrate);
+ m_totalTime = (qint64) m_soundFile->GetSongTime();
+ configure(m_freq, m_chan, m_bps);
m_inited = TRUE;
return TRUE;
}
-double DecoderModPlug::lengthInSeconds()
+qint64 DecoderModPlug::lengthInSeconds()
{
if (! m_inited)
return 0;
@@ -187,7 +184,7 @@ double DecoderModPlug::lengthInSeconds()
}
-void DecoderModPlug::seek(double pos)
+void DecoderModPlug::seek(qint64 pos)
{
m_seekTime = pos;
}
@@ -212,24 +209,22 @@ void DecoderModPlug::run()
mutex()->lock ();
ulong len = 0;
- if (! m_inited)
+ if (!m_inited)
{
mutex()->unlock();
-
return;
}
mutex()->unlock();
- dispatch(DecoderState::Decoding);
char *prebuf = new char[m_bks];
- while (! m_done && ! m_finish)
+ while (!m_done && !m_finish)
{
mutex()->lock ();
//seeking
- if (m_seekTime >= 0.0)
+ if (m_seekTime >= 0)
{
quint32 lMax;
quint32 lMaxtime;
@@ -318,9 +313,8 @@ void DecoderModPlug::run()
}
else
{
- // error in read
- error("DecoderModPlug: Error while decoding stream, File appears to be "
- "corrupted");
+ // error while read
+ qWarning("DecoderModPlug: Error while decoding stream, File appears to be corrupted");
m_finish = TRUE;
}
mutex()->unlock();
@@ -329,9 +323,7 @@ void DecoderModPlug::run()
mutex()->lock ();
if (m_finish)
- dispatch(DecoderState::Finished);
- else if (m_user_stop)
- dispatch(DecoderState::Stopped);
+ finish();
mutex()->unlock();
delete prebuf;
diff --git a/src/plugins/Input/modplug/decoder_modplug.h b/src/plugins/Input/modplug/decoder_modplug.h
index 4883c3b09..71f082c4a 100644
--- a/src/plugins/Input/modplug/decoder_modplug.h
+++ b/src/plugins/Input/modplug/decoder_modplug.h
@@ -28,13 +28,13 @@ class CSoundFile;
class DecoderModPlug : public Decoder
{
public:
- DecoderModPlug(QObject *, DecoderFactory *, QIODevice *, Output *);
+ DecoderModPlug(QObject *, DecoderFactory *, Output *, const QString &path);
virtual ~DecoderModPlug();
// Standard Decoder API
bool initialize();
- double lengthInSeconds();
- void seek(double);
+ qint64 lengthInSeconds();
+ void seek(qint64);
void stop();
void readSettings();
@@ -68,9 +68,10 @@ private:
long m_freq, m_bitrate;
int m_chan, m_sampleSize;
unsigned long m_output_size;
- double m_totalTime, m_seekTime;
+ qint64 m_totalTime, m_seekTime;
double m_preampFactor;
bool m_usePreamp;
+ QString m_path;
static DecoderModPlug* m_instance;
};
diff --git a/src/plugins/Input/modplug/decodermodplugfactory.cpp b/src/plugins/Input/modplug/decodermodplugfactory.cpp
index 1124abb79..9e13c0b74 100644
--- a/src/plugins/Input/modplug/decodermodplugfactory.cpp
+++ b/src/plugins/Input/modplug/decodermodplugfactory.cpp
@@ -65,49 +65,53 @@ const DecoderProperties DecoderModPlugFactory::properties() const
//properties.contentType = ;
properties.hasAbout = TRUE;
properties.hasSettings = TRUE;
+ properties.noInput = TRUE;
+ properties.protocols = "file";
return properties;
}
Decoder *DecoderModPlugFactory::create(QObject *parent, QIODevice *input,
- Output *output)
+ Output *output, const QString &path)
{
- return new DecoderModPlug(parent, this, input, output);
+ Q_UNUSED(input);
+ return new DecoderModPlug(parent, this, output, path);
}
-FileTag *DecoderModPlugFactory::createTag(const QString &source)
+QList<FileInfo *> DecoderModPlugFactory::createPlayList(const QString &fileName)
{
- FileTag *ftag = new FileTag();
+ QList <FileInfo*> list;
QSettings settings(QDir::homePath()+"/.qmmp/qmmprc", QSettings::IniFormat);
if (settings.value("UseFileName", FALSE).toBool())
{
- ftag->setValue(FileTag::TITLE, source.section('/',-1));
- return ftag;
+ list << new FileInfo(fileName);
+ list.at(0)->setMetaData(Qmmp::TITLE, fileName.section('/',-1));
+ return list;
}
ArchiveReader reader(0);
QByteArray buffer;
- if (reader.isSupported(source))
+ if (reader.isSupported(fileName))
{
- buffer = reader.unpack(source);
+ buffer = reader.unpack(fileName);
}
else
{
- QFile file(source);
+ QFile file(fileName);
if (!file.open(QIODevice::ReadOnly))
{
qWarning("DecoderModPlugFactory: error: %s", qPrintable(file.errorString ()));
- return ftag;
+ return list;
}
buffer = file.readAll();
file.close();
}
CSoundFile* soundFile = new CSoundFile();
soundFile->Create((uchar*) buffer.data(), buffer.size());
-
- ftag->setValue(FileTag::LENGTH, (int) soundFile->GetSongTime());
- ftag->setValue(FileTag::TITLE, QString::fromUtf8(soundFile->GetTitle()));
+ list << new FileInfo(fileName);
+ list.at(0)->setLength((int) soundFile->GetSongTime());
+ list.at(0)->setMetaData(Qmmp::TITLE, QString::fromUtf8(soundFile->GetTitle()));
soundFile->Destroy();
delete soundFile;
- return ftag;
+ return list;
}
QObject* DecoderModPlugFactory::showDetails(QWidget *parent, const QString &path)
diff --git a/src/plugins/Input/modplug/decodermodplugfactory.h b/src/plugins/Input/modplug/decodermodplugfactory.h
index 20378f739..8581e0d99 100644
--- a/src/plugins/Input/modplug/decodermodplugfactory.h
+++ b/src/plugins/Input/modplug/decodermodplugfactory.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 DecoderModPlugFactory : 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);
diff --git a/src/plugins/Input/mpc/decoder_mpc.cpp b/src/plugins/Input/mpc/decoder_mpc.cpp
index a7da95652..9b3679dd3 100644
--- a/src/plugins/Input/mpc/decoder_mpc.cpp
+++ b/src/plugins/Input/mpc/decoder_mpc.cpp
@@ -102,13 +102,12 @@ DecoderMPC::DecoderMPC(QObject *parent, DecoderFactory *d, QIODevice *i, Output
{
inited = FALSE;
user_stop = FALSE;
- stat = 0;
output_buf = 0;
output_bytes = 0;
output_at = 0;
bks = 0;
done = FALSE;
- finish = FALSE;
+ m_finish = FALSE;
len = 0;
freq = 0;
bitrate = 0;
@@ -127,7 +126,7 @@ DecoderMPC::DecoderMPC(QObject *parent, DecoderFactory *d, QIODevice *i, Output
DecoderMPC::~DecoderMPC()
{
deinit();
- if(data())
+ if (data())
{
delete data();
m_data = 0;
@@ -148,11 +147,11 @@ void DecoderMPC::flush(bool final)
{
ulong min = final ? 0 : bks;
- while ((! done && ! finish) && output_bytes > min)
+ while ((! done && ! m_finish) && output_bytes > min)
{
output()->recycler()->mutex()->lock ();
- while ((! done && ! finish) && output()->recycler()->full())
+ while ((! done && ! m_finish) && output()->recycler()->full())
{
mutex()->unlock();
@@ -162,7 +161,7 @@ void DecoderMPC::flush(bool final)
done = user_stop;
}
- if (user_stop || finish)
+ if (user_stop || m_finish)
{
inited = FALSE;
done = TRUE;
@@ -186,19 +185,18 @@ void DecoderMPC::flush(bool final)
bool DecoderMPC::initialize()
{
- bks = blockSize();
- inited = user_stop = done = finish = FALSE;
+ bks = Buffer::size();
+ inited = user_stop = done = m_finish = FALSE;
len = freq = bitrate = 0;
- stat = chan = 0;
+ chan = 0;
output_size = 0;
seekTime = -1.0;
totalTime = 0.0;
- if (! input())
+ if (!input())
{
- error("DecoderMPC: cannot initialize. No input.");
-
+ qWarning("DecoderMPC: cannot initialize. No input.");
return FALSE;
}
@@ -207,23 +205,11 @@ bool DecoderMPC::initialize()
output_at = 0;
output_bytes = 0;
- if (! input())
+ if (!input()->isOpen())
{
- error("DecoderMPC: cannot initialize. No input.");
-
- return FALSE;
- }
-
- if (! output_buf)
- output_buf = new char[globalBufferSize];
- output_at = 0;
- output_bytes = 0;
-
- if (! input()->isOpen())
- {
- if (! input()->open(QIODevice::ReadOnly))
+ if (!input()->open(QIODevice::ReadOnly))
{
- error("DecoderMPC: cannot open input.");
+ qWarning("DecoderMPC: unable to open input.");
return FALSE;
}
}
@@ -245,7 +231,7 @@ bool DecoderMPC::initialize()
if (mpc_streaminfo_read (&m_data->info, &m_data->reader) != ERROR_CODE_OK)
return FALSE;
chan = data()->info.channels;
- configure(data()->info.sample_freq, chan, 16, data()->info.bitrate);
+ configure(data()->info.sample_freq, chan, 16);
mpc_decoder_setup (&data()->decoder, &data()->reader);
@@ -253,7 +239,7 @@ bool DecoderMPC::initialize()
if (!mpc_decoder_initialize (&data()->decoder, &data()->info))
{
- error("DecoderMPC: cannot get info.");
+ qWarning("DecoderMPC: cannot get info.");
return FALSE;
}
totalTime = mpc_streaminfo_get_length(&data()->info);
@@ -263,7 +249,7 @@ bool DecoderMPC::initialize()
}
-double DecoderMPC::lengthInSeconds()
+qint64 DecoderMPC::lengthInSeconds()
{
if (! inited)
return 0;
@@ -272,7 +258,7 @@ double DecoderMPC::lengthInSeconds()
}
-void DecoderMPC::seek(double pos)
+void DecoderMPC::seek(qint64 pos)
{
seekTime = pos;
}
@@ -280,10 +266,9 @@ void DecoderMPC::seek(double pos)
void DecoderMPC::deinit()
{
- //FLAC__stream_decoder_finish (data()->decoder);
- inited = user_stop = done = finish = FALSE;
+ inited = user_stop = done = m_finish = FALSE;
len = freq = bitrate = 0;
- stat = chan = 0;
+ chan = 0;
output_size = 0;
}
@@ -291,21 +276,16 @@ void DecoderMPC::run()
{
mpc_uint32_t vbrAcc = 0;
mpc_uint32_t vbrUpd = 0;
- mutex()->lock ();
- if (! inited)
+ mutex()->lock ();
+ if (!inited)
{
mutex()->unlock();
-
return;
}
- stat = DecoderState::Decoding;
mutex()->unlock();
- {
- dispatch(DecoderState ((DecoderState::Type) stat));
- }
- while (! done && ! finish)
+ while (! done && ! m_finish)
{
mutex()->lock ();
// decode
@@ -354,33 +334,23 @@ void DecoderMPC::run()
done = TRUE;
if (! user_stop)
{
- finish = TRUE;
+ m_finish = TRUE;
}
}
else
{
// error in read
- error("DecoderMPC: Error while decoding stream, File appears to be "
- "corrupted");
-
- finish = TRUE;
+ qWarning("DecoderMPC: Error while decoding stream, file appears to be corrupted");
+ m_finish = TRUE;
}
mutex()->unlock();
}
-
mutex()->lock ();
- if (finish)
- stat = DecoderState::Finished;
- else if (user_stop)
- stat = DecoderState::Stopped;
+ if (m_finish)
+ finish();
mutex()->unlock();
-
- {
- dispatch(DecoderState ((DecoderState::Type) stat));
- }
-
deinit();
}
diff --git a/src/plugins/Input/mpc/decoder_mpc.h b/src/plugins/Input/mpc/decoder_mpc.h
index 9378d727e..733fcd8ca 100644
--- a/src/plugins/Input/mpc/decoder_mpc.h
+++ b/src/plugins/Input/mpc/decoder_mpc.h
@@ -40,17 +40,14 @@ public:
// Standard Decoder API
bool initialize();
- double lengthInSeconds();
- void seek(double);
+ qint64 lengthInSeconds();
+ void seek(qint64);
void stop();
- // Equalizer
- bool isEQSupported() const { return FALSE; }
- void setEQEnabled(bool) { ; }
- void setEQGain(int) { ; }
- void setEQBands(int[10]) { ; }
-
- struct mpc_data *data() { return m_data; }
+ struct mpc_data *data()
+ {
+ return m_data;
+ }
private:
@@ -62,18 +59,17 @@ private:
void deinit();
bool inited, user_stop;
- int stat;
// output buffer
char *output_buf;
ulong output_bytes, output_at;
unsigned int bks;
- bool done, finish;
+ bool done, m_finish;
long len, freq, bitrate;
int chan;
unsigned long output_size;
- double totalTime, seekTime;
+ qint64 totalTime, seekTime;
};
diff --git a/src/plugins/Input/mpc/decodermpcfactory.cpp b/src/plugins/Input/mpc/decodermpcfactory.cpp
index e0caab970..9b6368efe 100644
--- a/src/plugins/Input/mpc/decodermpcfactory.cpp
+++ b/src/plugins/Input/mpc/decodermpcfactory.cpp
@@ -53,38 +53,38 @@ const DecoderProperties DecoderMPCFactory::properties() const
}
Decoder *DecoderMPCFactory::create(QObject *parent, QIODevice *input,
- Output *output)
+ Output *output, const QString &)
{
return new DecoderMPC(parent, this, input, output);
}
-FileTag *DecoderMPCFactory::createTag(const QString &source)
+QList<FileInfo *> DecoderMPCFactory::createPlayList(const QString &fileName)
{
- FileTag *ftag = new FileTag();
+ FileInfo *info = new FileInfo(fileName);
- TagLib::FileRef fileRef(source.toLocal8Bit ());
+ TagLib::FileRef fileRef(fileName.toLocal8Bit ());
TagLib::Tag *tag = fileRef.tag();
-
if (tag && !tag->isEmpty())
{
- ftag->setValue(FileTag::ALBUM,
+ info->setMetaData(Qmmp::ALBUM,
QString::fromUtf8(tag->album().toCString(TRUE)).trimmed());
- ftag->setValue(FileTag::ARTIST,
+ info->setMetaData(Qmmp::ARTIST,
QString::fromUtf8(tag->artist().toCString(TRUE)).trimmed());
- ftag->setValue(FileTag::COMMENT,
+ info->setMetaData(Qmmp::COMMENT,
QString::fromUtf8(tag->comment().toCString(TRUE)).trimmed());
- ftag->setValue(FileTag::GENRE,
+ info->setMetaData(Qmmp::GENRE,
QString::fromUtf8(tag->genre().toCString(TRUE)).trimmed());
- ftag->setValue(FileTag::TITLE,
+ info->setMetaData(Qmmp::TITLE,
QString::fromUtf8(tag->title().toCString(TRUE)).trimmed());
- ftag->setValue(FileTag::YEAR, tag->year());
- ftag->setValue(FileTag::TRACK, tag->track());
+ info->setMetaData(Qmmp::YEAR, tag->year());
+ info->setMetaData(Qmmp::TRACK, tag->track());
}
-
if (fileRef.audioProperties())
- ftag->setValue(FileTag::LENGTH, fileRef.audioProperties()->length());
+ info->setLength(fileRef.audioProperties()->length());
- return ftag;
+ QList <FileInfo*> list;
+ list << info;
+ return list;
}
QObject* DecoderMPCFactory::showDetails(QWidget *parent, const QString &path)
diff --git a/src/plugins/Input/mpc/decodermpcfactory.h b/src/plugins/Input/mpc/decodermpcfactory.h
index 7ee6fb3c1..740a5f362 100644
--- a/src/plugins/Input/mpc/decodermpcfactory.h
+++ b/src/plugins/Input/mpc/decodermpcfactory.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>
@@ -43,8 +43,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);
diff --git a/src/plugins/Input/sndfile/decoder_sndfile.cpp b/src/plugins/Input/sndfile/decoder_sndfile.cpp
index dc7516854..4568a2fd9 100644
--- a/src/plugins/Input/sndfile/decoder_sndfile.cpp
+++ b/src/plugins/Input/sndfile/decoder_sndfile.cpp
@@ -31,9 +31,10 @@
// Decoder class
-DecoderSndFile::DecoderSndFile(QObject *parent, DecoderFactory *d, QIODevice *i, Output *o)
- : Decoder(parent, d, i, o)
+DecoderSndFile::DecoderSndFile(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;
@@ -107,7 +108,7 @@ void DecoderSndFile::flush(bool final)
bool DecoderSndFile::initialize()
{
- bks = blockSize();
+ bks = Buffer::size();
m_inited = m_user_stop = m_done = m_finish = FALSE;
m_freq = m_bitrate = 0;
m_output_size = 0;
@@ -115,28 +116,17 @@ bool DecoderSndFile::initialize()
m_totalTime = 0.0;
SF_INFO snd_info;
-
- if (! input())
- {
- error("DecoderSndFile: cannot initialize. No input.");
-
- return FALSE;
- }
-
- if (! m_output_buf)
+ 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();
-
memset (&snd_info, 0, sizeof(snd_info));
snd_info.format=0;
- m_sndfile = sf_open(filename.toLocal8Bit(), SFM_READ, &snd_info);
+ m_sndfile = sf_open(m_path.toLocal8Bit(), SFM_READ, &snd_info);
if (!m_sndfile)
{
- qWarning("DecoderSndFile: failed to open: %s", qPrintable(filename));
+ qWarning("DecoderSndFile: failed to open: %s", qPrintable(m_path));
return FALSE;
}
@@ -145,10 +135,10 @@ bool DecoderSndFile::initialize()
m_totalTime = (double) snd_info.frames / m_freq;
- m_bitrate = QFileInfo(filename).size () * 8.0 / m_totalTime / 1000.0 + 0.5;
+ m_bitrate = QFileInfo(m_path).size () * 8.0 / m_totalTime / 1000.0 + 0.5;
- configure(m_freq, m_chan, 16, m_bitrate);
- m_buf = new short[blockSize() / sizeof(short)];
+ configure(m_freq, m_chan, 16);
+ m_buf = new short[bks / sizeof(short)];
m_inited = TRUE;
qDebug("DecoderSndFile: detected format: %08X", snd_info.format);
qDebug("DecoderSndFile: initialize succes");
@@ -156,7 +146,7 @@ bool DecoderSndFile::initialize()
}
-double DecoderSndFile::lengthInSeconds()
+qint64 DecoderSndFile::lengthInSeconds()
{
if (! m_inited)
return 0;
@@ -165,7 +155,7 @@ double DecoderSndFile::lengthInSeconds()
}
-void DecoderSndFile::seek(double pos)
+void DecoderSndFile::seek(qint64 pos)
{
m_seekTime = pos;
}
@@ -178,10 +168,10 @@ void DecoderSndFile::deinit()
m_output_size = 0;
if (m_inited)
{
- delete m_buf;
- m_buf = 0;
- sf_close(m_sndfile);
- m_sndfile = 0;
+ delete m_buf;
+ m_buf = 0;
+ sf_close(m_sndfile);
+ m_sndfile = 0;
}
}
@@ -189,36 +179,28 @@ void DecoderSndFile::run()
{
long len = 0;
- int stat = 0;
mutex()->lock ();
- if (! m_inited)
+ if (!m_inited)
{
mutex()->unlock();
-
return;
}
-
- stat = DecoderState::Decoding;
mutex()->unlock();
- {
- dispatch(DecoderState ((DecoderState::Type) stat));
- }
-
- while (! m_done && ! m_finish)
+ while (!m_done && !m_finish)
{
mutex()->lock ();
// decode
- if (m_seekTime >= 0.0)
+ if (m_seekTime >= 0)
{
m_output_size = sf_seek(m_sndfile, m_freq*m_seekTime, SEEK_SET);
m_seekTime = -1.0;
}
- len = sizeof(short)* sf_read_short (m_sndfile, m_buf, blockSize() / sizeof(short));
+ len = sizeof(short)* sf_read_short (m_sndfile, m_buf, bks / sizeof(short));
if (len > 0)
{
@@ -256,25 +238,16 @@ void DecoderSndFile::run()
else
{
// error in read
- error("DecoderSndFile: Error while decoding stream, File appears to be "
- "corrupted");
-
+ qWarning("DecoderSndFile: Error while decoding stream, File appears to be corrupted");
m_finish = TRUE;
}
-
mutex()->unlock();
}
mutex()->lock ();
-
if (m_finish)
- stat = DecoderState::Finished;
- else if (m_user_stop)
- stat = DecoderState::Stopped;
-
+ finish();
mutex()->unlock();
- dispatch(DecoderState ((DecoderState::Type) stat));
deinit();
}
-
diff --git a/src/plugins/Input/sndfile/decoder_sndfile.h b/src/plugins/Input/sndfile/decoder_sndfile.h
index 9a66acd3d..e221065f2 100644
--- a/src/plugins/Input/sndfile/decoder_sndfile.h
+++ b/src/plugins/Input/sndfile/decoder_sndfile.h
@@ -30,13 +30,13 @@ extern "C"{
class DecoderSndFile : public Decoder
{
public:
- DecoderSndFile(QObject *, DecoderFactory *, QIODevice *, Output *);
+ DecoderSndFile(QObject *, DecoderFactory *, Output *, const QString &);
virtual ~DecoderSndFile();
// Standard Decoder API
bool initialize();
- double lengthInSeconds();
- void seek(double);
+ qint64 lengthInSeconds();
+ void seek(qint64);
void stop();
@@ -58,8 +58,9 @@ private:
bool m_done, m_finish, m_inited, m_user_stop;
long m_freq, m_bitrate;
int m_chan;
- unsigned long m_output_size;
- double m_totalTime, m_seekTime;
+ qint64 m_output_size;
+ qint64 m_totalTime, m_seekTime;
+ QString m_path;
};
diff --git a/src/plugins/Input/sndfile/decodersndfilefactory.cpp b/src/plugins/Input/sndfile/decodersndfilefactory.cpp
index 30178aabe..1828b8292 100644
--- a/src/plugins/Input/sndfile/decodersndfilefactory.cpp
+++ b/src/plugins/Input/sndfile/decodersndfilefactory.cpp
@@ -68,46 +68,50 @@ const DecoderProperties DecoderSndFileFactory::properties() const
//properties.contentType = "";
properties.hasAbout = TRUE;
properties.hasSettings = FALSE;
+ properties.noInput = TRUE;
+ properties.protocols = "file";
return properties;
}
Decoder *DecoderSndFileFactory::create(QObject *parent, QIODevice *input,
- Output *output)
+ Output *output, const QString &path)
{
- return new DecoderSndFile(parent, this, input, output);
+ Q_UNUSED(input);
+ return new DecoderSndFile(parent, this, output, path);
}
-FileTag *DecoderSndFileFactory::createTag(const QString &source)
+QList<FileInfo *> DecoderSndFileFactory::createPlayList(const QString &fileName)
{
- FileTag *ftag = new FileTag();
+ QList <FileInfo *> list;
SF_INFO snd_info;
SNDFILE *sndfile = 0;
memset (&snd_info, 0, sizeof(snd_info));
snd_info.format = 0;
- sndfile = sf_open(source.toLocal8Bit(), SFM_READ, &snd_info);
+ sndfile = sf_open(fileName.toLocal8Bit(), SFM_READ, &snd_info);
if (!sndfile)
- return ftag;
+ return list;
+ list << new FileInfo(fileName);
if (sf_get_string(sndfile, SF_STR_TITLE))
{
char* title = strdup(sf_get_string(sndfile, SF_STR_TITLE));
- ftag->setValue(FileTag::TITLE, QString::fromUtf8(title).trimmed());
+ list.at(0)->setMetaData(Qmmp::TITLE, QString::fromUtf8(title).trimmed());
}
if (sf_get_string(sndfile, SF_STR_ARTIST))
{
char* artist = strdup(sf_get_string(sndfile, SF_STR_ARTIST));
- ftag->setValue(FileTag::ARTIST, QString::fromUtf8(artist).trimmed());
+ list.at(0)->setMetaData(Qmmp::ARTIST, QString::fromUtf8(artist).trimmed());
}
if (sf_get_string(sndfile, SF_STR_COMMENT))
{
char* comment = strdup(sf_get_string(sndfile, SF_STR_COMMENT));
- ftag->setValue(FileTag::COMMENT, QString::fromUtf8(comment).trimmed());
+ list.at(0)->setMetaData(Qmmp::COMMENT, QString::fromUtf8(comment).trimmed());
}
- ftag->setValue(FileTag::LENGTH ,int(snd_info.frames / snd_info.samplerate));
+ list.at(0)->setLength(int(snd_info.frames / snd_info.samplerate));
sf_close(sndfile);
- return ftag;
+ return list;
}
QObject* DecoderSndFileFactory::showDetails(QWidget *parent, const QString &path)
diff --git a/src/plugins/Input/sndfile/decodersndfilefactory.h b/src/plugins/Input/sndfile/decodersndfilefactory.h
index ca1753cac..aab996d98 100644
--- a/src/plugins/Input/sndfile/decodersndfilefactory.h
+++ b/src/plugins/Input/sndfile/decodersndfilefactory.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>
@@ -43,8 +43,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 &path);
+ QList<FileInfo *> createPlayList(const QString &fileName);
QObject* showDetails(QWidget *parent, const QString &path);
void showSettings(QWidget *parent);
void showAbout(QWidget *parent);
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);
diff --git a/src/qmmp/decoder.cpp b/src/qmmp/decoder.cpp
index 63cd96c82..7c33cc112 100644
--- a/src/qmmp/decoder.cpp
+++ b/src/qmmp/decoder.cpp
@@ -32,14 +32,14 @@ Decoder::Decoder(QObject *parent, DecoderFactory *d, QIODevice *i, Output *o)
: QThread(parent), m_factory(d), m_input(i), m_output(o),m_eqInited(FALSE),
m_useEQ(FALSE)
{
- if (m_output)
- m_output->recycler()->clear();
- int b[] = {0,0,0,0,0,0,0,0,0,0};
- setEQ(b, 0);
- qRegisterMetaType<Qmmp::State>("Qmmp::State");
- blksize = Buffer::size();
- m_effects = Effect::create(this);
- m_handler = 0;
+ init();
+}
+
+Decoder::Decoder(QObject *parent, DecoderFactory *d, Output *o)
+ : QThread(parent), m_factory(d), m_input(0), m_output(o),m_eqInited(FALSE),
+ m_useEQ(FALSE)
+{
+ init();
}
Decoder::~Decoder()
@@ -50,6 +50,18 @@ Decoder::~Decoder()
blksize = 0;
}
+void Decoder::init()
+{
+ if (m_output)
+ m_output->recycler()->clear();
+ int b[] = {0,0,0,0,0,0,0,0,0,0};
+ setEQ(b, 0);
+ qRegisterMetaType<Qmmp::State>("Qmmp::State");
+ blksize = Buffer::size();
+ m_effects = Effect::create(this);
+ m_handler = 0;
+}
+
DecoderFactory *Decoder::factory() const
{
return m_factory;
@@ -362,8 +374,6 @@ DecoderFactory *Decoder::findByContent(QIODevice *input)
DecoderFactory *Decoder::findByURL(const QUrl &url)
{
- qDebug("url.scheme() %s", qPrintable(url.scheme()));
- qDebug("url.path() = %s", qPrintable(url.path()));
checkFactories();
foreach(DecoderFactory *fact, *m_factories)
{
diff --git a/src/qmmp/decoder.h b/src/qmmp/decoder.h
index 5691fe63b..027d4f1d4 100644
--- a/src/qmmp/decoder.h
+++ b/src/qmmp/decoder.h
@@ -36,6 +36,7 @@ class Decoder : public QThread
Q_OBJECT
public:
Decoder(QObject *parent, DecoderFactory *d, QIODevice *input = 0, Output *output = 0);
+ Decoder(QObject *parent, DecoderFactory *d, Output *output);
virtual ~Decoder();
@@ -85,6 +86,7 @@ protected slots:
void finish();
private:
+ void init();
void changeVolume(char *data, qint64 size, int chan);
static void checkFactories();