aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/Input/CMakeLists.txt2
-rw-r--r--src/plugins/Input/Input.pro2
-rw-r--r--src/plugins/Input/flac/decoder_flac.cpp92
-rw-r--r--src/plugins/Input/flac/decoder_flac.h26
-rw-r--r--src/plugins/Input/flac/decoderflacfactory.cpp39
-rw-r--r--src/plugins/Input/flac/decoderflacfactory.h10
6 files changed, 64 insertions, 107 deletions
diff --git a/src/plugins/Input/CMakeLists.txt b/src/plugins/Input/CMakeLists.txt
index 3222be482..977aaf93f 100644
--- a/src/plugins/Input/CMakeLists.txt
+++ b/src/plugins/Input/CMakeLists.txt
@@ -18,7 +18,7 @@ add_subdirectory(mad)
ENDIF(USE_MAD AND TAGLIB_FOUND)
IF(USE_FLAC AND TAGLIB_FOUND)
-#add_subdirectory(flac)
+add_subdirectory(flac)
ENDIF(USE_FLAC AND TAGLIB_FOUND)
IF(USE_VORBIS AND TAGLIB_FOUND)
diff --git a/src/plugins/Input/Input.pro b/src/plugins/Input/Input.pro
index e40e324cd..129253a84 100644
--- a/src/plugins/Input/Input.pro
+++ b/src/plugins/Input/Input.pro
@@ -18,7 +18,7 @@ contains(CONFIG, MUSEPACK_PLUGIN){
}
contains(CONFIG, FLAC_PLUGIN){
-# SUBDIRS += flac
+ SUBDIRS += flac
message(***********************)
message(* FLAC plugin enabled *)
message(***********************)
diff --git a/src/plugins/Input/flac/decoder_flac.cpp b/src/plugins/Input/flac/decoder_flac.cpp
index 28503959c..3f2935d6e 100644
--- a/src/plugins/Input/flac/decoder_flac.cpp
+++ b/src/plugins/Input/flac/decoder_flac.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 *
@@ -139,9 +139,9 @@ static int flac_decode (void *void_data, char *buf, int buf_len)
static FLAC__StreamDecoderReadStatus flac_callback_read (const FLAC__StreamDecoder*,
- FLAC__byte buffer[],
- size_t *bytes,
- void *client_data)
+ FLAC__byte buffer[],
+ size_t *bytes,
+ void *client_data)
{
DecoderFLAC *dflac = (DecoderFLAC *) client_data;
qint64 res;
@@ -164,9 +164,9 @@ static FLAC__StreamDecoderReadStatus flac_callback_read (const FLAC__StreamDecod
}
static FLAC__StreamDecoderWriteStatus flac_callback_write (const FLAC__StreamDecoder *,
- const FLAC__Frame *frame,
- const FLAC__int32* const buffer[],
- void *client_data)
+ const FLAC__Frame *frame,
+ const FLAC__int32* const buffer[],
+ void *client_data)
{
DecoderFLAC *dflac = (DecoderFLAC *) client_data;
const unsigned wide_samples = frame->header.blocksize;
@@ -185,8 +185,8 @@ static FLAC__StreamDecoderWriteStatus flac_callback_write (const FLAC__StreamDec
}
static FLAC__StreamDecoderTellStatus flac_callback_tell (const FLAC__StreamDecoder *,
- FLAC__uint64 *offset,
- void *client_data)
+ FLAC__uint64 *offset,
+ void *client_data)
{
DecoderFLAC *dflac = (DecoderFLAC *) client_data;
*offset = dflac->input()->pos ();
@@ -194,8 +194,8 @@ static FLAC__StreamDecoderTellStatus flac_callback_tell (const FLAC__StreamDecod
}
static FLAC__StreamDecoderSeekStatus flac_callback_seek (const FLAC__StreamDecoder *,
- FLAC__uint64 offset,
- void *client_data)
+ FLAC__uint64 offset,
+ void *client_data)
{
DecoderFLAC *dflac = (DecoderFLAC *) client_data;
@@ -205,8 +205,8 @@ static FLAC__StreamDecoderSeekStatus flac_callback_seek (const FLAC__StreamDecod
}
static FLAC__StreamDecoderLengthStatus flac_callback_length (const FLAC__StreamDecoder *,
- FLAC__uint64 *stream_length,
- void *client_data)
+ FLAC__uint64 *stream_length,
+ void *client_data)
{
DecoderFLAC *dflac = (DecoderFLAC *) client_data;
*stream_length = dflac->input()->size();
@@ -259,7 +259,7 @@ DecoderFLAC::DecoderFLAC(QObject *parent, DecoderFactory *d, QIODevice *i, Outpu
output_at = 0;
bks = 0;
done = FALSE;
- finish = FALSE;
+ m_finish = FALSE;
len = 0;
freq = 0;
bitrate = 0;
@@ -299,11 +299,11 @@ void DecoderFLAC::flush(bool final)
//qDebug("DecoderFLAC: flush()");
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();
@@ -313,7 +313,7 @@ void DecoderFLAC::flush(bool final)
done = user_stop;
}
- if (user_stop || finish)
+ if (user_stop || m_finish)
{
inited = FALSE;
done = TRUE;
@@ -337,8 +337,8 @@ void DecoderFLAC::flush(bool final)
bool DecoderFLAC::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;
output_size = 0;
@@ -348,8 +348,7 @@ bool DecoderFLAC::initialize()
if (! input())
{
- error("DecoderFLAC: cannot initialize. No input.");
-
+ qWarning("DecoderFLAC: cannot initialize. No input.");
return FALSE;
}
@@ -358,23 +357,15 @@ bool DecoderFLAC::initialize()
output_at = 0;
output_bytes = 0;
- if (! input()->isOpen())
+ if (!input()->isOpen())
{
- if (! input()->open(QIODevice::ReadOnly))
+ if (!input()->open(QIODevice::ReadOnly))
{
-
return FALSE;
}
}
- if (! input())
- {
- error("DecoderFLAC: cannot initialize. No input.");
-
- return FALSE;
- }
-
if (! output_buf)
output_buf = new char[globalBufferSize];
output_at = 0;
@@ -427,9 +418,9 @@ bool DecoderFLAC::initialize()
}
chan = data()->channels;
if (data()->bits_per_sample == 24)
- configure(data()->sample_rate, data()->channels, 32, bitrate);
+ configure(data()->sample_rate, data()->channels, 32);
else
- configure(data()->sample_rate, data()->channels, data()->bits_per_sample, bitrate);
+ configure(data()->sample_rate, data()->channels, data()->bits_per_sample);
totalTime = data()->length;
inited = TRUE;
@@ -438,7 +429,7 @@ bool DecoderFLAC::initialize()
}
-double DecoderFLAC::lengthInSeconds()
+qint64 DecoderFLAC::lengthInSeconds()
{
if (! inited)
return 0;
@@ -447,7 +438,7 @@ double DecoderFLAC::lengthInSeconds()
}
-void DecoderFLAC::seek(double pos)
+void DecoderFLAC::seek(qint64 pos)
{
seekTime = pos;
}
@@ -457,7 +448,7 @@ void DecoderFLAC::deinit()
{
if (data())
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;
output_size = 0;
@@ -467,19 +458,14 @@ void DecoderFLAC::run()
{
mutex()->lock ();
- if (! inited)
+ 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
@@ -528,16 +514,15 @@ void DecoderFLAC::run()
done = TRUE;
if (! user_stop)
{
- finish = TRUE;
+ m_finish = TRUE;
}
}
else
{
// error in read
- error("DecoderFLAC: Error while decoding stream, File appears to be "
- "corrupted");
-
- finish = TRUE;
+ qWarning("DecoderFLAC: Error while decoding stream, File appears to be "
+ "corrupted");
+ m_finish = TRUE;
}
mutex()->unlock();
@@ -545,16 +530,9 @@ void DecoderFLAC::run()
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/flac/decoder_flac.h b/src/plugins/Input/flac/decoder_flac.h
index 277348349..8431a4555 100644
--- a/src/plugins/Input/flac/decoder_flac.h
+++ b/src/plugins/Input/flac/decoder_flac.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 *
@@ -63,28 +63,10 @@ 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 flac_data *data()
{
return m_data;
@@ -111,7 +93,7 @@ private:
FLAC__StreamDecoder *m_flacDecoder;
unsigned int bks;
- bool done, finish;
+ bool done, m_finish;
long len, freq, bitrate;
int chan;
unsigned long output_size;
diff --git a/src/plugins/Input/flac/decoderflacfactory.cpp b/src/plugins/Input/flac/decoderflacfactory.cpp
index e59cb61cc..1843ccac0 100644
--- a/src/plugins/Input/flac/decoderflacfactory.cpp
+++ b/src/plugins/Input/flac/decoderflacfactory.cpp
@@ -54,38 +54,39 @@ const DecoderProperties DecoderFLACFactory::properties() const
}
Decoder *DecoderFLACFactory::create(QObject *parent, QIODevice *input,
- Output *output)
+ Output *output, const QString &)
{
return new DecoderFLAC(parent, this, input, output);
}
-FileTag *DecoderFLACFactory::createTag(const QString &source)
+QList<FileInfo *> DecoderFLACFactory::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,
- QString::fromUtf8(tag->album().toCString(TRUE)).trimmed());
- ftag->setValue(FileTag::ARTIST,
- QString::fromUtf8(tag->artist().toCString(TRUE)).trimmed());
- ftag->setValue(FileTag::COMMENT,
- QString::fromUtf8(tag->comment().toCString(TRUE)).trimmed());
- ftag->setValue(FileTag::GENRE,
- QString::fromUtf8(tag->genre().toCString(TRUE)).trimmed());
- ftag->setValue(FileTag::TITLE,
- QString::fromUtf8(tag->title().toCString(TRUE)).trimmed());
- ftag->setValue(FileTag::YEAR, tag->year());
- ftag->setValue(FileTag::TRACK, tag->track());
+ info->setMetaData(Qmmp::ALBUM,
+ QString::fromUtf8(tag->album().toCString(TRUE)).trimmed());
+ info->setMetaData(Qmmp::ARTIST,
+ QString::fromUtf8(tag->artist().toCString(TRUE)).trimmed());
+ info->setMetaData(Qmmp::COMMENT,
+ QString::fromUtf8(tag->comment().toCString(TRUE)).trimmed());
+ info->setMetaData(Qmmp::GENRE,
+ QString::fromUtf8(tag->genre().toCString(TRUE)).trimmed());
+ info->setMetaData(Qmmp::TITLE,
+ QString::fromUtf8(tag->title().toCString(TRUE)).trimmed());
+ info->setMetaData(Qmmp::YEAR, tag->year());
+ info->setMetaData(Qmmp::TRACK, tag->track());
}
if (fileRef.audioProperties())
- ftag->setValue(FileTag::LENGTH, fileRef.audioProperties()->length());
-
- return ftag;
+ info->setLength(fileRef.audioProperties()->length());
+ QList <FileInfo*> list;
+ list << info;
+ return list;
}
QObject* DecoderFLACFactory::showDetails(QWidget *parent, const QString &path)
diff --git a/src/plugins/Input/flac/decoderflacfactory.h b/src/plugins/Input/flac/decoderflacfactory.h
index 3e4beb5a8..983355d23 100644
--- a/src/plugins/Input/flac/decoderflacfactory.h
+++ b/src/plugins/Input/flac/decoderflacfactory.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,10 +28,6 @@
#include <qmmp/decoder.h>
#include <qmmp/output.h>
#include <qmmp/decoderfactory.h>
-#include <qmmp/filetag.h>
-
-
-
class DecoderFLACFactory : public QObject,
DecoderFactory
@@ -43,8 +39,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);