Moved various auxiliary macros into the MUtils library.

This commit is contained in:
LoRd_MuldeR 2014-11-30 21:32:23 +01:00
parent e579a5057d
commit dc98131fd1
57 changed files with 303 additions and 317 deletions

View File

@ -35,7 +35,7 @@
#define VER_LAMEXP_MINOR_LO 1
#define VER_LAMEXP_TYPE Beta
#define VER_LAMEXP_PATCH 3
#define VER_LAMEXP_BUILD 1607
#define VER_LAMEXP_BUILD 1608
#define VER_LAMEXP_CONFG 1558
///////////////////////////////////////////////////////////////////////////////

View File

@ -22,8 +22,13 @@
#include "Decoder_AAC.h"
//Internal
#include "Global.h"
//MUtils
#include <MUtils/Exception.h>
//Qt
#include <QDir>
#include <QProcess>
#include <QRegExp>
@ -34,7 +39,7 @@ AACDecoder::AACDecoder(void)
{
if(m_binary.isEmpty())
{
THROW("Error initializing AAC decoder. Tool 'faad.exe' is not registred!");
MUTILS_THROW("Error initializing AAC decoder. Tool 'faad.exe' is not registred!");
}
}

View File

@ -22,8 +22,13 @@
#include "Decoder_AC3.h"
//Internal
#include "Global.h"
//MUtils
#include <MUtils/Exception.h>
//Qt
#include <QDir>
#include <QProcess>
#include <QRegExp>
@ -34,7 +39,7 @@ AC3Decoder::AC3Decoder(void)
{
if(m_binary.isEmpty())
{
THROW("Error initializing Valib decoder. Tool 'valdec.exe' is not registred!");
MUTILS_THROW("Error initializing Valib decoder. Tool 'valdec.exe' is not registred!");
}
}

View File

@ -22,8 +22,13 @@
#include "Decoder_ADPCM.h"
//Internal
#include "Global.h"
//MUtils
#include <MUtils/Exception.h>
//Qt
#include <QDir>
#include <QProcess>
#include <QRegExp>
@ -34,7 +39,7 @@ ADPCMDecoder::ADPCMDecoder(void)
{
if(m_binary.isEmpty())
{
THROW("Error initializing Vorbis decoder. Tool 'sox.exe' is not registred!");
MUTILS_THROW("Error initializing Vorbis decoder. Tool 'sox.exe' is not registred!");
}
}

View File

@ -22,8 +22,13 @@
#include "Decoder_ALAC.h"
//Internal
#include "Global.h"
//MUtils
#include <MUtils/Exception.h>
//Qt
#include <QDir>
#include <QProcess>
#include <QRegExp>
@ -35,7 +40,7 @@ ALACDecoder::ALACDecoder(void)
{
if(m_binary.isEmpty())
{
THROW("Error initializing ALAC decoder. Tool 'refalac.exe' is not registred!");
MUTILS_THROW("Error initializing ALAC decoder. Tool 'refalac.exe' is not registred!");
}
}

View File

@ -22,8 +22,14 @@
#include "Decoder_Avisynth.h"
//Internal
#include "Global.h"
//MUtils
#include <MUtils/Exception.h>
//Qt
#include <QDir>
#include <QProcess>
#include <QRegExp>
@ -34,7 +40,7 @@ AvisynthDecoder::AvisynthDecoder(void)
{
if(m_binary.isEmpty())
{
THROW("Error initializing Avisynth decoder. Tool 'avs2wav.exe' is not registred!");
MUTILS_THROW("Error initializing Avisynth decoder. Tool 'avs2wav.exe' is not registred!");
}
}

View File

@ -22,8 +22,13 @@
#include "Decoder_FLAC.h"
//Internal
#include "Global.h"
//MUtils
#include <MUtils/Exception.h>
//Qt
#include <QDir>
#include <QProcess>
#include <QRegExp>
@ -34,7 +39,7 @@ FLACDecoder::FLACDecoder(void)
{
if(m_binary.isEmpty())
{
THROW("Error initializing FLAC decoder. Tool 'flac.exe' is not registred!");
MUTILS_THROW("Error initializing FLAC decoder. Tool 'flac.exe' is not registred!");
}
}

View File

@ -22,8 +22,13 @@
#include "Decoder_MAC.h"
//Internal
#include "Global.h"
//MUtils
#include <MUtils/Exception.h>
//Qt
#include <QDir>
#include <QProcess>
#include <QRegExp>
@ -34,7 +39,7 @@ MACDecoder::MACDecoder(void)
{
if(m_binary.isEmpty())
{
THROW("Error initializing MAC decoder. Tool 'mac.exe' is not registred!");
MUTILS_THROW("Error initializing MAC decoder. Tool 'mac.exe' is not registred!");
}
}

View File

@ -22,8 +22,13 @@
#include "Decoder_MP3.h"
//Internal
#include "Global.h"
//MUtils
#include <MUtils/Exception.h>
//Qt
#include <QDir>
#include <QProcess>
#include <QRegExp>
@ -34,7 +39,7 @@ MP3Decoder::MP3Decoder(void)
{
if(m_binary.isEmpty())
{
THROW("Error initializing MPG123 decoder. Tool 'mpg123.exe' is not registred!");
MUTILS_THROW("Error initializing MPG123 decoder. Tool 'mpg123.exe' is not registred!");
}
}

View File

@ -22,8 +22,13 @@
#include "Decoder_Musepack.h"
//Internal
#include "Global.h"
//MUtils
#include <MUtils/Exception.h>
//Qt
#include <QDir>
#include <QProcess>
#include <QRegExp>
@ -35,7 +40,7 @@ MusepackDecoder::MusepackDecoder(void)
{
if(m_binary.isEmpty())
{
THROW("Error initializing Musepack decoder. Tool 'mpcdec.exe' is not registred!");
MUTILS_THROW("Error initializing Musepack decoder. Tool 'mpcdec.exe' is not registred!");
}
}

View File

@ -22,8 +22,13 @@
#include "Decoder_Opus.h"
//Internal
#include "Global.h"
//MUtils
#include <MUtils/Exception.h>
//Qt
#include <QDir>
#include <QProcess>
#include <QRegExp>
@ -37,7 +42,7 @@ OpusDecoder::OpusDecoder(void)
{
if(m_binary.isEmpty())
{
THROW("Error initializing Opus decoder. Tool 'opusdec.exe' is not registred!");
MUTILS_THROW("Error initializing Opus decoder. Tool 'opusdec.exe' is not registred!");
}
}

View File

@ -22,8 +22,13 @@
#include "Decoder_Shorten.h"
//Internal
#include "Global.h"
//MUtils
#include <MUtils/Exception.h>
//Qt
#include <QDir>
#include <QProcess>
#include <QRegExp>
@ -35,7 +40,7 @@ ShortenDecoder::ShortenDecoder(void)
{
if(m_binary.isEmpty())
{
THROW("Error initializing Shorten decoder. Tool 'shorten.exe' is not registred!");
MUTILS_THROW("Error initializing Shorten decoder. Tool 'shorten.exe' is not registred!");
}
}

View File

@ -22,8 +22,13 @@
#include "Decoder_Speex.h"
//Internal
#include "Global.h"
//MUtils
#include <MUtils/Exception.h>
//Qt
#include <QDir>
#include <QProcess>
#include <QRegExp>
@ -34,7 +39,7 @@ SpeexDecoder::SpeexDecoder(void)
{
if(m_binary.isEmpty())
{
THROW("Error initializing Speex decoder. Tool 'speexdec.exe' is not registred!");
MUTILS_THROW("Error initializing Speex decoder. Tool 'speexdec.exe' is not registred!");
}
}

View File

@ -22,8 +22,13 @@
#include "Decoder_TTA.h"
//Internal
#include "Global.h"
//MUtils
#include <MUtils/Exception.h>
//Qt
#include <QDir>
#include <QProcess>
#include <QRegExp>
@ -35,7 +40,7 @@ TTADecoder::TTADecoder(void)
{
if(m_binary.isEmpty())
{
THROW("Error initializing TTA decoder. Tool 'ttaenc.exe' is not registred!");
MUTILS_THROW("Error initializing TTA decoder. Tool 'ttaenc.exe' is not registred!");
}
}

