WaveEncoder: Use MUtils::OS::copy_file() function instead of SHFileOperation(). Gives actual progress and is less clunky to use.
This commit is contained in:
parent
ce37f51a3d
commit
b6b0413e86
@ -84,6 +84,7 @@
|
|||||||
<h1 id="lamexp-v4.xx-history"><span class="header-section-number">1</span> LameXP v4.xx History</h1>
|
<h1 id="lamexp-v4.xx-history"><span class="header-section-number">1</span> LameXP v4.xx History</h1>
|
||||||
<h2 id="lamexp-v4.14-2016--" class="unnumbered">LameXP v4.14 [2016-??-??]</h2>
|
<h2 id="lamexp-v4.14-2016--" class="unnumbered">LameXP v4.14 [2016-??-??]</h2>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li>Upgraded build environment to Microsoft Visual Studio 2015 with Update-2</li>
|
||||||
<li>Fixed the location of temporary intermediate files for SoX-based audio effects</li>
|
<li>Fixed the location of temporary intermediate files for SoX-based audio effects</li>
|
||||||
<li>Enabled the "built-in" resampler for QAAC encoder</li>
|
<li>Enabled the "built-in" resampler for QAAC encoder</li>
|
||||||
<li>The "Algorithm Quality" slider now also affects the QAAC encoder</li>
|
<li>The "Algorithm Quality" slider now also affects the QAAC encoder</li>
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
## LameXP v4.14 [2016-??-??] ## {-}
|
## LameXP v4.14 [2016-??-??] ## {-}
|
||||||
|
|
||||||
|
* Upgraded build environment to Microsoft Visual Studio 2015 with Update-2
|
||||||
* Fixed the location of temporary intermediate files for SoX-based audio effects
|
* Fixed the location of temporary intermediate files for SoX-based audio effects
|
||||||
* Enabled the "built-in" resampler for QAAC encoder
|
* Enabled the "built-in" resampler for QAAC encoder
|
||||||
* The "Algorithm Quality" slider now also affects the QAAC encoder
|
* The "Algorithm Quality" slider now also affects the QAAC encoder
|
||||||
|
@ -34,8 +34,8 @@
|
|||||||
#define VER_LAMEXP_MINOR_HI 1
|
#define VER_LAMEXP_MINOR_HI 1
|
||||||
#define VER_LAMEXP_MINOR_LO 4
|
#define VER_LAMEXP_MINOR_LO 4
|
||||||
#define VER_LAMEXP_TYPE Alpha
|
#define VER_LAMEXP_TYPE Alpha
|
||||||
#define VER_LAMEXP_PATCH 7
|
#define VER_LAMEXP_PATCH 8
|
||||||
#define VER_LAMEXP_BUILD 1876
|
#define VER_LAMEXP_BUILD 1878
|
||||||
#define VER_LAMEXP_CONFG 1818
|
#define VER_LAMEXP_CONFG 1818
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -22,18 +22,18 @@
|
|||||||
|
|
||||||
#include "Encoder_Wave.h"
|
#include "Encoder_Wave.h"
|
||||||
|
|
||||||
|
#include <MUtils/Global.h>
|
||||||
|
#include <MUtils/OSSupport.h>
|
||||||
|
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "Model_Settings.h"
|
#include "Model_Settings.h"
|
||||||
|
|
||||||
#include <QDir>
|
typedef struct _callback_t
|
||||||
|
{
|
||||||
//Windows includes
|
WaveEncoder *pInstance;
|
||||||
#define NOMINMAX
|
volatile bool *abortFlag;
|
||||||
#define WIN32_LEAN_AND_MEAN
|
}
|
||||||
#include <Windows.h>
|
callback_t;
|
||||||
#include <Shellapi.h>
|
|
||||||
|
|
||||||
#define FIX_SEPARATORS(STR) for(int i = 0; STR[i]; i++) { if(STR[i] == L'/') STR[i] = L'\\'; }
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Encoder Info
|
// Encoder Info
|
||||||
@ -134,52 +134,42 @@ WaveEncoder::~WaveEncoder(void)
|
|||||||
|
|
||||||
bool WaveEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const QString &outputFile, volatile bool *abortFlag)
|
bool WaveEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo &metaInfo, const unsigned int duration, const QString &outputFile, volatile bool *abortFlag)
|
||||||
{
|
{
|
||||||
SHFILEOPSTRUCTW fileOperation;
|
emit messageLogged(QString("Copy file \"%1\" to \"%2\"\n").arg(sourceFile, outputFile));
|
||||||
memset(&fileOperation, 0, sizeof(SHFILEOPSTRUCTW));
|
|
||||||
fileOperation.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR | FOF_NOERRORUI | FOF_FILESONLY;
|
|
||||||
|
|
||||||
emit messageLogged(QString("Copy file \"%1\" to \"%2\"").arg(sourceFile, outputFile));
|
callback_t callbackData;
|
||||||
fileOperation.wFunc = FO_COPY;
|
callbackData.abortFlag = abortFlag;
|
||||||
|
callbackData.pInstance = this;
|
||||||
|
|
||||||
/*
|
emit statusUpdated(0);
|
||||||
if(lamexp_temp_folder().compare(QFileInfo(sourceFile).canonicalPath(), Qt::CaseInsensitive) == 0)
|
const bool success = MUtils::OS::copy_file(sourceFile, outputFile, true, progressCallback, &callbackData);
|
||||||
|
emit statusUpdated(100);
|
||||||
|
|
||||||
|
if (success)
|
||||||
{
|
{
|
||||||
//If the source is in the TEMP folder take shortcut and move the file
|
emit messageLogged(QLatin1String("File copied successfully."));
|
||||||
emit messageLogged(QString("Moving file \"%1\" to \"%2\"").arg(sourceFile, outputFile));
|
|
||||||
fileOperation.wFunc = FO_MOVE;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//...otherwise we actually copy the file in order to keep the source
|
emit messageLogged((*abortFlag) ? QLatin1String("Operation cancelled by user!") : QLatin1String("Error: Failed to copy file!"));
|
||||||
emit messageLogged(QString("Copy file \"%1\" to \"%2\"").arg(sourceFile, outputFile));
|
|
||||||
fileOperation.wFunc = FO_COPY;
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
size_t srcLen = wcslen(reinterpret_cast<const wchar_t*>(sourceFile.utf16())) + 3;
|
return success;
|
||||||
wchar_t *srcBuffer = new wchar_t[srcLen];
|
}
|
||||||
memset(srcBuffer, 0, srcLen * sizeof(wchar_t));
|
|
||||||
wcsncpy_s(srcBuffer, srcLen, reinterpret_cast<const wchar_t*>(sourceFile.utf16()), _TRUNCATE);
|
|
||||||
FIX_SEPARATORS (srcBuffer);
|
|
||||||
fileOperation.pFrom = srcBuffer;
|
|
||||||
|
|
||||||
size_t outLen = wcslen(reinterpret_cast<const wchar_t*>(outputFile.utf16())) + 3;
|
bool WaveEncoder::progressCallback(const double &progress, void *const userData)
|
||||||
wchar_t *outBuffer = new wchar_t[outLen];
|
{
|
||||||
memset(outBuffer, 0, outLen * sizeof(wchar_t));
|
const callback_t *const ptr = reinterpret_cast<callback_t*>(userData);
|
||||||
wcsncpy_s(outBuffer, outLen, reinterpret_cast<const wchar_t*>(outputFile.utf16()), _TRUNCATE);
|
if (*(ptr->abortFlag))
|
||||||
FIX_SEPARATORS (outBuffer);
|
{
|
||||||
fileOperation.pTo = outBuffer;
|
return false; /*user aborted*/
|
||||||
|
}
|
||||||
|
ptr->pInstance->updateProgress(progress);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
emit statusUpdated(0);
|
void WaveEncoder::updateProgress(const double &progress)
|
||||||
int result = SHFileOperation(&fileOperation);
|
{
|
||||||
emit statusUpdated(100);
|
emit statusUpdated(qRound(progress * 100.0));
|
||||||
|
|
||||||
emit messageLogged(QString().sprintf("\nExited with code: 0x%04X", result));
|
|
||||||
|
|
||||||
delete [] srcBuffer;
|
|
||||||
delete [] outBuffer;
|
|
||||||
|
|
||||||
return (result == 0 && fileOperation.fAnyOperationsAborted == false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WaveEncoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
bool WaveEncoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||||
|
@ -40,4 +40,8 @@ public:
|
|||||||
//Encoder info
|
//Encoder info
|
||||||
virtual const AbstractEncoderInfo *toEncoderInfo(void) const { return getEncoderInfo(); }
|
virtual const AbstractEncoderInfo *toEncoderInfo(void) const { return getEncoderInfo(); }
|
||||||
static const AbstractEncoderInfo *getEncoderInfo(void);
|
static const AbstractEncoderInfo *getEncoderInfo(void);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static bool progressCallback(const double &progress, void *const userData);
|
||||||
|
void updateProgress(const double &progress);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user