aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Input
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2008-03-06 14:13:41 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2008-03-06 14:13:41 +0000
commit892d61b4dc43869940959a82197d865390c04509 (patch)
treeaea57b6a989e172de3bd5822b44dfe82e7e22376 /src/plugins/Input
parentdb6aae42c16c42785d5e0a6c04d8159dade97cee (diff)
downloadqmmp-892d61b4dc43869940959a82197d865390c04509.tar.gz
qmmp-892d61b4dc43869940959a82197d865390c04509.tar.bz2
qmmp-892d61b4dc43869940959a82197d865390c04509.zip
added wavpack plugin
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@263 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Input')
-rw-r--r--src/plugins/Input/CMakeLists.txt8
-rw-r--r--src/plugins/Input/Input.pro2
-rw-r--r--src/plugins/Input/wavpack/CMakeLists.txt80
-rw-r--r--src/plugins/Input/wavpack/decoder_wavpack.cpp287
-rw-r--r--src/plugins/Input/wavpack/decoder_wavpack.h67
-rw-r--r--src/plugins/Input/wavpack/decoderwavpackfactory.cpp104
-rw-r--r--src/plugins/Input/wavpack/decoderwavpackfactory.h52
-rw-r--r--src/plugins/Input/wavpack/detailsdialog.cpp142
-rw-r--r--src/plugins/Input/wavpack/detailsdialog.h49
-rw-r--r--src/plugins/Input/wavpack/detailsdialog.ui382
-rw-r--r--src/plugins/Input/wavpack/wavpack.pro32
11 files changed, 1204 insertions, 1 deletions
diff --git a/src/plugins/Input/CMakeLists.txt b/src/plugins/Input/CMakeLists.txt
index 8114bc092..ef6db0a97 100644
--- a/src/plugins/Input/CMakeLists.txt
+++ b/src/plugins/Input/CMakeLists.txt
@@ -5,6 +5,7 @@ SET(USE_VORBIS TRUE CACHE BOOL "enable/disable ogg vorbis plugin")
SET(USE_FFMPEG TRUE CACHE BOOL "enable/disable ffmpeg plugin")
SET(USE_MPC TRUE CACHE BOOL "enable/disable mpc plugin")
SET(USE_SNDFILE TRUE CACHE BOOL "enable/disable sndfile plugin")
+SET(USE_WAVPACK TRUE CACHE BOOL "enable/disable wavpack plugin")
IF(USE_MAD)
MESSAGE( STATUS "MAD ON")
@@ -47,3 +48,10 @@ add_subdirectory(sndfile)
ELSE(USE_SNDFILE)
MESSAGE( STATUS "SNDFILE OFF")
ENDIF(USE_SNDFILE)
+
+IF(USE_WAVPACK)
+MESSAGE( STATUS "WAVPACK ON")
+add_subdirectory(wavpack)
+ELSE(USE_WAVPACK)
+MESSAGE( STATUS "WAVPACK OFF")
+ENDIF(USE_WAVPACK)
diff --git a/src/plugins/Input/Input.pro b/src/plugins/Input/Input.pro
index e180229cc..18f378419 100644
--- a/src/plugins/Input/Input.pro
+++ b/src/plugins/Input/Input.pro
@@ -1,6 +1,6 @@
include(../../../qmmp.pri)
-SUBDIRS += mad vorbis sndfile
+SUBDIRS += mad vorbis sndfile wavpack
TEMPLATE = subdirs
contains(CONFIG, MUSEPACK_PLUGIN){
diff --git a/src/plugins/Input/wavpack/CMakeLists.txt b/src/plugins/Input/wavpack/CMakeLists.txt
new file mode 100644
index 000000000..06b191d56
--- /dev/null
+++ b/src/plugins/Input/wavpack/CMakeLists.txt
@@ -0,0 +1,80 @@
+project(libwavpack)
+
+cmake_minimum_required(VERSION 2.4.0)
+
+
+INCLUDE(UsePkgConfig)
+INCLUDE(FindQt4)
+
+find_package(Qt4 REQUIRED) # find and setup Qt4 for this project
+include(${QT_USE_FILE})
+
+# qt plugin
+ADD_DEFINITIONS( -Wall )
+ADD_DEFINITIONS(${QT_DEFINITIONS})
+ADD_DEFINITIONS(-DQT_PLUGIN)
+ADD_DEFINITIONS(-DQT_NO_DEBUG)
+ADD_DEFINITIONS(-DQT_SHARED)
+ADD_DEFINITIONS(-DQT_THREAD)
+
+include_directories(${CMAKE_CURRENT_BINARY_DIR})
+
+SET(QT_INCLUDES
+ ${QT_INCLUDES}
+ ${CMAKE_CURRENT_BINARY_DIR}/../../../
+)
+
+# libqmmp
+include_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../)
+link_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../qmmp)
+
+# wavpack
+PKGCONFIG(wavpack WAVPACK_INCLUDE_DIR WAVPACK_LINK_DIR WAVPACK_LINK_FLAGS WAVPACK_CFLAGS)
+
+IF(NOT WAVPACK_LINK_FLAGS)
+ SET(WAVPACK_LINK_FLAGS -lwavpack -lm)
+ SET(WAVPACK_INCLUDE_DIR /usr/include)
+ SET(WAVPACK_CFLAGS -I/usr/include)
+ SET(WAVPACK_LINK_DIR /usr/lib)
+ENDIF(NOT WAVPACK_LINK_FLAGS)
+
+ADD_DEFINITIONS(${WAVPACK_CFLAGS})
+include_directories(${CWAVPACK_INCLUDE_DIR})
+link_directories(${WAVPACK_LINK_DIR})
+
+SET(libwavpack_SRCS
+ decoder_wavpack.cpp
+ decoderwavpackfactory.cpp
+ detailsdialog.cpp
+)
+
+SET(libwavpack_MOC_HDRS
+ decoderwavpackfactory.h
+ decoder_wavpack.h
+ detailsdialog.h
+)
+
+#SET(libwavpack_RCCS translations/translations.qrc)
+
+#QT4_ADD_RESOURCES(libwavpack_RCC_SRCS ${libwavpack_RCCS})
+
+QT4_WRAP_CPP(libwavpack_MOC_SRCS ${libwavpack_MOC_HDRS})
+
+# user interface
+
+
+SET(libwavpack_UIS
+ detailsdialog.ui
+)
+
+QT4_WRAP_UI(libwavpack_UIS_H ${libwavpack_UIS})
+# Don't forget to include output directory, otherwise
+# the UI file won't be wrapped!
+include_directories(${CMAKE_CURRENT_BINARY_DIR})
+
+ADD_LIBRARY(wavpack SHARED ${libwavpack_SRCS} ${libwavpack_MOC_SRCS} ${libwavpack_UIS_H}
+ ${libwavpack_RCC_SRCS})
+target_link_libraries(wavpack ${QT_LIBRARIES} -lqmmp ${WAVPACK_LINK_FLAGS} ${WAVPACK_CLAGS})
+install(TARGETS wavpack DESTINATION ${LIB_DIR}/qmmp/Input)
+
+
diff --git a/src/plugins/Input/wavpack/decoder_wavpack.cpp b/src/plugins/Input/wavpack/decoder_wavpack.cpp
new file mode 100644
index 000000000..7cca9545c
--- /dev/null
+++ b/src/plugins/Input/wavpack/decoder_wavpack.cpp
@@ -0,0 +1,287 @@
+/***************************************************************************
+ * Copyright (C) 2008 by Ilya Kotov *
+ * forkotov02@hotmail.ru *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+
+#include <QObject>
+#include <QIODevice>
+#include <QFile>
+#include <math.h>
+
+#include <qmmp/constants.h>
+#include <qmmp/buffer.h>
+#include <qmmp/output.h>
+#include <qmmp/recycler.h>
+
+#include "decoder_wavpack.h"
+
+// Decoder class
+
+DecoderWavPack::DecoderWavPack(QObject *parent, DecoderFactory *d, QIODevice *i, Output *o)
+ : Decoder(parent, d, i, o)
+{
+ m_inited = FALSE;
+ m_user_stop = FALSE;
+ m_output_buf = 0;
+ m_output_bytes = 0;
+ m_output_at = 0;
+ m_bks = 0;
+ m_done = FALSE;
+ m_finish = FALSE;
+ m_freq = 0;
+ m_bitrate = 0;
+ m_seekTime = -1.0;
+ m_totalTime = 0.0;
+ m_chan = 0;
+ m_output_size = 0;
+ m_context = 0;
+}
+
+DecoderWavPack::~DecoderWavPack()
+{
+ deinit();
+ if (m_output_buf)
+ delete [] m_output_buf;
+ m_output_buf = 0;
+}
+
+void DecoderWavPack::stop()
+{
+ m_user_stop = TRUE;
+}
+
+void DecoderWavPack::flush(bool final)
+{
+ ulong min = final ? 0 : m_bks;
+
+ while ((! m_done && ! m_finish) && m_output_bytes > min)
+ {
+ output()->recycler()->mutex()->lock ();
+
+ while ((! m_done && ! m_finish) && output()->recycler()->full())
+ {
+ mutex()->unlock();
+
+ output()->recycler()->cond()->wait(output()->recycler()->mutex());
+
+ mutex()->lock ();
+ m_done = m_user_stop;
+ }
+
+ if (m_user_stop || m_finish)
+ {
+ m_inited = FALSE;
+ m_done = TRUE;
+ }
+ else
+ {
+ m_output_bytes -= produceSound(m_output_buf, m_output_bytes, m_bitrate, m_chan);
+ m_output_size += m_bks;
+ m_output_at = m_output_bytes;
+ }
+
+ if (output()->recycler()->full())
+ {
+ output()->recycler()->cond()->wakeOne();
+ }
+
+ output()->recycler()->mutex()->unlock();
+ }
+}
+
+bool DecoderWavPack::initialize()
+{
+ m_bks = blockSize();
+ m_inited = m_user_stop = m_done = m_finish = FALSE;
+ m_freq = m_bitrate = 0;
+ m_chan = 0;
+ m_output_size = 0;
+ 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;
+
+ 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,
+ OPEN_WVC | OPEN_TAGS, 0);
+ if(!m_context)
+ {
+ error(QString("DecoderWavPack: error: %1").arg(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));
+ m_totalTime = (int) WavpackGetNumSamples(m_context)/m_freq;
+ m_inited = TRUE;
+ qDebug("DecoderWavPack: initialize succes");
+ return TRUE;
+}
+
+double DecoderWavPack::lengthInSeconds()
+{
+ if (! m_inited)
+ return 0;
+
+ return m_totalTime;
+}
+
+
+void DecoderWavPack::seek(double pos)
+{
+ m_seekTime = pos;
+}
+
+void DecoderWavPack::deinit()
+{
+ m_inited = m_user_stop = m_done = m_finish = FALSE;
+ m_freq = m_bitrate = 0;
+ m_chan = 0;
+ m_output_size = 0;
+ if(m_context)
+ {
+ WavpackCloseFile (m_context);
+ m_context = 0;
+ }
+}
+
+void DecoderWavPack::run()
+{
+ mutex()->lock ();
+
+ ulong len = 0;
+ int32_t *in = new int32_t[globalBufferSize * m_chan / m_chan / 4];
+ int16_t *out = new int16_t[globalBufferSize * m_chan / m_chan / 4];
+ uint32_t samples = 0;
+
+ if (! m_inited)
+ {
+ mutex()->unlock();
+
+ return;
+ }
+ mutex()->unlock();
+ dispatch(DecoderState::Decoding);
+
+ while (! m_done && ! m_finish)
+ {
+ mutex()->lock ();
+
+ //seeking
+
+ if (m_seekTime >= 0.0)
+ {
+ WavpackSeekSample (m_context, m_seekTime * m_freq);
+ m_seekTime = -1.0;
+ }
+
+ // decode
+ samples = (globalBufferSize-m_output_at)/m_chan/4;
+
+ len = WavpackUnpackSamples (m_context, in, samples);
+ for(ulong i = 0; i < len * m_chan; ++i)
+ out[i] = in[i];
+
+ len *= (m_chan * 2); //convert to number of bytes
+ memcpy(m_output_buf + m_output_at, (char *) out, len);
+
+ if (len > 0)
+ {
+ m_bitrate =int( WavpackGetInstantBitrate(m_context)/1000);
+ m_output_at += len;
+ m_output_bytes += len;
+
+ if (output())
+ flush();
+
+ }
+ else if (len == 0)
+ {
+ flush(TRUE);
+
+ if (output())
+ {
+ output()->recycler()->mutex()->lock ();
+ // end of stream
+ while (! output()->recycler()->empty() && ! m_user_stop)
+ {
+ output()->recycler()->cond()->wakeOne();
+ mutex()->unlock();
+ output()->recycler()->cond()->wait(output()->recycler()->mutex());
+ mutex()->lock ();
+ }
+ output()->recycler()->mutex()->unlock();
+ }
+
+ m_done = TRUE;
+ if (! m_user_stop)
+ {
+ m_finish = TRUE;
+ }
+ }
+ else
+ {
+ // error in read
+ error("DecoderWavPack: Error while decoding stream, File appears to be "
+ "corrupted");
+ m_finish = TRUE;
+ }
+ mutex()->unlock();
+ }
+
+ mutex()->lock ();
+
+ delete[] in;
+ delete[] out;
+
+ if (m_finish)
+ dispatch(DecoderState::Finished);
+ else if (m_user_stop)
+ dispatch(DecoderState::Stopped);
+
+ mutex()->unlock();
+
+ deinit();
+}
diff --git a/src/plugins/Input/wavpack/decoder_wavpack.h b/src/plugins/Input/wavpack/decoder_wavpack.h
new file mode 100644
index 000000000..eb3402160
--- /dev/null
+++ b/src/plugins/Input/wavpack/decoder_wavpack.h
@@ -0,0 +1,67 @@
+/***************************************************************************
+ * Copyright (C) 2008 by Ilya Kotov *
+ * forkotov02@hotmail.ru *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#ifndef DECODER_WAVPACK_H
+#define DECODER_WAVPACK_H
+
+extern "C"{
+#include <wavpack/wavpack.h>
+}
+
+#include <qmmp/decoder.h>
+
+
+class DecoderWavPack : public Decoder
+{
+public:
+ DecoderWavPack(QObject *, DecoderFactory *, QIODevice *, Output *);
+ virtual ~DecoderWavPack();
+
+ // Standard Decoder API
+ bool initialize();
+ double lengthInSeconds();
+ void seek(double);
+ void stop();
+
+private:
+ // thread run function
+ void run();
+ WavpackContext *m_context;
+ // helper functions
+ void flush(bool = FALSE);
+ void deinit();
+
+ bool m_inited, m_user_stop;
+ int m_bps; //bits per sample
+
+ // output buffer
+ char *m_output_buf;
+ ulong 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;
+};
+
+
+#endif // DECODER_WAVPACK_H
diff --git a/src/plugins/Input/wavpack/decoderwavpackfactory.cpp b/src/plugins/Input/wavpack/decoderwavpackfactory.cpp
new file mode 100644
index 000000000..51b07f28c
--- /dev/null
+++ b/src/plugins/Input/wavpack/decoderwavpackfactory.cpp
@@ -0,0 +1,104 @@
+#include <QtGui>
+
+extern "C"{
+#include <wavpack/wavpack.h>
+}
+
+#include "detailsdialog.h"
+#include "decoder_wavpack.h"
+#include "decoderwavpackfactory.h"
+
+
+// DecoderWavPackFactory
+
+bool DecoderWavPackFactory::supports(const QString &source) const
+{
+
+ return (source.right(3).toLower() == ".wv");
+}
+
+bool DecoderWavPackFactory::canDecode(QIODevice *) const
+{
+ return FALSE;
+}
+
+const DecoderProperties DecoderWavPackFactory::properties() const
+{
+ DecoderProperties properties;
+ properties.name = tr("WavPack Plugin");
+ properties.filter = "*.wv";
+ properties.description = tr("WavPackk Files");
+ //properties.contentType = ;
+ properties.hasAbout = TRUE;
+ properties.hasSettings = FALSE;
+ return properties;
+}
+
+Decoder *DecoderWavPackFactory::create(QObject *parent, QIODevice *input,
+ Output *output)
+{
+ return new DecoderWavPack(parent, this, input, output);
+}
+
+FileTag *DecoderWavPackFactory::createTag(const QString &source)
+{
+ FileTag *ftag = new FileTag();
+
+ char err[80];
+ WavpackContext *ctx = WavpackOpenFileInput (source.toLocal8Bit(), err,
+ OPEN_WVC | OPEN_TAGS, 0);
+
+ if(!ctx)
+ {
+ qWarning("DecoderWavPackFactory: error: %s", err);
+ return ftag;
+ }
+
+ char value[200];
+ WavpackGetTagItem (ctx, "Album", value, sizeof(value));
+ ftag->setValue(FileTag::ALBUM, QString::fromUtf8(value));
+ WavpackGetTagItem (ctx, "Artist", value, sizeof(value));
+ ftag->setValue(FileTag::ARTIST, QString::fromUtf8(value));
+ WavpackGetTagItem (ctx, "Comment", value, sizeof(value));
+ ftag->setValue(FileTag::COMMENT, QString::fromUtf8(value));
+ WavpackGetTagItem (ctx, "Genre", value, sizeof(value));
+ ftag->setValue(FileTag::GENRE, QString::fromUtf8(value));
+ WavpackGetTagItem (ctx, "Title", value, sizeof(value));
+ ftag->setValue(FileTag::TITLE, QString::fromUtf8(value));
+ WavpackGetTagItem (ctx, "Year", value, sizeof(value));
+ ftag->setValue(FileTag::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));
+ WavpackCloseFile (ctx);
+ return ftag;
+}
+
+QObject* DecoderWavPackFactory::showDetails(QWidget *parent, const QString &path)
+{
+ DetailsDialog *d = new DetailsDialog(parent, path);
+ d -> show();
+ return d;
+}
+
+void DecoderWavPackFactory::showSettings(QWidget *)
+{}
+
+void DecoderWavPackFactory::showAbout(QWidget *parent)
+{
+ QMessageBox::about (parent, tr("About WavPack Audio Plugin"),
+ tr("Qmmp WavPack Audio Plugin")+"\n"+
+ tr("WavPack library version:") +
+ QString(" %1").arg(WavpackGetLibraryVersionString ())+"\n"+
+ tr("Writen by: Ilya Kotov <forkotov02@hotmail.ru>"));
+}
+
+QTranslator *DecoderWavPackFactory::createTranslator(QObject *parent)
+{
+ QTranslator *translator = new QTranslator(parent);
+ QString locale = QLocale::system().name();
+ translator->load(QString(":/wavpack_plugin_") + locale);
+ return translator;
+}
+
+Q_EXPORT_PLUGIN(DecoderWavPackFactory)
diff --git a/src/plugins/Input/wavpack/decoderwavpackfactory.h b/src/plugins/Input/wavpack/decoderwavpackfactory.h
new file mode 100644
index 000000000..f3e2f5e22
--- /dev/null
+++ b/src/plugins/Input/wavpack/decoderwavpackfactory.h
@@ -0,0 +1,52 @@
+/***************************************************************************
+ * Copyright (C) 2008 by Ilya Kotov *
+ * forkotov02@hotmail.ru *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef DECODERWAVPACKFACTORY_H
+#define DECODERWAVPACKFACTORY_H
+
+#include <QObject>
+#include <QString>
+#include <QIODevice>
+#include <QWidget>
+
+#include <qmmp/decoder.h>
+#include <qmmp/output.h>
+#include <qmmp/decoderfactory.h>
+#include <qmmp/filetag.h>
+
+
+class DecoderWavPackFactory : public QObject,
+ DecoderFactory
+{
+Q_OBJECT
+Q_INTERFACES(DecoderFactory);
+
+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);
+ QObject* showDetails(QWidget *parent, const QString &path);
+ void showSettings(QWidget *parent);
+ void showAbout(QWidget *parent);
+ QTranslator *createTranslator(QObject *parent);
+};
+
+#endif
diff --git a/src/plugins/Input/wavpack/detailsdialog.cpp b/src/plugins/Input/wavpack/detailsdialog.cpp
new file mode 100644
index 000000000..9952e60d8
--- /dev/null
+++ b/src/plugins/Input/wavpack/detailsdialog.cpp
@@ -0,0 +1,142 @@
+/***************************************************************************
+ * Copyright (C) 2008 by Ilya Kotov *
+ * forkotov02@hotmail.ru *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include <QFile>
+#include <QFileInfo>
+
+extern "C"
+{
+#include <wavpack/wavpack.h>
+}
+
+#include "detailsdialog.h"
+
+DetailsDialog::DetailsDialog(QWidget *parent, const QString &path)
+ : QDialog(parent)
+{
+ ui.setupUi(this);
+ setAttribute(Qt::WA_DeleteOnClose);
+ m_path = path;
+ setWindowTitle (path.section('/',-1));
+ path.section('/',-1);
+ ui.pathLineEdit->setText(m_path);
+ if (QFile::exists(m_path))
+ {
+ loadWavPackInfo();
+ loadTag();
+ }
+}
+
+
+DetailsDialog::~DetailsDialog()
+{}
+
+void DetailsDialog::loadWavPackInfo()
+{
+ char err[80];
+ WavpackContext *ctx = WavpackOpenFileInput (m_path.toLocal8Bit(), err,
+ OPEN_WVC | OPEN_TAGS, 0);
+ if (!ctx)
+ {
+ qWarning("DetailsDialog: error: %s", err);
+ return;
+ }
+
+ QString text;
+ int length = (int) WavpackGetNumSamples(ctx)/WavpackGetSampleRate(ctx);
+ text = QString("%1").arg(length/60);
+ text +=":"+QString("%1").arg(length % 60, 2, 10, QChar('0'));
+ ui.lengthLabel->setText(text);
+ text = QString("%1").arg((int) WavpackGetSampleRate(ctx));
+ ui.sampleRateLabel->setText(text+" "+tr("Hz"));
+ text = QString("%1").arg((int) WavpackGetNumChannels(ctx));
+ ui.channelsLabel->setText(text);
+ text = QString("%1")
+ .arg((int) WavpackGetAverageBitrate(ctx, WavpackGetNumChannels(ctx))/1000);
+ ui.bitrateLabel->setText(text+" "+tr("kbps"));
+ QFileInfo info(m_path);
+ text = QString("%1 "+tr("KB")).arg((int) info.size()/1024);
+ ui.fileSizeLabel->setText(text);
+ ui.ratioLabel->setText(QString("%1").arg(WavpackGetRatio(ctx)));
+ ui.versionLabel->setText(QString("%1").arg(WavpackGetVersion(ctx)));
+ WavpackCloseFile (ctx);
+}
+
+void DetailsDialog::loadTag()
+{
+ char err[80];
+ WavpackContext *ctx = WavpackOpenFileInput (m_path.toLocal8Bit(), err,
+ OPEN_WVC | OPEN_TAGS, 0);
+ if (!ctx)
+ {
+ qWarning("DetailsDialog: error: %s", err);
+ return;
+ }
+
+ char value[200];
+ WavpackGetTagItem (ctx, "Title", value, sizeof(value));
+ ui.titleLineEdit->setText(QString::fromUtf8(value));
+ WavpackGetTagItem (ctx, "Artist", value, sizeof(value));
+ ui.artistLineEdit->setText(QString::fromUtf8(value));
+ WavpackGetTagItem (ctx, "Album", value, sizeof(value));
+ ui.albumLineEdit->setText(QString::fromUtf8(value));
+ WavpackGetTagItem (ctx, "Comment", value, sizeof(value));
+ ui.commentLineEdit->setText(QString::fromUtf8(value));
+ WavpackGetTagItem (ctx, "Year", value, sizeof(value));
+ ui.yearLineEdit->setText(QString::fromUtf8(value));
+ WavpackGetTagItem (ctx, "Track", value, sizeof(value));
+ ui.trackLineEdit->setText(QString::fromUtf8(value));
+ WavpackGetTagItem (ctx, "Genre", value, sizeof(value));
+ ui.genreLineEdit->setText(QString::fromUtf8(value));
+
+ QFileInfo info(m_path);
+ ui.saveButton->setEnabled(info.isWritable());
+ connect(ui.saveButton, SIGNAL(clicked()), SLOT(saveTag()));
+ WavpackCloseFile (ctx);
+}
+
+void DetailsDialog::saveTag()
+{
+ char err[80];
+ WavpackContext *ctx = WavpackOpenFileInput (m_path.toLocal8Bit(), err,
+ OPEN_WVC | OPEN_EDIT_TAGS, 0);
+ if (!ctx)
+ {
+ qWarning("DetailsDialog: error: %s", err);
+ return;
+ }
+ QByteArray value = ui.titleLineEdit->text().toUtf8();
+ WavpackAppendTagItem(ctx, "Title", value, value.size());
+ value = ui.artistLineEdit->text().toUtf8();
+ WavpackAppendTagItem(ctx, "Artist", value, value.size());
+ value = ui.albumLineEdit->text().toUtf8();
+ WavpackAppendTagItem(ctx, "Album", value, value.size());
+ value = ui.commentLineEdit->text().toUtf8();
+ WavpackAppendTagItem(ctx, "Comment", value, value.size());
+ value = ui.genreLineEdit->text().toUtf8();
+ WavpackAppendTagItem(ctx, "Genre", value, value.size());
+ value = ui.yearLineEdit->text().toUtf8();
+ WavpackAppendTagItem(ctx, "Year", value, value.size());
+ value = ui.trackLineEdit->text().toUtf8();
+ WavpackAppendTagItem(ctx, "Track", value, value.size());
+
+ WavpackWriteTag (ctx);
+ WavpackCloseFile (ctx);
+}
diff --git a/src/plugins/Input/wavpack/detailsdialog.h b/src/plugins/Input/wavpack/detailsdialog.h
new file mode 100644
index 000000000..a36f9695f
--- /dev/null
+++ b/src/plugins/Input/wavpack/detailsdialog.h
@@ -0,0 +1,49 @@
+/***************************************************************************
+ * Copyright (C) 2008 by Ilya Kotov *
+ * forkotov02@hotmail.ru *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef DETAILSDIALOG_H
+#define DETAILSDIALOG_H
+
+#include <QDialog>
+
+#include "ui_detailsdialog.h"
+
+/**
+ @author Ilya Kotov <forkotov02@hotmail.ru>
+*/
+class DetailsDialog : public QDialog
+{
+Q_OBJECT
+public:
+ DetailsDialog(QWidget *parent = 0, const QString &path = 0);
+
+ ~DetailsDialog();
+
+private slots:
+ void saveTag();
+
+private:
+ void loadWavPackInfo();
+ void loadTag();
+ Ui::DetailsDialog ui;
+ QString m_path;
+
+};
+
+#endif
diff --git a/src/plugins/Input/wavpack/detailsdialog.ui b/src/plugins/Input/wavpack/detailsdialog.ui
new file mode 100644
index 000000000..f6e0435a9
--- /dev/null
+++ b/src/plugins/Input/wavpack/detailsdialog.ui
@@ -0,0 +1,382 @@
+<ui version="4.0" >
+ <class>DetailsDialog</class>
+ <widget class="QDialog" name="DetailsDialog" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>449</width>
+ <height>375</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Details</string>
+ </property>
+ <layout class="QGridLayout" >
+ <property name="leftMargin" >
+ <number>8</number>
+ </property>
+ <property name="topMargin" >
+ <number>8</number>
+ </property>
+ <property name="rightMargin" >
+ <number>8</number>
+ </property>
+ <property name="bottomMargin" >
+ <number>8</number>
+ </property>
+ <property name="horizontalSpacing" >
+ <number>6</number>
+ </property>
+ <property name="verticalSpacing" >
+ <number>6</number>
+ </property>
+ <item rowspan="2" row="1" column="0" colspan="2" >
+ <widget class="QGroupBox" name="groupBox" >
+ <property name="minimumSize" >
+ <size>
+ <width>175</width>
+ <height>16</height>
+ </size>
+ </property>
+ <property name="title" >
+ <string>WavPack Info</string>
+ </property>
+ <layout class="QGridLayout" >
+ <item row="0" column="0" >
+ <widget class="QLabel" name="label" >
+ <property name="text" >
+ <string>Length:</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" >
+ <widget class="QLabel" name="lengthLabel" >
+ <property name="text" >
+ <string>-</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" >
+ <widget class="QLabel" name="label_3" >
+ <property name="text" >
+ <string>Sample rate:</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" >
+ <widget class="QLabel" name="sampleRateLabel" >
+ <property name="text" >
+ <string>-</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" >
+ <widget class="QLabel" name="label_5" >
+ <property name="text" >
+ <string>File size:</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" >
+ <widget class="QLabel" name="fileSizeLabel" >
+ <property name="text" >
+ <string>-</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" >
+ <widget class="QLabel" name="label_10" >
+ <property name="layoutDirection" >
+ <enum>Qt::LeftToRight</enum>
+ </property>
+ <property name="text" >
+ <string>Channels:</string>
+ </property>
+ <property name="textFormat" >
+ <enum>Qt::PlainText</enum>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1" >
+ <widget class="QLabel" name="channelsLabel" >
+ <property name="layoutDirection" >
+ <enum>Qt::LeftToRight</enum>
+ </property>
+ <property name="text" >
+ <string>-</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0" >
+ <widget class="QLabel" name="label_2" >
+ <property name="text" >
+ <string>Bitrate:</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1" >
+ <widget class="QLabel" name="bitrateLabel" >
+ <property name="text" >
+ <string>-</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0" >
+ <widget class="QLabel" name="label_4" >
+ <property name="text" >
+ <string>Ratio:</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1" >
+ <widget class="QLabel" name="ratioLabel" >
+ <property name="text" >
+ <string>-</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="0" >
+ <widget class="QLabel" name="label_6" >
+ <property name="text" >
+ <string>Version:</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="1" >
+ <widget class="QLabel" name="versionLabel" >
+ <property name="text" >
+ <string>-</string>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="0" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>74</width>
+ <height>101</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="0" column="1" colspan="3" >
+ <widget class="QLineEdit" name="pathLineEdit" >
+ <property name="readOnly" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" >
+ <widget class="QLabel" name="label_28" >
+ <property name="text" >
+ <string>File path:</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="3" >
+ <widget class="QPushButton" name="pushButton_3" >
+ <property name="text" >
+ <string>Close</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>111</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="1" column="2" colspan="2" >
+ <widget class="QGroupBox" name="groupBox_2" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title" >
+ <string>APE Tag</string>
+ </property>
+ <layout class="QGridLayout" >
+ <property name="leftMargin" >
+ <number>8</number>
+ </property>
+ <property name="topMargin" >
+ <number>8</number>
+ </property>
+ <property name="rightMargin" >
+ <number>8</number>
+ </property>
+ <property name="bottomMargin" >
+ <number>8</number>
+ </property>
+ <property name="horizontalSpacing" >
+ <number>6</number>
+ </property>
+ <property name="verticalSpacing" >
+ <number>6</number>
+ </property>
+ <item row="6" column="1" colspan="2" >
+ <widget class="QPushButton" name="saveButton" >
+ <property name="enabled" >
+ <bool>false</bool>
+ </property>
+ <property name="text" >
+ <string>Save</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="3" >
+ <widget class="QLineEdit" name="trackLineEdit" />
+ </item>
+ <item row="4" column="2" >
+ <widget class="QLabel" name="label_26" >
+ <property name="text" >
+ <string>Track number:</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1" >
+ <widget class="QLineEdit" name="yearLineEdit" />
+ </item>
+ <item row="4" column="0" >
+ <widget class="QLabel" name="label_25" >
+ <property name="text" >
+ <string>Year:</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0" >
+ <widget class="QLabel" name="label_27" >
+ <property name="text" >
+ <string>Genre:</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" >
+ <widget class="QLabel" name="label_24" >
+ <property name="text" >
+ <string>Comment:</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" >
+ <widget class="QLabel" name="label_23" >
+ <property name="text" >
+ <string>Album:</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" >
+ <widget class="QLabel" name="label_22" >
+ <property name="text" >
+ <string>Artist:</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" >
+ <widget class="QLabel" name="label_21" >
+ <property name="text" >
+ <string>Title:</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" colspan="3" >
+ <widget class="QLineEdit" name="titleLineEdit" />
+ </item>
+ <item row="1" column="1" colspan="3" >
+ <widget class="QLineEdit" name="artistLineEdit" />
+ </item>
+ <item row="2" column="1" colspan="3" >
+ <widget class="QLineEdit" name="albumLineEdit" />
+ </item>
+ <item row="3" column="1" colspan="3" >
+ <widget class="QLineEdit" name="commentLineEdit" />
+ </item>
+ <item row="5" column="1" colspan="2" >
+ <widget class="QLineEdit" name="genreLineEdit" />
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>pushButton_3</sender>
+ <signal>clicked()</signal>
+ <receiver>DetailsDialog</receiver>
+ <slot>close()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>623</x>
+ <y>353</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>539</x>
+ <y>352</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/src/plugins/Input/wavpack/wavpack.pro b/src/plugins/Input/wavpack/wavpack.pro
new file mode 100644
index 000000000..07967dce7
--- /dev/null
+++ b/src/plugins/Input/wavpack/wavpack.pro
@@ -0,0 +1,32 @@
+include(../../plugins.pri)
+
+FORMS += detailsdialog.ui
+HEADERS += decoderwavpackfactory.h \
+ decoder_wavpack.h \
+ detailsdialog.h
+SOURCES += decoder_wavpack.cpp \
+ decoderwavpackfactory.cpp \
+ detailsdialog.cpp
+
+TARGET=$$PLUGINS_PREFIX/Input/wavpack
+QMAKE_CLEAN =$$PLUGINS_PREFIX/Input/libwavpack.so
+
+
+INCLUDEPATH += ../../../
+CONFIG += release \
+warn_on \
+plugin \
+link_pkgconfig
+TEMPLATE = lib
+QMAKE_LIBDIR += ../../../../lib
+LIBS += -lqmmp -L/usr/lib -I/usr/include
+PKGCONFIG += wavpack
+#TRANSLATIONS = translations/wavpack_plugin_ru.ts
+#RESOURCES = translations/translations.qrc
+
+isEmpty (LIB_DIR){
+LIB_DIR = /lib
+}
+
+target.path = $$LIB_DIR/qmmp/Input
+INSTALLS += target