View File

@ -22,8 +22,13 @@
#include "Decoder_Vorbis.h"
//Internal
#include "Global.h"
//MUtils
#include <MUtils/Exception.h>
//Qt
#include <QDir>
#include <QProcess>
#include <QRegExp>
@ -34,7 +39,7 @@ VorbisDecoder::VorbisDecoder(void)
{
if(m_binary.isEmpty())
{
THROW("Error initializing Vorbis decoder. Tool 'oggdec.exe' is not registred!");
MUTILS_THROW("Error initializing Vorbis decoder. Tool 'oggdec.exe' is not registred!");
}
}

View File

@ -22,8 +22,13 @@
#include "Decoder_WMA.h"
//Internal
#include "Global.h"
//MUtils
#include <MUtils/Exception.h>
//Qt
#include <QDir>
#include <QProcess>
#include <QRegExp>
@ -36,7 +41,7 @@ WMADecoder::WMADecoder(void)
{
if(m_binary.isEmpty())
{
THROW("Error initializing WMA decoder. Tool 'wma2wav.exe' is not registred!");
MUTILS_THROW("Error initializing WMA decoder. Tool 'wma2wav.exe' is not registred!");
}
}

View File

@ -22,8 +22,13 @@
#include "Decoder_WavPack.h"
//Internal
#include "Global.h"
//MUtils
#include <MUtils/Exception.h>
//Qt
#include <QDir>
#include <QProcess>
#include <QRegExp>
@ -34,7 +39,7 @@ WavPackDecoder::WavPackDecoder(void)
{
if(m_binary.isEmpty())
{
THROW("Error initializing WavPack decoder. Tool 'wvunpack.exe' is not registred!");
MUTILS_THROW("Error initializing WavPack decoder. Tool 'wvunpack.exe' is not registred!");
}
}

View File

@ -51,6 +51,7 @@
#include <MUtils/Global.h>
#include <MUtils/OSSupport.h>
#include <MUtils/GUI.h>
#include <MUtils/Exception.h>
#include <MUtils/Version.h>
//Qt includes
@ -3342,7 +3343,7 @@ void MainWindow::outputFolderMouseEventOccurred(QWidget *sender, QEvent *event)
}
else
{
THROW("Oups, this is not supposed to happen!");
MUTILS_THROW("Oups, this is not supposed to happen!");
}
}
}
@ -3421,7 +3422,7 @@ void MainWindow::updateEncoder(int id)
if(ui->radioButtonModeQuality->isEnabled()) ui->radioButtonModeQuality->setChecked(true);
else if(ui->radioButtonModeAverageBitrate->isEnabled()) ui->radioButtonModeAverageBitrate->setChecked(true);
else if(ui->radioButtonConstBitrate->isEnabled()) ui->radioButtonConstBitrate->setChecked(true);
else THROW("It appears that the encoder does not support *any* RC mode!");
else MUTILS_THROW("It appears that the encoder does not support *any* RC mode!");
//Apply current RC mode
const int currentRCMode = EncoderRegistry::loadEncoderMode(m_settings, id);
@ -3430,7 +3431,7 @@ void MainWindow::updateEncoder(int id)
case SettingsModel::VBRMode: if(ui->radioButtonModeQuality->isEnabled()) ui->radioButtonModeQuality->setChecked(true); break;
case SettingsModel::ABRMode: if(ui->radioButtonModeAverageBitrate->isEnabled()) ui->radioButtonModeAverageBitrate->setChecked(true); break;
case SettingsModel::CBRMode: if(ui->radioButtonConstBitrate->isEnabled()) ui->radioButtonConstBitrate->setChecked(true); break;
default: THROW("updateEncoder(): Unknown rc-mode encountered!");
default: MUTILS_THROW("updateEncoder(): Unknown rc-mode encountered!");
}
//Display encoder description
@ -3551,7 +3552,7 @@ void MainWindow::updateBitrate(int value)
ui->labelBitrate->setText(tr("Uncompressed"));
break;
default:
THROW("Unknown display value type encountered!");
MUTILS_THROW("Unknown display value type encountered!");
break;
}
}

View File

