1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2013 LoRd_MuldeR <MuldeR2@GMX.de>
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.
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"
28 #include <QCoreApplication>
35 #include <QTextStream>
37 #include <QThreadPool>
41 #define PRINT_CPU_TYPE(X) case X: qDebug("Selected CPU is: " #X)
42 static const double g_allowedExtractDelay
= 12.0;
44 ////////////////////////////////////////////////////////////
45 // ExtractorTask class
46 ////////////////////////////////////////////////////////////
48 class ExtractorTask
: public QRunnable
51 ExtractorTask(const QDir
&appDir
, const QString
&toolName
, const QString
&toolShortName
, const QByteArray
&toolHash
, const unsigned int toolVersion
, const QString
&toolTag
)
53 QRunnable(), m_appDir(appDir
), m_toolName(toolName
), m_toolShortName(toolShortName
), m_toolHash(toolHash
), m_toolVersion(toolVersion
), m_toolTag(toolTag
)
58 static void clearFlags(void)
60 s_bAbort
= s_bCustom
= false;
64 static bool getAbort(void) { return s_bAbort
; }
65 static bool getCustom(void) { return s_bCustom
; }
66 static char *const getError(void) { return s_errMsg
; }
73 LockedFile
*lockedFile
= NULL
;
74 unsigned int version
= m_toolVersion
;
78 QFileInfo
customTool(QString("%1/tools/%2/%3").arg(m_appDir
.canonicalPath(), QString::number(lamexp_version_build()), m_toolShortName
));
79 if(customTool
.exists() && customTool
.isFile())
81 qDebug("Setting up file: %s <- %s", m_toolShortName
.toLatin1().constData(), m_appDir
.relativeFilePath(customTool
.canonicalFilePath()).toLatin1().constData());
82 lockedFile
= new LockedFile(customTool
.canonicalFilePath()); version
= UINT_MAX
; s_bCustom
= true;
86 qDebug("Extracting file: %s -> %s", m_toolName
.toLatin1().constData(), m_toolShortName
.toLatin1().constData());
87 lockedFile
= new LockedFile(QString(":/tools/%1").arg(m_toolName
), QString("%1/lxp_%2").arg(lamexp_temp_folder2(), m_toolShortName
), m_toolHash
);
92 QMutexLocker
lock(&s_mutex
);
93 lamexp_register_tool(m_toolShortName
, lockedFile
, version
, &m_toolTag
);
99 qWarning("At least one of the required tools could not be initialized:\n%s", errorMsg
);
100 if(s_mutex
.tryLock())
102 if(!s_bAbort
) { s_bAbort
= true; strncpy_s(s_errMsg
, 1024, errorMsg
, _TRUNCATE
); }
110 const QString m_toolName
;
111 const QString m_toolShortName
;
112 const QString m_toolTag
;
113 const QByteArray m_toolHash
;
114 const unsigned int m_toolVersion
;
116 static volatile bool s_bAbort
;
117 static volatile bool s_bCustom
;
118 static QMutex s_mutex
;
119 static char s_errMsg
[1024];
122 volatile bool ExtractorTask::s_bAbort
= false;
123 volatile bool ExtractorTask::s_bCustom
= false;
124 char ExtractorTask::s_errMsg
[1024] = {'\0'};
125 QMutex
ExtractorTask::s_mutex
;
127 ////////////////////////////////////////////////////////////
129 ////////////////////////////////////////////////////////////
131 InitializationThread::InitializationThread(const lamexp_cpu_t
*cpuFeatures
)
134 memset(&m_cpuFeatures
, 0, sizeof(lamexp_cpu_t
));
135 m_slowIndicator
= false;
139 memcpy(&m_cpuFeatures
, cpuFeatures
, sizeof(lamexp_cpu_t
));
143 ////////////////////////////////////////////////////////////
145 ////////////////////////////////////////////////////////////
147 void InitializationThread::run()
153 unsigned int cpuSupport
= 0;
154 if(m_cpuFeatures
.sse
&& m_cpuFeatures
.sse2
&& m_cpuFeatures
.intel
)
156 cpuSupport
= m_cpuFeatures
.x64
? CPU_TYPE_X64_SSE
: CPU_TYPE_X86_SSE
;
160 cpuSupport
= m_cpuFeatures
.x64
? CPU_TYPE_X64_GEN
: CPU_TYPE_X86_GEN
;
163 //Hack to disable x64 on Wine, as x64 binaries won't run under Wine (tested with Wine 1.4 under Ubuntu 12.04 x64)
164 if(cpuSupport
& CPU_TYPE_X64_ALL
)
166 //DWORD osVerNo = lamexp_get_os_version();
167 //if((HIWORD(osVerNo) == 6) && (LOWORD(osVerNo) == 2))
168 if(lamexp_detect_wine())
170 qWarning("Running under Wine on a 64-Bit system. Going to disable all x64 support!\n");
171 cpuSupport
= (cpuSupport
== CPU_TYPE_X64_SSE
) ? CPU_TYPE_X86_SSE
: CPU_TYPE_X86_GEN
;
175 //Print selected CPU type
178 PRINT_CPU_TYPE(CPU_TYPE_X86_GEN
); break;
179 PRINT_CPU_TYPE(CPU_TYPE_X86_SSE
); break;
180 PRINT_CPU_TYPE(CPU_TYPE_X64_GEN
); break;
181 PRINT_CPU_TYPE(CPU_TYPE_X64_SSE
); break;
182 default: throw "CPU support undefined!";
186 QMap
<QString
, QString
> mapChecksum
;
187 QMap
<QString
, unsigned int> mapVersion
;
188 QMap
<QString
, unsigned int> mapCpuType
;
189 QMap
<QString
, QString
> mapVersTag
;
192 for(int i
= 0; i
< INT_MAX
; i
++)
194 if(!g_lamexp_tools
[i
].pcName
&& !g_lamexp_tools
[i
].pcHash
&& !g_lamexp_tools
[i
].uiVersion
)
198 else if(g_lamexp_tools
[i
].pcName
&& g_lamexp_tools
[i
].pcHash
&& g_lamexp_tools
[i
].uiVersion
)
200 const QString currentTool
= QString::fromLatin1(g_lamexp_tools
[i
].pcName
);
201 mapChecksum
.insert(currentTool
, QString::fromLatin1(g_lamexp_tools
[i
].pcHash
));
202 mapCpuType
.insert(currentTool
, g_lamexp_tools
[i
].uiCpuType
);
203 mapVersion
.insert(currentTool
, g_lamexp_tools
[i
].uiVersion
);
204 mapVersTag
.insert(currentTool
, g_lamexp_tools
[i
].pcVersTag
);
208 qFatal("Inconsistent checksum data detected. Take care!");
212 QDir
toolsDir(":/tools/");
213 QList
<QFileInfo
> toolsList
= toolsDir
.entryInfoList(QStringList("*.*"), QDir::Files
, QDir::Name
);
214 QDir appDir
= QDir(QCoreApplication::applicationDirPath()).canonicalPath();
216 QThreadPool
*pool
= new QThreadPool();
217 int idealThreadCount
= QThread::idealThreadCount();
218 if(idealThreadCount
> 0)
220 pool
->setMaxThreadCount(idealThreadCount
* 2);
223 LockedFile::selfTest();
224 ExtractorTask::clearFlags();
230 while(!toolsList
.isEmpty())
234 QFileInfo currentTool
= toolsList
.takeFirst();
235 QString toolName
= currentTool
.fileName().toLower();
236 QString toolShortName
= QString("%1.%2").arg(currentTool
.baseName().toLower(), currentTool
.suffix().toLower());
238 QByteArray toolHash
= mapChecksum
.take(toolName
).toLatin1();
239 unsigned int toolCpuType
= mapCpuType
.take(toolName
);
240 unsigned int toolVersion
= mapVersion
.take(toolName
);
241 QString toolVersTag
= mapVersTag
.take(toolName
);
243 if(toolHash
.size() != 96)
245 throw "The required checksum is missing, take care!";
248 if(toolCpuType
& cpuSupport
)
250 pool
->start(new ExtractorTask(appDir
, toolName
, toolShortName
, toolHash
, toolVersion
, toolVersTag
));
251 QThread::yieldCurrentThread();
254 catch(char *errorMsg
)
256 qFatal("At least one of the required tools could not be initialized:\n%s", errorMsg
);
261 //Wait for extrator threads to finish
265 //Make sure all files were extracted correctly
266 if(ExtractorTask::getAbort())
268 qFatal("At least one of the required tools could not be initialized:\n%s", ExtractorTask::getError());
272 //Make sure all files were extracted
273 if(!mapChecksum
.isEmpty())
275 qFatal("At least one required tool could not be found:\n%s", toolsDir
.filePath(mapChecksum
.keys().first()).toLatin1().constData());
279 qDebug("All extracted.\n");
286 //Using any custom tools?
287 if(ExtractorTask::getCustom())
289 qWarning("Warning: Using custom tools, you might encounter unexpected problems!\n");
293 double delayExtract
= static_cast<double>(timer
.elapsed()) / 1000.0;
294 if(delayExtract
> g_allowedExtractDelay
)
296 m_slowIndicator
= true;
297 qWarning("Extracting tools took %.3f seconds -> probably slow realtime virus scanner.", delayExtract
);
298 qWarning("Please report performance problems to your anti-virus developer !!!\n");
302 qDebug("Extracting the tools took %.3f seconds (OK).\n", delayExtract
);
305 //Register all translations
308 //Look for AAC encoders
317 ////////////////////////////////////////////////////////////
319 ////////////////////////////////////////////////////////////
321 void InitializationThread::delay(void)
323 const char *temp
= "|/-\\";
324 printf("Thread is doing something important... ?\b");
326 for(int i
= 0; i
< 20; i
++)
328 printf("%c\b", temp
[i
%4]);
334 void InitializationThread::initTranslations(void)
336 //Search for language files
337 QStringList qmFiles
= QDir(":/localization").entryList(QStringList() << "LameXP_??.qm", QDir::Files
, QDir::Name
);
339 //Make sure we found at least one translation
340 if(qmFiles
.count() < 1)
342 qFatal("Could not find any translation files!");
346 //Add all available translations
347 while(!qmFiles
.isEmpty())
349 QString langId
, langName
;
350 unsigned int systemId
= 0, country
= 0;
351 QString qmFile
= qmFiles
.takeFirst();
353 QRegExp
langIdExp("LameXP_(\\w\\w)\\.qm", Qt::CaseInsensitive
);
354 if(langIdExp
.indexIn(qmFile
) >= 0)
356 langId
= langIdExp
.cap(1).toLower();
357 QResource langRes
= QResource(QString(":/localization/%1.txt").arg(qmFile
));
358 if(langRes
.isValid() && langRes
.size() > 0)
360 QByteArray data
= QByteArray::fromRawData(reinterpret_cast<const char*>(langRes
.data()), langRes
.size());
361 QTextStream
stream(&data
, QIODevice::ReadOnly
);
362 stream
.setAutoDetectUnicode(false); stream
.setCodec("UTF-8");
363 while(!stream
.atEnd())
365 QStringList langInfo
= stream
.readLine().simplified().split(",", QString::SkipEmptyParts
);
366 if(langInfo
.count() == 3)
368 systemId
= langInfo
.at(0).trimmed().toUInt();
369 country
= langInfo
.at(1).trimmed().toUInt();
370 langName
= langInfo
.at(2).trimmed();
377 if(!(langId
.isEmpty() || langName
.isEmpty() || systemId
== 0))
379 if(lamexp_translation_register(langId
, qmFile
, langName
, systemId
, country
))
381 qDebug("Registering translation: %s = %s (%u) [%u]", qmFile
.toUtf8().constData(), langName
.toUtf8().constData(), systemId
, country
);
385 qWarning("Failed to register: %s", qmFile
.toLatin1().constData());
390 qDebug("All registered.\n");
393 void InitializationThread::initNeroAac(void)
395 const QString appPath
= QDir(QCoreApplication::applicationDirPath()).canonicalPath();
397 QFileInfo neroFileInfo
[3];
398 neroFileInfo
[0] = QFileInfo(QString("%1/neroAacEnc.exe").arg(appPath
));
399 neroFileInfo
[1] = QFileInfo(QString("%1/neroAacDec.exe").arg(appPath
));
400 neroFileInfo
[2] = QFileInfo(QString("%1/neroAacTag.exe").arg(appPath
));
402 bool neroFilesFound
= true;
403 for(int i
= 0; i
< 3; i
++) { if(!neroFileInfo
[i
].exists()) neroFilesFound
= false; }
405 //Lock the Nero binaries
408 qDebug("Nero encoder binaries not found -> AAC encoding support will be disabled!\n");
412 qDebug("Found Nero AAC encoder binary:\n%s\n", neroFileInfo
[0].canonicalFilePath().toUtf8().constData());
414 LockedFile
*neroBin
[3];
415 for(int i
= 0; i
< 3; i
++) neroBin
[i
] = NULL
;
419 for(int i
= 0; i
< 3; i
++)
421 neroBin
[i
] = new LockedFile(neroFileInfo
[i
].canonicalFilePath());
426 for(int i
= 0; i
< 3; i
++) LAMEXP_DELETE(neroBin
[i
]);
427 qWarning("Failed to get excluive lock to Nero encoder binary -> AAC encoding support will be disabled!");
432 process
.setProcessChannelMode(QProcess::MergedChannels
);
433 process
.setReadChannel(QProcess::StandardOutput
);
434 process
.start(neroFileInfo
[0].canonicalFilePath(), QStringList() << "-help");
436 if(!process
.waitForStarted())
438 qWarning("Nero process failed to create!");
439 qWarning("Error message: \"%s\"\n", process
.errorString().toLatin1().constData());
441 process
.waitForFinished(-1);
442 for(int i
= 0; i
< 3; i
++) LAMEXP_DELETE(neroBin
[i
]);
446 unsigned int neroVersion
= 0;
448 while(process
.state() != QProcess::NotRunning
)
450 if(!process
.waitForReadyRead())
452 if(process
.state() == QProcess::Running
)
454 qWarning("Nero process time out -> killing!");
456 process
.waitForFinished(-1);
457 for(int i
= 0; i
< 3; i
++) LAMEXP_DELETE(neroBin
[i
]);
462 while(process
.canReadLine())
464 QString line
= QString::fromUtf8(process
.readLine().constData()).simplified();
465 QStringList tokens
= line
.split(" ", QString::SkipEmptyParts
, Qt::CaseInsensitive
);
466 int index1
= tokens
.indexOf("Package");
467 int index2
= tokens
.indexOf("version:");
468 if(index1
>= 0 && index2
>= 0 && index1
+ 1 == index2
&& index2
< tokens
.count() - 1)
470 QStringList versionTokens
= tokens
.at(index2
+ 1).split(".", QString::SkipEmptyParts
, Qt::CaseInsensitive
);
471 if(versionTokens
.count() == 4)
474 neroVersion
+= qMin(9, qMax(0, versionTokens
.at(3).toInt()));
475 neroVersion
+= qMin(9, qMax(0, versionTokens
.at(2).toInt())) * 10;
476 neroVersion
+= qMin(9, qMax(0, versionTokens
.at(1).toInt())) * 100;
477 neroVersion
+= qMin(9, qMax(0, versionTokens
.at(0).toInt())) * 1000;
483 if(!(neroVersion
> 0))
485 qWarning("Nero AAC version could not be determined -> AAC encoding support will be disabled!");
486 for(int i
= 0; i
< 3; i
++) LAMEXP_DELETE(neroBin
[i
]);
490 for(int i
= 0; i
< 3; i
++)
492 lamexp_register_tool(neroFileInfo
[i
].fileName(), neroBin
[i
], neroVersion
);
496 void InitializationThread::initFhgAac(void)
498 const QString appPath
= QDir(QCoreApplication::applicationDirPath()).canonicalPath();
500 QFileInfo fhgFileInfo
[5];
501 fhgFileInfo
[0] = QFileInfo(QString("%1/fhgaacenc.exe").arg(appPath
));
502 fhgFileInfo
[1] = QFileInfo(QString("%1/enc_fhgaac.dll").arg(appPath
));
503 fhgFileInfo
[2] = QFileInfo(QString("%1/nsutil.dll").arg(appPath
));
504 fhgFileInfo
[3] = QFileInfo(QString("%1/libmp4v2.dll").arg(appPath
));
505 fhgFileInfo
[4] = QFileInfo(QString("%1/libsndfile-1.dll").arg(appPath
));
507 bool fhgFilesFound
= true;
508 for(int i
= 0; i
< 5; i
++) { if(!fhgFileInfo
[i
].exists()) fhgFilesFound
= false; }
510 //Lock the FhgAacEnc binaries
513 qDebug("FhgAacEnc binaries not found -> FhgAacEnc support will be disabled!\n");
517 qDebug("Found FhgAacEnc cli_exe:\n%s\n", fhgFileInfo
[0].canonicalFilePath().toUtf8().constData());
518 qDebug("Found FhgAacEnc enc_dll:\n%s\n", fhgFileInfo
[1].canonicalFilePath().toUtf8().constData());
520 LockedFile
*fhgBin
[5];
521 for(int i
= 0; i
< 5; i
++) fhgBin
[i
] = NULL
;
525 for(int i
= 0; i
< 5; i
++)
527 fhgBin
[i
] = new LockedFile(fhgFileInfo
[i
].canonicalFilePath());
532 for(int i
= 0; i
< 5; i
++) LAMEXP_DELETE(fhgBin
[i
]);
533 qWarning("Failed to get excluive lock to FhgAacEnc binary -> FhgAacEnc support will be disabled!");
538 process
.setProcessChannelMode(QProcess::MergedChannels
);
539 process
.setReadChannel(QProcess::StandardOutput
);
540 process
.start(fhgFileInfo
[0].canonicalFilePath(), QStringList() << "--version");
542 if(!process
.waitForStarted())
544 qWarning("FhgAacEnc process failed to create!");
545 qWarning("Error message: \"%s\"\n", process
.errorString().toLatin1().constData());
547 process
.waitForFinished(-1);
548 for(int i
= 0; i
< 5; i
++) LAMEXP_DELETE(fhgBin
[i
]);
552 QRegExp
fhgAacEncSig("fhgaacenc version (\\d+) by tmkk", Qt::CaseInsensitive
);
553 unsigned int fhgVersion
= 0;
555 while(process
.state() != QProcess::NotRunning
)
557 process
.waitForReadyRead();
558 if(!process
.bytesAvailable() && process
.state() == QProcess::Running
)
560 qWarning("FhgAacEnc process time out -> killing!");
562 process
.waitForFinished(-1);
563 for(int i
= 0; i
< 5; i
++) LAMEXP_DELETE(fhgBin
[i
]);
566 while(process
.bytesAvailable() > 0)
568 QString line
= QString::fromUtf8(process
.readLine().constData()).simplified();
569 if(fhgAacEncSig
.lastIndexIn(line
) >= 0)
572 unsigned int temp
= fhgAacEncSig
.cap(1).toUInt(&ok
);
573 if(ok
) fhgVersion
= temp
;
578 if(!(fhgVersion
> 0))
580 qWarning("FhgAacEnc version couldn't be determined -> FhgAacEnc support will be disabled!");
581 for(int i
= 0; i
< 5; i
++) LAMEXP_DELETE(fhgBin
[i
]);
584 else if(fhgVersion
< lamexp_toolver_fhgaacenc())
586 qWarning("FhgAacEnc version is too much outdated (%s) -> FhgAacEnc support will be disabled!", lamexp_version2string("????-??-??", fhgVersion
, "N/A").toLatin1().constData());
587 qWarning("Minimum required FhgAacEnc version currently is: %s\n", lamexp_version2string("????-??-??", lamexp_toolver_fhgaacenc(), "N/A").toLatin1().constData());
588 for(int i
= 0; i
< 5; i
++) LAMEXP_DELETE(fhgBin
[i
]);
592 for(int i
= 0; i
< 5; i
++)
594 lamexp_register_tool(fhgFileInfo
[i
].fileName(), fhgBin
[i
], fhgVersion
);
598 void InitializationThread::initQAac(void)
600 const QString appPath
= QDir(QCoreApplication::applicationDirPath()).canonicalPath();
602 QFileInfo qaacFileInfo
[2];
603 qaacFileInfo
[0] = QFileInfo(QString("%1/qaac.exe").arg(appPath
));
604 qaacFileInfo
[1] = QFileInfo(QString("%1/libsoxrate.dll").arg(appPath
));
606 bool qaacFilesFound
= true;
607 for(int i
= 0; i
< 2; i
++) { if(!qaacFileInfo
[i
].exists()) qaacFilesFound
= false; }
609 //Lock the QAAC binaries
612 qDebug("QAAC binaries not found -> QAAC support will be disabled!\n");
616 qDebug("Found QAAC encoder:\n%s\n", qaacFileInfo
[0].canonicalFilePath().toUtf8().constData());
618 LockedFile
*qaacBin
[2];
619 for(int i
= 0; i
< 2; i
++) qaacBin
[i
] = NULL
;
623 for(int i
= 0; i
< 2; i
++)
625 qaacBin
[i
] = new LockedFile(qaacFileInfo
[i
].canonicalFilePath());
630 for(int i
= 0; i
< 2; i
++) LAMEXP_DELETE(qaacBin
[i
]);
631 qWarning("Failed to get excluive lock to QAAC binary -> QAAC support will be disabled!");
636 process
.setProcessChannelMode(QProcess::MergedChannels
);
637 process
.setReadChannel(QProcess::StandardOutput
);
638 process
.start(qaacFileInfo
[0].canonicalFilePath(), QStringList() << "--check");
640 if(!process
.waitForStarted())
642 qWarning("QAAC process failed to create!");
643 qWarning("Error message: \"%s\"\n", process
.errorString().toLatin1().constData());
645 process
.waitForFinished(-1);
646 for(int i
= 0; i
< 2; i
++) LAMEXP_DELETE(qaacBin
[i
]);
650 QRegExp
qaacEncSig("qaac (\\d)\\.(\\d)(\\d)", Qt::CaseInsensitive
);
651 QRegExp
coreEncSig("CoreAudioToolbox (\\d)\\.(\\d)\\.(\\d)\\.(\\d)", Qt::CaseInsensitive
);
652 unsigned int qaacVersion
= 0;
653 unsigned int coreVersion
= 0;
655 while(process
.state() != QProcess::NotRunning
)
657 process
.waitForReadyRead();
658 if(!process
.bytesAvailable() && process
.state() == QProcess::Running
)
660 qWarning("QAAC process time out -> killing!");
662 process
.waitForFinished(-1);
663 for(int i
= 0; i
< 2; i
++) LAMEXP_DELETE(qaacBin
[i
]);
666 while(process
.bytesAvailable() > 0)
668 QString line
= QString::fromUtf8(process
.readLine().constData()).simplified();
669 if(qaacEncSig
.lastIndexIn(line
) >= 0)
671 unsigned int tmp
[3] = {0, 0, 0};
672 bool ok
[3] = {false, false, false};
673 tmp
[0] = qaacEncSig
.cap(1).toUInt(&ok
[0]);
674 tmp
[1] = qaacEncSig
.cap(2).toUInt(&ok
[1]);
675 tmp
[2] = qaacEncSig
.cap(3).toUInt(&ok
[2]);
676 if(ok
[0] && ok
[1] && ok
[2])
678 qaacVersion
= (qBound(0U, tmp
[0], 9U) * 100) + (qBound(0U, tmp
[1], 9U) * 10) + qBound(0U, tmp
[2], 9U);
681 if(coreEncSig
.lastIndexIn(line
) >= 0)
683 unsigned int tmp
[4] = {0, 0, 0, 0};
684 bool ok
[4] = {false, false, false, false};
685 tmp
[0] = coreEncSig
.cap(1).toUInt(&ok
[0]);
686 tmp
[1] = coreEncSig
.cap(2).toUInt(&ok
[1]);
687 tmp
[2] = coreEncSig
.cap(3).toUInt(&ok
[2]);
688 tmp
[3] = coreEncSig
.cap(4).toUInt(&ok
[3]);
689 if(ok
[0] && ok
[1] && ok
[2] && ok
[3])
691 coreVersion
= (qBound(0U, tmp
[0], 9U) * 1000) + (qBound(0U, tmp
[1], 9U) * 100) + (qBound(0U, tmp
[2], 9U) * 10) + qBound(0U, tmp
[3], 9U);
697 //qDebug("qaac %d, CoreAudioToolbox %d", qaacVersion, coreVersion);
699 if(!(qaacVersion
> 0))
701 qWarning("QAAC version couldn't be determined -> QAAC support will be disabled!");
702 for(int i
= 0; i
< 2; i
++) LAMEXP_DELETE(qaacBin
[i
]);
705 else if(qaacVersion
< lamexp_toolver_qaacenc())
707 qWarning("QAAC version is too much outdated (%s) -> QAAC support will be disabled!", lamexp_version2string("v?.??", qaacVersion
, "N/A").toLatin1().constData());
708 qWarning("Minimum required QAAC version currently is: %s.\n", lamexp_version2string("v?.??", lamexp_toolver_qaacenc(), "N/A").toLatin1().constData());
709 for(int i
= 0; i
< 2; i
++) LAMEXP_DELETE(qaacBin
[i
]);
713 if(!(coreVersion
> 0))
715 qWarning("CoreAudioToolbox version couldn't be determined -> QAAC support will be disabled!");
716 for(int i
= 0; i
< 2; i
++) LAMEXP_DELETE(qaacBin
[i
]);
719 else if(coreVersion
< lamexp_toolver_coreaudio())
721 qWarning("CoreAudioToolbox version is too much outdated (%s) -> QAAC support will be disabled!", lamexp_version2string("v?.?.?.?", coreVersion
, "N/A").toLatin1().constData());
722 qWarning("Minimum required CoreAudioToolbox version currently is: %s.\n", lamexp_version2string("v?.??", lamexp_toolver_coreaudio(), "N/A").toLatin1().constData());
723 for(int i
= 0; i
< 2; i
++) LAMEXP_DELETE(qaacBin
[i
]);
727 lamexp_register_tool(qaacFileInfo
[0].fileName(), qaacBin
[0], qaacVersion
);
728 lamexp_register_tool(qaacFileInfo
[1].fileName(), qaacBin
[1], qaacVersion
);
731 void InitializationThread::selfTest(void)
733 const unsigned int cpu
[4] = {CPU_TYPE_X86_GEN
, CPU_TYPE_X86_SSE
, CPU_TYPE_X64_GEN
, CPU_TYPE_X64_SSE
};
735 for(size_t k
= 0; k
< 4; k
++)
740 PRINT_CPU_TYPE(CPU_TYPE_X86_GEN
); break;
741 PRINT_CPU_TYPE(CPU_TYPE_X86_SSE
); break;
742 PRINT_CPU_TYPE(CPU_TYPE_X64_GEN
); break;
743 PRINT_CPU_TYPE(CPU_TYPE_X64_SSE
); break;
744 default: throw "CPU support undefined!";
747 for(int i
= 0; i
< INT_MAX
; i
++)
749 if(!g_lamexp_tools
[i
].pcName
&& !g_lamexp_tools
[i
].pcHash
&& !g_lamexp_tools
[i
].uiVersion
)
753 if(g_lamexp_tools
[i
].uiCpuType
& cpu
[k
])
755 qDebug("%02i -> %s", ++n
, g_lamexp_tools
[i
].pcName
);
760 qFatal("Tool count mismatch !!!");
766 ////////////////////////////////////////////////////////////
768 ////////////////////////////////////////////////////////////