Improved the WaveDecoder to do proper progress reporting.
This commit is contained in:
parent
5b1b612775
commit
44a206d739
@ -35,7 +35,7 @@
|
|||||||
#define VER_LAMEXP_MINOR_LO 1
|
#define VER_LAMEXP_MINOR_LO 1
|
||||||
#define VER_LAMEXP_TYPE RC
|
#define VER_LAMEXP_TYPE RC
|
||||||
#define VER_LAMEXP_PATCH 3
|
#define VER_LAMEXP_PATCH 3
|
||||||
#define VER_LAMEXP_BUILD 1688
|
#define VER_LAMEXP_BUILD 1689
|
||||||
#define VER_LAMEXP_CONFG 1558
|
#define VER_LAMEXP_CONFG 1558
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -30,6 +30,14 @@
|
|||||||
//Qt
|
//Qt
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
|
//Type
|
||||||
|
typedef struct _ProgressData
|
||||||
|
{
|
||||||
|
WaveDecoder *const instance;
|
||||||
|
volatile bool *const abrtFlag;
|
||||||
|
}
|
||||||
|
ProgressData;
|
||||||
|
|
||||||
WaveDecoder::WaveDecoder(void)
|
WaveDecoder::WaveDecoder(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -41,9 +49,11 @@ WaveDecoder::~WaveDecoder(void)
|
|||||||
bool WaveDecoder::decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag)
|
bool WaveDecoder::decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag)
|
||||||
{
|
{
|
||||||
emit messageLogged(QString("Copy file \"%1\" to \"%2\"").arg(QDir::toNativeSeparators(sourceFile), QDir::toNativeSeparators(outputFile)));
|
emit messageLogged(QString("Copy file \"%1\" to \"%2\"").arg(QDir::toNativeSeparators(sourceFile), QDir::toNativeSeparators(outputFile)));
|
||||||
|
|
||||||
emit statusUpdated(0);
|
emit statusUpdated(0);
|
||||||
const bool okay = MUtils::OS::copy_file(sourceFile, outputFile);
|
|
||||||
|
ProgressData progressData = { this, abortFlag };
|
||||||
|
const bool okay = MUtils::OS::copy_file(sourceFile, outputFile, true, progressHandler, &progressData);
|
||||||
|
|
||||||
emit statusUpdated(100);
|
emit statusUpdated(100);
|
||||||
|
|
||||||
if(okay)
|
if(okay)
|
||||||
@ -75,3 +85,19 @@ QStringList WaveDecoder::supportedTypes(void)
|
|||||||
{
|
{
|
||||||
return QStringList() << "Waveform Audio File (*.wav)";
|
return QStringList() << "Waveform Audio File (*.wav)";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WaveDecoder::progressHandler(const double &progress, void *const data)
|
||||||
|
{
|
||||||
|
if(data)
|
||||||
|
{
|
||||||
|
//qWarning("Copy progress: %.2f", progress);
|
||||||
|
reinterpret_cast<ProgressData*>(data)->instance->updateProgress(progress);
|
||||||
|
return (!(*reinterpret_cast<ProgressData*>(data)->abrtFlag));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WaveDecoder::updateProgress(const double &progress)
|
||||||
|
{
|
||||||
|
emit statusUpdated(qBound(0, qRound(progress * 100.0), 100));
|
||||||
|
}
|
||||||
|
@ -31,6 +31,10 @@ public:
|
|||||||
~WaveDecoder(void);
|
~WaveDecoder(void);
|
||||||
|
|
||||||
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
|
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
|
||||||
|
|
||||||
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
|
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
|
||||||
static QStringList supportedTypes(void);
|
static QStringList supportedTypes(void);
|
||||||
|
|
||||||
|
static bool progressHandler(const double &progress, void *const data);
|
||||||
|
void updateProgress(const double &progress);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user