@ -34,6 +34,7 @@
//MUtils
#include <MUtils/UpdateChecker.h>
#include <MUtils/Version.h>
#include <MUtils/Exception.h>
//Qt includes
#include <QClipboard>
@ -48,18 +49,6 @@
///////////////////////////////////////////////////////////////////////////////
/*
template <class T>
T DO_ASYNC(T (*functionPointer)())
{
QFutureWatcher<T> watcher; QEventLoop loop;
QObject::connect(&watcher, SIGNAL(finished()), &loop, SLOT(quit()));
watcher.setFuture(QtConcurrent::run(functionPointer));
loop.exec(QEventLoop::ExcludeUserInputEvents);
return watcher.result();
}
*/
#define SHOW_HINT(TEXT, ICON) do \
{ \
ui->hintLabel->setText((TEXT)); \
@ -97,7 +86,7 @@ UpdateDialog::UpdateDialog(SettingsModel *settings, QWidget *parent)
{
if(m_binaryUpdater.isEmpty())
{
THROW("Tools not initialized correctly!");
MUTILS_THROW("Tools not initialized correctly!");
}
//Init the dialog, from the .ui file

View File

@ -49,7 +49,7 @@ class AACEncoderInfo : public AbstractEncoderInfo
return true;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -65,7 +65,7 @@ class AACEncoderInfo : public AbstractEncoderInfo
return 41;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -81,7 +81,7 @@ class AACEncoderInfo : public AbstractEncoderInfo
return qBound(8, index2bitrate(index), 400);
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -99,7 +99,7 @@ class AACEncoderInfo : public AbstractEncoderInfo
return TYPE_BITRATE;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -123,7 +123,7 @@ AACEncoder::AACEncoder(void)
{
if(m_binary_enc.isEmpty() || m_binary_tag.isEmpty() || m_binary_sox.isEmpty())
{
THROW("Error initializing AAC encoder. Tool 'neroAacEnc.exe' is not registred!");
MUTILS_THROW("Error initializing AAC encoder. Tool 'neroAacEnc.exe' is not registred!");
}
m_configProfile = 0;
@ -152,7 +152,7 @@ bool AACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
args << "-cbr" << QString::number(qBound(8, index2bitrate(m_configBitrate), 400) * 1000);
break;
default:
THROW("Bad rate-control mode!");
MUTILS_THROW("Bad rate-control mode!");
break;
}

View File

@ -52,7 +52,7 @@ class FHGAACEncoderInfo : public AbstractEncoderInfo
return false;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -68,7 +68,7 @@ class FHGAACEncoderInfo : public AbstractEncoderInfo
return 52;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -84,7 +84,7 @@ class FHGAACEncoderInfo : public AbstractEncoderInfo
return qBound(8, index2bitrate(index), 576);
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -102,7 +102,7 @@ class FHGAACEncoderInfo : public AbstractEncoderInfo
return TYPE_BITRATE;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -125,7 +125,7 @@ FHGAACEncoder::FHGAACEncoder(void)
{
if(m_binary_enc.isEmpty() || m_binary_dll.isEmpty())
{
THROW("Error initializing FhgAacEnc. Tool 'fhgaacenc.exe' is not registred!");
MUTILS_THROW("Error initializing FhgAacEnc. Tool 'fhgaacenc.exe' is not registred!");
}
m_configProfile = 0;
@ -169,7 +169,7 @@ bool FHGAACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaI
args << "--vbr" << QString::number(qBound(1, m_configBitrate + 1, 6));
break;
default:
THROW("Bad rate-control mode!");
MUTILS_THROW("Bad rate-control mode!");
break;
}

View File

@ -60,7 +60,7 @@ class QAACEncoderInfo : public AbstractEncoderInfo
return true;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -76,7 +76,7 @@ class QAACEncoderInfo : public AbstractEncoderInfo
return 52;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -92,7 +92,7 @@ class QAACEncoderInfo : public AbstractEncoderInfo
return qBound(8, index2bitrate(index), 576);
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -110,7 +110,7 @@ class QAACEncoderInfo : public AbstractEncoderInfo
return TYPE_BITRATE;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -134,7 +134,7 @@ QAACEncoder::QAACEncoder(void)
{
if(m_binary_qaac.isEmpty() || m_binary_soxr.isEmpty() || m_binary_soxc.isEmpty())
{
THROW("Error initializing QAAC. Tool 'qaac.exe' is not registred!");
MUTILS_THROW("Error initializing QAAC. Tool 'qaac.exe' is not registred!");
}
m_configProfile = 0;
@ -178,7 +178,7 @@ bool QAACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInf
args << "--tvbr" << QString::number(g_qaacVBRQualityLUT[qBound(0, m_configBitrate , 14)]);
break;
default:
THROW("Bad rate-control mode!");
MUTILS_THROW("Bad rate-control mode!");
break;
}

View File

@ -48,7 +48,7 @@ class AC3EncoderInfo : public AbstractEncoderInfo
return false;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -66,7 +66,7 @@ class AC3EncoderInfo : public AbstractEncoderInfo
return 19;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -82,7 +82,7 @@ class AC3EncoderInfo : public AbstractEncoderInfo
return g_ac3BitratesLUT[qBound(0, index, 18)];
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -98,7 +98,7 @@ class AC3EncoderInfo : public AbstractEncoderInfo
return TYPE_BITRATE;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -120,7 +120,7 @@ AC3Encoder::AC3Encoder(void)
{
if(m_binary.isEmpty())
{
THROW("Error initializing FLAC encoder. Tool 'aften.exe' is not registred!");
MUTILS_THROW("Error initializing FLAC encoder. Tool 'aften.exe' is not registred!");
}
m_configAudioCodingMode = 0;
@ -147,7 +147,7 @@ bool AC3Encoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
args << "-b" << QString::number(g_ac3BitratesLUT[qBound(0, m_configBitrate, 18)]);
break;
default:
THROW("Bad rate-control mode!");
MUTILS_THROW("Bad rate-control mode!");
break;
}

View File

@ -22,10 +22,14 @@
#pragma once
//Internal
#include "Global.h"
#include "Tool_Abstract.h"
#include "Model_AudioFile.h"
//MUtils
#include <MUtils/Exception.h>
class QProcess;
class QStringList;
class QMutex;
@ -76,7 +80,7 @@ public:
//Encoder info
static const AbstractEncoderInfo *getEncoderInfo(void)
{
THROW("This method shall be re-implemented in derived classes!");
MUTILS_THROW("This method shall be re-implemented in derived classes!");
return NULL;
}

View File

@ -52,7 +52,7 @@ class DCAEncoderInfo : public AbstractEncoderInfo
return true;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -68,7 +68,7 @@ class DCAEncoderInfo : public AbstractEncoderInfo
return 32;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -84,7 +84,7 @@ class DCAEncoderInfo : public AbstractEncoderInfo
return qBound(32, index2bitrate(index), 4096);
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -100,7 +100,7 @@ class DCAEncoderInfo : public AbstractEncoderInfo
return TYPE_BITRATE;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -122,7 +122,7 @@ DCAEncoder::DCAEncoder(void)
{
if(m_binary.isEmpty())
{
THROW("Error initializing DCA encoder. Tool 'dcaenc.exe' is not registred!");
MUTILS_THROW("Error initializing DCA encoder. Tool 'dcaenc.exe' is not registred!");
}
}

View File

@ -47,7 +47,7 @@ public:
return false;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -63,7 +63,7 @@ public:
return 0;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -79,7 +79,7 @@ public:
return -1;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -94,7 +94,7 @@ public:
case SettingsModel::CBRMode:
return -1;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -116,7 +116,7 @@ FLACEncoder::FLACEncoder(void)
{
if(m_binary.isEmpty())
{
THROW("Error initializing FLAC encoder. Tool 'flac.exe' is not registred!");
MUTILS_THROW("Error initializing FLAC encoder. Tool 'flac.exe' is not registred!");
}
}

View File

@ -46,7 +46,7 @@ class MACEncoderInfo : public AbstractEncoderInfo
return false;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -62,7 +62,7 @@ class MACEncoderInfo : public AbstractEncoderInfo
return -1;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -78,7 +78,7 @@ class MACEncoderInfo : public AbstractEncoderInfo
return -1;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -94,7 +94,7 @@ class MACEncoderInfo : public AbstractEncoderInfo
return -1;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -117,7 +117,7 @@ MACEncoder::MACEncoder(void)
{
if(m_binary_enc.isEmpty() || m_binary_tag.isEmpty())
{
THROW("Error initializing MAC encoder. Tool 'mac.exe' or 'tag.exe' is not registred!");
MUTILS_THROW("Error initializing MAC encoder. Tool 'mac.exe' or 'tag.exe' is not registred!");
}
}
@ -141,7 +141,7 @@ bool MACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
args << QString().sprintf("-c%d", (m_configBitrate + 1) * 1000);
break;
default:
THROW("Bad rate-control mode!");
MUTILS_THROW("Bad rate-control mode!");
break;
}

View File

@ -49,7 +49,7 @@ class MP3EncoderInfo : public AbstractEncoderInfo
return true;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -65,7 +65,7 @@ class MP3EncoderInfo : public AbstractEncoderInfo
return 14;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -81,7 +81,7 @@ class MP3EncoderInfo : public AbstractEncoderInfo
return g_mp3BitrateLUT[qBound(0, index, 13)];
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -99,7 +99,7 @@ class MP3EncoderInfo : public AbstractEncoderInfo
return TYPE_BITRATE;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -121,7 +121,7 @@ MP3Encoder::MP3Encoder(void)
{
if(m_binary.isEmpty())
{
THROW("Error initializing MP3 encoder. Tool 'lame.exe' is not registred!");
MUTILS_THROW("Error initializing MP3 encoder. Tool 'lame.exe' is not registred!");
}
m_algorithmQuality = 2;
@ -156,7 +156,7 @@ bool MP3Encoder::encode(const QString &sourceFile, const AudioFileModel_MetaInfo
args << "-b" << QString::number(g_mp3BitrateLUT[qBound(0, m_configBitrate, 13)]);
break;
default:
THROW("Bad rate-control mode!");
MUTILS_THROW("Bad rate-control mode!");
break;
}

View File

@ -45,7 +45,7 @@ class OpusEncoderInfo : public AbstractEncoderInfo
return true;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -59,7 +59,7 @@ class OpusEncoderInfo : public AbstractEncoderInfo
return 32;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -73,7 +73,7 @@ class OpusEncoderInfo : public AbstractEncoderInfo
return qBound(8, (index + 1) * 8, 256);
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -89,7 +89,7 @@ class OpusEncoderInfo : public AbstractEncoderInfo
return TYPE_BITRATE;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -111,7 +111,7 @@ OpusEncoder::OpusEncoder(void)
{
if(m_binary.isEmpty())
{
THROW("Error initializing Opus encoder. Tool 'opusenc.exe' is not registred!");
MUTILS_THROW("Error initializing Opus encoder. Tool 'opusenc.exe' is not registred!");
}
m_configOptimizeFor = 0;
@ -140,7 +140,7 @@ bool OpusEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInf
args << "--hard-cbr";
break;
default:
THROW("Bad rate-control mode!");
MUTILS_THROW("Bad rate-control mode!");
break;
}

View File

@ -46,7 +46,7 @@ class VorbisEncoderInfo : public AbstractEncoderInfo
return false;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -62,7 +62,7 @@ class VorbisEncoderInfo : public AbstractEncoderInfo
return 60;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -78,7 +78,7 @@ class VorbisEncoderInfo : public AbstractEncoderInfo
return qBound(32, (index + 4) * 8, 500);
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -96,7 +96,7 @@ class VorbisEncoderInfo : public AbstractEncoderInfo
return TYPE_BITRATE;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -118,7 +118,7 @@ VorbisEncoder::VorbisEncoder(void)
{
if(m_binary.isEmpty())
{
THROW("Error initializing Vorbis encoder. Tool 'oggenc2.exe' is not registred!");
MUTILS_THROW("Error initializing Vorbis encoder. Tool 'oggenc2.exe' is not registred!");
}
m_configBitrateMaximum = 0;
@ -145,7 +145,7 @@ bool VorbisEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaI
args << "-b" << QString::number(qBound(32, (m_configBitrate + 4) * 8, 500));
break;
default:
THROW("Bad rate-control mode!");
MUTILS_THROW("Bad rate-control mode!");
break;
}

View File

@ -54,7 +54,7 @@ public:
return true;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -68,7 +68,7 @@ public:
return 0;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -82,7 +82,7 @@ public:
return -1;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}
@ -96,7 +96,7 @@ public:
return TYPE_UNCOMPRESSED;
break;
default:
THROW("Bad RC mode specified!");
MUTILS_THROW("Bad RC mode specified!");
}
}

