2010-11-06 23:04:47 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// LameXP - Audio Encoder Front-End
|
2011-01-01 17:04:25 +01:00
|
|
|
// Copyright (C) 2004-2011 LoRd_MuldeR <MuldeR2@GMX.de>
|
2010-11-06 23:04:47 +01:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License along
|
|
|
|
// with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
//
|
|
|
|
// http://www.gnu.org/licenses/gpl-2.0.txt
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "Thread_Initialization.h"
|
|
|
|
|
|
|
|
#include "Global.h"
|
|
|
|
#include "LockedFile.h"
|
|
|
|
|
2010-11-11 22:58:02 +01:00
|
|
|
#include <QFileInfo>
|
|
|
|
#include <QCoreApplication>
|
2010-11-12 15:58:53 +01:00
|
|
|
#include <QProcess>
|
2010-12-12 01:49:07 +01:00
|
|
|
#include <QMap>
|
|
|
|
#include <QDir>
|
2010-12-12 13:44:11 +01:00
|
|
|
#include <QLibrary>
|
2011-01-04 19:58:18 +01:00
|
|
|
#include <QResource>
|
2011-01-25 01:41:57 +01:00
|
|
|
#include <QTime>
|
2010-12-12 13:44:11 +01:00
|
|
|
|
|
|
|
#include <Windows.h>
|
2010-11-11 22:58:02 +01:00
|
|
|
|
2010-11-06 23:04:47 +01:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
// TOOLS
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
2011-01-20 22:54:10 +01:00
|
|
|
static const struct
|
2010-11-06 23:04:47 +01:00
|
|
|
{
|
|
|
|
char *pcHash;
|
|
|
|
char *pcName;
|
2010-12-15 22:39:18 +01:00
|
|
|
unsigned int uiVersion;
|
2011-01-20 22:54:10 +01:00
|
|
|
}
|
|
|
|
g_lamexp_tools[] =
|
2010-11-06 23:04:47 +01:00
|
|
|
{
|
2011-01-20 22:54:10 +01:00
|
|
|
{"3b41f85dde8d4a5a0f4cd5f461099d0db24610ba", "alac.exe", UINT_MAX},
|
2011-01-20 21:06:25 +01:00
|
|
|
{"fb74ac8b73ad8cba2c3b4e6e61f23401d630dc22", "elevator.exe", UINT_MAX},
|
2011-01-26 20:15:21 +01:00
|
|
|
{"3c647950bccfcc75d0746c0772e7115684be4dc5", "faad.exe", 27},
|
2010-12-27 15:49:30 +01:00
|
|
|
{"d33cd86f04bd4067e244d2804466583c7b90a4e2", "flac.exe", 121},
|
2011-01-20 02:51:30 +01:00
|
|
|
{"9328a50e89b54ec065637496d9681a7e3eebf915", "gpgv.exe", 1411},
|
2010-12-15 22:39:18 +01:00
|
|
|
{"d837bf6ee4dab557d8b02d46c75a24e58980fffa", "gpgv.gpg", UINT_MAX},
|
2011-02-28 22:35:47 +01:00
|
|
|
{"62e301a56be4b56fc053710042d58992f25b1773", "lame.exe", 39914},
|
2011-01-16 22:00:49 +01:00
|
|
|
{"a4e929cfaa42fa2e61a3d0c6434c77a06d45aef3", "mac.exe", 406},
|
2011-03-05 01:56:00 +01:00
|
|
|
{"e83cad851d1f0d13057736d9133767960b5ca514", "mediainfo_i386.exe", 742},
|
|
|
|
{"6fb20ea7492fcf984e99957b7a3c5fe4fb06cca2", "mediainfo_x64.exe", 742},
|
2011-01-29 22:50:37 +01:00
|
|
|
{"aa89763a5ba4d1a5986549b9ee53e005c51940c1", "mpcdec.exe", 435},
|
2011-02-20 19:30:21 +01:00
|
|
|
{"38f81efca6c1eeab0b9dc39d06c2ac750267217f", "mpg123.exe", 1132},
|
2010-12-27 16:05:47 +01:00
|
|
|
{"8dd7138714c3bcb39f5a3213413addba13d06f1e", "oggdec.exe", UINT_MAX},
|
2011-02-28 17:52:43 +01:00
|
|
|
{"14a99d3b1f0b166dbd68db45196da871e58e14ec", "oggenc2_i386.exe", 287602},
|
|
|
|
{"36f8d93ef3df6a420a73a9b5cf02dafdaf4321f0", "oggenc2_sse2.exe", 287602},
|
|
|
|
{"87ad1af73e9b9db3da3db645e5c2253cb0c2a2ea", "oggenc2_x64.exe", 287602},
|
2011-01-30 01:45:34 +01:00
|
|
|
{"0d9035bb62bdf46a2785261f8be5a4a0972abd15", "shorten.exe", 361},
|
2011-03-19 22:47:43 +01:00
|
|
|
{"50ead3b852cbfc067a402e6c2d0d0d8879663dec", "sox.exe", 1432},
|
2011-02-01 22:15:57 +01:00
|
|
|
{"8671e16497a2d217d3707d4aa418678d02b16bcc", "speexdec.exe", 12},
|
2011-03-19 20:44:00 +01:00
|
|
|
{"093bfdec22872ca99e40183937c88785468be989", "tta.exe", 21},
|
2010-12-27 15:49:30 +01:00
|
|
|
{"8c842eef65248b46fa6cb9a9e5714f575672d999", "valdec.exe", 31},
|
2011-02-01 22:15:57 +01:00
|
|
|
{"62e2805d1b2eb2a4d86a5ca6e6ea58010d05d2a7", "wget.exe", 1114},
|
2011-01-25 00:52:00 +01:00
|
|
|
{"a7e8aad52213e339ad985829722f35eab62be182", "wupdate.exe", UINT_MAX},
|
2011-01-17 20:52:54 +01:00
|
|
|
{"b7d14b3540d24df13119a55d97623a61412de6e3", "wvunpack.exe", 4601},
|
2010-12-15 22:39:18 +01:00
|
|
|
{NULL, NULL, NULL}
|
2010-11-06 23:04:47 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
// Constructor
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
InitializationThread::InitializationThread(void)
|
|
|
|
{
|
|
|
|
m_bSuccess = false;
|
|
|
|
}
|
|
|
|
|
2010-11-12 15:58:53 +01:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
// Thread Main
|
|
|
|
////////////////////////////////////////////////////////////
|
2010-11-06 23:04:47 +01:00
|
|
|
|
|
|
|
void InitializationThread::run()
|
|
|
|
{
|
|
|
|
m_bSuccess = false;
|
|
|
|
delay();
|
|
|
|
|
2010-12-15 22:39:18 +01:00
|
|
|
QMap<QString, QString> checksum;
|
|
|
|
QMap<QString, unsigned int> version;
|
2010-12-12 01:49:07 +01:00
|
|
|
|
|
|
|
//Init checksums
|
2010-11-06 23:04:47 +01:00
|
|
|
for(int i = 0; i < INT_MAX; i++)
|
|
|
|
{
|
2010-12-18 15:15:17 +01:00
|
|
|
if(!g_lamexp_tools[i].pcName && !g_lamexp_tools[i].pcHash && !g_lamexp_tools[i].uiVersion)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if(g_lamexp_tools[i].pcName && g_lamexp_tools[i].pcHash && g_lamexp_tools[i].uiVersion)
|
2010-11-06 23:04:47 +01:00
|
|
|
{
|
2010-12-15 22:39:18 +01:00
|
|
|
const QString currentTool = QString::fromLatin1(g_lamexp_tools[i].pcName);
|
|
|
|
checksum.insert(currentTool, QString::fromLatin1(g_lamexp_tools[i].pcHash));
|
|
|
|
version.insert(currentTool, g_lamexp_tools[i].uiVersion);
|
2010-11-06 23:04:47 +01:00
|
|
|
}
|
2010-12-18 15:15:17 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
qFatal("Inconsistent checksum data detected. Take care!");
|
|
|
|
}
|
2010-12-12 01:49:07 +01:00
|
|
|
}
|
2010-11-06 23:04:47 +01:00
|
|
|
|
2010-12-12 01:49:07 +01:00
|
|
|
QDir toolsDir(":/tools/");
|
|
|
|
QList<QFileInfo> toolsList = toolsDir.entryInfoList(QStringList("*.*"), QDir::Files, QDir::Name);
|
2011-01-25 01:41:57 +01:00
|
|
|
|
|
|
|
QTime timer;
|
|
|
|
timer.start();
|
2010-12-12 01:49:07 +01:00
|
|
|
|
|
|
|
//Extract all files
|
|
|
|
for(int i = 0; i < toolsList.count(); i++)
|
|
|
|
{
|
2010-11-06 23:04:47 +01:00
|
|
|
try
|
|
|
|
{
|
2011-01-16 22:00:49 +01:00
|
|
|
QString toolName = toolsList.at(i).fileName().toLower();
|
|
|
|
qDebug("Extracting file: %s", toolName.toLatin1().constData());
|
2010-12-12 01:49:07 +01:00
|
|
|
QByteArray toolHash = checksum.take(toolName).toLatin1();
|
2010-12-15 22:39:18 +01:00
|
|
|
unsigned int toolVersion = version.take(toolName);
|
2010-12-12 01:49:07 +01:00
|
|
|
if(toolHash.size() != 40)
|
|
|
|
{
|
|
|
|
throw "The required checksum is missing, take care!";
|
|
|
|
}
|
2011-02-25 22:03:39 +01:00
|
|
|
LockedFile *lockedFile = new LockedFile(QString(":/tools/%1").arg(toolName), QString(lamexp_temp_folder2()).append(QString("/tool_%1").arg(toolName)), toolHash);
|
2010-12-15 22:39:18 +01:00
|
|
|
lamexp_register_tool(toolName, lockedFile, toolVersion);
|
2010-11-06 23:04:47 +01:00
|
|
|
}
|
|
|
|
catch(char *errorMsg)
|
|
|
|
{
|
2011-02-28 22:35:47 +01:00
|
|
|
qFatal("At least one of the required tools could not be extracted:\n%s", errorMsg);
|
2010-11-06 23:04:47 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-12 01:49:07 +01:00
|
|
|
if(!checksum.isEmpty())
|
|
|
|
{
|
|
|
|
qFatal("At least one required tool could not be found:\n%s", toolsDir.filePath(checksum.keys().first()).toLatin1().constData());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-11-06 23:04:47 +01:00
|
|
|
qDebug("All extracted.\n");
|
2010-11-11 22:58:02 +01:00
|
|
|
|
2011-01-25 01:41:57 +01:00
|
|
|
//Check delay
|
|
|
|
double delayExtract = static_cast<double>(timer.elapsed()) / 1000.0;
|
|
|
|
if(delayExtract > 8.0)
|
|
|
|
{
|
|
|
|
qWarning("Extracting tools took %.3f seconds -> probably slow realtime virus scanner.", delayExtract);
|
|
|
|
qWarning("Please report performance problems to your anti-virus developer !!!\n");
|
|
|
|
}
|
|
|
|
|
2011-01-04 19:58:18 +01:00
|
|
|
//Register all translations
|
|
|
|
initTranslations();
|
|
|
|
|
2010-11-11 22:58:02 +01:00
|
|
|
//Look for Nero encoder
|
2010-11-12 15:58:53 +01:00
|
|
|
initNeroAac();
|
|
|
|
|
2010-12-12 13:44:11 +01:00
|
|
|
//Look for WMA File decoder
|
|
|
|
initWmaDec();
|
|
|
|
|
2010-11-12 15:58:53 +01:00
|
|
|
delay();
|
|
|
|
m_bSuccess = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
// PUBLIC FUNCTIONS
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void InitializationThread::delay(void)
|
|
|
|
{
|
|
|
|
const char *temp = "|/-\\";
|
|
|
|
printf("Thread is doing something important... ?\b", temp[4]);
|
|
|
|
|
|
|
|
for(int i = 0; i < 20; i++)
|
|
|
|
{
|
|
|
|
printf("%c\b", temp[i%4]);
|
2011-01-25 01:41:57 +01:00
|
|
|
msleep(25);
|
2010-11-12 15:58:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
printf("Done\n\n");
|
|
|
|
}
|
|
|
|
|
2011-01-04 19:58:18 +01:00
|
|
|
void InitializationThread::initTranslations(void)
|
|
|
|
{
|
|
|
|
//Search for language files
|
|
|
|
QStringList qmFiles = QDir(":/localization").entryList(QStringList() << "LameXP_??.qm", QDir::Files, QDir::Name);
|
|
|
|
|
|
|
|
//Make sure we found at least one translation
|
|
|
|
if(qmFiles.count() < 1)
|
|
|
|
{
|
|
|
|
qFatal("Could not find any translation files!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Add all available translations
|
|
|
|
while(!qmFiles.isEmpty())
|
|
|
|
{
|
|
|
|
QString langId, langName;
|
|
|
|
unsigned int systemId = 0;
|
|
|
|
QString qmFile = qmFiles.takeFirst();
|
|
|
|
|
|
|
|
QRegExp langIdExp("LameXP_(\\w\\w)\\.qm", Qt::CaseInsensitive);
|
|
|
|
if(langIdExp.indexIn(qmFile) >= 0)
|
|
|
|
{
|
|
|
|
langId = langIdExp.cap(1).toLower();
|
|
|
|
}
|
|
|
|
|
|
|
|
QResource langRes = (QString(":/localization/%1.txt").arg(qmFile));
|
|
|
|
if(langRes.isValid() && langRes.size() > 0)
|
|
|
|
{
|
|
|
|
QStringList langInfo = QString::fromUtf8(reinterpret_cast<const char*>(langRes.data()), langRes.size()).simplified().split(",", QString::SkipEmptyParts);
|
|
|
|
if(langInfo.count() == 2)
|
|
|
|
{
|
|
|
|
systemId = langInfo.at(0).toUInt();
|
|
|
|
langName = langInfo.at(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(lamexp_translation_register(langId, qmFile, langName, systemId))
|
|
|
|
{
|
2011-03-12 21:58:46 +01:00
|
|
|
qDebug64("Registering translation: %1 = %2 (%3)", qmFile, langName, QString::number(systemId));
|
2011-01-04 19:58:18 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qWarning("Failed to register: %s", qmFile.toLatin1().constData());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
qDebug("All registered.\n");
|
|
|
|
}
|
|
|
|
|
2010-11-12 15:58:53 +01:00
|
|
|
void InitializationThread::initNeroAac(void)
|
|
|
|
{
|
2010-11-11 22:58:02 +01:00
|
|
|
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()));
|
|
|
|
|
|
|
|
bool neroFilesFound = true;
|
|
|
|
for(int i = 0; i < 3; i++) { if(!neroFileInfo[i].exists()) neroFilesFound = false; }
|
|
|
|
|
|
|
|
//Lock the Nero binaries
|
2010-11-12 15:58:53 +01:00
|
|
|
if(!neroFilesFound)
|
2010-11-11 22:58:02 +01:00
|
|
|
{
|
2010-11-12 15:58:53 +01:00
|
|
|
qDebug("Nero encoder binaries not found -> AAC encoding support will be disabled!\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-11-15 22:07:46 +01:00
|
|
|
qDebug("Found Nero AAC encoder binary:\n%s\n", neroFileInfo[0].canonicalFilePath().toUtf8().constData());
|
2010-11-12 15:58:53 +01:00
|
|
|
|
|
|
|
LockedFile *neroBin[3];
|
|
|
|
for(int i = 0; i < 3; i++) neroBin[i] = NULL;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
for(int i = 0; i < 3; i++)
|
|
|
|
{
|
2010-11-15 22:07:46 +01:00
|
|
|
neroBin[i] = new LockedFile(neroFileInfo[i].canonicalFilePath());
|
2010-11-12 15:58:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(...)
|
|
|
|
{
|
|
|
|
for(int i = 0; i < 3; i++) LAMEXP_DELETE(neroBin[i]);
|
2010-11-20 19:16:04 +01:00
|
|
|
qWarning("Failed to get excluive lock to Nero encoder binary -> AAC encoding support will be disabled!");
|
2010-11-12 15:58:53 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QProcess process;
|
|
|
|
process.setProcessChannelMode(QProcess::MergedChannels);
|
|
|
|
process.setReadChannel(QProcess::StandardOutput);
|
2010-11-20 16:17:51 +01:00
|
|
|
process.start(neroFileInfo[0].canonicalFilePath(), QStringList() << "-help");
|
2010-11-12 15:58:53 +01:00
|
|
|
|
|
|
|
if(!process.waitForStarted())
|
|
|
|
{
|
|
|
|
qWarning("Nero process failed to create!");
|
2010-11-18 22:37:35 +01:00
|
|
|
qWarning("Error message: \"%s\"\n", process.errorString().toLatin1().constData());
|
2010-11-12 15:58:53 +01:00
|
|
|
process.kill();
|
|
|
|
process.waitForFinished(-1);
|
|
|
|
for(int i = 0; i < 3; i++) LAMEXP_DELETE(neroBin[i]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int neroVersion = 0;
|
|
|
|
|
|
|
|
while(process.state() != QProcess::NotRunning)
|
|
|
|
{
|
|
|
|
if(!process.waitForReadyRead())
|
2010-11-11 22:58:02 +01:00
|
|
|
{
|
2010-11-12 15:58:53 +01:00
|
|
|
if(process.state() == QProcess::Running)
|
|
|
|
{
|
|
|
|
qWarning("Nero process time out -> killing!");
|
|
|
|
process.kill();
|
|
|
|
process.waitForFinished(-1);
|
|
|
|
for(int i = 0; i < 3; i++) LAMEXP_DELETE(neroBin[i]);
|
|
|
|
return;
|
|
|
|
}
|
2010-11-11 22:58:02 +01:00
|
|
|
}
|
2010-11-12 15:58:53 +01:00
|
|
|
|
2010-11-18 22:37:35 +01:00
|
|
|
while(process.canReadLine())
|
2010-11-11 22:58:02 +01:00
|
|
|
{
|
2010-11-18 22:37:35 +01:00
|
|
|
QString line = QString::fromUtf8(process.readLine().constData()).simplified();
|
2010-11-12 15:58:53 +01:00
|
|
|
QStringList tokens = line.split(" ", QString::SkipEmptyParts, Qt::CaseInsensitive);
|
|
|
|
int index1 = tokens.indexOf("Package");
|
|
|
|
int index2 = tokens.indexOf("version:");
|
|
|
|
if(index1 >= 0 && index2 >= 0 && index1 + 1 == index2 && index2 < tokens.count() - 1)
|
|
|
|
{
|
|
|
|
QStringList versionTokens = tokens.at(index2 + 1).split(".", QString::SkipEmptyParts, Qt::CaseInsensitive);
|
|
|
|
if(versionTokens.count() == 4)
|
|
|
|
{
|
|
|
|
neroVersion = 0;
|
2010-11-19 21:11:54 +01:00
|
|
|
neroVersion += min(9, max(0, versionTokens.at(3).toInt()));
|
|
|
|
neroVersion += min(9, max(0, versionTokens.at(2).toInt())) * 10;
|
|
|
|
neroVersion += min(9, max(0, versionTokens.at(1).toInt())) * 100;
|
|
|
|
neroVersion += min(9, max(0, versionTokens.at(0).toInt())) * 1000;
|
2010-11-12 15:58:53 +01:00
|
|
|
}
|
|
|
|
}
|
2010-11-11 22:58:02 +01:00
|
|
|
}
|
|
|
|
}
|
2010-11-12 15:58:53 +01:00
|
|
|
|
|
|
|
if(!(neroVersion > 0))
|
2010-11-11 22:58:02 +01:00
|
|
|
{
|
2010-12-14 01:25:13 +01:00
|
|
|
qWarning("Nero AAC version could not be determined -> AAC encoding support will be disabled!");
|
2010-11-12 15:58:53 +01:00
|
|
|
for(int i = 0; i < 3; i++) LAMEXP_DELETE(neroBin[i]);
|
|
|
|
return;
|
2010-11-11 22:58:02 +01:00
|
|
|
}
|
2010-11-06 23:04:47 +01:00
|
|
|
|
2010-11-12 15:58:53 +01:00
|
|
|
for(int i = 0; i < 3; i++)
|
|
|
|
{
|
|
|
|
lamexp_register_tool(neroFileInfo[i].fileName(), neroBin[i], neroVersion);
|
|
|
|
}
|
2010-11-06 23:04:47 +01:00
|
|
|
}
|
|
|
|
|
2010-12-12 13:44:11 +01:00
|
|
|
|
|
|
|
void InitializationThread::initWmaDec(void)
|
|
|
|
{
|
|
|
|
static const char* wmaDecoderComponentPath = "NCH Software/Components/wmawav/wmawav.exe";
|
|
|
|
|
|
|
|
LockedFile *wmaFileBin = NULL;
|
2010-12-15 18:43:21 +01:00
|
|
|
QFileInfo wmaFileInfo = QFileInfo(QString("%1/%2").arg(lamexp_known_folder(lamexp_folder_programfiles), wmaDecoderComponentPath));
|
2010-12-12 13:44:11 +01:00
|
|
|
|
|
|
|
if(!wmaFileInfo.exists())
|
|
|
|
{
|
|
|
|
qDebug("WMA File Decoder not found -> WMA decoding support will be disabled!\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
wmaFileBin = new LockedFile(wmaFileInfo.canonicalFilePath());
|
|
|
|
}
|
|
|
|
catch(...)
|
|
|
|
{
|
|
|
|
qWarning("Failed to get excluive lock to WMA File Decoder binary -> WMA decoding support will be disabled!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-12-14 01:25:13 +01:00
|
|
|
QProcess process;
|
|
|
|
process.setProcessChannelMode(QProcess::MergedChannels);
|
|
|
|
process.setReadChannel(QProcess::StandardOutput);
|
|
|
|
process.start(wmaFileInfo.canonicalFilePath(), QStringList());
|
|
|
|
|
|
|
|
if(!process.waitForStarted())
|
|
|
|
{
|
|
|
|
qWarning("WmaWav process failed to create!");
|
|
|
|
qWarning("Error message: \"%s\"\n", process.errorString().toLatin1().constData());
|
|
|
|
process.kill();
|
|
|
|
process.waitForFinished(-1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool b_wmaWavFound = false;
|
|
|
|
|
|
|
|
while(process.state() != QProcess::NotRunning)
|
|
|
|
{
|
|
|
|
if(!process.waitForReadyRead())
|
|
|
|
{
|
|
|
|
if(process.state() == QProcess::Running)
|
|
|
|
{
|
|
|
|
qWarning("WmaWav process time out -> killing!");
|
|
|
|
process.kill();
|
|
|
|
process.waitForFinished(-1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while(process.canReadLine())
|
|
|
|
{
|
|
|
|
QString line = QString::fromUtf8(process.readLine().constData()).simplified();
|
|
|
|
if(line.contains("Usage: wmatowav.exe WMAFileSpec WAVFileSpec", Qt::CaseInsensitive))
|
|
|
|
{
|
|
|
|
b_wmaWavFound = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!b_wmaWavFound)
|
|
|
|
{
|
|
|
|
qWarning("WmaWav could not be identified -> WMA decoding support will be disabled!\n");
|
|
|
|
LAMEXP_DELETE(wmaFileBin);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
qDebug("Found WMA File Decoder binary:\n%s\n", wmaFileInfo.canonicalFilePath().toUtf8().constData());
|
|
|
|
|
2010-12-12 13:44:11 +01:00
|
|
|
if(wmaFileBin)
|
|
|
|
{
|
|
|
|
lamexp_register_tool(wmaFileInfo.fileName(), wmaFileBin);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-06 23:04:47 +01:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
// EVENTS
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/*NONE*/
|