Implemented a new "disk observer" thread which will constantly check the free diskspace of the disk where the TEMP folder is located. If the diskspace drops below a critical limit (currently 100 MB) a warning message is emitted.

This commit is contained in:
LoRd_MuldeR 2011-03-28 04:26:47 +02:00
parent 3af79d261b
commit 23665ed4c9
27 changed files with 337 additions and 515 deletions

View File

@ -500,6 +500,10 @@
RelativePath=".\src\ShellIntegration.cpp"
>
</File>
<File
RelativePath=".\src\Thread_DiskObserver.cpp"
>
</File>
<File
RelativePath=".\src\Thread_FileAnalyzer.cpp"
>
@ -1432,6 +1436,40 @@
RelativePath=".\src\Targetver.h"
>
</File>
<File
RelativePath=".\src\Thread_DiskObserver.h"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="MOC &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
CommandLine="&quot;$(QTDIR)\bin\moc.exe&quot; -o &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot; &quot;$(InputPath)&quot;"
Outputs="&quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="MOC &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
CommandLine="&quot;$(QTDIR)\bin\moc.exe&quot; -o &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot; &quot;$(InputPath)&quot;"
Outputs="&quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
/>
</FileConfiguration>
<FileConfiguration
Name="Release_Static|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="MOC &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
CommandLine="&quot;$(QTDIR)\bin\moc.exe&quot; -o &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot; &quot;$(InputPath)&quot;"
Outputs="&quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\src\Thread_FileAnalyzer.h"
>
@ -1738,6 +1776,10 @@
RelativePath=".\tmp\MOC_ShellIntegration.cpp"
>
</File>
<File
RelativePath=".\tmp\MOC_Thread_DiskObserver.cpp"
>
</File>
<File
RelativePath=".\tmp\MOC_Thread_FileAnalyzer.cpp"
>

View File

@ -12,7 +12,7 @@
<li>Added an option to select a user-defined TEMP directory
<li>Added an option to shutdown the computer as soon as all files are completed
<li>Added an option to add directories recursively
<li>Added support for embedding cover artwork (currently works with LAME and Nero AAC only)
<li>Added support for embedding cover artwork (currently works with LAME, FLAC and Nero AAC only)
<li>Updated Qt runtime libraries to v4.7.2
<li>Updated LAME encoder to v3.99.0.15 (2011-03-22), compiled with ICL 12.0.2
<li>Updated Vorbis encoder to v2.87 using aoTuV Beta-6.02 (2011-02-28), compiled with ICL 11.1 and MSVC 9.0
@ -21,6 +21,7 @@
<li>Updated MediaInfo to v0.7.43 (2011-03-20), compiled with ICL 12.0.2 and MSVC 9.0
<li>Updated language files (big thank-you to all contributors !!!)
<li>Fixed a bug that caused AAC encoding to fail in CBR mode (the "-2pass" parameter was set wrongly)
<li>A warning message will be emitted, if diskspace drops below a critical limit while processing
</ul><br>
<a name="4.00">Changes between v3.18 and v4.00:</a><br><ul>

View File

@ -7,6 +7,10 @@
<source>LameXP &amp;minus; Audio Encoder Front-end</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>DEMO VERSION</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Please visit %1 for news and updates!</source>
<translation type="unfinished"></translation>
@ -238,6 +242,13 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DiskObserverThread</name>
<message>
<source>Low diskspace on drive &apos;%1&apos; detected (only %2 MB are free), problems can occur!</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DropBox</name>
<message>

View File