View File

@ -22,10 +22,15 @@
#include "Filter_Downmix.h"
//Internal
#include "Global.h"
#include "Tool_WaveProperties.h"
#include "Model_AudioFile.h"
//MUtils
#include <MUtils/Exception.h>
//Qt
#include <QDir>
#include <QProcess>
#include <QRegExp>
@ -36,7 +41,7 @@ DownmixFilter::DownmixFilter(void)
{
if(m_binary.isEmpty())
{
THROW("Error initializing SoX filter. Tool 'sox.exe' is not registred!");
MUTILS_THROW("Error initializing SoX filter. Tool 'sox.exe' is not registred!");
}
}

View File

@ -22,8 +22,13 @@
#include "Filter_Normalize.h"
//Internal
#include "Global.h"
//MUtils
#include <MUtils/Exception.h>
//Qt
#include <QDir>
#include <QProcess>
#include <QRegExp>
@ -34,7 +39,7 @@ NormalizeFilter::NormalizeFilter(int peakVolume, int equalizationMode)
{
if(m_binary.isEmpty())
{
THROW("Error initializing SoX filter. Tool 'sox.exe' is not registred!");
MUTILS_THROW("Error initializing SoX filter. Tool 'sox.exe' is not registred!");
}
m_peakVolume = qMin(-50, qMax(-3200, peakVolume));

View File

@ -22,9 +22,14 @@
#include "Filter_Resample.h"
//Internal
#include "Global.h"
#include "Model_AudioFile.h"
//MUtils
#include <MUtils/Exception.h>
//Qt
#include <QDir>
#include <QProcess>
#include <QRegExp>
@ -40,7 +45,7 @@ ResampleFilter::ResampleFilter(int samplingRate, int bitDepth)
{
if(m_binary.isEmpty())
{
THROW("Error initializing SoX filter. Tool 'sox.exe' is not registred!");
MUTILS_THROW("Error initializing SoX filter. Tool 'sox.exe' is not registred!");
}
m_samplingRate = (samplingRate > 0) ? qBound(8000, samplingRate, 192000) : 0;

View File

@ -22,8 +22,13 @@
#include "Filter_ToneAdjust.h"
//Internal
#include "Global.h"
//MUtils
#include <MUtils/Exception.h>
//Qt
#include <QDir>
#include <QProcess>
#include <QRegExp>
@ -35,7 +40,7 @@ ToneAdjustFilter::ToneAdjustFilter(int bass, int treble)
{
if(m_binary.isEmpty())
{
THROW("Error initializing SoX filter. Tool 'sox.exe' is not registred!");
MUTILS_THROW("Error initializing SoX filter. Tool 'sox.exe' is not registred!");
}
m_bass = qMax(-2000, qMin(2000, bass));

View File

@ -129,7 +129,6 @@ lamexp_icon_t *lamexp_set_window_icon(QWidget *window, const QIcon &icon, const
bool lamexp_sheet_of_glass(QWidget *window);
bool lamexp_sheet_of_glass_update(QWidget *window);
bool lamexp_shutdown_computer(const QString &message, const unsigned long timeout = 30, const bool forceShutdown = true, const bool hibernate = false);
void lamexp_sleep(const unsigned int delay);
QColor lamexp_system_color(const int color_id);
const char *lamexp_support_url(void);
bool lamexp_themes_enabled(void);
@ -160,50 +159,4 @@ const char *lamexp_website_url(void);
// HELPER MACROS
///////////////////////////////////////////////////////////////////////////////
#define LAMEXP_CLOSE(HANDLE) do { if(HANDLE != NULL && HANDLE != INVALID_HANDLE_VALUE) { CloseHandle(HANDLE); HANDLE = NULL; } } while(0)
#define LAMEXP_MAKE_STRING_EX(X) #X
#define LAMEXP_MAKE_STRING(X) LAMEXP_MAKE_STRING_EX(X)
#define LAMEXP_SAFE_FREE(PTR) do { if(PTR) { free((void*) PTR); PTR = NULL; } } while(0)
#define LAMEXP_ZERO_MEMORY(X) memset(&(X), 0, sizeof((X)))
#define NOBR(STR) (QString("<nobr>%1</nobr>").arg((STR)).replace("-", "&minus;"))
//Helper macro for throwing exceptions
#define THROW(MESSAGE) do \
{ \
throw std::runtime_error((MESSAGE)); \
} \
while(0)
#define THROW_FMT(FORMAT, ...) do \
{ \
char _error_msg[512]; \
_snprintf_s(_error_msg, 512, _TRUNCATE, (FORMAT), __VA_ARGS__); \
throw std::runtime_error(_error_msg); \
} \
while(0)
#define PRINT_ERROR(X, ...) do \
{ \
fflush(stdout); \
fprintf(stderr, (X), __VA_ARGS__); \
fflush(stderr); \
} \
while(0)
//Memory check
#if LAMEXP_DEBUG
#define LAMEXP_MEMORY_CHECK(FUNC, RETV, ...) do \
{ \
size_t _privateBytesBefore = lamexp_dbg_private_bytes(); \
RETV = FUNC(__VA_ARGS__); \
size_t _privateBytesLeak = (lamexp_dbg_private_bytes() - _privateBytesBefore) / 1024; \
if(_privateBytesLeak > 0) { \
lamexp_dbg_dbg_output_string("\nMemory leak: Lost %u KiloBytes of PrivateUsage memory!\n\n", _privateBytesLeak); \
} \
} \
while(0)
#else
#define LAMEXP_MEMORY_CHECK(FUNC, RETV, ...) do \
{ \
RETV = __noop(__VA_ARGS__); \
} \
while(0)
#endif

View File

@ -24,6 +24,7 @@
//MUtils
#include <MUtils/Global.h>
#include <MUtils/Exception.h>
//Qt includes
#include <QSharedMemory>
@ -192,7 +193,7 @@ void lamexp_ipc_send(unsigned int command, const char* message)
if(!g_lamexp_ipc_ptr.sharedmem || !g_lamexp_ipc_ptr.semaphore_read || !g_lamexp_ipc_ptr.semaphore_write || !g_lamexp_ipc_ptr.semaphore_read_mutex || !g_lamexp_ipc_ptr.semaphore_write_mutex)
{
THROW("Shared memory for IPC not initialized yet.");
MUTILS_THROW("Shared memory for IPC not initialized yet.");
}
lamexp_ipc_data_t ipc_data;
@ -229,7 +230,7 @@ void lamexp_ipc_read(unsigned int *command, char* message, size_t buffSize)
if(!g_lamexp_ipc_ptr.sharedmem || !g_lamexp_ipc_ptr.semaphore_read || !g_lamexp_ipc_ptr.semaphore_write || !g_lamexp_ipc_ptr.semaphore_read_mutex || !g_lamexp_ipc_ptr.semaphore_write_mutex)
{
THROW("Shared memory for IPC not initialized yet.");
MUTILS_THROW("Shared memory for IPC not initialized yet.");
}
lamexp_ipc_data_t ipc_data;
@ -264,7 +265,7 @@ void lamexp_ipc_read(unsigned int *command, char* message, size_t buffSize)
extern "C" void _lamexp_global_init_ipcom(void)
{
LAMEXP_ZERO_MEMORY(g_lamexp_ipc_ptr);
MUTILS_ZERO_MEMORY(g_lamexp_ipc_ptr);
}
///////////////////////////////////////////////////////////////////////////////

View File

@ -38,6 +38,7 @@
//MUtils
#include <MUtils/Global.h>
#include <MUtils/Exception.h>
///////////////////////////////////////////////////////////////////////////////
// GLOBAL VARS
@ -89,7 +90,7 @@ void lamexp_register_tool(const QString &toolName, LockedFile *file, unsigned in
if(g_lamexp_tools.registry->contains(toolName.toLower()))
{
THROW("lamexp_register_tool: Tool is already registered!");
MUTILS_THROW("lamexp_register_tool: Tool is already registered!");
}
g_lamexp_tools.registry->insert(toolName.toLower(), file);
@ -352,9 +353,9 @@ bool lamexp_install_translator_from_file(const QString &qmFile)
extern "C" void _lamexp_global_init_tools(void)
{
LAMEXP_ZERO_MEMORY(g_lamexp_tools);
LAMEXP_ZERO_MEMORY(g_lamexp_currentTranslator);
LAMEXP_ZERO_MEMORY(g_lamexp_translation);
MUTILS_ZERO_MEMORY(g_lamexp_tools);
MUTILS_ZERO_MEMORY(g_lamexp_currentTranslator);
MUTILS_ZERO_MEMORY(g_lamexp_translation);
}
///////////////////////////////////////////////////////////////////////////////

View File

@ -37,6 +37,7 @@
//MUtils
#include <MUtils/Global.h>
#include <MUtils/OSSupport.h>
//CRT includes
#include <time.h>
@ -154,14 +155,14 @@ void lamexp_blink_window(QWidget *poWindow, unsigned int count, unsigned int del
{
poWindow->setWindowOpacity(x);
QApplication::processEvents();
lamexp_sleep(sleep);
MUtils::OS::sleep_ms(sleep);
}
for(double x = minOpac; x <= maxOpac; x += delOpac)
{
poWindow->setWindowOpacity(x);
QApplication::processEvents();
lamexp_sleep(sleep);
MUtils::OS::sleep_ms(sleep);
}
}
@ -280,7 +281,7 @@ const QIcon &lamexp_app_icon(void)
extern "C" void _lamexp_global_init_utils(void)
{
LAMEXP_ZERO_MEMORY(g_lamexp_app_icon);
MUTILS_ZERO_MEMORY(g_lamexp_app_icon);
}
///////////////////////////////////////////////////////////////////////////////

View File

@ -171,7 +171,7 @@ bool lamexp_portable_mode(void)
extern "C" void _lamexp_global_init_versn(void)
{
LAMEXP_ZERO_MEMORY(g_lamexp_portable);
MUTILS_ZERO_MEMORY(g_lamexp_portable);
}
///////////////////////////////////////////////////////////////////////////////

View File

@ -155,59 +155,6 @@ const char* LAMEXP_DEFAULT_TRANSLATION = "LameXP_EN.qm";
// GLOBAL FUNCTIONS
///////////////////////////////////////////////////////////////////////////////
/*
* Check for debugger (detect routine)
*/
static __forceinline bool lamexp_check_for_debugger(void)
{
__try
{
CloseHandle((HANDLE)((DWORD_PTR)-3));
}
__except(1)
{
return true;
}
BOOL bHaveDebugger = FALSE;
if(CheckRemoteDebuggerPresent(GetCurrentProcess(), &bHaveDebugger))
{
if(bHaveDebugger) return true;
}
return IsDebuggerPresent();
}
/*
* Check for debugger (thread proc)
*/
static unsigned int __stdcall lamexp_debug_thread_proc(LPVOID lpParameter)
{
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_LOWEST);
forever
{
if(lamexp_check_for_debugger())
{
MUtils::OS::fatal_exit(L"Not a debug build. Please unload debugger and try again!");
return 666;
}
lamexp_sleep(100);
}
}
/*
* Check for debugger (startup routine)
*/
static HANDLE lamexp_debug_thread_init()
{
if(lamexp_check_for_debugger())
{
MUtils::OS::fatal_exit(L"Not a debug build. Please unload debugger and try again!");
}
const uintptr_t h = _beginthreadex(NULL, 0, lamexp_debug_thread_proc, NULL, 0, NULL);
return (HANDLE)(h^0xdeadbeef);
}
/*
* Convert QIcon to HICON -> caller is responsible for destroying the HICON!
*/
@ -1089,60 +1036,17 @@ static DWORD WINAPI lamexp_fatal_exit_helper(LPVOID lpParameter)
return 0;
}
/*
* Initialize debug thread
*/
static const HANDLE g_debug_thread1 = MUTILS_DEBUG ? NULL : lamexp_debug_thread_init();
/*
* Get number private bytes [debug only]
*/
unsigned long lamexp_dbg_private_bytes(void)
{
#if LAMEXP_DEBUG
for(int i = 0; i < 8; i++) _heapmin();
PROCESS_MEMORY_COUNTERS_EX memoryCounters;
memoryCounters.cb = sizeof(PROCESS_MEMORY_COUNTERS_EX);
GetProcessMemoryInfo(GetCurrentProcess(), (PPROCESS_MEMORY_COUNTERS) &memoryCounters, sizeof(PROCESS_MEMORY_COUNTERS_EX));
return memoryCounters.PrivateUsage;
#else
THROW("Cannot call this function in a non-debug build!");
#endif //LAMEXP_DEBUG
}
/*
* Output string to debugger [debug only]
*/
void lamexp_dbg_dbg_output_string(const char* format, ...)
{
#if LAMEXP_DEBUG
char buffer[256];
va_list args;
va_start (args, format);
vsnprintf_s(buffer, 256, _TRUNCATE, format, args);
OutputDebugStringA(buffer);
va_end(args);
#else
THROW("Cannot call this function in a non-debug build!");
#endif //LAMEXP_DEBUG
}
///////////////////////////////////////////////////////////////////////////////
// INITIALIZATION
///////////////////////////////////////////////////////////////////////////////
extern "C" void _lamexp_global_init_win32(void)
{
if((!MUTILS_DEBUG) && lamexp_check_for_debugger())
{
MUtils::OS::fatal_exit(L"Not a debug build. Please unload debugger and try again!");
}
//Zero *before* constructors are called
LAMEXP_ZERO_MEMORY(g_lamexp_wine);
LAMEXP_ZERO_MEMORY(g_lamexp_themes_enabled);
LAMEXP_ZERO_MEMORY(g_lamexp_dwmapi);
LAMEXP_ZERO_MEMORY(g_lamexp_sounds);
MUTILS_ZERO_MEMORY(g_lamexp_wine);
MUTILS_ZERO_MEMORY(g_lamexp_themes_enabled);
MUTILS_ZERO_MEMORY(g_lamexp_dwmapi);
MUTILS_ZERO_MEMORY(g_lamexp_sounds);
}
///////////////////////////////////////////////////////////////////////////////

View File

@ -25,6 +25,8 @@
//MUtils
#include <MUtils/KeccakHash.h>
#include <MUtils/OSSupport.h>
#include <MUtils/Exception.h>
//Qt
#include <QResource>
@ -52,6 +54,15 @@
static const bool g_useFileDescrForQFile = false;
#endif
static void CLOSE_HANDLE(HANDLE &h)
{
if((h != NULL) && (h != INVALID_HANDLE_VALUE))
{
CloseHandle(h);
h = NULL;
}
}
///////////////////////////////////////////////////////////////////////////////
static const char *g_blnk = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
@ -100,7 +111,7 @@ LockedFile::LockedFile(QResource *const resource, const QString &outPath, const
//Make sure the resource is valid
if(!(resource->isValid() && resource->data()))
{
THROW_FMT("The resource at %p is invalid!", resource);
MUTILS_THROW_FMT("The resource at %p is invalid!", resource);
}
QFile outFile(m_filePath);
@ -119,12 +130,12 @@ LockedFile::LockedFile(QResource *const resource, const QString &outPath, const
if(outFile.write(reinterpret_cast<const char*>(resource->data()), resource->size()) != resource->size())
{
QFile::remove(QFileInfo(outFile).canonicalFilePath());
THROW_FMT("File '%s' could not be written!", MUTILS_UTF8(QFileInfo(outFile).fileName()));
MUTILS_THROW_FMT("File '%s' could not be written!", MUTILS_UTF8(QFileInfo(outFile).fileName()));
}
}
else
{
THROW_FMT("File '%s' could not be created!", MUTILS_UTF8(QFileInfo(outFile).fileName()));
MUTILS_THROW_FMT("File '%s' could not be created!", MUTILS_UTF8(QFileInfo(outFile).fileName()));
}
//Close file after it has been written
@ -143,14 +154,14 @@ LockedFile::LockedFile(QResource *const resource, const QString &outPath, const
if((fileHandle == NULL) || (fileHandle == INVALID_HANDLE_VALUE))
{
QFile::remove(QFileInfo(outFile).canonicalFilePath());
THROW_FMT("File '%s' could not be locked!", MUTILS_UTF8(QFileInfo(m_filePath).fileName()));
MUTILS_THROW_FMT("File '%s' could not be locked!", MUTILS_UTF8(QFileInfo(m_filePath).fileName()));
}
//Get file descriptor
m_fileDescriptor = _open_osfhandle(reinterpret_cast<intptr_t>(fileHandle), _O_RDONLY | _O_BINARY);
if(m_fileDescriptor < 0)
{
THROW_FMT("Failed to obtain C Runtime file descriptor!");
MUTILS_THROW_FMT("Failed to obtain C Runtime file descriptor!");
}
QFile checkFile;
@ -175,7 +186,7 @@ LockedFile::LockedFile(QResource *const resource, const QString &outPath, const
if(!checkFile.isOpen())
{
QFile::remove(m_filePath);
THROW_FMT("File '%s' could not be read!", MUTILS_UTF8(QFileInfo(m_filePath).fileName()));
MUTILS_THROW_FMT("File '%s' could not be read!", MUTILS_UTF8(QFileInfo(m_filePath).fileName()));
}
//Verify file contents
@ -186,9 +197,9 @@ LockedFile::LockedFile(QResource *const resource, const QString &outPath, const
if(hash.isNull() || _stricmp(hash.constData(), expectedHash.constData()))
{
qWarning("\nFile checksum error:\n A = %s\n B = %s\n", expectedHash.constData(), hash.constData());
LAMEXP_CLOSE(fileHandle);
CLOSE_HANDLE(fileHandle);
QFile::remove(m_filePath);
THROW_FMT("File '%s' is corruputed, take care!", MUTILS_UTF8(QFileInfo(m_filePath).fileName()));
MUTILS_THROW_FMT("File '%s' is corruputed, take care!", MUTILS_UTF8(QFileInfo(m_filePath).fileName()));
}
}
@ -206,7 +217,7 @@ LockedFile::LockedFile(const QString &filePath, const bool bOwnsFile)
//Make sure the file exists, before we try to lock it
if((!existingFileInfo.exists()) || (!existingFileInfo.isFile()) || m_filePath.isEmpty())
{
THROW_FMT("File '%s' does not exist!", MUTILS_UTF8(filePath));
MUTILS_THROW_FMT("File '%s' does not exist!", MUTILS_UTF8(filePath));
}
//Now lock the file
@ -221,14 +232,14 @@ LockedFile::LockedFile(const QString &filePath, const bool bOwnsFile)
//Locked successfully?
if((fileHandle == NULL) || (fileHandle == INVALID_HANDLE_VALUE))
{
THROW_FMT("File '%s' could not be locked!", MUTILS_UTF8(QFileInfo(m_filePath).fileName()));
MUTILS_THROW_FMT("File '%s' could not be locked!", MUTILS_UTF8(QFileInfo(m_filePath).fileName()));
}
//Get file descriptor
m_fileDescriptor = _open_osfhandle(reinterpret_cast<intptr_t>(fileHandle), _O_RDONLY | _O_BINARY);
if(m_fileDescriptor < 0)
{
THROW_FMT("Failed to obtain C Runtime file descriptor!");
MUTILS_THROW_FMT("Failed to obtain C Runtime file descriptor!");
}
}
@ -246,7 +257,7 @@ LockedFile::~LockedFile(void)
for(int i = 0; i < 64; i++)
{
if(QFile::remove(m_filePath)) break;
lamexp_sleep(1);
MUtils::OS::sleep_ms(1);
}
}
}
@ -261,6 +272,6 @@ void LockedFile::selfTest()
{
if(!MUtils::KeccakHash::selfTest())
{
THROW("QKeccakHash self-test has failed!");
MUTILS_THROW("QKeccakHash self-test has failed!");
}
}

View File

@ -28,6 +28,7 @@
//MUtils
#include <MUtils/Global.h>
#include <MUtils/OSSupport.h>
//Qt
#include <QApplication>
@ -516,7 +517,7 @@ int CueSheetModel::parseCueFile(QFile &cueFile, const QDir &baseDir, QCoreApplic
if(application)
{
application->processEvents();
if(lines < 128) lamexp_sleep(10);
if(lines < 128) MUtils::OS::sleep_ms(10);
}
if(cueStream.atEnd())
@ -740,7 +741,7 @@ int CueSheetModel::parseCueFile(QFile &cueFile, const QDir &baseDir, QCoreApplic
if(application)
{
application->processEvents();
lamexp_sleep(10);
MUtils::OS::sleep_ms(10);
}
CueSheetFile *currentFile = m_files.at(i);
@ -773,7 +774,7 @@ int CueSheetModel::parseCueFile(QFile &cueFile, const QDir &baseDir, QCoreApplic
if(application)
{
application->processEvents();
lamexp_sleep(10);
MUtils::OS::sleep_ms(10);
}
CueSheetFile *currentFile = m_files.at(i);
int nTracks = currentFile->trackCount();

View File

@ -28,6 +28,7 @@
//MUtils
#include <MUtils/Global.h>
#include <MUtils/OSSupport.h>
//Qt
#include <QSettings>
@ -543,7 +544,7 @@ QString SettingsModel::initDirectory(const QString &path) const
for(int i = 0; i < 32; i++)
{
if(QDir(path).mkpath(".")) break;
lamexp_sleep(1);
MUtils::OS::sleep_ms(1);
}
}

View File

@ -115,7 +115,7 @@ AbstractEncoder *EncoderRegistry::createInstance(const int encoderId, const Sett
}
break;
default:
THROW("makeEncoder(): Unknown AAC encoder specified!");
MUTILS_THROW("makeEncoder(): Unknown AAC encoder specified!");
break;
}
}
@ -171,13 +171,13 @@ AbstractEncoder *EncoderRegistry::createInstance(const int encoderId, const Sett
break;
/*-------- default --------*/
default:
THROW("Unsupported encoder!");
MUTILS_THROW("Unsupported encoder!");
}
//Sanity checking
if(!encoder)
{
THROW("No encoder instance has been assigend!");
MUTILS_THROW("No encoder instance has been assigend!");
}
//Apply common settings
@ -212,16 +212,16 @@ const AbstractEncoderInfo *EncoderRegistry::getEncoderInfo(const int encoderId)
case SettingsModel::AAC_ENCODER_QAAC: info = QAACEncoder::getEncoderInfo(); break;
case SettingsModel::AAC_ENCODER_FHG: info = FHGAACEncoder::getEncoderInfo(); break;
case SettingsModel::AAC_ENCODER_NERO: info = AACEncoder::getEncoderInfo(); break;
default: THROW("Unknown AAC encoder specified!");
default: MUTILS_THROW("Unknown AAC encoder specified!");
}
break;
default: THROW("Unsupported encoder!");
default: MUTILS_THROW("Unsupported encoder!");
}
//Sanity checking
if(!info)
{
THROW("No encoder instance has been assigend!");
MUTILS_THROW("No encoder instance has been assigend!");
}
return info;
@ -248,7 +248,7 @@ void EncoderRegistry::saveEncoderMode(SettingsModel *settings, const int encoder
//Sanity checking
if((rcMode < SettingsModel::VBRMode) || (rcMode > SettingsModel::CBRMode))
{
THROW("Unknown rate-control mode!");
MUTILS_THROW("Unknown rate-control mode!");
}
//Store the encoder bitrate/quality value
@ -263,7 +263,7 @@ void EncoderRegistry::saveEncoderMode(SettingsModel *settings, const int encoder
case SettingsModel::DCAEncoder: STORE_MODE(DcaEnc, rcMode); break;
case SettingsModel::MACEncoder: STORE_MODE(MacEnc, rcMode); break;
case SettingsModel::PCMEncoder: STORE_MODE(Wave, rcMode); break;
default: THROW("Unsupported encoder!");
default: MUTILS_THROW("Unsupported encoder!");
}
}
@ -283,7 +283,7 @@ int EncoderRegistry::loadEncoderMode(const SettingsModel *settings, const int en
case SettingsModel::DCAEncoder: LOAD_MODE(rcMode, DcaEnc); break;
case SettingsModel::MACEncoder: LOAD_MODE(rcMode, MacEnc); break;
case SettingsModel::PCMEncoder: LOAD_MODE(rcMode, Wave); break;
default: THROW("Unsupported encoder!");
default: MUTILS_THROW("Unsupported encoder!");
}
return rcMode;
@ -314,7 +314,7 @@ void EncoderRegistry::saveEncoderValue(SettingsModel *settings, const int encode
//Sanity checking
if((rcMode < SettingsModel::VBRMode) || (rcMode > SettingsModel::CBRMode))
{
THROW("Unknown rate-control mode!");
MUTILS_THROW("Unknown rate-control mode!");
}
//Store the encoder bitrate/quality value
@ -329,7 +329,7 @@ void EncoderRegistry::saveEncoderValue(SettingsModel *settings, const int encode
case SettingsModel::DCAEncoder: STORE_VALUE(DcaEnc, rcMode, value); break;
case SettingsModel::MACEncoder: STORE_VALUE(MacEnc, rcMode, value); break;
case SettingsModel::PCMEncoder: STORE_VALUE(Wave, rcMode, value); break;
default: THROW("Unsupported encoder!");
default: MUTILS_THROW("Unsupported encoder!");
}
}
@ -340,7 +340,7 @@ int EncoderRegistry::loadEncoderValue(const SettingsModel *settings, const int e
//Sanity checking
if((rcMode < SettingsModel::VBRMode) || (rcMode > SettingsModel::CBRMode))
{
THROW("Unknown rate-control mode!");
MUTILS_THROW("Unknown rate-control mode!");
}
//Load the encoder bitrate/quality value
@ -355,7 +355,7 @@ int EncoderRegistry::loadEncoderValue(const SettingsModel *settings, const int e
case SettingsModel::DCAEncoder: LOAD_VALUE(value, DcaEnc, rcMode); break;
case SettingsModel::MACEncoder: LOAD_VALUE(value, MacEnc, rcMode); break;
case SettingsModel::PCMEncoder: LOAD_VALUE(value, Wave, rcMode); break;
default: THROW("Unsupported encoder!");
default: MUTILS_THROW("Unsupported encoder!");
}
return value;
@ -391,7 +391,7 @@ void EncoderRegistry::saveEncoderCustomParams(SettingsModel *settings, const int
case SettingsModel::DCAEncoder: STORE_PARAMS(DcaEnc, params.trimmed()); break;
case SettingsModel::MACEncoder: STORE_PARAMS(MacEnc, params.trimmed()); break;
case SettingsModel::PCMEncoder: STORE_PARAMS(Wave, params.trimmed()); break;
default: THROW("Unsupported encoder!");
default: MUTILS_THROW("Unsupported encoder!");
}
}
@ -411,7 +411,7 @@ QString EncoderRegistry::loadEncoderCustomParams(const SettingsModel *settings,
case SettingsModel::DCAEncoder: LOAD_PARAMS(params, DcaEnc); break;
case SettingsModel::MACEncoder: LOAD_PARAMS(params, MacEnc); break;
case SettingsModel::PCMEncoder: LOAD_PARAMS(params, Wave); break;
default: THROW("Unsupported encoder!");
default: MUTILS_THROW("Unsupported encoder!");
}
return params;

View File

@ -28,6 +28,7 @@
//MUtils
#include <MUtils/Global.h>
#include <MUtils/Exception.h>
//Qt
#include <QString>
@ -59,7 +60,7 @@ QMutex ShellIntegration::m_mutex;
ShellIntegration::ShellIntegration(void)
{
THROW("Cannot create instance of this class, sorry!");
MUTILS_THROW("Cannot create instance of this class, sorry!");
}
////////////////////////////////////////////////////////////

View File

@ -26,6 +26,7 @@
//MUtils
#include <MUtils/OSSupport.h>
#include <MUtils/Exception.h>
//Qt
#include <QDir>
@ -61,12 +62,12 @@ void CPUObserverThread::run(void)
}
catch(const std::exception &error)
{
PRINT_ERROR("\nGURU MEDITATION !!!\n\nException error:\n%s\n", error.what());
MUTILS_PRINT_ERROR("\nGURU MEDITATION !!!\n\nException error:\n%s\n", error.what());
MUtils::OS::fatal_exit(L"Unhandeled C++ exception error, application will exit!");
}
catch(...)
{
PRINT_ERROR("\nGURU MEDITATION !!!\n\nUnknown exception error!\n");
MUTILS_PRINT_ERROR("\nGURU MEDITATION !!!\n\nUnknown exception error!\n");
MUtils::OS::fatal_exit(L"Unhandeled C++ exception error, application will exit!");
}

