Updated MediaInfo and wma2wav binaries. Now compiled with new stdout/stderr Unicode...
[LameXP.git] / src / Thread_Initialization.cpp
blobc79f36bf3e3f60ed8e1d18db3b876e512ce068bb
1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2011 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License along
16 // with this program; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 // http://www.gnu.org/licenses/gpl-2.0.txt
20 ///////////////////////////////////////////////////////////////////////////////
22 #include "Thread_Initialization.h"
24 #include "LockedFile.h"
26 #include <QFileInfo>
27 #include <QCoreApplication>
28 #include <QProcess>
29 #include <QMap>
30 #include <QDir>
31 #include <QLibrary>
32 #include <QResource>
33 #include <QTime>
35 ////////////////////////////////////////////////////////////
36 // CPU FLags
37 ////////////////////////////////////////////////////////////
39 /* CPU_TYPE_<ARCH>_<TYPE> */
41 #define CPU_TYPE_X86_GEN 0x00000001UL //x86, no enhanced instruction set
42 #define CPU_TYPE_X86_SSE 0x00000002UL //x86, with SSE and SSE2 support (Intel only!)
43 #define CPU_TYPE_X64_GEN 0x00000004UL //x64, generic (x64 always includes SSE2)
45 #define CPU_TYPE_X86_ALL (CPU_TYPE_X86_GEN|CPU_TYPE_X86_SSE) //all x86 CPU's, but not x64)
46 #define CPU_TYPE_ALL_SSE (CPU_TYPE_X86_SSE|CPU_TYPE_X64_GEN) //all SSE2-capable CPU's (x86 and x64)
47 #define CPU_TYPE_ALL_ALL (CPU_TYPE_X86_ALL|CPU_TYPE_X64_GEN) //all CPU's, no exceptions
49 #define IS_CPU_TYPE_X64_GEN (m_cpuFeatures.x64 && m_cpuFeatures.sse && m_cpuFeatures.sse2)
50 #define IS_CPU_TYPE_X86_SSE (m_cpuFeatures.intel && m_cpuFeatures.sse && m_cpuFeatures.sse2)
52 ////////////////////////////////////////////////////////////
53 // TOOLS
54 ////////////////////////////////////////////////////////////
56 static const struct
58 char *pcHash;
59 unsigned int uiCpuType;
60 char *pcName;
61 unsigned int uiVersion;
63 g_lamexp_tools[] =
65 {"1e4c983fe00ccc6236ee1c3f76250f64139cf86a6f4aa68f36929907fe45cf37b00862d8", CPU_TYPE_X86_GEN, "aften.i386.exe", 8},
66 {"7c843f1eaf61823285237911493d8d20da11149853d4bb7953a3279196f6dbbd310c61e3", CPU_TYPE_X86_SSE, "aften.sse2.exe", 8},
67 {"29da0d3e810bc3e8d2cddb3db452325eefca0d0c1fff1379fa17806ad447752be1b88e2f", CPU_TYPE_X64_GEN, "aften.x64.exe", 8},
68 {"1cca303fabd889a18fc01c32a7fd861194cfcac60ba63740ea2d7c55d049dbf8f59259fa", CPU_TYPE_ALL_ALL, "alac.exe", 20},
69 {"6d22d4bbd7ce2162e38f70ac9187bc84eb28233b36ee6c0492d0a6195318782d7f05c444", CPU_TYPE_ALL_ALL, "avs2wav.exe", 13},
70 {"9b9cd7b7ee180ed9eec1ff61584b4c6a941e72e928140e1cada124bd5974b2a38bfe469e", CPU_TYPE_ALL_ALL, "elevator.exe", UINT_MAX},
71 {"9ae98a3fc779f69ee876a3b477fbc35a709ba5066823b2eb62eeb015057c38807e4be51f", CPU_TYPE_ALL_ALL, "faad.exe", 27},
72 {"446054f9a7f705f1aadc9053ca7b8a86a775499ef159978954ebdea92de056c34f8841f7", CPU_TYPE_ALL_ALL, "flac.exe", 121},
73 {"dd68d074c5e13a607580f3a24595c0f3882e37211d2ca628f46e6df20fabcc832dad488a", CPU_TYPE_ALL_ALL, "gpgv.exe", 1411},
74 {"b3fca757b3567dab75c042e62213c231de378ea0fdd7fe29b733417cd5d3d33558452f94", CPU_TYPE_ALL_ALL, "gpgv.gpg", UINT_MAX},
75 {"df995d8a9e4e5fab551d0e3460b9209320714dead70f662929fcc00a4bd72d8a6d23844a", CPU_TYPE_X86_GEN, "lame.i386.exe", 3990},
76 {"873faeddc44243b4712cd42dd0bfc3174a07113d245dd834657519ffe5dbd4b1e395ce32", CPU_TYPE_ALL_SSE, "lame.sse2.exe", 3990},
77 {"67933924d68ce319795989648f29e7bd1abaac4ec09c26cbb0ff0d15a67a9df17e257933", CPU_TYPE_ALL_ALL, "mac.exe", 406},
78 {"a521603c070cbd91a54df54bbaf0d74336a61e9cf527b98eb2ee62c2ab424e6b834e3292", CPU_TYPE_X86_ALL, "mediainfo.i386.exe", 750},
79 {"6ca4f3c6e15df2e2091257d6f2647372e419e375ea914094c5f631d7d54c07375e685335", CPU_TYPE_X64_GEN, "mediainfo.x64.exe", 750},
80 {"a93ec86187025e66fb78026af35555bd3b4e30fe1a40e8d66f600cfd918f07f431f0b2f2", CPU_TYPE_ALL_ALL, "mpcdec.exe", 435},
81 {"5a89768010efb1ddfd88ccc378a89433ceaecb403a7b1f83f8716f6848d9a05b3d3c6d93", CPU_TYPE_ALL_ALL, "mpg123.exe", 1133},
82 {"0c781805dda931c529bd16069215f616a7a4c5e5c2dfb6b75fe85d52b20511830693e528", CPU_TYPE_ALL_ALL, "oggdec.exe", UINT_MAX},
83 {"0c019e13450dc664987e21f4e5489d182be7d6d0d81efbbaaf1c78693dfe3e38e0355b93", CPU_TYPE_X86_GEN, "oggenc2.i386.exe", 287603},
84 {"693dd6f779df70a047c15c2c79350855db38d5b0cd7e529b6877b7c821cfe6addfdd50a4", CPU_TYPE_X86_SSE, "oggenc2.sse2.exe", 287603},
85 {"32cb0b2182488e5e9278ba6b9fc9141214c7546eec67ee02fa895810b0e56900368695be", CPU_TYPE_X64_GEN, "oggenc2.x64.exe", 287603},
86 {"58c2b8bcff8f27bfa8fab8172b80f5da731221d072c7dba4dd3a3d7d6423490a25dc6760", CPU_TYPE_ALL_ALL, "shorten.exe", 361},
87 {"abdf9b20a8031a09d0abca9cb10c31c8418f72403b5d1350fd69bfa34041591aca3060ab", CPU_TYPE_ALL_ALL, "sox.exe", 1432},
88 {"48e7f81c024cd17dac0eaeab253aad6b223e72dc80688f7576276b0563209514ff0bb9c8", CPU_TYPE_ALL_ALL, "speexdec.exe", 12},
89 {"9b50cf64747d4afbad5d8d9b5a0a2d41c5a58256f47ebdbd8cc920e7e576085dfe1b14ff", CPU_TYPE_ALL_ALL, "tta.exe", 21},
90 {"875871c942846f6ad163f9e4949bba2f4331bec678ca5aefe58c961b6825bd0d419a078b", CPU_TYPE_ALL_ALL, "valdec.exe", 31},
91 {"e657331e281840878a37eb4fb357cb79f33d528ddbd5f9b2e2f7d2194bed4720e1af8eaf", CPU_TYPE_ALL_ALL, "wget.exe", 1114},
92 {"8923cf65e181f8a99f28e9d1ea0d89ace02142241a7f76dae3d540ffd0790495af815644", CPU_TYPE_ALL_ALL, "wma2wav.exe", 20111001},
93 {"e3b14951b7121f12fa656c70488db6df5d07862effa243a3f3f93398ae9265bc684b74c2", CPU_TYPE_ALL_ALL, "wupdate.exe", 20110929},
94 {"6b053b37d47a9c8659ebf2de43ad19dcba17b9cd868b26974b9cc8c27b6167e8bf07a5a2", CPU_TYPE_ALL_ALL, "wvunpack.exe", 4601},
95 {NULL, NULL, NULL, NULL}
98 static const double g_allowedExtractDelay = 10.0;
100 ////////////////////////////////////////////////////////////
101 // Constructor
102 ////////////////////////////////////////////////////////////
104 InitializationThread::InitializationThread(const lamexp_cpu_t *cpuFeatures)
106 m_bSuccess = false;
107 memset(&m_cpuFeatures, 0, sizeof(lamexp_cpu_t));
108 m_slowIndicator = false;
110 if(cpuFeatures)
112 memcpy(&m_cpuFeatures, cpuFeatures, sizeof(lamexp_cpu_t));
116 ////////////////////////////////////////////////////////////
117 // Thread Main
118 ////////////////////////////////////////////////////////////
120 void InitializationThread::run()
122 m_bSuccess = false;
123 bool bCustom = false;
124 delay();
126 //CPU type selection
127 const unsigned int cpuSupport = IS_CPU_TYPE_X64_GEN ? CPU_TYPE_X64_GEN : (IS_CPU_TYPE_X86_SSE ? CPU_TYPE_X86_SSE : CPU_TYPE_X86_GEN);
129 //Allocate maps
130 QMap<QString, QString> mapChecksum;
131 QMap<QString, unsigned int> mapVersion;
132 QMap<QString, unsigned int> mapCpuType;
134 //Init properties
135 for(int i = 0; i < INT_MAX; i++)
137 if(!g_lamexp_tools[i].pcName && !g_lamexp_tools[i].pcHash && !g_lamexp_tools[i].uiVersion)
139 break;
141 else if(g_lamexp_tools[i].pcName && g_lamexp_tools[i].pcHash && g_lamexp_tools[i].uiVersion)
143 const QString currentTool = QString::fromLatin1(g_lamexp_tools[i].pcName);
144 mapChecksum.insert(currentTool, QString::fromLatin1(g_lamexp_tools[i].pcHash));
145 mapCpuType.insert(currentTool, g_lamexp_tools[i].uiCpuType);
146 mapVersion.insert(currentTool, g_lamexp_tools[i].uiVersion);
148 else
150 qFatal("Inconsistent checksum data detected. Take care!");
154 QDir toolsDir(":/tools/");
155 QList<QFileInfo> toolsList = toolsDir.entryInfoList(QStringList("*.*"), QDir::Files, QDir::Name);
156 QDir appDir = QDir(QCoreApplication::applicationDirPath()).canonicalPath();
158 QTime timer;
159 timer.start();
161 //Extract all files
162 while(!toolsList.isEmpty())
166 QFileInfo currentTool = toolsList.takeFirst();
167 QString toolName = currentTool.fileName().toLower();
168 QString toolShortName = QString("%1.%2").arg(currentTool.baseName().toLower(), currentTool.suffix().toLower());
170 QByteArray toolHash = mapChecksum.take(toolName).toLatin1();
171 unsigned int toolCpuType = mapCpuType.take(toolName);
172 unsigned int toolVersion = mapVersion.take(toolName);
174 if(toolHash.size() != 72)
176 throw "The required checksum is missing, take care!";
179 if(toolCpuType & cpuSupport)
181 QFileInfo customTool(QString("%1/tools/%2/%3").arg(appDir.canonicalPath(), QString::number(lamexp_version_build()), toolShortName));
182 if(customTool.exists() && customTool.isFile())
184 bCustom = true;
185 qDebug("Setting up file: %s <- %s", toolShortName.toLatin1().constData(), appDir.relativeFilePath(customTool.canonicalFilePath()).toLatin1().constData());
186 LockedFile *lockedFile = new LockedFile(customTool.canonicalFilePath());
187 lamexp_register_tool(toolShortName, lockedFile, UINT_MAX);
189 else
191 qDebug("Extracting file: %s -> %s", toolName.toLatin1().constData(), toolShortName.toLatin1().constData());
192 LockedFile *lockedFile = new LockedFile(QString(":/tools/%1").arg(toolName), QString("%1/tool_%2").arg(lamexp_temp_folder2(), toolShortName), toolHash);
193 lamexp_register_tool(toolShortName, lockedFile, toolVersion);
197 catch(char *errorMsg)
199 qFatal("At least one of the required tools could not be initialized:\n%s", errorMsg);
200 return;
204 //Make sure all files were extracted
205 if(!mapChecksum.isEmpty())
207 qFatal("At least one required tool could not be found:\n%s", toolsDir.filePath(mapChecksum.keys().first()).toLatin1().constData());
208 return;
211 qDebug("All extracted.\n");
213 //Clean-up
214 mapChecksum.clear();
215 mapVersion.clear();
216 mapCpuType.clear();
218 //Using any custom tools?
219 if(bCustom)
221 qWarning("Warning: Using custom tools, you might encounter unexpected problems!\n");
224 //Check delay
225 double delayExtract = static_cast<double>(timer.elapsed()) / 1000.0;
226 if(delayExtract > g_allowedExtractDelay)
228 m_slowIndicator = true;
229 qWarning("Extracting tools took %.3f seconds -> probably slow realtime virus scanner.", delayExtract);
230 qWarning("Please report performance problems to your anti-virus developer !!!\n");
233 //Register all translations
234 initTranslations();
236 //Look for Nero AAC encoder
237 initNeroAac();
239 //Look for FHG AAC encoder
240 initFhgAac();
242 delay();
243 m_bSuccess = true;
246 ////////////////////////////////////////////////////////////
247 // PUBLIC FUNCTIONS
248 ////////////////////////////////////////////////////////////
250 void InitializationThread::delay(void)
252 const char *temp = "|/-\\";
253 printf("Thread is doing something important... ?\b", temp[4]);
255 for(int i = 0; i < 20; i++)
257 printf("%c\b", temp[i%4]);
258 msleep(25);
261 printf("Done\n\n");
264 void InitializationThread::initTranslations(void)
266 //Search for language files
267 QStringList qmFiles = QDir(":/localization").entryList(QStringList() << "LameXP_??.qm", QDir::Files, QDir::Name);
269 //Make sure we found at least one translation
270 if(qmFiles.count() < 1)
272 qFatal("Could not find any translation files!");
273 return;
276 //Add all available translations
277 while(!qmFiles.isEmpty())
279 QString langId, langName;
280 unsigned int systemId = 0;
281 QString qmFile = qmFiles.takeFirst();
283 QRegExp langIdExp("LameXP_(\\w\\w)\\.qm", Qt::CaseInsensitive);
284 if(langIdExp.indexIn(qmFile) >= 0)
286 langId = langIdExp.cap(1).toLower();
289 QResource langRes = (QString(":/localization/%1.txt").arg(qmFile));
290 if(langRes.isValid() && langRes.size() > 0)
292 QStringList langInfo = QString::fromUtf8(reinterpret_cast<const char*>(langRes.data()), langRes.size()).simplified().split(",", QString::SkipEmptyParts);
293 if(langInfo.count() == 2)
295 systemId = langInfo.at(0).toUInt();
296 langName = langInfo.at(1);
300 if(lamexp_translation_register(langId, qmFile, langName, systemId))
302 qDebug("Registering translation: %s = %s (%u)", qmFile.toUtf8().constData(), langName.toUtf8().constData(), systemId);
304 else
306 qWarning("Failed to register: %s", qmFile.toLatin1().constData());
310 qDebug("All registered.\n");
313 void InitializationThread::initNeroAac(void)
315 const QString appPath = QDir(QCoreApplication::applicationDirPath()).canonicalPath();
317 QFileInfo neroFileInfo[3];
318 neroFileInfo[0] = QFileInfo(QString("%1/neroAacEnc.exe").arg(appPath));
319 neroFileInfo[1] = QFileInfo(QString("%1/neroAacDec.exe").arg(appPath));
320 neroFileInfo[2] = QFileInfo(QString("%1/neroAacTag.exe").arg(appPath));
322 bool neroFilesFound = true;
323 for(int i = 0; i < 3; i++) { if(!neroFileInfo[i].exists()) neroFilesFound = false; }
325 //Lock the Nero binaries
326 if(!neroFilesFound)
328 qDebug("Nero encoder binaries not found -> AAC encoding support will be disabled!\n");
329 return;
332 qDebug("Found Nero AAC encoder binary:\n%s\n", neroFileInfo[0].canonicalFilePath().toUtf8().constData());
334 LockedFile *neroBin[3];
335 for(int i = 0; i < 3; i++) neroBin[i] = NULL;
339 for(int i = 0; i < 3; i++)
341 neroBin[i] = new LockedFile(neroFileInfo[i].canonicalFilePath());
344 catch(...)
346 for(int i = 0; i < 3; i++) LAMEXP_DELETE(neroBin[i]);
347 qWarning("Failed to get excluive lock to Nero encoder binary -> AAC encoding support will be disabled!");
348 return;
351 QProcess process;
352 process.setProcessChannelMode(QProcess::MergedChannels);
353 process.setReadChannel(QProcess::StandardOutput);
354 process.start(neroFileInfo[0].canonicalFilePath(), QStringList() << "-help");
356 if(!process.waitForStarted())
358 qWarning("Nero process failed to create!");
359 qWarning("Error message: \"%s\"\n", process.errorString().toLatin1().constData());
360 process.kill();
361 process.waitForFinished(-1);
362 for(int i = 0; i < 3; i++) LAMEXP_DELETE(neroBin[i]);
363 return;
366 unsigned int neroVersion = 0;
368 while(process.state() != QProcess::NotRunning)
370 if(!process.waitForReadyRead())
372 if(process.state() == QProcess::Running)
374 qWarning("Nero process time out -> killing!");
375 process.kill();
376 process.waitForFinished(-1);
377 for(int i = 0; i < 3; i++) LAMEXP_DELETE(neroBin[i]);
378 return;
382 while(process.canReadLine())
384 QString line = QString::fromUtf8(process.readLine().constData()).simplified();
385 QStringList tokens = line.split(" ", QString::SkipEmptyParts, Qt::CaseInsensitive);
386 int index1 = tokens.indexOf("Package");
387 int index2 = tokens.indexOf("version:");
388 if(index1 >= 0 && index2 >= 0 && index1 + 1 == index2 && index2 < tokens.count() - 1)
390 QStringList versionTokens = tokens.at(index2 + 1).split(".", QString::SkipEmptyParts, Qt::CaseInsensitive);
391 if(versionTokens.count() == 4)
393 neroVersion = 0;
394 neroVersion += min(9, max(0, versionTokens.at(3).toInt()));
395 neroVersion += min(9, max(0, versionTokens.at(2).toInt())) * 10;
396 neroVersion += min(9, max(0, versionTokens.at(1).toInt())) * 100;
397 neroVersion += min(9, max(0, versionTokens.at(0).toInt())) * 1000;
403 if(!(neroVersion > 0))
405 qWarning("Nero AAC version could not be determined -> AAC encoding support will be disabled!");
406 for(int i = 0; i < 3; i++) LAMEXP_DELETE(neroBin[i]);
407 return;
410 for(int i = 0; i < 3; i++)
412 lamexp_register_tool(neroFileInfo[i].fileName(), neroBin[i], neroVersion);
416 void InitializationThread::initFhgAac(void)
418 const QString appPath = QDir(QCoreApplication::applicationDirPath()).canonicalPath();
420 QFileInfo fhgFileInfo[4];
421 fhgFileInfo[0] = QFileInfo(QString("%1/fhgaacenc.exe").arg(appPath));
422 fhgFileInfo[1] = QFileInfo(QString("%1/enc_fhgaac.dll").arg(appPath));
423 fhgFileInfo[2] = QFileInfo(QString("%1/nsutil.dll").arg(appPath));
424 fhgFileInfo[3] = QFileInfo(QString("%1/libmp4v2.dll").arg(appPath));
426 bool fhgFilesFound = true;
427 for(int i = 0; i < 4; i++) { if(!fhgFileInfo[i].exists()) fhgFilesFound = false; }
429 //Lock the FhgAacEnc binaries
430 if(!fhgFilesFound)
432 qDebug("FhgAacEnc binaries not found -> FhgAacEnc support will be disabled!\n");
433 return;
436 qDebug("Found FhgAacEnc cli_exe:\n%s\n", fhgFileInfo[0].canonicalFilePath().toUtf8().constData());
437 qDebug("Found FhgAacEnc enc_dll:\n%s\n", fhgFileInfo[1].canonicalFilePath().toUtf8().constData());
439 LockedFile *fhgBin[4];
440 for(int i = 0; i < 4; i++) fhgBin[i] = NULL;
444 for(int i = 0; i < 4; i++)
446 fhgBin[i] = new LockedFile(fhgFileInfo[i].canonicalFilePath());
449 catch(...)
451 for(int i = 0; i < 4; i++) LAMEXP_DELETE(fhgBin[i]);
452 qWarning("Failed to get excluive lock to FhgAacEnc binary -> FhgAacEnc support will be disabled!");
453 return;
456 QProcess process;
457 process.setProcessChannelMode(QProcess::MergedChannels);
458 process.setReadChannel(QProcess::StandardOutput);
459 process.start(fhgFileInfo[0].canonicalFilePath(), QStringList() << "--version");
461 if(!process.waitForStarted())
463 qWarning("FhgAacEnc process failed to create!");
464 qWarning("Error message: \"%s\"\n", process.errorString().toLatin1().constData());
465 process.kill();
466 process.waitForFinished(-1);
467 for(int i = 0; i < 4; i++) LAMEXP_DELETE(fhgBin[i]);
468 return;
471 QRegExp fhgAacEncSig("fhgaacenc version (\\d+) by tmkk", Qt::CaseInsensitive);
472 unsigned int fhgVersion = 0;
474 while(process.state() != QProcess::NotRunning)
476 process.waitForReadyRead();
477 if(!process.bytesAvailable() && process.state() == QProcess::Running)
479 qWarning("FhgAacEnc process time out -> killing!");
480 process.kill();
481 process.waitForFinished(-1);
482 for(int i = 0; i < 4; i++) LAMEXP_DELETE(fhgBin[i]);
483 return;
485 while(process.bytesAvailable() > 0)
487 QString line = QString::fromUtf8(process.readLine().constData()).simplified();
488 if(fhgAacEncSig.lastIndexIn(line) >= 0)
490 bool ok = false;
491 unsigned int temp = fhgAacEncSig.cap(1).toUInt(&ok);
492 if(ok) fhgVersion = temp;
497 if(!(fhgVersion > 0))
499 qWarning("FhgAacEnc version couldn't be determined -> FhgAacEnc support will be disabled!");
500 for(int i = 0; i < 4; i++) LAMEXP_DELETE(fhgBin[i]);
501 return;
503 else if(fhgVersion < lamexp_toolver_fhgaacenc())
505 qWarning("FhgAacEnc version is too much outdated -> FhgAacEnc support will be disabled!");
506 for(int i = 0; i < 4; i++) LAMEXP_DELETE(fhgBin[i]);
507 return;
510 for(int i = 0; i < 4; i++)
512 lamexp_register_tool(fhgFileInfo[i].fileName(), fhgBin[i], fhgVersion);
516 //void InitializationThread::initWmaDec(void)
518 // static const char* wmaDecoderComponentPath = "NCH Software/Components/wmawav/wmawav.exe";
520 // LockedFile *wmaFileBin = NULL;
521 // QFileInfo wmaFileInfo = QFileInfo(QString("%1/%2").arg(lamexp_known_folder(lamexp_folder_programfiles), wmaDecoderComponentPath));
523 // if(!(wmaFileInfo.exists() && wmaFileInfo.isFile()))
524 // {
525 // wmaFileInfo.setFile(QString("%1/%2").arg(QDir(QCoreApplication::applicationDirPath()).canonicalPath(), "wmawav.exe"));
526 // }
527 // if(!(wmaFileInfo.exists() && wmaFileInfo.isFile()))
528 // {
529 // qDebug("WMA File Decoder not found -> WMA decoding support will be disabled!\n");
530 // return;
531 // }
533 // try
534 // {
535 // wmaFileBin = new LockedFile(wmaFileInfo.canonicalFilePath());
536 // }
537 // catch(...)
538 // {
539 // qWarning("Failed to get excluive lock to WMA File Decoder binary -> WMA decoding support will be disabled!");
540 // return;
541 // }
543 // QProcess process;
544 // process.setProcessChannelMode(QProcess::MergedChannels);
545 // process.setReadChannel(QProcess::StandardOutput);
546 // process.start(wmaFileInfo.canonicalFilePath(), QStringList());
548 // if(!process.waitForStarted())
549 // {
550 // qWarning("WmaWav process failed to create!");
551 // qWarning("Error message: \"%s\"\n", process.errorString().toLatin1().constData());
552 // process.kill();
553 // process.waitForFinished(-1);
554 // return;
555 // }
557 // bool b_wmaWavFound = false;
559 // while(process.state() != QProcess::NotRunning)
560 // {
561 // if(!process.waitForReadyRead())
562 // {
563 // if(process.state() == QProcess::Running)
564 // {
565 // qWarning("WmaWav process time out -> killing!");
566 // process.kill();
567 // process.waitForFinished(-1);
568 // return;
569 // }
570 // }
571 // while(process.canReadLine())
572 // {
573 // QString line = QString::fromUtf8(process.readLine().constData()).simplified();
574 // if(line.contains("Usage: wmatowav.exe WMAFileSpec WAVFileSpec", Qt::CaseInsensitive))
575 // {
576 // b_wmaWavFound = true;
577 // }
578 // }
579 // }
581 // if(!b_wmaWavFound)
582 // {
583 // qWarning("WmaWav could not be identified -> WMA decoding support will be disabled!\n");
584 // LAMEXP_DELETE(wmaFileBin);
585 // return;
586 // }
588 // qDebug("Found WMA File Decoder binary:\n%s\n", wmaFileInfo.canonicalFilePath().toUtf8().constData());
590 // if(wmaFileBin)
591 // {
592 // lamexp_register_tool(wmaFileInfo.fileName(), wmaFileBin);
593 // }
596 ////////////////////////////////////////////////////////////
597 // EVENTS
598 ////////////////////////////////////////////////////////////
600 /*NONE*/