From 02b7cdc3e16050dc055cc3d50cb758c7c514e266 Mon Sep 17 00:00:00 2001 From: lordmulder Date: Sat, 29 Oct 2011 16:26:09 +0200 Subject: [PATCH] Added indicators for current CPU usage, RAM usage and free disk space to the processing window. --- LameXP_VS2010.vcxproj | 26 ++++ LameXP_VS2010.vcxproj.filters | 18 +++ doc/Changelog.html | 1 + etc/Translation/Blank.ts | 334 ++++++++++++++++++++++-------------------- etc/Translation/LameXP_DE.ts | 12 ++ etc/Translation/LameXP_ES.ts | 12 ++ etc/Translation/LameXP_FR.ts | 12 ++ etc/Translation/LameXP_IT.ts | 12 ++ etc/Translation/LameXP_KR.ts | 12 ++ etc/Translation/LameXP_PL.ts | 334 ++++++++++++++++++++++-------------------- etc/Translation/LameXP_RU.ts | 12 ++ etc/Translation/LameXP_UK.ts | 12 ++ etc/Translation/update.lst | 4 + gui/ProcessingDialog.ui | 261 ++++++++++++++++++++++++++++++++- res/Icons.qrc | 2 + res/icons/cpu.png | Bin 0 -> 635 bytes res/icons/memory.png | Bin 0 -> 349 bytes res/localization/LameXP_DE.qm | Bin 72934 -> 73379 bytes src/Config.h | 2 +- src/Dialog_CueImport.cpp | 10 +- src/Dialog_MainWindow.cpp | 10 +- src/Dialog_Processing.cpp | 76 +++++++++- src/Dialog_Processing.h | 7 + src/Global.cpp | 4 +- src/Global.h | 2 +- src/Thread_CPUObserver.cpp | 131 +++++++++++++++++ src/Thread_CPUObserver.h | 46 ++++++ src/Thread_DiskObserver.cpp | 27 +++- src/Thread_DiskObserver.h | 1 + src/Thread_RAMObserver.cpp | 96 ++++++++++++ src/Thread_RAMObserver.h | 45 ++++++ 31 files changed, 1180 insertions(+), 341 deletions(-) create mode 100644 res/icons/cpu.png create mode 100644 res/icons/memory.png create mode 100644 src/Thread_CPUObserver.cpp create mode 100644 src/Thread_CPUObserver.h create mode 100644 src/Thread_RAMObserver.cpp create mode 100644 src/Thread_RAMObserver.h diff --git a/LameXP_VS2010.vcxproj b/LameXP_VS2010.vcxproj index a13d5220..0c4cb832 100644 --- a/LameXP_VS2010.vcxproj +++ b/LameXP_VS2010.vcxproj @@ -298,6 +298,7 @@ del "$(TargetDir)imageformats\q???d4.dll" + @@ -305,6 +306,7 @@ del "$(TargetDir)imageformats\q???d4.dll" + @@ -334,6 +336,7 @@ del "$(TargetDir)imageformats\q???d4.dll" + @@ -341,6 +344,7 @@ del "$(TargetDir)imageformats\q???d4.dll" + @@ -410,6 +414,28 @@ del "$(TargetDir)imageformats\q???d4.dll" $(SolutionDir)tmp\MOC_%(Filename).cpp;%(Outputs) $(SolutionDir)tmp\MOC_%(Filename).cpp;%(Outputs) + + "$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\MOC_%(Filename).cpp" "%(FullPath)" + "$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\MOC_%(Filename).cpp" "%(FullPath)" + "$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\MOC_%(Filename).cpp" "%(FullPath)" + MOC "$(SolutionDir)tmp\MOC_%(Filename).cpp" + MOC "$(SolutionDir)tmp\MOC_%(Filename).cpp" + MOC "$(SolutionDir)tmp\MOC_%(Filename).cpp" + $(SolutionDir)tmp\MOC_%(Filename).cpp;%(Outputs) + $(SolutionDir)tmp\MOC_%(Filename).cpp;%(Outputs) + $(SolutionDir)tmp\MOC_%(Filename).cpp;%(Outputs) + + + "$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\MOC_%(Filename).cpp" "%(FullPath)" + "$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\MOC_%(Filename).cpp" "%(FullPath)" + "$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\MOC_%(Filename).cpp" "%(FullPath)" + MOC "$(SolutionDir)tmp\MOC_%(Filename).cpp" + MOC "$(SolutionDir)tmp\MOC_%(Filename).cpp" + MOC "$(SolutionDir)tmp\MOC_%(Filename).cpp" + $(SolutionDir)tmp\MOC_%(Filename).cpp;%(Outputs) + $(SolutionDir)tmp\MOC_%(Filename).cpp;%(Outputs) + $(SolutionDir)tmp\MOC_%(Filename).cpp;%(Outputs) + diff --git a/LameXP_VS2010.vcxproj.filters b/LameXP_VS2010.vcxproj.filters index 5e2e5b3e..869668f0 100644 --- a/LameXP_VS2010.vcxproj.filters +++ b/LameXP_VS2010.vcxproj.filters @@ -322,6 +322,18 @@ Generated Files\QRC + + Source Files\Threads + + + Generated Files\MOC + + + Source Files\Threads + + + Generated Files\MOC + @@ -608,6 +620,12 @@ Resources + + Header Files\Threads + + + Header Files\Threads + diff --git a/doc/Changelog.html b/doc/Changelog.html index 51ae3606..80b988f8 100644 --- a/doc/Changelog.html +++ b/doc/Changelog.html @@ -25,6 +25,7 @@ a:visited { color: #0000EE; }
  • Added an option to hibernate the computer (aka "Suspend-to-Disk") instead of shutting it down
  • Added Polish translation, thanks to Sir Daniel K <sir.daniel.k@gmail.com>
  • Added channel equalization options to the normalization filter (also fixes multi-channel processing) +
  • Added indicators for current CPU usage, RAM usage and free diskspace to the processing window
  • Updated Qt runtime libraries to v4.8.0 RC-1 (2011-10-13), compiled with MSVC 10.0
  • Updated LAME encoder to v3.99 Final (2011-10-17), compiled with ICL 12.1.6 and MSVC 10.0 (details)
  • Updated mpg123 decoder to v1.13.4 (2011-09-07), compiled with GCC 4.6.1 diff --git a/etc/Translation/Blank.ts b/etc/Translation/Blank.ts index 12b7b1c7..523960d6 100644 --- a/etc/Translation/Blank.ts +++ b/etc/Translation/Blank.ts @@ -378,8 +378,8 @@ - - + + Cue Sheet Error @@ -436,67 +436,67 @@ - + Low Diskspace Warning - + There are less than %1 GB of free diskspace available in the selected output directory. - + It is highly recommend to free up more diskspace before proceeding with the import! - + Analyzing file(s), please wait... - + Analysis Failed - + Warning: The format of some of the input files could not be determined! - + Continue Anyway - + Abort - + Splitting file(s), please wait... - + Process was aborted by the user after %1 track(s)! - + An unexpected error has occured while splitting the Cue Sheet! - + Imported %1 track(s) from the Cue Sheet and skipped %2 track(s). - + Cue Sheet Completed @@ -606,7 +606,7 @@ DiskObserverThread - + Low diskspace on drive '%1' detected (only %2 MB are free), problems can occur! @@ -1410,13 +1410,13 @@ - + Disable Update Reminder - + Disable Sound Effects @@ -1502,7 +1502,7 @@ - + Access Denied @@ -1657,8 +1657,8 @@ - - + + Discard @@ -1680,8 +1680,8 @@ - - + + Update Reminder @@ -1757,8 +1757,8 @@ - - + + LameXP @@ -1788,412 +1788,412 @@ - + There are less than %1 GB of free diskspace available on your system's TEMP folder. - + It is highly recommend to free up more diskspace before proceeding with the encode! - + Your TEMP folder is located at: - + Low Diskspace Warning - + Abort Encoding Process - + Clean Disk Now - + Ignore - + Low Diskspace - + You are proceeding with low diskspace. Problems might occur! - + Sorry, an unsupported encoder has been chosen! - + Cannot write to the selected output directory. - + Please choose a different directory! - + Load Translation - + Translation Files - + Do you really want to disable the update reminder? - - - - - - - + + + + + + + Yes - - - - - - - + + + + + + + No - + The update reminder has been disabled. - + Please remember to check for updates at regular intervals! - + The update reminder has been re-enabled. - + Do you really want to disable all sound effects? - - + + Sound Effects - + All sound effects have been disabled. - + The sound effects have been re-enabled. - - + + Nero AAC Notifications - + Do you really want to disable all Nero AAC Encoder notifications? - + All Nero AAC Encoder notifications have been disabled. - + The Nero AAC Encoder notifications have been re-enabled. - - + + Slow Startup Notifications - + Do you really want to disable the slow startup notifications? - + The slow startup notifications have been disabled. - + The slow startup notifications have been re-enabled. - - + + Open Cue Sheet - - + + Cue Sheet File - - + + Beta Updates - + Do you really want LameXP to check for Beta (pre-release) updates? - + LameXP will check for Beta (pre-release) updates from now on. - + Check Now - + LameXP will <i>not</i> check for Beta (pre-release) updates from now on. - - + + Hibernate Computer - + Do you really want the computer to be hibernated on shutdown? - + LameXP will hibernate the computer on shutdown from now on. - + LameXP will <i>not</i> hibernate the computer on shutdown from now on. - - - + + + Shell Integration - + Do you really want to disable the LameXP shell integration? - + The LameXP shell integration has been disabled. - + The LameXP shell integration has been re-enabled. - - + + Add file(s) - - + + Add Folder - - + + New Folder - + Enter the name of the new folder: - + Failed to create folder - + The new folder could not be created: - + Drive is read-only or insufficient access rights! - - - - + + + + Quality Level %1 - - - + + + Compression %1 - - - + + + Uncompressed - + Best Quality (Very Slow) - + High Quality (Recommended) - + Average Quality (Default) - + Low Quality (Fast) - + Poor Quality (Very Fast) - + File name without extension - + Track number with leading zero - + Track title - + Artist name - + Album name - + Year with (at least) four digits - + Comment - + Characters forbidden in file names: - + Rename Macros - + %1 Instance(s) - + Cannot write to the selected directory. Please choose another directory! - + Already Running - + LameXP is already running, please use the running instance! @@ -2600,129 +2600,147 @@ - + Shutdown the computer as soon as all files have been converted - + + + CPU Usage (Overall) + + + + + + Physical RAM Usage + + + + + + Free Disk Space (Temp Folder) + + + + Abort - + Close - + Show details for selected job - + Browse Output File Location - + Encoding Files - + Your files are being encoded, please be patient... - + Encoding files, please wait... - + Multi-threading enabled: Running %1 instances in parallel! - + Aborted! Waiting for running jobs to terminate... - + Encoding: %1 files of %2 completed so far, please wait... - + Creating the playlist file, please wait... - + Process was aborted by the user after %1 file(s)! - + Process was aborted prematurely by the user! - + LameXP - Aborted - + Process was aborted by the user. - + Error: %1 of %2 files failed. Double-click failed items for detailed information! - + LameXP - Error - + At least one file has failed! - - + + All files completed successfully. - + LameXP - Done - + Playlist creation failed - + The playlist file could not be created: - + Warning: Computer will shutdown in %1 seconds... - - + + Cancel Shutdown diff --git a/etc/Translation/LameXP_DE.ts b/etc/Translation/LameXP_DE.ts index 7d9e88c4..0d3143dd 100644 --- a/etc/Translation/LameXP_DE.ts +++ b/etc/Translation/LameXP_DE.ts @@ -2113,6 +2113,18 @@ Cancel Shutdown Herunterfahren abbrechen + + CPU Usage (Overall) + Prozessorauslastung (insgesamt) + + + Physical RAM Usage + Speicherauslastung (physikalischer Arbeitsspeicher) + + + Free Disk Space (Temp Folder) + Freier Festplattenspeicher (Temp Ordner) + ProgressModel diff --git a/etc/Translation/LameXP_ES.ts b/etc/Translation/LameXP_ES.ts index 0b2f3bc5..14537289 100644 --- a/etc/Translation/LameXP_ES.ts +++ b/etc/Translation/LameXP_ES.ts @@ -2112,6 +2112,18 @@ Cancel Shutdown Cancelar apagado + + CPU Usage (Overall) + + + + Physical RAM Usage + + + + Free Disk Space (Temp Folder) + + ProgressModel diff --git a/etc/Translation/LameXP_FR.ts b/etc/Translation/LameXP_FR.ts index 70389ce9..fcc0b4d8 100644 --- a/etc/Translation/LameXP_FR.ts +++ b/etc/Translation/LameXP_FR.ts @@ -2122,6 +2122,18 @@ Ouvrir le dossier récursivement... Cancel Shutdown Annuler l'extinction + + CPU Usage (Overall) + + + + Physical RAM Usage + + + + Free Disk Space (Temp Folder) + + ProgressModel diff --git a/etc/Translation/LameXP_IT.ts b/etc/Translation/LameXP_IT.ts index 898e61db..22b697a7 100644 --- a/etc/Translation/LameXP_IT.ts +++ b/etc/Translation/LameXP_IT.ts @@ -2113,6 +2113,18 @@ Cancel Shutdown + + CPU Usage (Overall) + + + + Physical RAM Usage + + + + Free Disk Space (Temp Folder) + + ProgressModel diff --git a/etc/Translation/LameXP_KR.ts b/etc/Translation/LameXP_KR.ts index 6250ab9a..0cc50eab 100644 --- a/etc/Translation/LameXP_KR.ts +++ b/etc/Translation/LameXP_KR.ts @@ -2112,6 +2112,18 @@ Cancel Shutdown 컴퓨터 종료 취소 + + CPU Usage (Overall) + + + + Physical RAM Usage + + + + Free Disk Space (Temp Folder) + + ProgressModel diff --git a/etc/Translation/LameXP_PL.ts b/etc/Translation/LameXP_PL.ts index 3624ae60..bfba6690 100644 --- a/etc/Translation/LameXP_PL.ts +++ b/etc/Translation/LameXP_PL.ts @@ -378,8 +378,8 @@ - - + + Cue Sheet Error Błąd pliku Cue Sheet @@ -436,67 +436,67 @@ Błąd: Nie można zapisać w wybranej lokalizacji wyjściowej! - + Low Diskspace Warning Ostrzeżenie o małej ilości miejsca na dysku - + There are less than %1 GB of free diskspace available in the selected output directory. Jest mniej niż %1 GB wolnego miejsca w wybranej lokalizacji wyjściowej. - + It is highly recommend to free up more diskspace before proceeding with the import! Jest wysoce zalecane zwolnić miejsce na dysku zanim zaczniesz importować! - + Analyzing file(s), please wait... Analizowanie pliku/ów, prosze czekać... - + Analysis Failed Analiza zakończona niepowodzeniem - + Warning: The format of some of the input files could not be determined! Ostrzeżenie: Nie można rozpoznać formatu kilku plików wejściowych! - + Continue Anyway Kontynuuj pomimo to - + Abort Przerwij - + Splitting file(s), please wait... Dzielenie pliku/ów, prosze czekać... - + Process was aborted by the user after %1 track(s)! Proces został przerwany przez użytkownika po imporcie %1 ścieżek! - + An unexpected error has occured while splitting the Cue Sheet! Wystąpił nieoczekiwany błąd podczas podziału pliku Cue Sheet! - + Imported %1 track(s) from the Cue Sheet and skipped %2 track(s). Zaimportowano %1 ścieżek i opuszczono %2 ścieżek z pliku Cue Sheet. - + Cue Sheet Completed Stworzono plik Cue Sheet @@ -606,7 +606,7 @@ DiskObserverThread - + Low diskspace on drive '%1' detected (only %2 MB are free), problems can occur! Mało miejsca na dysku '%1' (tylko %2 MB dostępnych), mogą wystąpić problemy! @@ -1410,13 +1410,13 @@ - + Disable Update Reminder Wyłącz przypominanie o aktualizacji - + Disable Sound Effects Wyłącz efekty dźwiękowe @@ -1502,7 +1502,7 @@ - + Access Denied Dostęp zablokowany @@ -1652,8 +1652,8 @@ - - + + Discard Zamknij @@ -1675,8 +1675,8 @@ - - + + Update Reminder Powiadomienie aktualizacji @@ -1747,8 +1747,8 @@ - - + + LameXP LameXP @@ -1778,12 +1778,12 @@ Anuluj - + Low Diskspace Warning Ostrzeżenie o małej ilości miejsca na dysku - + There are less than %1 GB of free diskspace available on your system's TEMP folder. Jest mniej niż %1 GB dostępnego miejsca w systemowym folderze TEMP. @@ -1798,402 +1798,402 @@ - + It is highly recommend to free up more diskspace before proceeding with the encode! Jest wysoce zalecane zwolnić miejsce na dysku zanim zaczniesz kompresję! - + Your TEMP folder is located at: Twój folder TEMP znajduję się: - + Abort Encoding Process Przerwij proces kompresji - + Clean Disk Now Wykonaj oczyszczanie dysku - + Ignore Ignoruj - + Low Diskspace Mało miejsca na dysku - + You are proceeding with low diskspace. Problems might occur! Chcesz zacząć działać z małą ilością miejsca na dysku. Mogą wystąpić problemy! - + Sorry, an unsupported encoder has been chosen! Został wybrany koder, który nie jest wspierany! - + Cannot write to the selected output directory. Nie można zapisać do wybranej lokalizacji. - + Please choose a different directory! Prosze wybrać inną lokalizację! - + Load Translation Zaladuj plik językowy - + Translation Files Pliki językowe - + Do you really want to disable the update reminder? Czy na pewno chcesz wyłączyć przypominanie o aktualizacjach? - - - - - - - + + + + + + + Yes Tak - - - - - - - + + + + + + + No Nie - + The update reminder has been disabled. Przypominanie o aktualizacjach wyłączone. - + Please remember to check for updates at regular intervals! Prosze pamiętać o okresowym sprawdzaniu aktualizacji! - + The update reminder has been re-enabled. Przypominanie o aktualizacjach ponownie włączone. - + Do you really want to disable all sound effects? Czy na pewno chcesz wyłączyć wszystkie dźwiękowe? - - + + Sound Effects Efekty dźwiękowe - + All sound effects have been disabled. Wszystkie efekty dźwiękowe zostały wyłączone. - + The sound effects have been re-enabled. Efekty dźwiękowe zostały ponownie włączone. - - + + Nero AAC Notifications Powiadomienia Nero AAC - + Do you really want to disable all Nero AAC Encoder notifications? Czy na pewno chcesz wyłączyć wszystkie powiadomienia Nero AAC? - + All Nero AAC Encoder notifications have been disabled. Wszystkie powiadomienia kodera Nero AAC zostały wyłączone. - + The Nero AAC Encoder notifications have been re-enabled. Powiadomienia Nero AAC zostały ponownie włączone. - - + + Slow Startup Notifications Powiadomienia o powolnym starcie - + Do you really want to disable the slow startup notifications? Czy na pewno chcesz wyłączyć powiadomienia o powolnym starcie? - + The slow startup notifications have been disabled. Powiadomienia o powolnym starcie zostały wyłączone. - + The slow startup notifications have been re-enabled. Powiadomienia o powolnym starcie zostały ponownie włączone. - - + + Open Cue Sheet Otwórz plik Cue Sheet - - + + Cue Sheet File Plik Cue Sheet - - + + Beta Updates Aktualizacje Beta - + Do you really want LameXP to check for Beta (pre-release) updates? Czy na pewno chcesz aby LameXP sprawdzał aktualizacje Beta? - + LameXP will check for Beta (pre-release) updates from now on. Od teraz LameXP będzie sprawdzał aktualizacje Beta. - + Check Now Sprawdź teraz - + LameXP will <i>not</i> check for Beta (pre-release) updates from now on. LameXP od teraz <i>nie będzie</i> sprawdzał aktualizacji Beta. - - + + Hibernate Computer - + Do you really want the computer to be hibernated on shutdown? - + LameXP will hibernate the computer on shutdown from now on. - + LameXP will <i>not</i> hibernate the computer on shutdown from now on. - - - + + + Shell Integration Integracja z systemem - + Do you really want to disable the LameXP shell integration? Czy na pewno chcesz wyłączyć integrację LameXP z systemem? - + The LameXP shell integration has been disabled. Integracja LameXP z systemem zostałą wyłączona. - + The LameXP shell integration has been re-enabled. Integracja LameXP z systemem została ponownie włączona. - - + + Add file(s) Dodaj plik(i) - - + + Add Folder Dodaj folder - - + + New Folder Nowy folder - + Enter the name of the new folder: Wprowadź nazwę nowego folderu: - + Failed to create folder Utworzenie folderu zakończone niepowodzeniem - + The new folder could not be created: Nowy folder nie mógł zostać stworzony: - + Drive is read-only or insufficient access rights! Dysk tylko do odczytu lub brak praw dostępu! - - - - + + + + Quality Level %1 Poziom jakości %1 - - - + + + Compression %1 Kompresja %1 - - - + + + Uncompressed Nieskompresowany - + Best Quality (Very Slow) Najlepsza jakość (Bardzo wolno) - + High Quality (Recommended) Wysoka jakość (Zalecane) - + Average Quality (Default) Średnia jakość (Domyślnie) - + Low Quality (Fast) Niska jakość (Szybko) - + Poor Quality (Very Fast) Najniższa jakość (Bardzo szybko) - + File name without extension Nazwa pliku bez rozszerzenia - + Track number with leading zero Numer ścieżki z zerem na początku - + Track title Nazwa ścieżki - + Artist name Nazwa Artysty - + Album name Nazwa Albumu - + Year with (at least) four digits Rok z (przynajmniej) czterema cyframi - + Comment Komentarz - + Characters forbidden in file names: Zabronione znaki w nazwach plików: - + Rename Macros Zmień nazwy makr - + %1 Instance(s) %1 wątek/ki - + Cannot write to the selected directory. Please choose another directory! Nie można zapisać do wybranej lokalizacji. Prosze wybierz inną lokalizację! - + Already Running Już działa - + LameXP is already running, please use the running instance! LameXP już działa, przejdź do działającego programu! @@ -2600,129 +2600,147 @@ Inicjowanie, prosze czekać... - + Shutdown the computer as soon as all files have been converted Wyłącz komputer po przetworzeniu wszystkich plików - + + + CPU Usage (Overall) + + + + + + Physical RAM Usage + + + + + + Free Disk Space (Temp Folder) + + + + Abort Przerwij - + Close Powrót - + Show details for selected job Pokaż szczegóły wybranego zadania - + Browse Output File Location Wybierz lokalizację dla plików wyjściowych - + Encoding Files Kompresowanie plików - + Your files are being encoded, please be patient... Twoje pliki są właśnie kompresowane, prosze być cierpliwy... - + Encoding files, please wait... Kompresowanie plików, prosze czekać... - + Multi-threading enabled: Running %1 instances in parallel! Wielowątkowosć włączona: Równolegle wykonywanych jest %1 kodowań! - + Aborted! Waiting for running jobs to terminate... Przerwano! Czekanie na wyłączenie procesu... - + Encoding: %1 files of %2 completed so far, please wait... Kompresja: Prosze czekać, jak dotąd wykonano %1 z %2 plików... - + Creating the playlist file, please wait... Tworzenie pliku playlisty, prosze czekać... - + Process was aborted by the user after %1 file(s)! Proces został przerwany przez użytkownika po wykonaniu %1 plików! - + Process was aborted prematurely by the user! Proces został przedwcześnie zakończony przez użytkownika! - + LameXP - Aborted LameXP - Przerwano - + Process was aborted by the user. Proces został przerwany przez użytkownika. - + Error: %1 of %2 files failed. Double-click failed items for detailed information! Błąd: %1 z %2 plików nie zostało skompresowanych. Kliknij dwukrotnie na plik aby zobaczyć szczegóły! - + LameXP - Error LameXP - Błąd - + At least one file has failed! Przynajmniej jeden plik nie został skompresowany! - - + + All files completed successfully. Kompresja wszystkich plików zakończona powodzeniem. - + LameXP - Done LameXP - Zrobione - + Playlist creation failed Tworzenie playlisty zakończone niepowodzeniem - + The playlist file could not be created: Playlista nie mogła zostać utworzona: - + Warning: Computer will shutdown in %1 seconds... Ostrzeżenie: Komputer zostanie zamknięty za %1 sekund/y... - - + + Cancel Shutdown Anuluj wyłączenie komputera diff --git a/etc/Translation/LameXP_RU.ts b/etc/Translation/LameXP_RU.ts index 7d1eff61..5a9836ec 100644 --- a/etc/Translation/LameXP_RU.ts +++ b/etc/Translation/LameXP_RU.ts @@ -2120,6 +2120,18 @@ Cancel Shutdown Отменить выключение + + CPU Usage (Overall) + + + + Physical RAM Usage + + + + Free Disk Space (Temp Folder) + + ProgressModel diff --git a/etc/Translation/LameXP_UK.ts b/etc/Translation/LameXP_UK.ts index 8d131585..8f671dc5 100644 --- a/etc/Translation/LameXP_UK.ts +++ b/etc/Translation/LameXP_UK.ts @@ -2113,6 +2113,18 @@ Cancel Shutdown Відмінити Вимкнення + + CPU Usage (Overall) + + + + Physical RAM Usage + + + + Free Disk Space (Temp Folder) + + ProgressModel diff --git a/etc/Translation/update.lst b/etc/Translation/update.lst index 9a713dbf..2ec4c8c2 100644 --- a/etc/Translation/update.lst +++ b/etc/Translation/update.lst @@ -62,6 +62,7 @@ ..\..\src\PlaylistImporter.cpp ..\..\src\Registry_Decoder.cpp ..\..\src\ShellIntegration.cpp +..\..\src\Thread_CPUObserver.cpp ..\..\src\Thread_CueSplitter.cpp ..\..\src\Thread_DiskObserver.cpp ..\..\src\Thread_FileAnalyzer.cpp @@ -69,6 +70,7 @@ ..\..\src\Thread_MessageHandler.cpp ..\..\src\Thread_MessageProducer.cpp ..\..\src\Thread_Process.cpp +..\..\src\Thread_RAMObserver.cpp ..\..\src\Tool_Abstract.cpp ..\..\src\WinSevenTaskbar.cpp ..\..\src\Config.h @@ -128,6 +130,7 @@ ..\..\src\Resource.h ..\..\src\ShellIntegration.h ..\..\src\Targetver.h +..\..\src\Thread_CPUObserver.h ..\..\src\Thread_CueSplitter.h ..\..\src\Thread_DiskObserver.h ..\..\src\Thread_FileAnalyzer.h @@ -135,6 +138,7 @@ ..\..\src\Thread_MessageHandler.h ..\..\src\Thread_MessageProducer.h ..\..\src\Thread_Process.h +..\..\src\Thread_RAMObserver.h ..\..\src\Tools.h ..\..\src\Tool_Abstract.h ..\..\src\WinSevenTaskbar.h diff --git a/gui/ProcessingDialog.ui b/gui/ProcessingDialog.ui index 5225d7f5..dcc00921 100644 --- a/gui/ProcessingDialog.ui +++ b/gui/ProcessingDialog.ui @@ -302,11 +302,264 @@ - - - Shutdown the computer as soon as all files have been converted + + + 0 - + + + + + 0 + 0 + + + + Shutdown the computer as soon as all files have been converted + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 12 + 20 + + + + + + + + CPU Usage (Overall) + + + + + + :/icons/cpu.png + + + + + + + + + + + + 0 + 0 + 255 + + + + + + + + + 0 + 0 + 255 + + + + + + + + + 120 + 120 + 120 + + + + + + + + + 50 + false + + + + CPU Usage (Overall) + + + 0% + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 8 + 0 + + + + QFrame::VLine + + + QFrame::Raised + + + + + + + Physical RAM Usage + + + + + + :/icons/memory.png + + + + + + + + + + + + 0 + 0 + 255 + + + + + + + + + 0 + 0 + 255 + + + + + + + + + 120 + 120 + 120 + + + + + + + + Physical RAM Usage + + + 0% + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 8 + 0 + + + + QFrame::VLine + + + QFrame::Raised + + + + + + + Free Disk Space (Temp Folder) + + + + + + :/icons/drive.png + + + + + + + + + + + + 0 + 0 + 255 + + + + + + + + + 0 + 0 + 255 + + + + + + + + + 120 + 120 + 120 + + + + + + + + Free Disk Space (Temp Folder) + + + 0% + + + + diff --git a/res/Icons.qrc b/res/Icons.qrc index 3fbdcb8d..5eaa89a2 100644 --- a/res/Icons.qrc +++ b/res/Icons.qrc @@ -31,6 +31,7 @@ icons/controller.png icons/control_pause_blue.png icons/control_play_blue.png + icons/cpu.png icons/cross.png icons/date.png icons/delete.png @@ -60,6 +61,7 @@ icons/information.png icons/lightning.png icons/media_play.png + icons/memory.png icons/money_dollar.png icons/monitor.png icons/music.png diff --git a/res/icons/cpu.png b/res/icons/cpu.png new file mode 100644 index 0000000000000000000000000000000000000000..37e9794222d91f6a4e1dc4d92a6be77f06a6e4d9 GIT binary patch literal 635 zcmV->0)+jEP)x{Z#$ z4n!i6UA$TV6omfVB6O(i`0^<#C2zQBX;UvTE@OI$uX z05K@=^k%9dGS513>V^V=3PiD3RBeXCVY~_bhD=C2{`svTGS513#FJOQM#~jr-MiGF zc;8Q!78P*4$U1Svlc#P7Js3wD`kVe2m+{WcxF@Ny(R1%{Bh&=l@qEd3-Ic!r3;=a7 VH9Kxj761SM002ovPDHLkV1nr!94!C< literal 0 HcmV?d00001 diff --git a/res/icons/memory.png b/res/icons/memory.png new file mode 100644 index 0000000000000000000000000000000000000000..4c71a247d68aaba26b00a4adf655d02a1e90201c GIT binary patch literal 349 zcmV-j0iyniP)%eKPc3{L}TPkcHt7gF#+sp2MF%e~8w}!otEZY4s#VFdJw9)2C0L7@kge3YPf( z{W}9gC<6oQ23DMWg;E6ukUnr2{Qvcz>GP-03_pJSU|?rwXZZH*8^f<(zwq)w>OuM- zF8B#_!RJp5uV23gV-Vo_!Nu_H^*5Y+kb00lm;ubve;FA*rwTBrvU4-s{`nO`r?TPX zgVclcL89>o15>qzDcJNnZ407kkb00lunYd*`G0BdiHp*=_uYOrm;a&^u{1~@I30kz v2*kWV%uGTW_zT3Jf%)hgg?n+~lmeiz~f9jGu-C@95^NmGZc9?pkwaJL(@D z0Mtp;S0{lVHr>q$A%B8RQ3H2#{Q@Oe+;OMvASP?d77Xjw1kb{zov7nS_^_kbgVio<&t$h1<4 z?gIbobIR(<`Ot8ZL$b4j^W8v&l4QT`at0NW%O^=O#3aVvq_`o-uRlYV4Q_t>1g$q-u`f6b$s=C^-<~lXos@yOmuRi&K9OH_eAlXLVLEMMsO~Ui);b+5gLSfG5oUSrPMQCB^excAeEcRQeXsR%8D7Vi$0y zpVE03xc+MzviSMp0A(#MZj94SEhv$+{J)zMIX zwS9TU)^Ri+s7u*Gt!KgHak`xEe@K4Pc5$>3uzqKo>Nx~x10gWWBa(QNMdWdmjSM_6 zHnnF9Jcyzj`=LS;qg$*3hzS=Ks-Z{tF0{jmbqEQk34iy?06Imj!XRkSiRq~I_?$j1 z(5^byHT9~|Ksa2HTCK36k*6{nWyu3K?L5Arc7@X-2%U%s-z2*26;xH|eO8G(s;bVq zkhag+90{}uVvE`tak{(1d)4SaR4w-fe?5q1fl)=UHgv2&{x5n&)cZv25cY}aVWHZ; u|2VNtw107h(4rYy7-pC@lw*e z+Ib3J>7hYh#H9#I7ivv^P6`IgYvA8LA=(iHmfL7hNY%Gx0jC;;L*cuC`~d9~9Rk)e z$s;@)5Mt0{v{LOPMv*5$^2VSt`Lh!EY`Kh)&b{Ib&p2M0RJ}{ z3>oGsGj)X8xo?QfdJ9*7rfhuzpZZ9pdOM$PruTZc92Yv>J)rz?+FNSKVO;Z&I*ci% z;6cO1RwHo0Z74q8uh=(Jz-ZsZ-G-4aE1-XCn7DQqxLREdrmGQ@_o8TObClN^)<5AL R@F$60T6@krzjM|b{U5MJ%1
    %2").arg(tr("There are less than %1 GB of free diskspace available in the selected output directory.").arg(QString::number(minimumFreeDiskspaceMultiplier)), tr("It is highly recommend to free up more diskspace before proceeding with the import!"))); return; diff --git a/src/Dialog_MainWindow.cpp b/src/Dialog_MainWindow.cpp index 21c9e90d..cafecd92 100644 --- a/src/Dialog_MainWindow.cpp +++ b/src/Dialog_MainWindow.cpp @@ -1145,8 +1145,8 @@ void MainWindow::showAnnounceBox(void) */ void MainWindow::encodeButtonClicked(void) { - static const __int64 oneGigabyte = 1073741824i64; - static const __int64 minimumFreeDiskspaceMultiplier = 2i64; + static const unsigned __int64 oneGigabyte = 1073741824ui64; + static const unsigned __int64 minimumFreeDiskspaceMultiplier = 2ui64; static const char *writeTestBuffer = "LAMEXP_WRITE_TEST"; ABORT_IF_BUSY; @@ -1168,8 +1168,10 @@ void MainWindow::encodeButtonClicked(void) return; } - qint64 currentFreeDiskspace = lamexp_free_diskspace(tempFolder); - if(currentFreeDiskspace < (oneGigabyte * minimumFreeDiskspaceMultiplier)) + bool ok = false; + unsigned __int64 currentFreeDiskspace = lamexp_free_diskspace(tempFolder, &ok); + + if(ok && (currentFreeDiskspace < (oneGigabyte * minimumFreeDiskspaceMultiplier))) { QStringList tempFolderParts = tempFolder.split("/", QString::SkipEmptyParts, Qt::CaseInsensitive); tempFolderParts.takeLast(); diff --git a/src/Dialog_Processing.cpp b/src/Dialog_Processing.cpp index d4b323e2..e0fd6b2b 100644 --- a/src/Dialog_Processing.cpp +++ b/src/Dialog_Processing.cpp @@ -27,6 +27,8 @@ #include "Model_Progress.h" #include "Model_Settings.h" #include "Thread_Process.h" +#include "Thread_CPUObserver.h" +#include "Thread_RAMObserver.h" #include "Thread_DiskObserver.h" #include "Dialog_LogView.h" #include "Encoder_MP3.h" @@ -97,7 +99,9 @@ ProcessingDialog::ProcessingDialog(FileListModel *fileListModel, AudioFileModel m_settings(settings), m_metaInfo(metaInfo), m_shutdownFlag(shutdownFlag_None), - m_diskObserver(NULL) + m_diskObserver(NULL), + m_cpuObserver(NULL), + m_ramObserver(NULL) { //Init the dialog, from the .ui file setupUi(this); @@ -188,7 +192,29 @@ ProcessingDialog::~ProcessingDialog(void) if(m_diskObserver) { m_diskObserver->stop(); - m_diskObserver->wait(15000); + if(!m_diskObserver->wait(15000)) + { + m_diskObserver->terminate(); + m_diskObserver->wait(); + } + } + if(m_cpuObserver) + { + m_cpuObserver->stop(); + if(!m_cpuObserver->wait(15000)) + { + m_cpuObserver->terminate(); + m_cpuObserver->wait(); + } + } + if(m_ramObserver) + { + m_ramObserver->stop(); + if(!m_ramObserver->wait(15000)) + { + m_ramObserver->terminate(); + m_ramObserver->wait(); + } } LAMEXP_DELETE(m_progressIndicator); @@ -196,6 +222,8 @@ ProcessingDialog::~ProcessingDialog(void) LAMEXP_DELETE(m_contextMenu); LAMEXP_DELETE(m_systemTray); LAMEXP_DELETE(m_diskObserver); + LAMEXP_DELETE(m_cpuObserver); + LAMEXP_DELETE(m_ramObserver); WinSevenTaskbar::setOverlayIcon(this, NULL); WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarNoState); @@ -225,6 +253,10 @@ void ProcessingDialog::showEvent(QShowEvent *event) SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); } + ramUsageHasChanged(0.0); + cpuUsageHasChanged(0.0); + diskUsageHasChanged(0ui64); + QTimer::singleShot(1000, this, SLOT(initEncoding())); } @@ -302,8 +334,21 @@ void ProcessingDialog::initEncoding(void) { 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); + connect(m_diskObserver, SIGNAL(freeSpaceChanged(quint64)), this, SLOT(diskUsageHasChanged(quint64)), Qt::QueuedConnection); m_diskObserver->start(); } + if(!m_cpuObserver) + { + m_cpuObserver = new CPUObserverThread(); + connect(m_cpuObserver, SIGNAL(currentUsageChanged(double)), this, SLOT(cpuUsageHasChanged(double)), Qt::QueuedConnection); + m_cpuObserver->start(); + } + if(!m_ramObserver) + { + m_ramObserver = new RAMObserverThread(); + connect(m_ramObserver, SIGNAL(currentUsageChanged(double)), this, SLOT(ramUsageHasChanged(double)), Qt::QueuedConnection); + m_ramObserver->start(); + } int maximumInstances = max(min(m_settings->maximumInstances(), MAX_INSTANCES), 0); if(maximumInstances < 1) @@ -831,6 +876,33 @@ void ProcessingDialog::systemTrayActivated(QSystemTrayIcon::ActivationReason rea } } +void ProcessingDialog::cpuUsageHasChanged(const double val) +{ + + this->label_cpu->setText(QString().sprintf(" %d%%", qRound(val * 100.0))); +} + +void ProcessingDialog::ramUsageHasChanged(const double val) +{ + + this->label_ram->setText(QString().sprintf(" %d%%", qRound(val * 100.0))); +} + +void ProcessingDialog::diskUsageHasChanged(const quint64 val) +{ + int postfix = 0; + const char *postfixStr[6] = {"B", "KB", "MB", "GB", "TB", "PB"}; + double space = static_cast(val); + + while((space >= 1000.0) && (postfix < 5)) + { + space = space / 1024.0; + postfix++; + } + + this->label_disk->setText(QString().sprintf(" %3.1f %s", space, postfixStr[postfix])); +} + bool ProcessingDialog::shutdownComputer(void) { const int iTimeout = m_settings->hibernateComputer() ? 10 : 30; diff --git a/src/Dialog_Processing.h b/src/Dialog_Processing.h index c4caf06a..d4567601 100644 --- a/src/Dialog_Processing.h +++ b/src/Dialog_Processing.h @@ -33,6 +33,8 @@ class ProcessThread; class FileListModel; class AudioFileModel; class SettingsModel; +class CPUObserverThread; +class RAMObserverThread; class DiskObserverThread; enum shutdownFlag_t @@ -64,6 +66,9 @@ private slots: void contextMenuDetailsActionTriggered(void); void contextMenuShowFileActionTriggered(void); void systemTrayActivated(QSystemTrayIcon::ActivationReason reason); + void cpuUsageHasChanged(const double val); + void ramUsageHasChanged(const double val); + void diskUsageHasChanged(const quint64 val); protected: void showEvent(QShowEvent *event); @@ -93,5 +98,7 @@ private: bool m_userAborted; QSystemTrayIcon *m_systemTray; int m_shutdownFlag; + CPUObserverThread *m_cpuObserver; + RAMObserverThread *m_ramObserver; DiskObserverThread *m_diskObserver; }; diff --git a/src/Global.cpp b/src/Global.cpp index 792a4c0b..add998b5 100644 --- a/src/Global.cpp +++ b/src/Global.cpp @@ -1486,15 +1486,17 @@ bool lamexp_themes_enabled(void) /* * Get number of free bytes on disk */ -__int64 lamexp_free_diskspace(const QString &path) +unsigned __int64 lamexp_free_diskspace(const QString &path, bool *ok) { ULARGE_INTEGER freeBytesAvailable, totalNumberOfBytes, totalNumberOfFreeBytes; if(GetDiskFreeSpaceExW(reinterpret_cast(QDir::toNativeSeparators(path).utf16()), &freeBytesAvailable, &totalNumberOfBytes, &totalNumberOfFreeBytes)) { + if(ok) *ok = true; return freeBytesAvailable.QuadPart; } else { + if(ok) *ok = false; return 0; } } diff --git a/src/Global.h b/src/Global.h index 18db832b..4e54423c 100644 --- a/src/Global.h +++ b/src/Global.h @@ -119,7 +119,7 @@ static const char* LAMEXP_DEFAULT_LANGID = "en"; bool lamexp_clean_folder(const QString &folderPath); const QString lamexp_version2string(const QString &pattern, unsigned int version, const QString &defaultText); QString lamexp_known_folder(lamexp_known_folder_t folder_id); -__int64 lamexp_free_diskspace(const QString &path); +unsigned __int64 lamexp_free_diskspace(const QString &path, bool *ok = NULL); bool lamexp_remove_file(const QString &filename); bool lamexp_themes_enabled(void); void lamexp_blink_window(QWidget *poWindow, unsigned int count = 10, unsigned int delay = 150); diff --git a/src/Thread_CPUObserver.cpp b/src/Thread_CPUObserver.cpp new file mode 100644 index 00000000..99b04086 --- /dev/null +++ b/src/Thread_CPUObserver.cpp @@ -0,0 +1,131 @@ +/////////////////////////////////////////////////////////////////////////////// +// LameXP - Audio Encoder Front-End +// Copyright (C) 2004-2011 LoRd_MuldeR +// +// 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_CPUObserver.h" +#include "Global.h" + +#include + +//////////////////////////////////////////////////////////// +// Constructor & Destructor +//////////////////////////////////////////////////////////// + +CPUObserverThread::CPUObserverThread(void) +{ + m_terminated = false; +} + +CPUObserverThread::~CPUObserverThread(void) +{ +} + +//////////////////////////////////////////////////////////// +// Protected functions +//////////////////////////////////////////////////////////// + +void CPUObserverThread::run(void) +{ + qDebug("CPU observer started!"); + m_terminated = false; + + try + { + observe(); + } + catch(...) + { + fflush(stdout); + fflush(stderr); + fprintf(stderr, "\nGURU MEDITATION !!!\n"); + FatalAppExit(0, L"Unhandeled exception error, application will exit!"); + TerminateProcess(GetCurrentProcess(), -1); + } +} + +ULONGLONG CPUObserverThread::filetime2ulonglong(const void *ftime) +{ + ULARGE_INTEGER tmp; tmp.QuadPart = 0UI64; + const FILETIME* fileTime = reinterpret_cast(ftime); + tmp.LowPart = fileTime->dwLowDateTime; + tmp.HighPart = fileTime->dwHighDateTime; + return tmp.QuadPart; +} + +void CPUObserverThread::observe(void) +{ + ULONGLONG sys[2], usr[2], idl[2]; + FILETIME sysTime, usrTime, idlTime; + bool first = true; + double previous = -1.0; + + for(size_t i = 0; i < 2; i++) + { + sys[i] = 0; usr[i] = 0; idl[i] = 0; + } + + while(!m_terminated) + { + if(GetSystemTimes(&idlTime, &sysTime, &usrTime)) + { + sys[1] = sys[0]; sys[0] = filetime2ulonglong(&sysTime); + usr[1] = usr[0]; usr[0] = filetime2ulonglong(&usrTime); + idl[1] = idl[0]; idl[0] = filetime2ulonglong(&idlTime); + + if(first) + { + first = false; + emit currentUsageChanged(1.0); + msleep(250); + continue; + } + + ULONGLONG timeIdl = (idl[0] - idl[1]); //Idle time only + ULONGLONG timeSys = (sys[0] - sys[1]); //Kernel mode time (incl. Idle time!) + ULONGLONG timeUsr = (usr[0] - usr[1]); //User mode time only + + ULONGLONG timeSum = timeUsr + timeSys; //Overall CPU time that has elapsed + ULONGLONG timeWrk = timeSum - timeIdl; //Time the CPU spent working + + if((timeSum > 0) || (timeWrk > 0)) + { + double current = static_cast(timeWrk) / static_cast(timeSum); + if(current != previous) + { + emit currentUsageChanged(current); + previous = current; + } + } + } + msleep(1000); + } +} + +//////////////////////////////////////////////////////////// +// SLOTS +//////////////////////////////////////////////////////////// + +/*NONE*/ + +//////////////////////////////////////////////////////////// +// EVENTS +//////////////////////////////////////////////////////////// + +/*NONE*/ diff --git a/src/Thread_CPUObserver.h b/src/Thread_CPUObserver.h new file mode 100644 index 00000000..dda416ee --- /dev/null +++ b/src/Thread_CPUObserver.h @@ -0,0 +1,46 @@ +/////////////////////////////////////////////////////////////////////////////// +// LameXP - Audio Encoder Front-End +// Copyright (C) 2004-2011 LoRd_MuldeR +// +// 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 + +class CPUObserverThread: public QThread +{ + Q_OBJECT + +public: + CPUObserverThread(void); + ~CPUObserverThread(void); + + void stop(void) { m_terminated = true; } + +protected: + void run(void); + void observe(void); + +signals: + void currentUsageChanged(const double usage); + +private: + volatile bool m_terminated; + static inline unsigned __int64 filetime2ulonglong(const void *ftime); +}; diff --git a/src/Thread_DiskObserver.cpp b/src/Thread_DiskObserver.cpp index 564521bd..5d0aaa5d 100644 --- a/src/Thread_DiskObserver.cpp +++ b/src/Thread_DiskObserver.cpp @@ -25,7 +25,7 @@ #include -#define MIN_DISKSPACE 104857600LL //100 MB +#define MIN_DISKSPACE 104857600ui64 //100 MB //////////////////////////////////////////////////////////// // Constructor & Destructor @@ -49,6 +49,7 @@ DiskObserverThread::~DiskObserverThread(void) void DiskObserverThread::run(void) { qDebug("DiskSpace observer started!"); + m_terminated = false; try { @@ -66,18 +67,28 @@ void DiskObserverThread::run(void) void DiskObserverThread::observe(void) { - __int64 freeSpace, minimumSpace = MIN_DISKSPACE; + unsigned __int64 minimumSpace = MIN_DISKSPACE; + unsigned __int64 freeSpace, previousSpace = 0ui64; + bool ok = false; while(!m_terminated) { - freeSpace = lamexp_free_diskspace(m_path); - if(freeSpace < minimumSpace) + freeSpace = lamexp_free_diskspace(m_path, &ok); + if(ok) { - qWarning("Free diskspace on '%s' dropped below %s MB, only %s MB free!", m_path.toUtf8().constData(), QString::number(minimumSpace / 1048576ui64).toUtf8().constData(), QString::number(freeSpace / 1048576ui64).toUtf8().constData()); - 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 / 1048576ui64)), true); - minimumSpace = min(freeSpace, (minimumSpace >> 1)); + if(freeSpace < minimumSpace) + { + qWarning("Free diskspace on '%s' dropped below %s MB, only %s MB free!", m_path.toUtf8().constData(), QString::number(minimumSpace / 1048576ui64).toUtf8().constData(), QString::number(freeSpace / 1048576ui64).toUtf8().constData()); + 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 / 1048576ui64)), true); + minimumSpace = min(freeSpace, (minimumSpace >> 1)); + } + if(freeSpace != previousSpace) + { + emit freeSpaceChanged(freeSpace); + previousSpace = freeSpace; + } } - Sleep(1000); + msleep(1000); } } diff --git a/src/Thread_DiskObserver.h b/src/Thread_DiskObserver.h index 05c71c84..1bf4a0c2 100644 --- a/src/Thread_DiskObserver.h +++ b/src/Thread_DiskObserver.h @@ -41,6 +41,7 @@ protected: signals: void messageLogged(const QString &text, bool isWarning); + void freeSpaceChanged(const quint64); private: volatile bool m_terminated; diff --git a/src/Thread_RAMObserver.cpp b/src/Thread_RAMObserver.cpp new file mode 100644 index 00000000..d7979bf5 --- /dev/null +++ b/src/Thread_RAMObserver.cpp @@ -0,0 +1,96 @@ +/////////////////////////////////////////////////////////////////////////////// +// LameXP - Audio Encoder Front-End +// Copyright (C) 2004-2011 LoRd_MuldeR +// +// 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_RAMObserver.h" +#include "Global.h" + +#include + +//////////////////////////////////////////////////////////// +// Constructor & Destructor +//////////////////////////////////////////////////////////// + +RAMObserverThread::RAMObserverThread(void) +{ + m_terminated = false; +} + +RAMObserverThread::~RAMObserverThread(void) +{ +} + +//////////////////////////////////////////////////////////// +// Protected functions +//////////////////////////////////////////////////////////// + +void RAMObserverThread::run(void) +{ + qDebug("RAM observer started!"); + m_terminated = false; + + 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 RAMObserverThread::observe(void) +{ + MEMORYSTATUSEX memoryStatus; + double previous = -1.0; + + while(!m_terminated) + { + memset(&memoryStatus, 0, sizeof(MEMORYSTATUSEX)); + memoryStatus.dwLength = sizeof(MEMORYSTATUSEX); + + if(GlobalMemoryStatusEx(&memoryStatus)) + { + double current = static_cast(memoryStatus.dwMemoryLoad) / 100.0; + if(current != previous) + { + emit currentUsageChanged(current); + previous = current; + } + } + msleep(1000); + } +} + +//////////////////////////////////////////////////////////// +// SLOTS +//////////////////////////////////////////////////////////// + +/*NONE*/ + +//////////////////////////////////////////////////////////// +// EVENTS +//////////////////////////////////////////////////////////// + +/*NONE*/ diff --git a/src/Thread_RAMObserver.h b/src/Thread_RAMObserver.h new file mode 100644 index 00000000..06585f24 --- /dev/null +++ b/src/Thread_RAMObserver.h @@ -0,0 +1,45 @@ +/////////////////////////////////////////////////////////////////////////////// +// LameXP - Audio Encoder Front-End +// Copyright (C) 2004-2011 LoRd_MuldeR +// +// 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 + +class RAMObserverThread: public QThread +{ + Q_OBJECT + +public: + RAMObserverThread(void); + ~RAMObserverThread(void); + + void stop(void) { m_terminated = true; } + +protected: + void run(void); + void observe(void); + +signals: + void currentUsageChanged(const double usage); + +private: + volatile bool m_terminated; +}; -- 2.11.0