View File

@ -32,6 +32,7 @@
//MUtils
#include <MUtils/Global.h>
#include <MUtils/OSSupport.h>
//Qt
#include <QDir>
@ -228,7 +229,7 @@ void CueSplitter::run()
}
emit progressValChanged(10 * nTracksTotal);
lamexp_sleep(333);
MUtils::OS::sleep_ms(333);
qDebug("All files were split.\n");
m_bSuccess = true;

View File

@ -29,6 +29,7 @@
//MUtils
#include <MUtils/Global.h>
#include <MUtils/OSSupport.h>
#include <MUtils/Exception.h>
//Qt
#include <QDir>
@ -63,12 +64,12 @@ void DiskObserverThread::run(void)
}
catch(const std::exception &error)
{
PRINT_ERROR("\nGURU MEDITATION !!!\n\nException error:\n%s\n", error.what());
MUTILS_PRINT_ERROR("\nGURU MEDITATION !!!\n\nException error:\n%s\n", error.what());
MUtils::OS::fatal_exit(L"Unhandeled C++ exception error, application will exit!");
}
catch(...)
{
PRINT_ERROR("\nGURU MEDITATION !!!\n\nUnknown exception error!\n");
MUTILS_PRINT_ERROR("\nGURU MEDITATION !!!\n\nUnknown exception error!\n");
MUtils::OS::fatal_exit(L"Unhandeled C++ exception error, application will exit!");
}

