diff --git a/LameXP_VS2013.vcxproj b/LameXP_VS2013.vcxproj
index f9da17ad..0eb2413c 100644
--- a/LameXP_VS2013.vcxproj
+++ b/LameXP_VS2013.vcxproj
@@ -81,7 +81,7 @@
$(SolutionDir)\tmp\$(ProjectName);$(SolutionDir)\..\MUtilities\include;$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(SolutionDir)\..\Prerequisites\VisualLeakDetector\include;%(AdditionalIncludeDirectories)
_CONFIG_NAME=$(ConfigurationName);WIN32;_DEBUG;_CONSOLE;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT;QT_DLL;QT_DEBUG;%(PreprocessorDefinitions)
false
- EnableFastChecks
+ Default
MultiThreadedDebugDLL
NoExtensions
NotUsing
@@ -89,6 +89,7 @@
ProgramDatabase
false
true
+ Disabled
"/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" %(AdditionalOptions)
diff --git a/src/Config.h b/src/Config.h
index 95a5633a..aff46bab 100644
--- a/src/Config.h
+++ b/src/Config.h
@@ -34,8 +34,8 @@
#define VER_LAMEXP_MINOR_HI 1
#define VER_LAMEXP_MINOR_LO 1
#define VER_LAMEXP_TYPE Beta
-#define VER_LAMEXP_PATCH 9
-#define VER_LAMEXP_BUILD 1639
+#define VER_LAMEXP_PATCH 10
+#define VER_LAMEXP_BUILD 1646
#define VER_LAMEXP_CONFG 1558
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/Decoder_AAC.cpp b/src/Decoder_AAC.cpp
index 9af6c0b6..a1c77b03 100644
--- a/src/Decoder_AAC.cpp
+++ b/src/Decoder_AAC.cpp
@@ -35,7 +35,7 @@
AACDecoder::AACDecoder(void)
:
- m_binary(lamexp_tool_lookup("faad.exe"))
+ m_binary(lamexp_tools_lookup("faad.exe"))
{
if(m_binary.isEmpty())
{
diff --git a/src/Decoder_AC3.cpp b/src/Decoder_AC3.cpp
index 01adb7e0..77bdf365 100644
--- a/src/Decoder_AC3.cpp
+++ b/src/Decoder_AC3.cpp
@@ -35,7 +35,7 @@
AC3Decoder::AC3Decoder(void)
:
- m_binary(lamexp_tool_lookup("valdec.exe"))
+ m_binary(lamexp_tools_lookup("valdec.exe"))
{
if(m_binary.isEmpty())
{
diff --git a/src/Decoder_ADPCM.cpp b/src/Decoder_ADPCM.cpp
index c3cba410..c43bbe7f 100644
--- a/src/Decoder_ADPCM.cpp
+++ b/src/Decoder_ADPCM.cpp
@@ -35,7 +35,7 @@
ADPCMDecoder::ADPCMDecoder(void)
:
- m_binary(lamexp_tool_lookup("sox.exe"))
+ m_binary(lamexp_tools_lookup("sox.exe"))
{
if(m_binary.isEmpty())
{
diff --git a/src/Decoder_ALAC.cpp b/src/Decoder_ALAC.cpp
index ecdc438e..d4d3733c 100644
--- a/src/Decoder_ALAC.cpp
+++ b/src/Decoder_ALAC.cpp
@@ -36,7 +36,7 @@
ALACDecoder::ALACDecoder(void)
:
- m_binary(lamexp_tool_lookup("refalac.exe"))
+ m_binary(lamexp_tools_lookup("refalac.exe"))
{
if(m_binary.isEmpty())
{
diff --git a/src/Decoder_Avisynth.cpp b/src/Decoder_Avisynth.cpp
index 2c809a6f..88942c41 100644
--- a/src/Decoder_Avisynth.cpp
+++ b/src/Decoder_Avisynth.cpp
@@ -36,7 +36,7 @@
AvisynthDecoder::AvisynthDecoder(void)
:
- m_binary(lamexp_tool_lookup("avs2wav.exe"))
+ m_binary(lamexp_tools_lookup("avs2wav.exe"))
{
if(m_binary.isEmpty())
{
diff --git a/src/Decoder_FLAC.cpp b/src/Decoder_FLAC.cpp
index f7a7edab..4197678b 100644
--- a/src/Decoder_FLAC.cpp
+++ b/src/Decoder_FLAC.cpp
@@ -35,7 +35,7 @@
FLACDecoder::FLACDecoder(void)
:
- m_binary(lamexp_tool_lookup("flac.exe"))
+ m_binary(lamexp_tools_lookup("flac.exe"))
{
if(m_binary.isEmpty())
{
diff --git a/src/Decoder_MAC.cpp b/src/Decoder_MAC.cpp
index 36cd6077..a9bd8f93 100644
--- a/src/Decoder_MAC.cpp
+++ b/src/Decoder_MAC.cpp
@@ -35,7 +35,7 @@
MACDecoder::MACDecoder(void)
:
- m_binary(lamexp_tool_lookup("mac.exe"))
+ m_binary(lamexp_tools_lookup("mac.exe"))
{
if(m_binary.isEmpty())
{
diff --git a/src/Decoder_MP3.cpp b/src/Decoder_MP3.cpp
index 9c31aaae..6a133dba 100644
--- a/src/Decoder_MP3.cpp
+++ b/src/Decoder_MP3.cpp
@@ -35,7 +35,7 @@
MP3Decoder::MP3Decoder(void)
:
- m_binary(lamexp_tool_lookup("mpg123.exe"))
+ m_binary(lamexp_tools_lookup("mpg123.exe"))
{
if(m_binary.isEmpty())
{
diff --git a/src/Decoder_Musepack.cpp b/src/Decoder_Musepack.cpp
index 32a7cdd5..74a628b0 100644
--- a/src/Decoder_Musepack.cpp
+++ b/src/Decoder_Musepack.cpp
@@ -36,7 +36,7 @@
MusepackDecoder::MusepackDecoder(void)
:
- m_binary(lamexp_tool_lookup("mpcdec.exe"))
+ m_binary(lamexp_tools_lookup("mpcdec.exe"))
{
if(m_binary.isEmpty())
{
diff --git a/src/Decoder_Opus.cpp b/src/Decoder_Opus.cpp
index 8b76b699..8bc124f4 100644
--- a/src/Decoder_Opus.cpp
+++ b/src/Decoder_Opus.cpp
@@ -38,7 +38,7 @@ bool OpusDecoder::m_disableResampling = false;
OpusDecoder::OpusDecoder(void)
:
- m_binary(lamexp_tool_lookup("opusdec.exe"))
+ m_binary(lamexp_tools_lookup("opusdec.exe"))
{
if(m_binary.isEmpty())
{
diff --git a/src/Decoder_Shorten.cpp b/src/Decoder_Shorten.cpp
index cae1cd76..5b33613b 100644
--- a/src/Decoder_Shorten.cpp
+++ b/src/Decoder_Shorten.cpp
@@ -36,7 +36,7 @@
ShortenDecoder::ShortenDecoder(void)
:
- m_binary(lamexp_tool_lookup("shorten.exe"))
+ m_binary(lamexp_tools_lookup("shorten.exe"))
{
if(m_binary.isEmpty())
{
diff --git a/src/Decoder_Speex.cpp b/src/Decoder_Speex.cpp
index c5b1d39a..7218f23c 100644
--- a/src/Decoder_Speex.cpp
+++ b/src/Decoder_Speex.cpp
@@ -35,7 +35,7 @@
SpeexDecoder::SpeexDecoder(void)
:
- m_binary(lamexp_tool_lookup("speexdec.exe"))
+ m_binary(lamexp_tools_lookup("speexdec.exe"))
{
if(m_binary.isEmpty())
{
diff --git a/src/Decoder_TTA.cpp b/src/Decoder_TTA.cpp
index 4b7e22c7..4f1aed01 100644
--- a/src/Decoder_TTA.cpp
+++ b/src/Decoder_TTA.cpp
@@ -36,7 +36,7 @@
TTADecoder::TTADecoder(void)
:
- m_binary(lamexp_tool_lookup("tta.exe"))
+ m_binary(lamexp_tools_lookup("tta.exe"))
{
if(m_binary.isEmpty())
{
diff --git a/src/Decoder_Vorbis.cpp b/src/Decoder_Vorbis.cpp
index 87e798bd..773937b9 100644
--- a/src/Decoder_Vorbis.cpp
+++ b/src/Decoder_Vorbis.cpp
@@ -35,7 +35,7 @@
VorbisDecoder::VorbisDecoder(void)
:
- m_binary(lamexp_tool_lookup("oggdec.exe"))
+ m_binary(lamexp_tools_lookup("oggdec.exe"))
{
if(m_binary.isEmpty())
{
diff --git a/src/Decoder_WMA.cpp b/src/Decoder_WMA.cpp
index 571b03eb..2ada2257 100644
--- a/src/Decoder_WMA.cpp
+++ b/src/Decoder_WMA.cpp
@@ -37,7 +37,7 @@
WMADecoder::WMADecoder(void)
:
- m_binary(lamexp_tool_lookup("wma2wav.exe"))
+ m_binary(lamexp_tools_lookup("wma2wav.exe"))
{
if(m_binary.isEmpty())
{
diff --git a/src/Decoder_WavPack.cpp b/src/Decoder_WavPack.cpp
index 36881612..389ad3bd 100644
--- a/src/Decoder_WavPack.cpp
+++ b/src/Decoder_WavPack.cpp
@@ -35,7 +35,7 @@
WavPackDecoder::WavPackDecoder(void)
:
- m_binary(lamexp_tool_lookup("wvunpack.exe"))
+ m_binary(lamexp_tools_lookup("wvunpack.exe"))
{
if(m_binary.isEmpty())
{
diff --git a/src/Dialog_About.cpp b/src/Dialog_About.cpp
index 7b09e3d8..b1b79b20 100644
--- a/src/Dialog_About.cpp
+++ b/src/Dialog_About.cpp
@@ -915,8 +915,8 @@ QString AboutDialog::makeToolText(const QString &toolName, const QString &toolBi
if(!toolBin.isEmpty())
{
- const unsigned int version = lamexp_tool_version(toolBin, &toolTag);
- verStr = lamexp_version2string(toolVerFmt, version, tr("n/a"), &toolTag);
+ const unsigned int version = lamexp_tools_version(toolBin, &toolTag);
+ verStr = lamexp_version2string(toolVerFmt, version, tr("n/a"), toolTag);
}
toolText += QString("
%1 ").arg(NOBR(QString("%1 (%2) ").arg(toolName, verStr)));
diff --git a/src/Dialog_MainWindow.cpp b/src/Dialog_MainWindow.cpp
index f025ef8e..8342ade5 100644
--- a/src/Dialog_MainWindow.cpp
+++ b/src/Dialog_MainWindow.cpp
@@ -52,6 +52,7 @@
#include
#include
#include
+#include
#include
//Qt includes
@@ -601,18 +602,20 @@ MainWindow::MainWindow(MUtils::IPCChannel *const ipcChannel, FileListModel *cons
//Populate the language menu
m_languageActionGroup = new QActionGroup(this);
- QStringList translations = lamexp_query_translations();
- while(!translations.isEmpty())
+ QStringList translations;
+ if(MUtils::Translation::enumerate(translations) > 0)
{
- QString langId = translations.takeFirst();
- QAction *currentLanguage = new QAction(this);
- currentLanguage->setData(langId);
- currentLanguage->setText(lamexp_translation_name(langId));
- currentLanguage->setIcon(QIcon(QString(":/flags/%1.png").arg(langId)));
- currentLanguage->setCheckable(true);
- currentLanguage->setChecked(false);
- m_languageActionGroup->addAction(currentLanguage);
- ui->menuLanguage->insertAction(ui->actionLoadTranslationFromFile, currentLanguage);
+ for(QStringList::ConstIterator iter = translations.constBegin(); iter != translations.constEnd(); iter++)
+ {
+ QAction *currentLanguage = new QAction(this);
+ currentLanguage->setData(*iter);
+ currentLanguage->setText(MUtils::Translation::get_name(*iter));
+ currentLanguage->setIcon(QIcon(QString(":/flags/%1.png").arg(*iter)));
+ currentLanguage->setCheckable(true);
+ currentLanguage->setChecked(false);
+ m_languageActionGroup->addAction(currentLanguage);
+ ui->menuLanguage->insertAction(ui->actionLoadTranslationFromFile, currentLanguage);
+ }
}
ui->menuLanguage->insertSeparator(ui->actionLoadTranslationFromFile);
connect(ui->actionLoadTranslationFromFile, SIGNAL(triggered(bool)), this, SLOT(languageFromFileActionActivated(bool)));
@@ -942,7 +945,7 @@ void MainWindow::initializeTranslation(void)
const QString qmFilePath = QFileInfo(m_settings->currentLanguageFile()).canonicalFilePath();
if((!qmFilePath.isEmpty()) && QFileInfo(qmFilePath).exists() && QFileInfo(qmFilePath).isFile() && (QFileInfo(qmFilePath).suffix().compare("qm", Qt::CaseInsensitive) == 0))
{
- if(lamexp_install_translator_from_file(qmFilePath))
+ if(MUtils::Translation::install_translator_from_file(qmFilePath))
{
QList actions = m_languageActionGroup->actions();
while(!actions.isEmpty()) actions.takeFirst()->setChecked(false);
@@ -975,7 +978,7 @@ void MainWindow::initializeTranslation(void)
while(!languageActions.isEmpty())
{
QAction *currentLanguage = languageActions.takeFirst();
- if(currentLanguage->data().toString().compare(LAMEXP_DEFAULT_LANGID, Qt::CaseInsensitive) == 0)
+ if(currentLanguage->data().toString().compare(MUtils::Translation::DEFAULT_LANGID, Qt::CaseInsensitive) == 0)
{
currentLanguage->setChecked(true);
languageActionActivated(currentLanguage);
@@ -1417,11 +1420,11 @@ void MainWindow::windowShown(void)
{
if(m_settings->neroAacNotificationsEnabled())
{
- if(lamexp_tool_version("neroAacEnc.exe") < lamexp_toolver_neroaac())
+ if(lamexp_tools_version("neroAacEnc.exe") < lamexp_toolver_neroaac())
{
QString messageText;
messageText += NOBR(tr("LameXP detected that your version of the Nero AAC encoder is outdated!")).append(" ");
- messageText += NOBR(tr("The current version available is %1 (or later), but you still have version %2 installed.").arg(lamexp_version2string("?.?.?.?", lamexp_toolver_neroaac(), tr("n/a")), lamexp_version2string("?.?.?.?", lamexp_tool_version("neroAacEnc.exe"), tr("n/a")))).append(" ");
+ messageText += NOBR(tr("The current version available is %1 (or later), but you still have version %2 installed.").arg(lamexp_version2string("?.?.?.?", lamexp_toolver_neroaac(), tr("n/a")), lamexp_version2string("?.?.?.?", lamexp_tools_version("neroAacEnc.exe"), tr("n/a")))).append(" ");
messageText += NOBR(tr("You can download the latest version of the Nero AAC encoder from the Nero website at:")).append(" ");
messageText += "" + LINK(AboutDialog::neroAacUrl) + " ";
messageText += NOBR(tr("(Hint: Please ignore the name of the downloaded ZIP file and check the included 'changelog.txt' instead!)")).append(" ");
@@ -1870,7 +1873,7 @@ void MainWindow::languageActionActivated(QAction *action)
{
QString langId = action->data().toString();
- if(lamexp_install_translator(langId))
+ if(MUtils::Translation::install_translator(langId))
{
action->setChecked(true);
ui->actionLoadTranslationFromFile->setChecked(false);
@@ -1893,7 +1896,7 @@ void MainWindow::languageFromFileActionActivated(bool checked)
{
QStringList selectedFiles = dialog.selectedFiles();
const QString qmFile = QFileInfo(selectedFiles.first()).canonicalFilePath();
- if(lamexp_install_translator_from_file(qmFile))
+ if(MUtils::Translation::install_translator_from_file(qmFile))
{
QList actions = m_languageActionGroup->actions();
while(!actions.isEmpty())
@@ -4012,7 +4015,7 @@ void MainWindow::customParamsHelpRequested(QWidget *obj, QEvent *event)
*/
void MainWindow::showCustomParamsHelpScreen(const QString &toolName, const QString &command)
{
- const QString binary = lamexp_tool_lookup(toolName);
+ const QString binary = lamexp_tools_lookup(toolName);
if(binary.isEmpty())
{
MUtils::Sound::beep(MUtils::Sound::BEEP_ERR);
diff --git a/src/Dialog_Update.cpp b/src/Dialog_Update.cpp
index 436a4479..aa22d6c9 100644
--- a/src/Dialog_Update.cpp
+++ b/src/Dialog_Update.cpp
@@ -82,10 +82,10 @@ UpdateDialog::UpdateDialog(const SettingsModel *const settings, QWidget *parent)
m_firstShow(true),
m_updateReadyToInstall(false),
m_updaterProcess(NULL),
- m_binaryUpdater(lamexp_tool_lookup("wupdate.exe")),
- m_binaryWGet(lamexp_tool_lookup("wget.exe")),
- m_binaryGnuPG(lamexp_tool_lookup("gpgv.exe")),
- m_binaryKeys(lamexp_tool_lookup("gpgv.gpg"))
+ m_binaryUpdater(lamexp_tools_lookup("wupdate.exe")),
+ m_binaryWGet(lamexp_tools_lookup("wget.exe")),
+ m_binaryGnuPG(lamexp_tools_lookup("gpgv.exe")),
+ m_binaryKeys(lamexp_tools_lookup("gpgv.gpg"))
{
if(m_binaryUpdater.isEmpty())
{
diff --git a/src/Encoder_AAC.cpp b/src/Encoder_AAC.cpp
index 1130ed91..361746af 100644
--- a/src/Encoder_AAC.cpp
+++ b/src/Encoder_AAC.cpp
@@ -117,9 +117,9 @@ static const g_aacEncoderInfo;
AACEncoder::AACEncoder(void)
:
- m_binary_enc(lamexp_tool_lookup("neroAacEnc.exe")),
- m_binary_tag(lamexp_tool_lookup("neroAacTag.exe")),
- m_binary_sox(lamexp_tool_lookup("sox.exe"))
+ m_binary_enc(lamexp_tools_lookup("neroAacEnc.exe")),
+ m_binary_tag(lamexp_tools_lookup("neroAacTag.exe")),
+ m_binary_sox(lamexp_tools_lookup("sox.exe"))
{
if(m_binary_enc.isEmpty() || m_binary_tag.isEmpty() || m_binary_sox.isEmpty())
{
diff --git a/src/Encoder_AAC_FHG.cpp b/src/Encoder_AAC_FHG.cpp
index 8e53a64f..fb0c3634 100644
--- a/src/Encoder_AAC_FHG.cpp
+++ b/src/Encoder_AAC_FHG.cpp
@@ -120,8 +120,8 @@ static const g_fhgAacEncoderInfo;
FHGAACEncoder::FHGAACEncoder(void)
:
- m_binary_enc(lamexp_tool_lookup("fhgaacenc.exe")),
- m_binary_dll(lamexp_tool_lookup("enc_fhgaac.dll"))
+ m_binary_enc(lamexp_tools_lookup("fhgaacenc.exe")),
+ m_binary_dll(lamexp_tools_lookup("enc_fhgaac.dll"))
{
if(m_binary_enc.isEmpty() || m_binary_dll.isEmpty())
{
diff --git a/src/Encoder_AAC_QAAC.cpp b/src/Encoder_AAC_QAAC.cpp
index 5523cfbe..29160863 100644
--- a/src/Encoder_AAC_QAAC.cpp
+++ b/src/Encoder_AAC_QAAC.cpp
@@ -128,9 +128,9 @@ static const g_qaacEncoderInfo;
QAACEncoder::QAACEncoder(void)
:
- m_binary_qaac(lamexp_tool_lookup("qaac.exe")),
- m_binary_soxr(lamexp_tool_lookup("libsoxr.dll")),
- m_binary_soxc(lamexp_tool_lookup("libsoxconvolver.dll"))
+ m_binary_qaac(lamexp_tools_lookup("qaac.exe")),
+ m_binary_soxr(lamexp_tools_lookup("libsoxr.dll")),
+ m_binary_soxc(lamexp_tools_lookup("libsoxconvolver.dll"))
{
if(m_binary_qaac.isEmpty() || m_binary_soxr.isEmpty() || m_binary_soxc.isEmpty())
{
diff --git a/src/Encoder_AC3.cpp b/src/Encoder_AC3.cpp
index 7b9026c4..752deb20 100644
--- a/src/Encoder_AC3.cpp
+++ b/src/Encoder_AC3.cpp
@@ -116,7 +116,7 @@ static const g_aftenEncoderInfo;
AC3Encoder::AC3Encoder(void)
:
- m_binary(lamexp_tool_lookup("aften.exe"))
+ m_binary(lamexp_tools_lookup("aften.exe"))
{
if(m_binary.isEmpty())
{
diff --git a/src/Encoder_DCA.cpp b/src/Encoder_DCA.cpp
index 6b0d134c..a3aa3477 100644
--- a/src/Encoder_DCA.cpp
+++ b/src/Encoder_DCA.cpp
@@ -118,7 +118,7 @@ static const g_dcaEncoderInfo;
DCAEncoder::DCAEncoder(void)
:
- m_binary(lamexp_tool_lookup("dcaenc.exe"))
+ m_binary(lamexp_tools_lookup("dcaenc.exe"))
{
if(m_binary.isEmpty())
{
diff --git a/src/Encoder_FLAC.cpp b/src/Encoder_FLAC.cpp
index 29afd8ae..ff183d3c 100644
--- a/src/Encoder_FLAC.cpp
+++ b/src/Encoder_FLAC.cpp
@@ -112,7 +112,7 @@ static const g_flacEncoderInfo;
FLACEncoder::FLACEncoder(void)
:
- m_binary(lamexp_tool_lookup("flac.exe"))
+ m_binary(lamexp_tools_lookup("flac.exe"))
{
if(m_binary.isEmpty())
{
diff --git a/src/Encoder_MAC.cpp b/src/Encoder_MAC.cpp
index c1c3ffd7..5ae1e88f 100644
--- a/src/Encoder_MAC.cpp
+++ b/src/Encoder_MAC.cpp
@@ -112,8 +112,8 @@ static const g_macEncoderInfo;
MACEncoder::MACEncoder(void)
:
- m_binary_enc(lamexp_tool_lookup("mac.exe")),
- m_binary_tag(lamexp_tool_lookup("tag.exe"))
+ m_binary_enc(lamexp_tools_lookup("mac.exe")),
+ m_binary_tag(lamexp_tools_lookup("tag.exe"))
{
if(m_binary_enc.isEmpty() || m_binary_tag.isEmpty())
{
diff --git a/src/Encoder_MP3.cpp b/src/Encoder_MP3.cpp
index 8929457f..e7c02315 100644
--- a/src/Encoder_MP3.cpp
+++ b/src/Encoder_MP3.cpp
@@ -117,7 +117,7 @@ static const g_mp3EncoderInfo;
MP3Encoder::MP3Encoder(void)
:
- m_binary(lamexp_tool_lookup("lame.exe"))
+ m_binary(lamexp_tools_lookup("lame.exe"))
{
if(m_binary.isEmpty())
{
diff --git a/src/Encoder_Opus.cpp b/src/Encoder_Opus.cpp
index c535df13..c487b241 100644
--- a/src/Encoder_Opus.cpp
+++ b/src/Encoder_Opus.cpp
@@ -107,7 +107,7 @@ static const g_opusEncoderInfo;
OpusEncoder::OpusEncoder(void)
:
- m_binary(lamexp_tool_lookup("opusenc.exe"))
+ m_binary(lamexp_tools_lookup("opusenc.exe"))
{
if(m_binary.isEmpty())
{
diff --git a/src/Encoder_Vorbis.cpp b/src/Encoder_Vorbis.cpp
index fe62e226..d866a03c 100644
--- a/src/Encoder_Vorbis.cpp
+++ b/src/Encoder_Vorbis.cpp
@@ -114,7 +114,7 @@ static const g_vorbisEncoderInfo;
VorbisEncoder::VorbisEncoder(void)
:
- m_binary(lamexp_tool_lookup("oggenc2.exe"))
+ m_binary(lamexp_tools_lookup("oggenc2.exe"))
{
if(m_binary.isEmpty())
{
diff --git a/src/Filter_Downmix.cpp b/src/Filter_Downmix.cpp
index 212bef13..5a3ba0fc 100644
--- a/src/Filter_Downmix.cpp
+++ b/src/Filter_Downmix.cpp
@@ -37,7 +37,7 @@
DownmixFilter::DownmixFilter(void)
:
- m_binary(lamexp_tool_lookup("sox.exe"))
+ m_binary(lamexp_tools_lookup("sox.exe"))
{
if(m_binary.isEmpty())
{
diff --git a/src/Filter_Normalize.cpp b/src/Filter_Normalize.cpp
index be4c72a1..0c04e9b1 100644
--- a/src/Filter_Normalize.cpp
+++ b/src/Filter_Normalize.cpp
@@ -35,7 +35,7 @@
NormalizeFilter::NormalizeFilter(int peakVolume, int equalizationMode)
:
- m_binary(lamexp_tool_lookup("sox.exe"))
+ m_binary(lamexp_tools_lookup("sox.exe"))
{
if(m_binary.isEmpty())
{
diff --git a/src/Filter_Resample.cpp b/src/Filter_Resample.cpp
index 397f6c48..582d5ecf 100644
--- a/src/Filter_Resample.cpp
+++ b/src/Filter_Resample.cpp
@@ -41,7 +41,7 @@ static __inline int multipleOf(int value, int base)
ResampleFilter::ResampleFilter(int samplingRate, int bitDepth)
:
- m_binary(lamexp_tool_lookup("sox.exe"))
+ m_binary(lamexp_tools_lookup("sox.exe"))
{
if(m_binary.isEmpty())
{
diff --git a/src/Filter_ToneAdjust.cpp b/src/Filter_ToneAdjust.cpp
index 7a55d45b..ea222e55 100644
--- a/src/Filter_ToneAdjust.cpp
+++ b/src/Filter_ToneAdjust.cpp
@@ -36,7 +36,7 @@
ToneAdjustFilter::ToneAdjustFilter(int bass, int treble)
:
- m_binary(lamexp_tool_lookup("sox.exe"))
+ m_binary(lamexp_tools_lookup("sox.exe"))
{
if(m_binary.isEmpty())
{
diff --git a/src/Global.h b/src/Global.h
index d8d752ba..bec5eb92 100644
--- a/src/Global.h
+++ b/src/Global.h
@@ -28,6 +28,7 @@
#include
#include
+#include
//Forward declarations
class QDate;
@@ -35,36 +36,17 @@ class QStringList;
class QIcon;
class LockedFile;
-///////////////////////////////////////////////////////////////////////////////
-// GLOBAL CONSTANTS
-///////////////////////////////////////////////////////////////////////////////
-
-extern const char* LAMEXP_DEFAULT_LANGID;
-extern const char* LAMEXP_DEFAULT_TRANSLATION;
-
///////////////////////////////////////////////////////////////////////////////
// GLOBAL FUNCTIONS
///////////////////////////////////////////////////////////////////////////////
-/*
- * Translation Support
- */
-QStringList lamexp_query_translations(void);
-unsigned int lamexp_translation_country(const QString &langId);
-bool lamexp_translation_init(void);
-QString lamexp_translation_name(const QString &language);
-bool lamexp_translation_register(const QString &langId, const QString &qmFile, const QString &langName, unsigned int &systemId, unsigned int &country);
-unsigned int lamexp_translation_sysid(const QString &langId);
-bool lamexp_install_translator(const QString &language);
-bool lamexp_install_translator_from_file(const QString &qmFile);
-
/*
* Tools Support
*/
-bool lamexp_tool_check (const QString &toolName);
-const QString& lamexp_tool_lookup (const QString &toolName);
-void lamexp_tool_register(const QString &toolName, LockedFile *file, unsigned int version = 0, const QString *tag = NULL);
-unsigned int lamexp_tool_version (const QString &toolName, QString *tag = NULL);
+void lamexp_tools_register(const QString &toolName, LockedFile *const file, const quint32 &version, const QString &tag = QString());
+bool lamexp_tools_check (const QString &toolName);
+const QString& lamexp_tools_lookup (const QString &toolName);
+const quint32& lamexp_tools_version (const QString &toolName, QString *const tagOut = NULL);
/*
* Version getters
@@ -76,13 +58,12 @@ unsigned int lamexp_version_confg (void);
const char* lamexp_version_release (void);
bool lamexp_version_portable (void);
bool lamexp_version_demo (void);
-QDate& lamexp_version_expires (void);
+const 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);
-
/*
* URL getters
*/
@@ -95,12 +76,7 @@ const char *lamexp_tracker_url(void);
* Misc Functions
*/
const QIcon& lamexp_app_icon(void);
-const QString lamexp_version2string(const QString &pattern, unsigned int version, const QString &defaultText, const QString *tag = NULL);
-
-/*
- * Finalization
- */
-void lamexp_finalization(void);
+const QString lamexp_version2string(const QString &pattern, unsigned int version, const QString &defaultText, const QString &tag = QString());
///////////////////////////////////////////////////////////////////////////////
// HELPER MACROS
diff --git a/src/Global_Tools.cpp b/src/Global_Tools.cpp
index 7f2c9202..377cf7d2 100644
--- a/src/Global_Tools.cpp
+++ b/src/Global_Tools.cpp
@@ -27,372 +27,147 @@
//Qt includes
#include
-#include
+#include
#include
-#include
-#include
#include
#include
-#include
#include
+#include
//MUtils
#include
#include
+//CRT
+#include
+
///////////////////////////////////////////////////////////////////////////////
// GLOBAL VARS
///////////////////////////////////////////////////////////////////////////////
-//Tools
-static struct
-{
- QMap *registry;
- QMap *versions;
- QMap *tags;
- QReadWriteLock lock;
-}
-g_lamexp_tools;
+//Typedef
+typedef QPair tool_info_t;
+typedef QPair tool_data_t;
+typedef QHash tool_hash_t;
-//Supported languages
-static struct
-{
- QMap *files;
- QMap *names;
- QMap *sysid;
- QMap *cntry;
- QReadWriteLock lock;
-}
-g_lamexp_translation;
-
-//Translator
-static struct
-{
- QTranslator *instance;
- QReadWriteLock lock;
-}
-g_lamexp_currentTranslator;
+//Tool registry
+static QScopedPointer g_lamexp_tools_data;
+static QReadWriteLock g_lamexp_tools_lock;
//Null String
-static const QString g_null;
+static const QString g_null_string;
+
+//UINT_MAX
+static const quint32 g_max_uint32 = UINT32_MAX;
+
+//Helper Macro
+#define MAKE_ENTRY(LOCK_FILE,VER,TAG) \
+ qMakePair((LOCK_FILE),qMakePair((VER),(TAG)))
///////////////////////////////////////////////////////////////////////////////
// GLOBAL FUNCTIONS
///////////////////////////////////////////////////////////////////////////////
+/*
+ * Clean-up *all* registered tools
+ */
+static void lamexp_tools_clean_up(void)
+{
+ QWriteLocker writeLock(&g_lamexp_tools_lock);
+
+ if(!g_lamexp_tools_data.isNull())
+ {
+ const QStringList keys = g_lamexp_tools_data->keys();
+ for(QStringList::ConstIterator iter = keys.constBegin(); iter != keys.constEnd(); iter++)
+ {
+ tool_data_t currentTool = (*g_lamexp_tools_data)[*iter];
+ MUTILS_DELETE(currentTool.first);
+ }
+ g_lamexp_tools_data->clear();
+ }
+}
+
/*
* Register tool
*/
-void lamexp_tool_register(const QString &toolName, LockedFile *file, unsigned int version, const QString *tag)
+void lamexp_tools_register(const QString &toolName, LockedFile *const file, const quint32 &version, const QString &tag)
{
- QWriteLocker writeLock(&g_lamexp_tools.lock);
+ QWriteLocker writeLock(&g_lamexp_tools_lock);
- if(!g_lamexp_tools.registry) g_lamexp_tools.registry = new QMap();
- if(!g_lamexp_tools.versions) g_lamexp_tools.versions = new QMap();
- if(!g_lamexp_tools.tags) g_lamexp_tools.tags = new QMap();
+ if(g_lamexp_tools_data.isNull())
+ {
+ g_lamexp_tools_data.reset(new tool_hash_t());
+ atexit(lamexp_tools_clean_up);
+ }
- if(g_lamexp_tools.registry->contains(toolName.toLower()))
+ const QString key = toolName.simplified().toLower();
+ if(g_lamexp_tools_data->contains(key))
{
MUTILS_THROW("lamexp_register_tool: Tool is already registered!");
}
- g_lamexp_tools.registry->insert(toolName.toLower(), file);
- g_lamexp_tools.versions->insert(toolName.toLower(), version);
- g_lamexp_tools.tags->insert(toolName.toLower(), (tag) ? (*tag) : QString());
+ g_lamexp_tools_data->insert(key, MAKE_ENTRY(file, version, tag));
}
/*
* Check for tool
*/
-bool lamexp_tool_check(const QString &toolName)
+bool lamexp_tools_check(const QString &toolName)
{
- QReadLocker readLock(&g_lamexp_tools.lock);
- return (g_lamexp_tools.registry) ? g_lamexp_tools.registry->contains(toolName.toLower()) : false;
+ QReadLocker readLock(&g_lamexp_tools_lock);
+
+ if(!g_lamexp_tools_data.isNull())
+ {
+ const QString key = toolName.simplified().toLower();
+ return g_lamexp_tools_data->contains(key);
+ }
+
+ return false;
}
/*
* Lookup tool path
*/
-const QString &lamexp_tool_lookup(const QString &toolName)
+const QString &lamexp_tools_lookup(const QString &toolName)
{
- QReadLocker readLock(&g_lamexp_tools.lock);
+ QReadLocker readLock(&g_lamexp_tools_lock);
- if(g_lamexp_tools.registry)
+ if(!g_lamexp_tools_data.isNull())
{
- if(g_lamexp_tools.registry->contains(toolName.toLower()))
+ const QString key = toolName.simplified().toLower();
+ if(g_lamexp_tools_data->contains(key))
{
- return g_lamexp_tools.registry->value(toolName.toLower())->filePath();
- }
- else
- {
- return g_null;
+ return (*g_lamexp_tools_data)[key].first->filePath();
}
}
- else
- {
- return g_null;
- }
+
+ return g_null_string;
}
/*
* Lookup tool version
*/
-unsigned int lamexp_tool_version(const QString &toolName, QString *tag)
+const quint32 &lamexp_tools_version(const QString &toolName, QString *const tagOut)
{
- QReadLocker readLock(&g_lamexp_tools.lock);
- if(tag) tag->clear();
+ QReadLocker readLock(&g_lamexp_tools_lock);
- if(g_lamexp_tools.versions)
+ if(!g_lamexp_tools_data.isNull())
{
- if(g_lamexp_tools.versions->contains(toolName.toLower()))
+ const QString key = toolName.simplified().toLower();
+ if(g_lamexp_tools_data->contains(key))
{
- if(tag)
+ const tool_info_t &info = (*g_lamexp_tools_data)[key].second;
+ if(tagOut)
{
- if(g_lamexp_tools.tags->contains(toolName.toLower())) *tag = g_lamexp_tools.tags->value(toolName.toLower());
+ *tagOut = info.second;
}
- return g_lamexp_tools.versions->value(toolName.toLower());
- }
- else
- {
- return UINT_MAX;
- }
- }
- else
- {
- return UINT_MAX;
- }
-}
-
-/*
- * Version number to human-readable string
- */
-const QString lamexp_version2string(const QString &pattern, unsigned int version, const QString &defaultText, const QString *tag)
-{
- if(version == UINT_MAX)
- {
- return defaultText;
- }
-
- QString result = pattern;
- const int digits = result.count(QChar(L'?'), Qt::CaseInsensitive);
-
- if(digits < 1)
- {
- return result;
- }
-
- int pos = 0, index = -1;
- const QString versionStr = QString().sprintf("%0*u", digits, version);
- Q_ASSERT(versionStr.length() == digits);
-
- while((index = result.indexOf(QChar(L'?'), Qt::CaseInsensitive)) >= 0)
- {
- result[index] = versionStr[pos++];
- }
-
- if(tag)
- {
- if((index = result.indexOf(QChar(L'#'), Qt::CaseInsensitive)) >= 0)
- {
- result.remove(index, 1).insert(index, (*tag));
+ return info.first;
}
}
- return result;
-}
-
-/*
- * Initialize translations and add default language
- */
-bool lamexp_translation_init(void)
-{
- QWriteLocker writeLockTranslations(&g_lamexp_translation.lock);
-
- if((!g_lamexp_translation.files) && (!g_lamexp_translation.names))
+ if(tagOut)
{
- g_lamexp_translation.files = new QMap();
- g_lamexp_translation.names = new QMap();
- g_lamexp_translation.files->insert(LAMEXP_DEFAULT_LANGID, "");
- g_lamexp_translation.names->insert(LAMEXP_DEFAULT_LANGID, "English");
- return true;
- }
- else
- {
- qWarning("[lamexp_translation_init] Error: Already initialized!");
- return false;
+ tagOut->clear();
}
-}
-
-/*
- * Register a new translation
- */
-bool lamexp_translation_register(const QString &langId, const QString &qmFile, const QString &langName, unsigned int &systemId, unsigned int &country)
-{
- QWriteLocker writeLockTranslations(&g_lamexp_translation.lock);
-
- if(qmFile.isEmpty() || langName.isEmpty() || systemId < 1)
- {
- return false;
- }
-
- if(!g_lamexp_translation.files) g_lamexp_translation.files = new QMap();
- if(!g_lamexp_translation.names) g_lamexp_translation.names = new QMap();
- if(!g_lamexp_translation.sysid) g_lamexp_translation.sysid = new QMap();
- if(!g_lamexp_translation.cntry) g_lamexp_translation.cntry = new QMap();
-
- g_lamexp_translation.files->insert(langId, qmFile);
- g_lamexp_translation.names->insert(langId, langName);
- g_lamexp_translation.sysid->insert(langId, systemId);
- g_lamexp_translation.cntry->insert(langId, country);
-
- return true;
-}
-
-/*
- * Get list of all translations
- */
-QStringList lamexp_query_translations(void)
-{
- QReadLocker readLockTranslations(&g_lamexp_translation.lock);
- return (g_lamexp_translation.files) ? g_lamexp_translation.files->keys() : QStringList();
-}
-
-/*
- * Get translation name
- */
-QString lamexp_translation_name(const QString &langId)
-{
- QReadLocker readLockTranslations(&g_lamexp_translation.lock);
- return (g_lamexp_translation.names) ? g_lamexp_translation.names->value(langId.toLower(), QString()) : QString();
-}
-
-/*
- * Get translation system id
- */
-unsigned int lamexp_translation_sysid(const QString &langId)
-{
- QReadLocker readLockTranslations(&g_lamexp_translation.lock);
- return (g_lamexp_translation.sysid) ? g_lamexp_translation.sysid->value(langId.toLower(), 0) : 0;
-}
-
-/*
- * Get translation script id
- */
-unsigned int lamexp_translation_country(const QString &langId)
-{
- QReadLocker readLockTranslations(&g_lamexp_translation.lock);
- return (g_lamexp_translation.cntry) ? g_lamexp_translation.cntry->value(langId.toLower(), 0) : 0;
-}
-
-/*
- * Install a new translator
- */
-bool lamexp_install_translator(const QString &langId)
-{
- bool success = false;
- const QString qmFileToPath(":/localization/%1");
-
- if(langId.isEmpty() || langId.toLower().compare(LAMEXP_DEFAULT_LANGID) == 0)
- {
- success = lamexp_install_translator_from_file(qmFileToPath.arg(LAMEXP_DEFAULT_TRANSLATION));
- }
- else
- {
- QReadLocker readLock(&g_lamexp_translation.lock);
- QString qmFile = (g_lamexp_translation.files) ? g_lamexp_translation.files->value(langId.toLower(), QString()) : QString();
- readLock.unlock();
-
- if(!qmFile.isEmpty())
- {
- success = lamexp_install_translator_from_file(qmFileToPath.arg(qmFile));
- }
- else
- {
- qWarning("Translation '%s' not available!", langId.toLatin1().constData());
- }
- }
-
- return success;
-}
-
-/*
- * Install a new translator from file
- */
-bool lamexp_install_translator_from_file(const QString &qmFile)
-{
- QWriteLocker writeLock(&g_lamexp_currentTranslator.lock);
- bool success = false;
-
- if(!g_lamexp_currentTranslator.instance)
- {
- g_lamexp_currentTranslator.instance = new QTranslator();
- }
-
- if(!qmFile.isEmpty())
- {
- QString qmPath = QFileInfo(qmFile).canonicalFilePath();
- QApplication::removeTranslator(g_lamexp_currentTranslator.instance);
- if(success = g_lamexp_currentTranslator.instance->load(qmPath))
- {
- QApplication::installTranslator(g_lamexp_currentTranslator.instance);
- }
- else
- {
- qWarning("Failed to load translation:\n\"%s\"", qmPath.toLatin1().constData());
- }
- }
- else
- {
- QApplication::removeTranslator(g_lamexp_currentTranslator.instance);
- success = true;
- }
-
- return success;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// INITIALIZATION
-///////////////////////////////////////////////////////////////////////////////
-
-extern "C" void _lamexp_global_init_tools(void)
-{
- MUTILS_ZERO_MEMORY(g_lamexp_tools);
- MUTILS_ZERO_MEMORY(g_lamexp_currentTranslator);
- MUTILS_ZERO_MEMORY(g_lamexp_translation);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// FINALIZATION
-///////////////////////////////////////////////////////////////////////////////
-
-extern "C" void _lamexp_global_free_tools(void)
-{
- //Free *all* registered translations
- if(g_lamexp_currentTranslator.instance)
- {
- QApplication::removeTranslator(g_lamexp_currentTranslator.instance);
- MUTILS_DELETE(g_lamexp_currentTranslator.instance);
- }
- MUTILS_DELETE(g_lamexp_translation.files);
- MUTILS_DELETE(g_lamexp_translation.names);
- MUTILS_DELETE(g_lamexp_translation.cntry);
- MUTILS_DELETE(g_lamexp_translation.sysid);
-
- //Free *all* registered tools
- if(g_lamexp_tools.registry)
- {
- QStringList keys = g_lamexp_tools.registry->keys();
- for(int i = 0; i < keys.count(); i++)
- {
- LockedFile *lf = g_lamexp_tools.registry->take(keys.at(i));
- MUTILS_DELETE(lf);
- }
- g_lamexp_tools.registry->clear();
- g_lamexp_tools.versions->clear();
- g_lamexp_tools.tags->clear();
- }
- MUTILS_DELETE(g_lamexp_tools.registry);
- MUTILS_DELETE(g_lamexp_tools.versions);
- MUTILS_DELETE(g_lamexp_tools.tags);
-
+ return g_max_uint32;
}
diff --git a/src/Global_Utils.cpp b/src/Global_Utils.cpp
index b75ec82a..5c623721 100644
--- a/src/Global_Utils.cpp
+++ b/src/Global_Utils.cpp
@@ -151,3 +151,41 @@ const QIcon &lamexp_app_icon(void)
return *g_lamexp_icon_data;
}
+
+/*
+ * Version number to human-readable string
+ */
+const QString lamexp_version2string(const QString &pattern, unsigned int version, const QString &defaultText, const QString &tag)
+{
+ if(version == UINT_MAX)
+ {
+ return defaultText;
+ }
+
+ QString result = pattern;
+ const int digits = result.count(QChar(L'?'), Qt::CaseInsensitive);
+
+ if(digits < 1)
+ {
+ return result;
+ }
+
+ int pos = 0, index = -1;
+ const QString versionStr = QString().sprintf("%0*u", digits, version);
+ Q_ASSERT(versionStr.length() == digits);
+
+ while((index = result.indexOf(QChar(L'?'), Qt::CaseInsensitive)) >= 0)
+ {
+ result[index] = versionStr[pos++];
+ }
+
+ if(!tag.isEmpty())
+ {
+ if((index = result.indexOf(QChar(L'#'), Qt::CaseInsensitive)) >= 0)
+ {
+ result.remove(index, 1).insert(index, tag);
+ }
+ }
+
+ return result;
+}
diff --git a/src/Global_Version.cpp b/src/Global_Version.cpp
index db1b0952..9a59f54d 100644
--- a/src/Global_Version.cpp
+++ b/src/Global_Version.cpp
@@ -23,7 +23,7 @@
#include "Global.h"
//LameXP includes
-#define LAMEXP_INC_CONFIG
+#define LAMEXP_INC_CONFIG 1
#include "Resource.h"
#include "Config.h"
@@ -121,7 +121,7 @@ bool lamexp_version_demo(void)
/*
* Calculate expiration date
*/
-QDate &lamexp_version_expires(void)
+const QDate &lamexp_version_expires(void)
{
QReadLocker readLock(&g_lamexp_version_lock);
diff --git a/src/Global_Zero.cpp b/src/Global_Zero.cpp
index 809c8bff..e4b9c872 100644
--- a/src/Global_Zero.cpp
+++ b/src/Global_Zero.cpp
@@ -39,10 +39,6 @@ Q_IMPORT_PLUGIN(QICOPlugin)
#endif
#endif
-//Localization
-const char* LAMEXP_DEFAULT_LANGID = "en";
-const char* LAMEXP_DEFAULT_TRANSLATION = "LameXP_EN.qm";
-
///////////////////////////////////////////////////////////////////////////////
// GLOBAL FUNCTIONS
///////////////////////////////////////////////////////////////////////////////
@@ -70,14 +66,11 @@ static size_t lamexp_entry_check(void)
extern "C"
{
int mainCRTStartup(void);
- void _lamexp_global_init_tools(void);
- void _lamexp_global_free_tools(void);
}
/*
* Application entry point (runs before static initializers)
*/
-
extern "C" int lamexp_entry_point(void)
{
if(g_lamexp_entry_check_flag != 0x789E09B2)
@@ -85,23 +78,9 @@ extern "C" int lamexp_entry_point(void)
MUtils::OS::fatal_exit(L"Application initialization has failed, take care!");
}
- //Call global initialization functions
- _lamexp_global_init_tools();
-
//Make sure we will pass the check
g_lamexp_entry_check_flag = (~g_lamexp_entry_check_flag);
//Now initialize the C Runtime library!
return mainCRTStartup();
}
-
-/*
- * Application finalization function
- */
-void lamexp_finalization(void)
-{
- qDebug("lamexp_finalization()");
-
- //Call global finalization functions, in proper order
- _lamexp_global_free_tools();
-}
diff --git a/src/Main.cpp b/src/Main.cpp
index b5d2cf1a..d4ab54a1 100644
--- a/src/Main.cpp
+++ b/src/Main.cpp
@@ -48,6 +48,11 @@
#include
#include
+//VLD
+#ifdef _MSC_VER
+#include
+#endif
+
///////////////////////////////////////////////////////////////////////////////
// Helper functions
///////////////////////////////////////////////////////////////////////////////
@@ -114,13 +119,24 @@ static void lamexp_show_splash(const MUtils::CPUFetaures::cpu_info_t &cpuFeature
settingsModel->slowStartup(poInitializationThread->getSlowIndicator());
}
-static int lamexp_main_loop_helper(MUtils::IPCChannel *const ipcChannel, FileListModel *const fileListModel, AudioFileModel_MetaInfo *const metaInfo, SettingsModel *const settingsModel, int &iShutdown)
+static int lamexp_main_loop(const MUtils::CPUFetaures::cpu_info_t &cpuFeatures, MUtils::IPCChannel *const ipcChannel, int &iShutdown)
{
int iResult = -1;
bool bAccepted = true;
+ //Create models
+ QScopedPointer fileListModel(new FileListModel() );
+ QScopedPointer metaInfo (new AudioFileModel_MetaInfo());
+ QScopedPointer settingsModel(new SettingsModel() );
+
+ //Show splash screen
+ lamexp_show_splash(cpuFeatures, settingsModel.data());
+
+ //Validate settings
+ settingsModel->validate();
+
//Create main window
- QScopedPointer poMainWindow(new MainWindow(ipcChannel, fileListModel, metaInfo, settingsModel));
+ QScopedPointer poMainWindow(new MainWindow(ipcChannel, fileListModel.data(), metaInfo.data(), settingsModel.data()));
//Main application loop
while(bAccepted && (iShutdown <= SHUTDOWN_FLAG_NONE))
@@ -136,7 +152,7 @@ static int lamexp_main_loop_helper(MUtils::IPCChannel *const ipcChannel, FileLis
//Show processing dialog
if(bAccepted && (fileListModel->rowCount() > 0))
{
- ProcessingDialog *processingDialog = new ProcessingDialog(fileListModel, metaInfo, settingsModel);
+ ProcessingDialog *processingDialog = new ProcessingDialog(fileListModel.data(), metaInfo.data(), settingsModel.data());
processingDialog->exec();
iShutdown = processingDialog->getShutdownFlag();
MUTILS_DELETE(processingDialog);
@@ -146,23 +162,6 @@ static int lamexp_main_loop_helper(MUtils::IPCChannel *const ipcChannel, FileLis
return iResult;
}
-static int lamexp_main_loop(const MUtils::CPUFetaures::cpu_info_t &cpuFeatures, MUtils::IPCChannel *const ipcChannel, int &iShutdown)
-{
- //Create models
- QScopedPointer fileListModel(new FileListModel() );
- QScopedPointer metaInfo (new AudioFileModel_MetaInfo());
- QScopedPointer settingsModel(new SettingsModel() );
-
- //Show splash screen
- lamexp_show_splash(cpuFeatures, settingsModel.data());
-
- //Validate settings
- settingsModel->validate();
-
- //Main processing loop
- return lamexp_main_loop_helper(ipcChannel, fileListModel.data(), metaInfo.data(), settingsModel.data(), iShutdown);
-}
-
///////////////////////////////////////////////////////////////////////////////
// Main function
///////////////////////////////////////////////////////////////////////////////
@@ -195,18 +194,15 @@ static int lamexp_main(int &argc, char **argv)
qDebug(" Number of CPU's : %d\n", cpuFeatures.count);
//Initialize Qt
- if(!MUtils::Startup::init_qt(argc, argv, QLatin1String("LameXP - Audio Encoder Front-End")))
+ QScopedPointer application(MUtils::Startup::create_qt(argc, argv, QLatin1String("LameXP - Audio Encoder Front-End")));
+ if(application.isNull())
{
- lamexp_finalization();
return EXIT_FAILURE;
}
//Initialize application
- qApp->setWindowIcon(lamexp_app_icon());
- qApp->setApplicationVersion(QString().sprintf("%d.%02d.%04d", lamexp_version_major(), lamexp_version_minor(), lamexp_version_build()));
-
- //Add the default translations
- lamexp_translation_init();
+ application->setWindowIcon(lamexp_app_icon());
+ application->setApplicationVersion(QString().sprintf("%d.%02d.%04d", lamexp_version_major(), lamexp_version_minor(), lamexp_version_build()));
//Check for expiration
if(lamexp_version_demo())
@@ -231,7 +227,6 @@ static int lamexp_main(int &argc, char **argv)
{
if(!arguments[i].compare("--kill", Qt::CaseInsensitive) || !arguments[i].compare("--force-kill", Qt::CaseInsensitive))
{
- lamexp_finalization();
return EXIT_SUCCESS;
}
}
@@ -258,7 +253,6 @@ static int lamexp_main(int &argc, char **argv)
}
//Terminate
- lamexp_finalization();
return iResult;
}
diff --git a/src/Model_Settings.cpp b/src/Model_Settings.cpp
index 4f7dfc16..8dcb7d24 100644
--- a/src/Model_Settings.cpp
+++ b/src/Model_Settings.cpp
@@ -28,6 +28,7 @@
//MUtils
#include
+#include
#include
//Qt
@@ -54,26 +55,22 @@
class SettingsCache
{
public:
- SettingsCache(QSettings *configFile) : m_configFile(configFile)
+ SettingsCache(QSettings *configFile)
+ :
+ m_configFile(configFile),
+ m_cache(new cache_data_t()),
+ m_cacheDirty(new string_set_t())
{
- m_cache = new QHash();
- m_cacheLock = new QMutex();
- m_cacheDirty = new QSet();
}
~SettingsCache(void)
{
flushValues();
-
- MUTILS_DELETE(m_cache);
- MUTILS_DELETE(m_cacheDirty);
- MUTILS_DELETE(m_cacheLock);
- MUTILS_DELETE(m_configFile);
}
inline void storeValue(const QString &key, const QVariant &value)
{
- QMutexLocker lock(m_cacheLock);
+ QWriteLocker writeLock(&m_cacheLock);
if(!m_cache->contains(key))
{
@@ -92,7 +89,15 @@ public:
inline QVariant loadValue(const QString &key, const QVariant &defaultValue) const
{
- QMutexLocker lock(m_cacheLock);
+ QReadLocker readLock(&m_cacheLock);
+
+ if(m_cache->contains(key))
+ {
+ return m_cache->value(key, defaultValue);
+ }
+
+ readLock.unlock();
+ QWriteLocker writeLock(&m_cacheLock);
if(!m_cache->contains(key))
{
@@ -105,7 +110,7 @@ public:
inline void flushValues(void)
{
- QMutexLocker lock(m_cacheLock);
+ QWriteLocker writeLock(&m_cacheLock);
if(!m_cacheDirty->isEmpty())
{
@@ -127,10 +132,14 @@ public:
}
private:
- QSettings *m_configFile;
- QHash *m_cache;
- QSet *m_cacheDirty;
- QMutex *m_cacheLock;
+ typedef QSet string_set_t;
+ typedef QHash cache_data_t;
+
+ QScopedPointer m_configFile;
+ QScopedPointer m_cache;
+ QScopedPointer m_cacheDirty;
+
+ mutable QReadWriteLock m_cacheLock;
};
////////////////////////////////////////////////////////////
@@ -277,13 +286,13 @@ LAMEXP_MAKE_ID(writeMetaTags, "Flags/WriteMetaTags");
//LUT
const int SettingsModel::samplingRates[8] = {0, 16000, 22050, 24000, 32000, 44100, 48000, -1};
-static QReadWriteLock s_lock;
-
////////////////////////////////////////////////////////////
// Constructor
////////////////////////////////////////////////////////////
SettingsModel::SettingsModel(void)
+:
+ m_configCache(NULL)
{
QString configPath = "LameXP.ini";
@@ -357,7 +366,6 @@ SettingsModel::SettingsModel(void)
SettingsModel::~SettingsModel(void)
{
MUTILS_DELETE(m_configCache);
- MUTILS_DELETE(m_defaultLanguage);
}
////////////////////////////////////////////////////////////
@@ -417,10 +425,14 @@ void SettingsModel::validate(void)
}
}
- if(!lamexp_query_translations().contains(this->currentLanguage(), Qt::CaseInsensitive))
+ QStringList translations;
+ if(MUtils::Translation::enumerate(translations) > 0)
{
- qWarning("Current language \"%s\" is unknown, reverting to default language!", this->currentLanguage().toLatin1().constData());
- this->currentLanguage(defaultLanguage());
+ if(!translations.contains(this->currentLanguage(), Qt::CaseInsensitive))
+ {
+ qWarning("Current language \"%s\" is unknown, reverting to default language!", this->currentLanguage().toLatin1().constData());
+ this->currentLanguage(defaultLanguage());
+ }
}
if(this->hibernateComputer())
@@ -435,7 +447,6 @@ void SettingsModel::validate(void)
{
this->overwriteMode(SettingsModel::Overwrite_KeepBoth);
}
-
}
void SettingsModel::syncNow(void)
@@ -447,24 +458,12 @@ void SettingsModel::syncNow(void)
// Private Functions
////////////////////////////////////////////////////////////
-QString *SettingsModel::m_defaultLanguage = NULL;
-
QString SettingsModel::defaultLanguage(void) const
{
- QReadLocker readLock(&s_lock);
+ QMutexLocker lock(&m_defaultLangLock);
//Default already initialized?
- if(m_defaultLanguage)
- {
- return *m_defaultLanguage;
- }
-
- //Acquire write lock now
- readLock.unlock();
- QWriteLocker writeLock(&s_lock);
-
- //Default still not initialized?
- if(m_defaultLanguage)
+ if(!m_defaultLanguage.isNull())
{
return *m_defaultLanguage;
}
@@ -479,40 +478,40 @@ QString SettingsModel::defaultLanguage(void) const
//Check if we can use the default translation
if(systemLanguage.language() == QLocale::English /*|| systemLanguage.language() == QLocale::C*/)
{
- m_defaultLanguage = new QString(LAMEXP_DEFAULT_LANGID);
- return LAMEXP_DEFAULT_LANGID;
+ m_defaultLanguage.reset(new QString(MUtils::Translation::DEFAULT_LANGID));
+ return MUtils::Translation::DEFAULT_LANGID;
}
- //Try to find a suitable translation for the user's system language *and* country
- QStringList languages = lamexp_query_translations();
- while(!languages.isEmpty())
+ QStringList languages;
+ if(MUtils::Translation::enumerate(languages) > 0)
{
- QString currentLangId = languages.takeFirst();
- if(lamexp_translation_sysid(currentLangId) == systemLanguage.language())
+ //Try to find a suitable translation for the user's system language *and* country
+ for(QStringList::ConstIterator iter = languages.constBegin(); iter != languages.constEnd(); iter++)
{
- if(lamexp_translation_country(currentLangId) == systemLanguage.country())
+ if(MUtils::Translation::get_sysid(*iter) == systemLanguage.language())
{
- m_defaultLanguage = new QString(currentLangId);
- return currentLangId;
+ if(MUtils::Translation::get_country(*iter) == systemLanguage.country())
+ {
+ m_defaultLanguage.reset(new QString(*iter));
+ return (*iter);
+ }
+ }
+ }
+
+ //Try to find a suitable translation for the user's system language
+ for(QStringList::ConstIterator iter = languages.constBegin(); iter != languages.constEnd(); iter++)
+ {
+ if(MUtils::Translation::get_sysid(*iter) == systemLanguage.language())
+ {
+ m_defaultLanguage.reset(new QString(*iter));
+ return (*iter);
}
}
}
- //Try to find a suitable translation for the user's system language
- languages = lamexp_query_translations();
- while(!languages.isEmpty())
- {
- QString currentLangId = languages.takeFirst();
- if(lamexp_translation_sysid(currentLangId) == systemLanguage.language())
- {
- m_defaultLanguage = new QString(currentLangId);
- return currentLangId;
- }
- }
-
//Fall back to the default translation
- m_defaultLanguage = new QString(LAMEXP_DEFAULT_LANGID);
- return LAMEXP_DEFAULT_LANGID;
+ m_defaultLanguage.reset(new QString(MUtils::Translation::DEFAULT_LANGID));
+ return MUtils::Translation::DEFAULT_LANGID;
}
QString SettingsModel::defaultDirectory(void) const
diff --git a/src/Model_Settings.h b/src/Model_Settings.h
index 2d92fe08..508573a9 100644
--- a/src/Model_Settings.h
+++ b/src/Model_Settings.h
@@ -22,6 +22,9 @@
#pragma once
+#include
+#include
+
class QString;
class SettingsCache;
@@ -201,13 +204,17 @@ public:
void syncNow(void);
private:
- SettingsCache *m_configCache;
+ SettingsModel(const SettingsModel &other) {}
+ SettingsModel &operator=(const SettingsModel &other) { return *this; }
QString initDirectory(const QString &path) const;
QString defaultLanguage(void) const;
QString defaultDirectory(void) const;
- static QString *m_defaultLanguage;
+ SettingsCache *m_configCache;
+
+ mutable QMutex m_defaultLangLock;
+ mutable QScopedPointer m_defaultLanguage;
};
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/Registry_Encoder.cpp b/src/Registry_Encoder.cpp
index f76e250d..b3852eef 100644
--- a/src/Registry_Encoder.cpp
+++ b/src/Registry_Encoder.cpp
@@ -476,15 +476,15 @@ void EncoderRegistry::resetAllEncoders(SettingsModel *settings)
int EncoderRegistry::getAacEncoder(void)
{
- if(lamexp_tool_check("qaac.exe") && lamexp_tool_check("libsoxr.dll") && lamexp_tool_check("libsoxconvolver.dll"))
+ if(lamexp_tools_check("qaac.exe") && lamexp_tools_check("libsoxr.dll") && lamexp_tools_check("libsoxconvolver.dll"))
{
return SettingsModel::AAC_ENCODER_QAAC;
}
- else if(lamexp_tool_check("fhgaacenc.exe") && lamexp_tool_check("enc_fhgaac.dll") && lamexp_tool_check("nsutil.dll") && lamexp_tool_check("libmp4v2.dll"))
+ else if(lamexp_tools_check("fhgaacenc.exe") && lamexp_tools_check("enc_fhgaac.dll") && lamexp_tools_check("nsutil.dll") && lamexp_tools_check("libmp4v2.dll"))
{
return SettingsModel::AAC_ENCODER_FHG;
}
- else if(lamexp_tool_check("neroAacEnc.exe") && lamexp_tool_check("neroAacDec.exe") && lamexp_tool_check("neroAacTag.exe"))
+ else if(lamexp_tools_check("neroAacEnc.exe") && lamexp_tools_check("neroAacDec.exe") && lamexp_tools_check("neroAacTag.exe"))
{
return SettingsModel::AAC_ENCODER_NERO;
}
diff --git a/src/Thread_CueSplitter.cpp b/src/Thread_CueSplitter.cpp
index ce064d5d..468abcd6 100644
--- a/src/Thread_CueSplitter.cpp
+++ b/src/Thread_CueSplitter.cpp
@@ -56,7 +56,7 @@ CueSplitter::CueSplitter(const QString &outputDir, const QString &baseName, CueS
m_model(model),
m_outputDir(outputDir),
m_baseName(baseName),
- m_soxBin(lamexp_tool_lookup("sox.exe"))
+ m_soxBin(lamexp_tools_lookup("sox.exe"))
{
if(m_soxBin.isEmpty())
{
diff --git a/src/Thread_FileAnalyzer_Task.cpp b/src/Thread_FileAnalyzer_Task.cpp
index 64384682..aa4d0264 100644
--- a/src/Thread_FileAnalyzer_Task.cpp
+++ b/src/Thread_FileAnalyzer_Task.cpp
@@ -63,8 +63,8 @@ AnalyzeTask::AnalyzeTask(const int taskId, const QString &inputFile, const QStri
m_taskId(taskId),
m_inputFile(inputFile),
m_templateFile(templateFile),
- m_mediaInfoBin(lamexp_tool_lookup("mediainfo.exe")),
- m_avs2wavBin(lamexp_tool_lookup("avs2wav.exe")),
+ m_mediaInfoBin(lamexp_tools_lookup("mediainfo.exe")),
+ m_avs2wavBin(lamexp_tools_lookup("avs2wav.exe")),
m_abortFlag(abortFlag)
{
if(m_mediaInfoBin.isEmpty() || m_avs2wavBin.isEmpty())
diff --git a/src/Thread_Initialization.cpp b/src/Thread_Initialization.cpp
index 99d63e50..26b0121e 100644
--- a/src/Thread_Initialization.cpp
+++ b/src/Thread_Initialization.cpp
@@ -23,13 +23,15 @@
#include "Thread_Initialization.h"
//Internal
-#include "LockedFile.h"
+#define LAMEXP_INC_TOOLS 1
#include "Tools.h"
+#include "LockedFile.h"
#include "Tool_Abstract.h"
//MUtils
#include
#include
+#include
#include
//Qt
@@ -183,7 +185,7 @@ protected:
if(lockedFile)
{
- lamexp_tool_register(toolShortName, lockedFile, version, &m_toolTag);
+ lamexp_tools_register(toolShortName, lockedFile, version, m_toolTag);
}
}
@@ -483,7 +485,8 @@ void InitializationThread::delay(void)
void InitializationThread::initTranslations(void)
{
//Search for language files
- QStringList qmFiles = QDir(":/localization").entryList(QStringList() << "LameXP_??.qm", QDir::Files, QDir::Name);
+ const QDir qmDirectory(":/localization");
+ const QStringList qmFiles = qmDirectory.entryList(QStringList() << "LameXP_??.qm", QDir::Files, QDir::Name);
//Make sure we found at least one translation
if(qmFiles.count() < 1)
@@ -492,27 +495,31 @@ void InitializationThread::initTranslations(void)
return;
}
+ //Initialize variables
+ const QString langResTemplate(":/localization/%1.txt");
+ QRegExp langIdExp("^LameXP_(\\w\\w)\\.qm$", Qt::CaseInsensitive);
+
//Add all available translations
- while(!qmFiles.isEmpty())
+ for(QStringList::ConstIterator iter = qmFiles.constBegin(); iter != qmFiles.constEnd(); iter++)
{
+ const QString langFile = qmDirectory.absoluteFilePath(*iter);
QString langId, langName;
unsigned int systemId = 0, country = 0;
- QString qmFile = qmFiles.takeFirst();
- QRegExp langIdExp("LameXP_(\\w\\w)\\.qm", Qt::CaseInsensitive);
- if(langIdExp.indexIn(qmFile) >= 0)
+ if(QFileInfo(langFile).isFile() && (langIdExp.indexIn(*iter) >= 0))
{
langId = langIdExp.cap(1).toLower();
- QResource langRes = QResource(QString(":/localization/%1.txt").arg(qmFile));
+ QResource langRes = QResource(langResTemplate.arg(*iter));
if(langRes.isValid() && langRes.size() > 0)
{
QByteArray data = QByteArray::fromRawData(reinterpret_cast(langRes.data()), langRes.size());
QTextStream stream(&data, QIODevice::ReadOnly);
stream.setAutoDetectUnicode(false); stream.setCodec("UTF-8");
- while(!stream.atEnd())
+
+ while(!(stream.atEnd() || (stream.status() != QTextStream::Ok)))
{
QStringList langInfo = stream.readLine().simplified().split(",", QString::SkipEmptyParts);
- if(langInfo.count() == 3)
+ if(langInfo.count() >= 3)
{
systemId = langInfo.at(0).trimmed().toUInt();
country = langInfo.at(1).trimmed().toUInt();
@@ -523,15 +530,15 @@ void InitializationThread::initTranslations(void)
}
}
- if(!(langId.isEmpty() || langName.isEmpty() || systemId == 0))
+ if(!(langId.isEmpty() || langName.isEmpty() || (systemId == 0)))
{
- if(lamexp_translation_register(langId, qmFile, langName, systemId, country))
+ if(MUtils::Translation::insert(langId, langFile, langName, systemId, country))
{
- qDebug("Registering translation: %s = %s (%u) [%u]", MUTILS_UTF8(qmFile), MUTILS_UTF8(langName), systemId, country);
+ qDebug("Registering translation: %s = %s (%u) [%u]", MUTILS_UTF8(*iter), MUTILS_UTF8(langName), systemId, country);
}
else
{
- qWarning("Failed to register: %s", qmFile.toLatin1().constData());
+ qWarning("Failed to register: %s", langFile.toLatin1().constData());
}
}
}
@@ -647,7 +654,7 @@ void InitializationThread::initNeroAac(void)
for(int i = 0; i < 3; i++)
{
- lamexp_tool_register(neroFileInfo[i].fileName(), neroBin[i], neroVersion);
+ lamexp_tools_register(neroFileInfo[i].fileName(), neroBin[i], neroVersion);
}
}
@@ -755,7 +762,7 @@ void InitializationThread::initFhgAac(void)
for(int i = 0; i < 5; i++)
{
- lamexp_tool_register(fhgFileInfo[i].fileName(), fhgBin[i], fhgVersion);
+ lamexp_tools_register(fhgFileInfo[i].fileName(), fhgBin[i], fhgVersion);
}
}
@@ -909,10 +916,10 @@ void InitializationThread::initQAac(void)
return;
}
- lamexp_tool_register(qaacFileInfo[0].fileName(), qaacBin[0], qaacVersion);
- lamexp_tool_register(qaacFileInfo[1].fileName(), qaacBin[1], qaacVersion);
- lamexp_tool_register(qaacFileInfo[2].fileName(), qaacBin[2], qaacVersion);
- lamexp_tool_register(qaacFileInfo[3].fileName(), qaacBin[3], qaacVersion);
+ lamexp_tools_register(qaacFileInfo[0].fileName(), qaacBin[0], qaacVersion);
+ lamexp_tools_register(qaacFileInfo[1].fileName(), qaacBin[1], qaacVersion);
+ lamexp_tools_register(qaacFileInfo[2].fileName(), qaacBin[2], qaacVersion);
+ lamexp_tools_register(qaacFileInfo[3].fileName(), qaacBin[3], qaacVersion);
}
void InitializationThread::selfTest(void)
diff --git a/src/Tool_WaveProperties.cpp b/src/Tool_WaveProperties.cpp
index c1229497..4d454e10 100644
--- a/src/Tool_WaveProperties.cpp
+++ b/src/Tool_WaveProperties.cpp
@@ -35,7 +35,7 @@
WaveProperties::WaveProperties(void)
:
- m_binary(lamexp_tool_lookup("sox.exe"))
+ m_binary(lamexp_tools_lookup("sox.exe"))
{
if(m_binary.isEmpty())
{
diff --git a/src/Tools.h b/src/Tools.h
index adeb3cb4..810ba510 100644
--- a/src/Tools.h
+++ b/src/Tools.h
@@ -22,6 +22,10 @@
#include
+#ifndef LAMEXP_INC_TOOLS
+#error Please do *not* include TOOLS.H directly!
+#endif
+
////////////////////////////////////////////////////////////
// CPU FLags
////////////////////////////////////////////////////////////