@ -195,6 +195,10 @@
<source>Silk Icons &amp;minus; Over 700 icons in PNG format</source>
<translation>Silk Icons &amp;minus; Über 700 Symbole im PNG Format</translation>
</message>
<message>
<source>DEMO VERSION</source>
<translation>DEMO VERSION</translation>
</message>
</context>
<context>
<name>AudioFileModel</name>
@ -238,6 +242,13 @@
<translation>Wiedergabelisten</translation>
</message>
</context>
<context>
<name>DiskObserverThread</name>
<message>
<source>Low diskspace on drive &apos;%1&apos; detected (only %2 MB are free), problems can occur!</source>
<translation>Wenig freier Speicher auf Laufwerk &apos;%1&apos; (nur noch %2 MB frei), Probleme können auftreten!</translation>
</message>
</context>
<context>
<name>DropBox</name>
<message>

View File

@ -195,6 +195,10 @@
<source>GNU Wget &amp;minus; Software for retrieving files using HTTP</source>
<translation>GNU Wget &amp;minus; Software para descarga de archivos mediante HTTP</translation>
</message>
<message>
<source>DEMO VERSION</source>
<translation>VERSIÓN DEMO</translation>
</message>
</context>
<context>
<name>AudioFileModel</name>
@ -238,6 +242,13 @@
<translation>Listas de reproducción</translation>
</message>
</context>
<context>
<name>DiskObserverThread</name>
<message>
<source>Low diskspace on drive &apos;%1&apos; detected (only %2 MB are free), problems can occur!</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DropBox</name>
<message>

View File

@ -199,6 +199,10 @@
<source>GNU Wget &amp;minus; Software for retrieving files using HTTP</source>
<translation>GNU Wget &amp;minus; Logiciel permettant de récupérer des fichiers à l&apos;aide du HTTP</translation>
</message>
<message>
<source>DEMO VERSION</source>
<translation>VERSION DE DEMO</translation>
</message>
</context>
<context>
<name>AudioFileModel</name>
@ -242,6 +246,13 @@
<translation>Listes de lecture</translation>
</message>
</context>
<context>
<name>DiskObserverThread</name>
<message>
<source>Low diskspace on drive &apos;%1&apos; detected (only %2 MB are free), problems can occur!</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DropBox</name>
<message>

View File

@ -195,6 +195,10 @@
<source>GNU Wget &amp;minus; Software for retrieving files using HTTP</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>DEMO VERSION</source>
<translation>VERSIONE DEMO</translation>
</message>
</context>
<context>
<name>AudioFileModel</name>
@ -238,6 +242,13 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DiskObserverThread</name>
<message>
<source>Low diskspace on drive &apos;%1&apos; detected (only %2 MB are free), problems can occur!</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DropBox</name>
<message>

File diff suppressed because it is too large Load Diff

View File

@ -195,6 +195,10 @@
<source>n/a</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>DEMO VERSION</source>
<translation type="unfinished">ДЕМО ВЕРСІЯ</translation>
</message>
</context>
<context>
<name>AudioFileModel</name>
@ -238,6 +242,13 @@
<translation type="unfinished">Всі файли</translation>
</message>
</context>
<context>
<name>DiskObserverThread</name>
<message>
<source>Low diskspace on drive &apos;%1&apos; detected (only %2 MB are free), problems can occur!</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DropBox</name>
<message>

View File

@ -56,6 +56,7 @@
..\..\src\PlaylistImporter.cpp
..\..\src\Registry_Decoder.cpp
..\..\src\ShellIntegration.cpp
..\..\src\Thread_DiskObserver.cpp
..\..\src\Thread_FileAnalyzer.cpp
..\..\src\Thread_Initialization.cpp
..\..\src\Thread_MessageHandler.cpp
@ -115,6 +116,7 @@
..\..\src\Resource.h
..\..\src\ShellIntegration.h
..\..\src\Targetver.h
..\..\src\Thread_DiskObserver.h
..\..\src\Thread_FileAnalyzer.h
..\..\src\Thread_Initialization.h
..\..\src\Thread_MessageHandler.h

View File

@ -238,10 +238,10 @@
<item row="1" column="1">
<widget class="QFrame" name="frameArtworkInner">
<property name="frameShape">
<enum>QFrame::Panel</enum>
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="spacing">
@ -497,6 +497,7 @@
<include location="../res/Images.qrc"/>
<include location="../res/Images.qrc"/>
<include location="../res/Images.qrc"/>
<include location="../res/Images.qrc"/>
</resources>
<connections>
<connection>

