diff --git a/doc/Changelog.html b/doc/Changelog.html
index 6665595e..4680de9a 100644
--- a/doc/Changelog.html
+++ b/doc/Changelog.html
@@ -84,6 +84,7 @@
LameXP v4.xx History
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
- Enabled the "built-in" resampler for QAAC encoder
- The "Algorithm Quality" slider now also affects the QAAC encoder
diff --git a/doc/Changelog.md b/doc/Changelog.md
index 3577846e..bf8d6a41 100644
--- a/doc/Changelog.md
+++ b/doc/Changelog.md
@@ -4,6 +4,7 @@
## 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
* Enabled the "built-in" resampler for QAAC encoder
* The "Algorithm Quality" slider now also affects the QAAC encoder
diff --git a/src/Config.h b/src/Config.h
index 6d0411d7..18bbe03a 100644
--- a/src/Config.h
+++ b/src/Config.h
@@ -34,8 +34,8 @@
#define VER_LAMEXP_MINOR_HI 1
#define VER_LAMEXP_MINOR_LO 4
#define VER_LAMEXP_TYPE Alpha
-#define VER_LAMEXP_PATCH 7
-#define VER_LAMEXP_BUILD 1876
+#define VER_LAMEXP_PATCH 8
+#define VER_LAMEXP_BUILD 1878
#define VER_LAMEXP_CONFG 1818
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/Encoder_Wave.cpp b/src/Encoder_Wave.cpp
index 809bddbc..397468a4 100644
--- a/src/Encoder_Wave.cpp
+++ b/src/Encoder_Wave.cpp
@@ -22,18 +22,18 @@
#include "Encoder_Wave.h"
+#include
+#include
+
#include "Global.h"
#include "Model_Settings.h"
-#include
-
-//Windows includes
-#define NOMINMAX
-#define WIN32_LEAN_AND_MEAN
-#include
-#include
-
-#define FIX_SEPARATORS(STR) for(int i = 0; STR[i]; i++) { if(STR[i] == L'/') STR[i] = L'\\'; }
+typedef struct _callback_t
+{
+ WaveEncoder *pInstance;
+ volatile bool *abortFlag;
+}
+callback_t;
///////////////////////////////////////////////////////////////////////////////
// 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)
{
- SHFILEOPSTRUCTW fileOperation;
- 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\"\n").arg(sourceFile, outputFile));
- emit messageLogged(QString("Copy file \"%1\" to \"%2\"").arg(sourceFile, outputFile));
- fileOperation.wFunc = FO_COPY;
+ callback_t callbackData;
+ callbackData.abortFlag = abortFlag;
+ callbackData.pInstance = this;
- /*
- if(lamexp_temp_folder().compare(QFileInfo(sourceFile).canonicalPath(), Qt::CaseInsensitive) == 0)
+ emit statusUpdated(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(QString("Moving file \"%1\" to \"%2\"").arg(sourceFile, outputFile));
- fileOperation.wFunc = FO_MOVE;
+ emit messageLogged(QLatin1String("File copied successfully."));
}
else
{
- //...otherwise we actually copy the file in order to keep the source
- emit messageLogged(QString("Copy file \"%1\" to \"%2\"").arg(sourceFile, outputFile));
- fileOperation.wFunc = FO_COPY;
+ emit messageLogged((*abortFlag) ? QLatin1String("Operation cancelled by user!") : QLatin1String("Error: Failed to copy file!"));
}
- */
-
- size_t srcLen = wcslen(reinterpret_cast(sourceFile.utf16())) + 3;
- wchar_t *srcBuffer = new wchar_t[srcLen];
- memset(srcBuffer, 0, srcLen * sizeof(wchar_t));
- wcsncpy_s(srcBuffer, srcLen, reinterpret_cast(sourceFile.utf16()), _TRUNCATE);
- FIX_SEPARATORS (srcBuffer);
- fileOperation.pFrom = srcBuffer;
- size_t outLen = wcslen(reinterpret_cast(outputFile.utf16())) + 3;
- wchar_t *outBuffer = new wchar_t[outLen];
- memset(outBuffer, 0, outLen * sizeof(wchar_t));
- wcsncpy_s(outBuffer, outLen, reinterpret_cast(outputFile.utf16()), _TRUNCATE);
- FIX_SEPARATORS (outBuffer);
- fileOperation.pTo = outBuffer;
+ return success;
+}
- emit statusUpdated(0);
- int result = SHFileOperation(&fileOperation);
- emit statusUpdated(100);
+bool WaveEncoder::progressCallback(const double &progress, void *const userData)
+{
+ const callback_t *const ptr = reinterpret_cast(userData);
+ if (*(ptr->abortFlag))
+ {
+ return false; /*user aborted*/
+ }
+ ptr->pInstance->updateProgress(progress);
+ return true;
+}
- emit messageLogged(QString().sprintf("\nExited with code: 0x%04X", result));
-
- delete [] srcBuffer;
- delete [] outBuffer;
-
- return (result == 0 && fileOperation.fAnyOperationsAborted == false);
+void WaveEncoder::updateProgress(const double &progress)
+{
+ emit statusUpdated(qRound(progress * 100.0));
}
bool WaveEncoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
diff --git a/src/Encoder_Wave.h b/src/Encoder_Wave.h
index 27b91933..785409d5 100644
--- a/src/Encoder_Wave.h
+++ b/src/Encoder_Wave.h
@@ -40,4 +40,8 @@ public:
//Encoder info
virtual const AbstractEncoderInfo *toEncoderInfo(void) const { return getEncoderInfo(); }
static const AbstractEncoderInfo *getEncoderInfo(void);
+
+private:
+ static bool progressCallback(const double &progress, void *const userData);
+ void updateProgress(const double &progress);
};