From 63bf596ce8e2ec81a80a7ae14844ca57c2add3d4 Mon Sep 17 00:00:00 2001 From: lordmulder Date: Tue, 21 Jun 2011 16:23:42 +0200 Subject: [PATCH] Recognize WMA decoder (wamwav.exe) from the LameXP program directory. Might be helpful for people using LameXP as a portable application. --- src/Config.h | 2 +- src/LockedFile.cpp | 12 ++++++------ src/Thread_Initialization.cpp | 6 +++++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/Config.h b/src/Config.h index 689fd034..8bf08d72 100644 --- a/src/Config.h +++ b/src/Config.h @@ -30,7 +30,7 @@ #define VER_LAMEXP_MINOR_LO 3 #define VER_LAMEXP_TYPE Alpha #define VER_LAMEXP_PATCH 1 -#define VER_LAMEXP_BUILD 579 +#define VER_LAMEXP_BUILD 580 /////////////////////////////////////////////////////////////////////////////// // Tools versions diff --git a/src/LockedFile.cpp b/src/LockedFile.cpp index 8a7f3c5b..65203cea 100644 --- a/src/LockedFile.cpp +++ b/src/LockedFile.cpp @@ -58,14 +58,14 @@ LockedFile::LockedFile(const QString &resourcePath, const QString &outPath, cons } //Now lock the file! - for(int i = 0; i < 1000; i++) + for(int i = 0; i < 64; i++) { - if((m_fileHandle = CreateFileW(QWCHAR(QDir::toNativeSeparators(m_filePath)), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, NULL)) != INVALID_HANDLE_VALUE) - { - break; - } + m_fileHandle = CreateFileW(QWCHAR(QDir::toNativeSeparators(m_filePath)), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, NULL); + if((m_fileHandle != NULL) && (m_fileHandle != INVALID_HANDLE_VALUE)) break; Sleep(100); } + + //Locked successfully? if((m_fileHandle == NULL) || (m_fileHandle == INVALID_HANDLE_VALUE)) { QFile::remove(QFileInfo(outFile).canonicalFilePath()); @@ -120,7 +120,7 @@ LockedFile::LockedFile(const QString &filePath) m_filePath = existingFile.canonicalFilePath(); //Now lock the file - for(int i = 0; i < 10; i++) + for(int i = 0; i < 64; i++) { m_fileHandle = CreateFileW(QWCHAR(QDir::toNativeSeparators(filePath)), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, NULL); if((m_fileHandle != NULL) && (m_fileHandle != INVALID_HANDLE_VALUE)) break; diff --git a/src/Thread_Initialization.cpp b/src/Thread_Initialization.cpp index 44dbeead..a9625e2e 100644 --- a/src/Thread_Initialization.cpp +++ b/src/Thread_Initialization.cpp @@ -405,7 +405,11 @@ void InitializationThread::initWmaDec(void) LockedFile *wmaFileBin = NULL; QFileInfo wmaFileInfo = QFileInfo(QString("%1/%2").arg(lamexp_known_folder(lamexp_folder_programfiles), wmaDecoderComponentPath)); - if(!wmaFileInfo.exists()) + if(!(wmaFileInfo.exists() && wmaFileInfo.isFile())) + { + wmaFileInfo.setFile(QString("%1/%2").arg(QDir(QCoreApplication::applicationDirPath()).canonicalPath(), "wmawav.exe")); + } + if(!(wmaFileInfo.exists() && wmaFileInfo.isFile())) { qDebug("WMA File Decoder not found -> WMA decoding support will be disabled!\n"); return;