From cd593aefbf6deb1866d87cfa338ff0a84d594242 Mon Sep 17 00:00:00 2001 From: lordmulder Date: Sun, 17 Apr 2011 20:38:49 +0200 Subject: [PATCH] Added a method to use custom binaries instead of the "built-in" ones: Simply put the custom binary to "$ORIGIN\tools\\.exe" and it will be detected at runtime. --- doc/Changelog.html | 1 + src/Config.h | 2 +- src/Thread_Initialization.cpp | 43 ++++++++++++++++++++++++++++++++----------- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/doc/Changelog.html b/doc/Changelog.html index c06b646a..7acf80a6 100644 --- a/doc/Changelog.html +++ b/doc/Changelog.html @@ -20,6 +20,7 @@ a:visited { color: #0000EE; }
  • Upgraded build environment to Microsoft Visual Studio 2010
  • Dropping support for Windows 2000 and for Windows XP RTM/SP1, Windows XP needs SP2 or SP3 now!
  • Added a new translation: Korean +
  • Added a method to use custom tools instead of the "built-in" ones (see FAQ doc for details)
  • Updated LAME encoder to v3.99.1.0 (2011-04-15), compiled with ICL 12.0.3 and MSVC 10.0 (details)
  • Updated MediaInfo to v0.7.43 (2011-04-10), compiled with ICL 12.0.3 and MSVC 10.0
  • Updated language files (big thank-you to all contributors !!!) diff --git a/src/Config.h b/src/Config.h index 22e8575d..38ab8b32 100644 --- a/src/Config.h +++ b/src/Config.h @@ -30,7 +30,7 @@ #define VER_LAMEXP_MINOR_LO 2 #define VER_LAMEXP_TYPE Alpha #define VER_LAMEXP_PATCH 4 -#define VER_LAMEXP_BUILD 447 +#define VER_LAMEXP_BUILD 448 /////////////////////////////////////////////////////////////////////////////// // Tools versions diff --git a/src/Thread_Initialization.cpp b/src/Thread_Initialization.cpp index 76f3f26c..97169fde 100644 --- a/src/Thread_Initialization.cpp +++ b/src/Thread_Initialization.cpp @@ -101,6 +101,7 @@ InitializationThread::InitializationThread(const lamexp_cpu_t *cpuFeatures) void InitializationThread::run() { m_bSuccess = false; + bool bCustom = false; delay(); //CPU type selection @@ -133,10 +134,11 @@ void InitializationThread::run() QDir toolsDir(":/tools/"); QList toolsList = toolsDir.entryInfoList(QStringList("*.*"), QDir::Files, QDir::Name); - + QDir appDir = QDir(QCoreApplication::applicationDirPath()).canonicalPath(); + QTime timer; timer.start(); - + //Extract all files while(!toolsList.isEmpty()) { @@ -157,14 +159,25 @@ void InitializationThread::run() if(toolCpuType & cpuSupport) { - qDebug("Extracting file: %s -> %s", toolName.toLatin1().constData(), toolShortName.toLatin1().constData()); - LockedFile *lockedFile = new LockedFile(QString(":/tools/%1").arg(toolName), QString("%1/tool_%2").arg(lamexp_temp_folder2(), toolShortName), toolHash); - lamexp_register_tool(toolShortName, lockedFile, toolVersion); + QFileInfo customTool(QString("%1/tools/%2/%3").arg(appDir.canonicalPath(), QString::number(lamexp_version_build()), toolShortName)); + if(customTool.exists() && customTool.isFile()) + { + bCustom = true; + qDebug("Setting up file: %s <- %s", toolShortName.toLatin1().constData(), appDir.relativeFilePath(customTool.canonicalFilePath()).toLatin1().constData()); + LockedFile *lockedFile = new LockedFile(customTool.canonicalFilePath()); + lamexp_register_tool(toolShortName, lockedFile, UINT_MAX); + } + else + { + qDebug("Extracting file: %s -> %s", toolName.toLatin1().constData(), toolShortName.toLatin1().constData()); + LockedFile *lockedFile = new LockedFile(QString(":/tools/%1").arg(toolName), QString("%1/tool_%2").arg(lamexp_temp_folder2(), toolShortName), toolHash); + lamexp_register_tool(toolShortName, lockedFile, toolVersion); + } } } catch(char *errorMsg) { - qFatal("At least one of the required tools could not be extracted:\n%s", errorMsg); + qFatal("At least one of the required tools could not be initialized:\n%s", errorMsg); return; } } @@ -176,12 +189,18 @@ void InitializationThread::run() return; } + qDebug("All extracted.\n"); + //Clean-up mapChecksum.clear(); mapVersion.clear(); mapCpuType.clear(); - - qDebug("All extracted.\n"); + + //Using any custom tools? + if(bCustom) + { + qWarning("Warning: Using custom tools, you might encounter unexpected problems!\n"); + } //Check delay double delayExtract = static_cast(timer.elapsed()) / 1000.0; @@ -273,10 +292,12 @@ void InitializationThread::initTranslations(void) void InitializationThread::initNeroAac(void) { + const QString appPath = QDir(QCoreApplication::applicationDirPath()).canonicalPath(); + QFileInfo neroFileInfo[3]; - neroFileInfo[0] = QFileInfo(QString("%1/neroAacEnc.exe").arg(QCoreApplication::applicationDirPath())); - neroFileInfo[1] = QFileInfo(QString("%1/neroAacDec.exe").arg(QCoreApplication::applicationDirPath())); - neroFileInfo[2] = QFileInfo(QString("%1/neroAacTag.exe").arg(QCoreApplication::applicationDirPath())); + neroFileInfo[0] = QFileInfo(QString("%1/neroAacEnc.exe").arg(appPath)); + neroFileInfo[1] = QFileInfo(QString("%1/neroAacDec.exe").arg(appPath)); + neroFileInfo[2] = QFileInfo(QString("%1/neroAacTag.exe").arg(appPath)); bool neroFilesFound = true; for(int i = 0; i < 3; i++) { if(!neroFileInfo[i].exists()) neroFilesFound = false; } -- 2.11.0