View File

@ -31,6 +31,7 @@
//MUtils
#include <MUtils/Global.h>
#include <MUtils/Exception.h>
//Qt
#include <QDir>
@ -411,7 +412,7 @@ void FileAnalyzer::taskFileAnalyzed(const unsigned int taskId, const int fileTyp
m_filesRejected++;
break;
default:
THROW("Unknown file type identifier!");
MUTILS_THROW("Unknown file type identifier!");
}
//Emit all pending files

View File

@ -30,6 +30,7 @@
//MUtils
#include <MUtils/Global.h>
#include <MUtils/OSSupport.h>
#include <MUtils/Exception.h>
//Qt
#include <QDir>
@ -89,12 +90,12 @@ void AnalyzeTask::run()
}
catch(const std::exception &error)
{
PRINT_ERROR("\nGURU MEDITATION !!!\n\nException error:\n%s\n", error.what());
MUTILS_PRINT_ERROR("\nGURU MEDITATION !!!\n\nException error:\n%s\n", error.what());
MUtils::OS::fatal_exit(L"Unhandeled C++ exception error, application will exit!");
}
catch(...)
{
PRINT_ERROR("\nGURU MEDITATION !!!\n\nUnknown exception error!\n");
MUTILS_PRINT_ERROR("\nGURU MEDITATION !!!\n\nUnknown exception error!\n");
MUtils::OS::fatal_exit(L"Unhandeled C++ exception error, application will exit!");
}
}

