More reliable method to detect QAAC and make sure the required CoreAudioToolbox library is available.
This commit is contained in:
parent
da5dfdc85e
commit
20f425c284
@ -33,12 +33,13 @@
|
||||
#define VER_LAMEXP_BUILD 782
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Tools versions
|
||||
// Tool versions (minimum expected versions!)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define VER_LAMEXP_TOOL_NEROAAC 1540
|
||||
#define VER_LAMEXP_TOOL_FHGAACENC 20110822
|
||||
#define VER_LAMEXP_TOOL_QAAC 104
|
||||
#define VER_LAMEXP_TOOL_COREAUDIO 7710
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Helper macros (aka: having fun with the C pre-processor)
|
||||
|
@ -50,6 +50,8 @@ bool QAACEncoder::encode(const QString &sourceFile, const AudioFileModel &metaIn
|
||||
QProcess process;
|
||||
QStringList args;
|
||||
|
||||
process.setWorkingDirectory(QFileInfo(outputFile).canonicalPath());
|
||||
|
||||
if(m_configRCMode != SettingsModel::VBRMode)
|
||||
{
|
||||
switch(m_configProfile)
|
||||
@ -88,6 +90,7 @@ bool QAACEncoder::encode(const QString &sourceFile, const AudioFileModel &metaIn
|
||||
if(metaInfo.filePosition()) args << "--track" << QString::number(metaInfo.filePosition());
|
||||
if(!metaInfo.fileCover().isEmpty()) args << "--artwork" << metaInfo.fileCover();
|
||||
|
||||
args << "-d" << ".";
|
||||
args << "-o" << QDir::toNativeSeparators(outputFile);
|
||||
args << QDir::toNativeSeparators(sourceFile);
|
||||
|
||||
|
@ -170,6 +170,7 @@ static const char *g_lamexp_support_url = "http://forum.doom9.org/showthread.php
|
||||
static const unsigned int g_lamexp_toolver_neroaac = VER_LAMEXP_TOOL_NEROAAC;
|
||||
static const unsigned int g_lamexp_toolver_fhgaacenc = VER_LAMEXP_TOOL_FHGAACENC;
|
||||
static const unsigned int g_lamexp_toolver_qaacenc = VER_LAMEXP_TOOL_QAAC;
|
||||
static const unsigned int g_lamexp_toolver_coreaudio = VER_LAMEXP_TOOL_COREAUDIO;
|
||||
|
||||
//Special folders
|
||||
static QString g_lamexp_temp_folder;
|
||||
@ -241,6 +242,8 @@ const char *lamexp_version_arch(void) { return g_lamexp_version_arch; }
|
||||
unsigned int lamexp_toolver_neroaac(void) { return g_lamexp_toolver_neroaac; }
|
||||
unsigned int lamexp_toolver_fhgaacenc(void) { return g_lamexp_toolver_fhgaacenc; }
|
||||
unsigned int lamexp_toolver_qaacenc(void) { return g_lamexp_toolver_qaacenc; }
|
||||
unsigned int lamexp_toolver_coreaudio(void) { return g_lamexp_toolver_coreaudio; }
|
||||
|
||||
/*
|
||||
* URL getters
|
||||
*/
|
||||
|
@ -82,6 +82,7 @@ QDate lamexp_version_expires(void);
|
||||
unsigned int lamexp_toolver_neroaac(void);
|
||||
unsigned int lamexp_toolver_fhgaacenc(void);
|
||||
unsigned int lamexp_toolver_qaacenc(void);
|
||||
unsigned int lamexp_toolver_coreaudio(void);
|
||||
const char *lamexp_website_url(void);
|
||||
const char *lamexp_support_url(void);
|
||||
DWORD lamexp_get_os_version(void);
|
||||
|
@ -494,7 +494,7 @@ void InitializationThread::initQAac(void)
|
||||
bool qaacFilesFound = true;
|
||||
for(int i = 0; i < 4; i++) { if(!qaacFileInfo[i].exists()) qaacFilesFound = false; }
|
||||
|
||||
//Lock the FhgAacEnc binaries
|
||||
//Lock the QAAC binaries
|
||||
if(!qaacFilesFound)
|
||||
{
|
||||
qDebug("QAAC binaries not found -> QAAC support will be disabled!\n");
|
||||
@ -516,14 +516,14 @@ void InitializationThread::initQAac(void)
|
||||
catch(...)
|
||||
{
|
||||
for(int i = 0; i < 4; i++) LAMEXP_DELETE(qaacBin[i]);
|
||||
qWarning("Failed to get excluive lock to FhgAacEnc binary -> FhgAacEnc support will be disabled!");
|
||||
qWarning("Failed to get excluive lock to QAAC binary -> QAAC support will be disabled!");
|
||||
return;
|
||||
}
|
||||
|
||||
QProcess process;
|
||||
process.setProcessChannelMode(QProcess::MergedChannels);
|
||||
process.setReadChannel(QProcess::StandardOutput);
|
||||
process.start(qaacFileInfo[0].canonicalFilePath(), QStringList());
|
||||
process.start(qaacFileInfo[0].canonicalFilePath(), QStringList() << "--check");
|
||||
|
||||
if(!process.waitForStarted())
|
||||
{
|
||||
@ -536,7 +536,9 @@ void InitializationThread::initQAac(void)
|
||||
}
|
||||
|
||||
QRegExp qaacEncSig("qaac (\\d)\\.(\\d)(\\d)", Qt::CaseInsensitive);
|
||||
QRegExp coreEncSig("CoreAudioToolbox (\\d)\\.(\\d)\\.(\\d)\\.(\\d)", Qt::CaseInsensitive);
|
||||
unsigned int qaacVersion = 0;
|
||||
unsigned int coreVersion = 0;
|
||||
|
||||
while(process.state() != QProcess::NotRunning)
|
||||
{
|
||||
@ -564,9 +566,24 @@ void InitializationThread::initQAac(void)
|
||||
qaacVersion = (qBound(0U, tmp[0], 9U) * 100) + (qBound(0U, tmp[1], 9U) * 10) + qBound(0U, tmp[2], 9U);
|
||||
}
|
||||
}
|
||||
if(coreEncSig.lastIndexIn(line) >= 0)
|
||||
{
|
||||
unsigned int tmp[4] = {0, 0, 0, 0};
|
||||
bool ok[4] = {false, false, false, false};
|
||||
tmp[0] = coreEncSig.cap(1).toUInt(&ok[0]);
|
||||
tmp[1] = coreEncSig.cap(2).toUInt(&ok[1]);
|
||||
tmp[2] = coreEncSig.cap(3).toUInt(&ok[2]);
|
||||
tmp[3] = coreEncSig.cap(4).toUInt(&ok[3]);
|
||||
if(ok[0] && ok[1] && ok[2] && ok[3])
|
||||
{
|
||||
coreVersion = (qBound(0U, tmp[0], 9U) * 1000) + (qBound(0U, tmp[1], 9U) * 100) + (qBound(0U, tmp[2], 9U) * 10) + qBound(0U, tmp[3], 9U);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//qDebug("qaac %d, CoreAudioToolbox %d", qaacVersion, coreVersion);
|
||||
|
||||
if(!(qaacVersion > 0))
|
||||
{
|
||||
qWarning("QAAC version couldn't be determined -> QAAC support will be disabled!");
|
||||
@ -575,7 +592,20 @@ void InitializationThread::initQAac(void)
|
||||
}
|
||||
else if(qaacVersion < lamexp_toolver_qaacenc())
|
||||
{
|
||||
qWarning("QAAC version is too much outdated -> QAAC support will be disabled!");
|
||||
qWarning("QAAC version is too much outdated (%s) -> QAAC support will be disabled!", lamexp_version2string("v?.??", qaacVersion, "N/A").toLatin1().constData());
|
||||
for(int i = 0; i < 4; i++) LAMEXP_DELETE(qaacBin[i]);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!(coreVersion > 0))
|
||||
{
|
||||
qWarning("CoreAudioToolbox version couldn't be determined -> QAAC support will be disabled!");
|
||||
for(int i = 0; i < 4; i++) LAMEXP_DELETE(qaacBin[i]);
|
||||
return;
|
||||
}
|
||||
else if(coreVersion < lamexp_toolver_coreaudio())
|
||||
{
|
||||
qWarning("CoreAudioToolbox version is too much outdated (%s) -> QAAC support will be disabled!", lamexp_version2string("v?.?.?.?", coreVersion, "N/A").toLatin1().constData());
|
||||
for(int i = 0; i < 4; i++) LAMEXP_DELETE(qaacBin[i]);
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user