View File

@ -56,6 +56,8 @@
<file>icons/money_dollar.png</file>
<file>icons/monitor.png</file>
<file>icons/music.png</file>
<file>icons/network.png</file>
<file>icons/network_error.png</file>
<file>icons/palette.png</file>
<file>icons/package.png</file>
<file>icons/page_white_cplusplus.png</file>
@ -70,6 +72,7 @@
<file>icons/script_edit.png</file>
<file>icons/server_error.png</file>
<file>icons/shield_admin.png</file>
<file>icons/shield_error.png</file>
<file>icons/shield_exclamation.png</file>
<file>icons/shield_green.png</file>
<file>icons/sound.png</file>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -25,8 +25,8 @@
#define VER_LAMEXP_MAJOR 4
#define VER_LAMEXP_MINOR_HI 0
#define VER_LAMEXP_MINOR_LO 1
#define VER_LAMEXP_BUILD 406
#define VER_LAMEXP_SUFFIX Beta-14
#define VER_LAMEXP_BUILD 412
#define VER_LAMEXP_SUFFIX Beta-15
/*
* Tools versions

View File

@ -75,11 +75,13 @@ AboutDialog::AboutDialog(SettingsModel *settings, QWidget *parent, bool firstSta
QMessageBox(parent),
m_settings(settings)
{
const QString versionStr = QString().sprintf("Version %d.%02d %s, Build %d [%s]", lamexp_version_major(), lamexp_version_minor(), lamexp_version_release(), lamexp_version_build(), lamexp_version_date().toString(Qt::ISODate).toLatin1().constData());
QString aboutText;
aboutText += QString("<h2>%1</h2>").arg(tr("LameXP &minus; Audio Encoder Front-end"));
aboutText += QString("<b>Copyright (C) 2004-%1 LoRd_MuldeR &lt;MuldeR2@GMX.de&gt;. Some rights reserved.</b><br>").arg(max(lamexp_version_date().year(),QDate::currentDate().year()));
aboutText += QString().sprintf("<b>Version %d.%02d %s, Build %d [%s]</b><br><br>", lamexp_version_major(), lamexp_version_minor(), lamexp_version_release(), lamexp_version_build(), lamexp_version_date().toString(Qt::ISODate).toLatin1().constData());
aboutText += lamexp_version_demo() ? QString("<b>%1, %2</b><br><br>").arg(versionStr, tr("DEMO VERSION")) : QString("<b>%1</b><br><br>").arg(versionStr);
aboutText += QString("<nobr>%1</nobr><br>").arg(tr("Please visit %1 for news and updates!").arg(LINK(lamexp_website_url())));
aboutText += "<hr><br>";
aboutText += "<nobr><tt>This program is free software; you can redistribute it and/or<br>";

View File

@ -1230,6 +1230,11 @@ void MainWindow::tabPageChanged(int idx)
actions.at(i)->setChecked(true);
}
}
if(idx == tabWidget->indexOf(tabSourceFiles))
{
m_dropNoteLabel->setGeometry(0, 0, sourceFileView->width(), sourceFileView->height());
}
}
/*

View File

@ -27,6 +27,7 @@
#include "Model_Progress.h"
#include "Model_Settings.h"
#include "Thread_Process.h"
#include "Thread_DiskObserver.h"
#include "Dialog_LogView.h"
#include "Encoder_MP3.h"
#include "Encoder_Vorbis.h"
@ -92,7 +93,8 @@ ProcessingDialog::ProcessingDialog(FileListModel *fileListModel, AudioFileModel
m_systemTray(new QSystemTrayIcon(QIcon(":/icons/cd_go.png"), this)),
m_settings(settings),
m_metaInfo(metaInfo),
m_shutdownFlag(false)
m_shutdownFlag(false),
m_diskObserver(NULL)
{
//Init the dialog, from the .ui file
setupUi(this);
@ -172,11 +174,23 @@ ProcessingDialog::ProcessingDialog(FileListModel *fileListModel, AudioFileModel
ProcessingDialog::~ProcessingDialog(void)
{
view_log->setModel(NULL);
if(m_progressIndicator) m_progressIndicator->stop();
if(m_progressIndicator)
{
m_progressIndicator->stop();
}
if(m_diskObserver)
{
m_diskObserver->stop();
m_diskObserver->wait(15000);
}
LAMEXP_DELETE(m_progressIndicator);
LAMEXP_DELETE(m_progressModel);
LAMEXP_DELETE(m_contextMenu);
LAMEXP_DELETE(m_systemTray);
LAMEXP_DELETE(m_diskObserver);
WinSevenTaskbar::setOverlayIcon(this, NULL);
WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarNoState);
@ -279,6 +293,13 @@ void ProcessingDialog::initEncoding(void)
WinSevenTaskbar::setTaskbarProgress(this, 0, m_pendingJobs.count());
WinSevenTaskbar::setOverlayIcon(this, &QIcon(":/icons/control_play_blue.png"));
if(!m_diskObserver)
{
m_diskObserver = new DiskObserverThread(m_settings->customTempPathEnabled() ? m_settings->customTempPath() : lamexp_temp_folder2());
connect(m_diskObserver, SIGNAL(messageLogged(QString,bool)), m_progressModel, SLOT(addSystemMessage(QString,bool)), Qt::QueuedConnection);
m_diskObserver->start();
}
int maximumInstances = max(min(m_settings->maximumInstances(), MAX_INSTANCES), 0);
if(maximumInstances < 1)
{

View File

@ -33,6 +33,7 @@ class ProcessThread;
class FileListModel;
class AudioFileModel;
class SettingsModel;
class DiskObserverThread;
class ProcessingDialog : public QDialog, private Ui::ProcessingDialog
{
@ -84,4 +85,5 @@ private:
bool m_userAborted;
QSystemTrayIcon *m_systemTray;
bool m_shutdownFlag;
DiskObserverThread *m_diskObserver;
};

View File

@ -29,7 +29,8 @@ ProgressModel::ProgressModel(void)
m_iconPaused(":/icons/control_pause_blue.png"),
m_iconComplete(":/icons/tick.png"),
m_iconFailed(":/icons/exclamation.png"),
m_iconSystem(":/icons/computer.png")
m_iconSystem(":/icons/computer.png"),
m_iconWarning(":/icons/error.png")
{
}
@ -82,6 +83,9 @@ QVariant ProgressModel::data(const QModelIndex &index, int role) const
case JobSystem:
return m_iconSystem;
break;
case JobWarning:
return m_iconWarning;
break;
default:
return m_iconFailed;
break;
@ -187,7 +191,7 @@ const QUuid &ProgressModel::getJobId(const QModelIndex &index)
return *(reinterpret_cast<QUuid*>(NULL));
}
void ProgressModel::addSystemMessage(const QString &text)
void ProgressModel::addSystemMessage(const QString &text, bool isWarning)
{
const QUuid &jobId = QUuid::createUuid();
@ -202,7 +206,7 @@ void ProgressModel::addSystemMessage(const QString &text)
m_jobList.append(jobId);
m_jobName.insert(jobId, text);
m_jobStatus.insert(jobId, QString());
m_jobState.insert(jobId, JobSystem);
m_jobState.insert(jobId, isWarning ? JobWarning : JobSystem);
m_jobLogFile.insert(jobId, QStringList());
endInsertRows();

View File

@ -44,7 +44,8 @@ public:
JobPaused = 1,
JobComplete = 2,
JobFailed = 3,
JobSystem = 4
JobSystem = 4,
JobWarning = 5
};
//Model functions
@ -61,7 +62,7 @@ public slots:
void addJob(const QUuid &jobId, const QString &jobName, const QString &jobInitialStatus = QString("Initializing..."), int jobInitialState = JobRunning);
void updateJob(const QUuid &jobId, const QString &newStatus, int newState);
void appendToLog(const QUuid &jobId, const QString &line);
void addSystemMessage(const QString &text);
void addSystemMessage(const QString &text, bool isWarning = false);
private:
QList<QUuid> m_jobList;
@ -75,4 +76,5 @@ private:
const QIcon m_iconComplete;
const QIcon m_iconFailed;
const QIcon m_iconSystem;
const QIcon m_iconWarning;
};

114
src/Thread_DiskObserver.cpp Normal file
View File

@ -0,0 +1,114 @@
///////////////////////////////////////////////////////////////////////////////
// LameXP - Audio Encoder Front-End
// Copyright (C) 2004-2011 LoRd_MuldeR <MuldeR2@GMX.de>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/licenses/gpl-2.0.txt
///////////////////////////////////////////////////////////////////////////////
#include "Thread_DiskObserver.h"
#include "Global.h"
#include <QDir>
#include <Windows.h>
#define MIN_DISKSPACE 104857600LL //100 MB
////////////////////////////////////////////////////////////
// Constructor & Destructor
////////////////////////////////////////////////////////////
DiskObserverThread::DiskObserverThread(const QString &path)
:
m_path(makeRootDir(path))
{
m_terminated = false;
}
DiskObserverThread::~DiskObserverThread(void)
{
}
////////////////////////////////////////////////////////////
// Protected functions
////////////////////////////////////////////////////////////
void DiskObserverThread::run(void)
{
qDebug("DiskSpace observer started!");
try
{
observe();
}
catch(...)
{
fflush(stdout);
fflush(stderr);
fprintf(stderr, "\nGURU MEDITATION !!!\n");
FatalAppExit(0, L"Unhandeled exception error, application will exit!");
TerminateProcess(GetCurrentProcess(), -1);
}
}
void DiskObserverThread::observe(void)
{
__int64 freeSpace, minimumSpace = MIN_DISKSPACE;
while(!m_terminated)
{
freeSpace = lamexp_free_diskspace(m_path);
if(freeSpace < minimumSpace)
{
qWarning64("Free diskspace on '%1' dropped below %2 MB, only %3 MB free!", m_path, QString::number(minimumSpace / 1048576), QString::number(freeSpace / 1048576));
emit messageLogged(tr("Low diskspace on drive '%1' detected (only %2 MB are free), problems can occur!").arg(QDir::toNativeSeparators(m_path), QString::number(freeSpace / 1048576)), true);
minimumSpace = min(freeSpace, (minimumSpace >> 1));
}
Sleep(1000);
}
}
QString DiskObserverThread::makeRootDir(const QString &baseDir)
{
QDir dir(baseDir);
if(!dir.exists())
{
return baseDir;
}
bool success = true;
while(success)
{
success = dir.cdUp();
}
return dir.canonicalPath();
}
////////////////////////////////////////////////////////////
// SLOTS
////////////////////////////////////////////////////////////
/*NONE*/
////////////////////////////////////////////////////////////
// EVENTS
////////////////////////////////////////////////////////////
/*NONE*/

48
src/Thread_DiskObserver.h Normal file
View File

@ -0,0 +1,48 @@
///////////////////////////////////////////////////////////////////////////////
// LameXP - Audio Encoder Front-End
// Copyright (C) 2004-2011 LoRd_MuldeR <MuldeR2@GMX.de>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/licenses/gpl-2.0.txt
///////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QThread>
class DiskObserverThread: public QThread
{
Q_OBJECT
public:
DiskObserverThread(const QString &path);
~DiskObserverThread(void);
void stop(void) { m_terminated = true; }
protected:
void run(void);
void observe(void);
static QString makeRootDir(const QString &baseDir);
signals:
void messageLogged(const QString &text, bool isWarning);
private:
volatile bool m_terminated;
const QString m_path;
};