View File

@ -30,6 +30,7 @@
//MUtils
#include <MUtils/Global.h>
#include <MUtils/OSSupport.h>
#include <MUtils/Exception.h>
//Qt
#include <QFileInfo>
@ -235,12 +236,12 @@ void InitializationThread::run(void)
}
catch(const std::exception &error)
{
PRINT_ERROR("\nGURU MEDITATION !!!\n\nException error:\n%s\n", error.what());
MUTILS_PRINT_ERROR("\nGURU MEDITATION !!!\n\nException error:\n%s\n", error.what());
MUtils::OS::fatal_exit(L"Unhandeled C++ exception error, application will exit!");
}
catch(...)
{
PRINT_ERROR("\nGURU MEDITATION !!!\n\nUnknown exception error!\n");
MUTILS_PRINT_ERROR("\nGURU MEDITATION !!!\n\nUnknown exception error!\n");
MUtils::OS::fatal_exit(L"Unhandeled C++ exception error, application will exit!");
}
}
@ -278,7 +279,7 @@ double InitializationThread::doInit(const size_t threadCount)
PRINT_CPU_TYPE(CPU_TYPE_X86_SSE); break;
PRINT_CPU_TYPE(CPU_TYPE_X64_GEN); break;
PRINT_CPU_TYPE(CPU_TYPE_X64_SSE); break;
default: THROW("CPU support undefined!");
default: MUTILS_THROW("CPU support undefined!");
}
//Allocate queues
@ -462,7 +463,7 @@ void InitializationThread::runBenchmark(void)
qFatal("Benchmark complete. Thanks and bye bye!");
#else //ENABLE_BENCHMARK
THROW("Sorry, the benchmark is *not* available in this build!");
MUTILS_THROW("Sorry, the benchmark is *not* available in this build!");
#endif //ENABLE_BENCHMARK
}
@ -472,7 +473,7 @@ void InitializationThread::runBenchmark(void)
void InitializationThread::delay(void)
{
lamexp_sleep(333);
MUtils::OS::sleep_ms(333);
}
void InitializationThread::initTranslations(void)
@ -925,7 +926,7 @@ void InitializationThread::selfTest(void)
PRINT_CPU_TYPE(CPU_TYPE_X86_SSE); break;
PRINT_CPU_TYPE(CPU_TYPE_X64_GEN); break;
PRINT_CPU_TYPE(CPU_TYPE_X64_SSE); break;
default: THROW("CPU support undefined!");
default: MUTILS_THROW("CPU support undefined!");
}
unsigned int n = 0;
for(int i = 0; true; i++)

View File

@ -133,7 +133,7 @@ bool ProcessThread::start(QThreadPool *pool)
//Make sure object was initialized correctly
if(m_initialized < 0)
{
THROW("Object not initialized yet!");
MUTILS_THROW("Object not initialized yet!");
}
if(m_initialized < 1)
@ -187,12 +187,12 @@ void ProcessThread::run()
}
catch(const std::exception &error)
{
PRINT_ERROR("\nGURU MEDITATION !!!\n\nException error:\n%s\n", error.what());
MUTILS_PRINT_ERROR("\nGURU MEDITATION !!!\n\nException error:\n%s\n", error.what());
MUtils::OS::fatal_exit(L"Unhandeled C++ exception error, application will exit!");
}
catch(...)
{
PRINT_ERROR("\nGURU MEDITATION !!!\n\nUnknown exception error!\n");
MUTILS_PRINT_ERROR("\nGURU MEDITATION !!!\n\nUnknown exception error!\n");
MUtils::OS::fatal_exit(L"Unhandeled C++ exception error, application will exit!");
}
}
@ -205,7 +205,7 @@ void ProcessThread::processFile()
//Make sure object was initialized correctly
if(m_initialized < 1)
{
THROW("Object not initialized yet!");
MUTILS_THROW("Object not initialized yet!");
}
QString sourceFile = m_audioFile.filePath();
@ -332,7 +332,7 @@ void ProcessThread::processFile()
bSuccess = fileInfo.exists() && fileInfo.isFile() && (fileInfo.size() > 0);
}
lamexp_sleep(125);
MUtils::OS::sleep_ms(125);
//Report result
emit processStateChanged(m_jobId, (m_aborted ? tr("Aborted!") : (bSuccess ? tr("Done.") : tr("Failed!"))), ((bSuccess && !m_aborted) ? ProgressModel::JobComplete : ProgressModel::JobFailed));
@ -462,7 +462,7 @@ int ProcessThread::generateOutFileName(QString &outFileName)
{
break;
}
lamexp_sleep(125);
MUtils::OS::sleep_ms(125);
}
}
if(QFileInfo(outFileName).exists())

View File

@ -25,6 +25,7 @@
//MUtils
#include <MUtils/OSSupport.h>
#include <MUtils/Exception.h>
//Qt
#include <QDir>
@ -60,12 +61,12 @@ void RAMObserverThread::run(void)
}
catch(const std::exception &error)
{
PRINT_ERROR("\nGURU MEDITATION !!!\n\nException error:\n%s\n", error.what());
MUTILS_PRINT_ERROR("\nGURU MEDITATION !!!\n\nException error:\n%s\n", error.what());
MUtils::OS::fatal_exit(L"Unhandeled C++ exception error, application will exit!");
}
catch(...)
{
PRINT_ERROR("\nGURU MEDITATION !!!\n\nUnknown exception error!\n");
MUTILS_PRINT_ERROR("\nGURU MEDITATION !!!\n\nUnknown exception error!\n");
MUtils::OS::fatal_exit(L"Unhandeled C++ exception error, application will exit!");
}

View File

@ -28,6 +28,7 @@
//MUtils
#include <MUtils/Global.h>
#include <MUtils/OSSupport.h>
//Qt
#include <QProcess>
@ -97,7 +98,7 @@ bool AbstractTool::startProcess(QProcess &process, const QString &program, const
if(lamexp_current_file_time() <= s_lastLaunchTime)
{
lamexp_sleep(START_DELAY);
MUtils::OS::sleep_ms(START_DELAY);
}
emit messageLogged(commandline2string(program, args) + "\n");

View File

@ -22,9 +22,14 @@
#include "Tool_WaveProperties.h"
//Internal
#include "Global.h"
#include "Model_AudioFile.h"
//MUtils
#include <MUtils/Exception.h>
//Qt
#include <QDir>
#include <QProcess>
@ -34,7 +39,7 @@ WaveProperties::WaveProperties(void)
{
if(m_binary.isEmpty())
{
THROW("Error initializing MP3 encoder. Tool 'lame.exe' is not registred!");
MUTILS_THROW("Error initializing MP3 encoder. Tool 'lame.exe' is not registred!");
}
}

View File

@ -22,6 +22,10 @@
#include "WinSevenTaskbar.h"
//MUtils
#include <MUtils/Exception.h>
//Qt
#include <QWidget>
#include <QIcon>
@ -36,7 +40,7 @@ static ITaskbarList3 *s_ptbl = NULL;
WinSevenTaskbar::WinSevenTaskbar(void)
{
THROW("Cannot create instance of this class!");
MUTILS_THROW("Cannot create instance of this class!");
}
WinSevenTaskbar::~WinSevenTaskbar(void)