diff --git a/src/core/core.vcxproj b/src/core/core.vcxproj
index 11b202b7b..593b482d9 100755
--- a/src/core/core.vcxproj
+++ b/src/core/core.vcxproj
@@ -101,7 +101,7 @@
-
+
@@ -145,7 +145,7 @@
-
+
diff --git a/src/core/core.vcxproj.filters b/src/core/core.vcxproj.filters
index b3d8c4edd..a93fa14c6 100755
--- a/src/core/core.vcxproj.filters
+++ b/src/core/core.vcxproj.filters
@@ -124,9 +124,6 @@
src\library
-
- src\library\track
-
src\library\track
@@ -157,6 +154,9 @@
src
+
+ src\library\track
+
@@ -273,9 +273,6 @@
src\library
-
- src\library\track
-
src\library\track
@@ -321,5 +318,8 @@
src
+
+ src\library\track
+
\ No newline at end of file
diff --git a/src/core/library/Indexer.cpp b/src/core/library/Indexer.cpp
index 2c188e6b6..02112424d 100644
--- a/src/core/library/Indexer.cpp
+++ b/src/core/library/Indexer.cpp
@@ -386,7 +386,7 @@ void Indexer::SyncDirectory(
stmt.BindInt(2, parentDirId);
stmt.BindText(3, relativePath);
- if (!stmt.Step() == db::Done) {
+ if (stmt.Step() != db::Done) {
return; /* ugh, failed? */
}
@@ -822,8 +822,6 @@ void Indexer::SyncOptimize() {
}
}
}
-
-
}
//////////////////////////////////////////
@@ -978,7 +976,7 @@ void Indexer::RunAnalyzers() {
}
}
- if(this->Exited() || this->Restarted()){
+ if (this->Exited() || this->Restarted()){
return;
}
diff --git a/src/core/library/Indexer.h b/src/core/library/Indexer.h
index 7bc83902d..711f91708 100644
--- a/src/core/library/Indexer.h
+++ b/src/core/library/Indexer.h
@@ -113,7 +113,7 @@ namespace musik { namespace core {
std::string path;
};
- typedef std::vector > MetadataReaderList;
+ typedef std::vector> MetadataReaderList;
std::deque addRemoveQueue;
diff --git a/src/core/library/track/GenericTrack.cpp b/src/core/library/track/InMemoryTrack.cpp
similarity index 80%
rename from src/core/library/track/GenericTrack.cpp
rename to src/core/library/track/InMemoryTrack.cpp
index 6564deb92..16118982b 100644
--- a/src/core/library/track/GenericTrack.cpp
+++ b/src/core/library/track/InMemoryTrack.cpp
@@ -36,32 +36,32 @@
#include "pch.hpp"
-#include
+#include
#include
using namespace musik::core;
-TrackPtr GenericTrack::Create(const char *uri) {
- GenericTrack *newTrack = new GenericTrack(uri);
+TrackPtr InMemoryTrack::Create(const char *uri) {
+ InMemoryTrack *newTrack = new InMemoryTrack(uri);
TrackPtr track(newTrack);
newTrack->selfPtr = track; /* used to make another shared_ptr */
NonLibraryTrackHelper::Instance().ReadTrack(track);
return track;
}
-GenericTrack::GenericTrack() {
+InMemoryTrack::InMemoryTrack() {
}
-GenericTrack::GenericTrack(const char *uri) {
+InMemoryTrack::InMemoryTrack(const char *uri) {
if (uri) {
this->uri = uri;
}
}
-GenericTrack::~GenericTrack() {
+InMemoryTrack::~InMemoryTrack() {
}
-std::string GenericTrack::GetValue(const char* metakey) {
+std::string InMemoryTrack::GetValue(const char* metakey) {
if (metakey) {
std::string metaKey(metakey);
@@ -99,44 +99,44 @@ std::string GenericTrack::GetValue(const char* metakey) {
return "";
}
-void GenericTrack::SetValue(const char* metakey, const char* value){
+void InMemoryTrack::SetValue(const char* metakey, const char* value){
if (metakey && value) {
boost::mutex::scoped_lock lock(this->metadataMutex);
this->metadata.insert(std::pair(metakey,value));
}
}
-void GenericTrack::ClearValue(const char* metakey) {
+void InMemoryTrack::ClearValue(const char* metakey) {
boost::mutex::scoped_lock lock(this->metadataMutex);
this->metadata.erase(metakey);
}
-void GenericTrack::SetThumbnail(const char *data,long size) {
+void InMemoryTrack::SetThumbnail(const char *data,long size) {
}
-std::string GenericTrack::URI() {
+std::string InMemoryTrack::URI() {
return this->uri;
}
-std::string GenericTrack::URL() {
+std::string InMemoryTrack::URL() {
return this->uri;
}
-Track::MetadataIteratorRange GenericTrack::GetValues(const char* metakey) {
+Track::MetadataIteratorRange InMemoryTrack::GetValues(const char* metakey) {
boost::mutex::scoped_lock lock(this->metadataMutex);
return this->metadata.equal_range(metakey);
}
-Track::MetadataIteratorRange GenericTrack::GetAllValues() {
+Track::MetadataIteratorRange InMemoryTrack::GetAllValues() {
return Track::MetadataIteratorRange(this->metadata.begin(),this->metadata.end());
}
-TrackPtr GenericTrack::Copy() {
+TrackPtr InMemoryTrack::Copy() {
TrackPtr trackCopy;
if (trackCopy = this->selfPtr.lock()) {
return trackCopy;
}
- return GenericTrack::Create(this->uri.c_str());
+ return InMemoryTrack::Create(this->uri.c_str());
}
diff --git a/src/core/library/track/GenericTrack.h b/src/core/library/track/InMemoryTrack.h
similarity index 90%
rename from src/core/library/track/GenericTrack.h
rename to src/core/library/track/InMemoryTrack.h
index b5b29f7f7..bfd7a3199 100644
--- a/src/core/library/track/GenericTrack.h
+++ b/src/core/library/track/InMemoryTrack.h
@@ -46,18 +46,18 @@ namespace musik { namespace core {
//////////////////////////////////////////
///\brief
- ///A GenericTrack is not related to any library. It must contain a URI
+ ///A InMemoryTrack is not related to any library. It must contain a URI
//////////////////////////////////////////
- class GenericTrack : public Track {
+ class InMemoryTrack : public Track {
public:
static TrackPtr Create(const char *uri);
protected:
- GenericTrack();
- GenericTrack(const char *uri);
+ InMemoryTrack();
+ InMemoryTrack(const char *uri);
public:
- virtual ~GenericTrack();
+ virtual ~InMemoryTrack();
virtual std::string GetValue(const char* metakey);
virtual void SetValue(const char* metakey,const char* value);
diff --git a/src/core/library/track/TrackFactory.cpp b/src/core/library/track/TrackFactory.cpp
index 717618411..c6542cf51 100644
--- a/src/core/library/track/TrackFactory.cpp
+++ b/src/core/library/track/TrackFactory.cpp
@@ -37,7 +37,7 @@
#include "pch.hpp"
#include
#include
-#include
+#include
#include
#include
@@ -54,7 +54,7 @@ TrackPtr TrackFactory::CreateTrack(const std::string& uri) {
}
}
- return GenericTrack::Create(uri.c_str());
+ return InMemoryTrack::Create(uri.c_str());
}
diff --git a/src/core/playback/Transport.cpp b/src/core/playback/Transport.cpp
index 5af914e82..506c7a9bc 100644
--- a/src/core/playback/Transport.cpp
+++ b/src/core/playback/Transport.cpp
@@ -149,9 +149,10 @@ double Transport::Volume(){
}
void Transport::SetVolume(double volume){
- musik::debug::info("transport", boost::str(boost::format("set volume %d%%") % (volume * 100)));
+ musik::debug::info(TAG, boost::str(boost::format("set volume %d%%") % round(volume * 100)));
- this->volume = volume;
+ volume = max(0, min(1.0, volume));
+ this->volume = volume;
if(this->currentPlayer){
for(PlayerList::iterator player=this->players.begin();player!=this->players.end();++player){
(*player)->SetVolume(volume);
diff --git a/src/square/BorderedWindow.cpp b/src/square/BorderedWindow.cpp
index 13bd298ad..4e7a4797b 100755
--- a/src/square/BorderedWindow.cpp
+++ b/src/square/BorderedWindow.cpp
@@ -9,7 +9,8 @@ BorderedWindow::BorderedWindow() {
this->width = 0;
this->x = 0;
this->y = 0;
- this->color = -1;
+ this->contentColor = -1;
+ this->borderColor = -1;
this->scrollable = false;
}
@@ -51,8 +52,22 @@ int BorderedWindow::GetY() const {
return this->y;
}
-void BorderedWindow::SetColor(int color) {
- this->color = color;
+void BorderedWindow::SetContentColor(int color) {
+ this->contentColor = color;
+
+ if (this->contentColor != -1 && this->contents) {
+ wbkgd(this->contents, COLOR_PAIR(this->contentColor));
+ this->Repaint();
+ }
+}
+
+void BorderedWindow::SetBorderColor(int color) {
+ this->borderColor = color;
+
+ if (this->borderColor != -1 && this->border) {
+ wbkgd(this->border, COLOR_PAIR(this->borderColor));
+ this->Repaint();
+ }
}
void BorderedWindow::SetScrollable(bool scrollable) {
@@ -83,8 +98,12 @@ void BorderedWindow::Create() {
scrollok(this->contents, this->scrollable);
- if (this->color != -1) {
- wbkgd(this->contents, COLOR_PAIR(this->color));
+ if (this->contentColor != -1) {
+ wbkgd(this->contents, COLOR_PAIR(this->contentColor));
+ }
+
+ if (this->borderColor != -1) {
+ wbkgd(this->border, COLOR_PAIR(this->borderColor));
}
touchwin(this->contents);
diff --git a/src/square/BorderedWindow.h b/src/square/BorderedWindow.h
index 01f6cc7bf..f0786996d 100755
--- a/src/square/BorderedWindow.h
+++ b/src/square/BorderedWindow.h
@@ -1,6 +1,6 @@
#pragma once
-#include
+#include "curses_config.h"
class BorderedWindow {
public:
@@ -11,11 +11,14 @@ class BorderedWindow {
void Destroy();
virtual void Repaint();
+ virtual void SetContentColor(int color);
+ virtual void SetBorderColor(int color);
+
protected:
WINDOW* GetContents() const;
void SetSize(int width, int height);
void SetPosition(int x, int y);
- void SetColor(int color);
+
void SetScrollable(bool scrollable);
void Clear();
int GetWidth() const;
@@ -29,6 +32,6 @@ class BorderedWindow {
private:
WINDOW* border;
WINDOW* contents;
- int width, height, x, y, color;
+ int width, height, x, y, contentColor, borderColor;
bool scrollable;
};
\ No newline at end of file
diff --git a/src/square/Colors.cpp b/src/square/Colors.cpp
index 5b13bcc50..e7abe1119 100755
--- a/src/square/Colors.cpp
+++ b/src/square/Colors.cpp
@@ -2,7 +2,6 @@
#include "stdafx.h"
#include "Colors.h"
-#include
Colors::Colors() {
}
@@ -13,4 +12,7 @@ void Colors::Init() {
init_pair(BOX_COLOR_YELLOW_ON_BLUE, COLOR_YELLOW, COLOR_BLUE);
init_pair(BOX_COLOR_BLACK_ON_GREY, COLOR_BLACK, COLOR_WHITE);
init_pair(BOX_COLOR_BLACK_ON_GREEN, COLOR_BLACK, COLOR_GREEN);
+ init_pair(BOX_COLOR_YELLOW_ON_BLACK, COLOR_YELLOW, COLOR_BLACK);
+ init_pair(BOX_COLOR_WHITE_ON_BLACK, COLOR_WHITE, COLOR_BLACK);
}
+
diff --git a/src/square/Colors.h b/src/square/Colors.h
index 036f4d525..f5b9c69a4 100755
--- a/src/square/Colors.h
+++ b/src/square/Colors.h
@@ -1,12 +1,14 @@
#pragma once
-#include "stdafx.h"
+#include "curses_config.h"
#define BOX_COLOR_WHITE_ON_BLUE 1
#define BOX_COLOR_RED_ON_BLUE 2
#define BOX_COLOR_YELLOW_ON_BLUE 3
#define BOX_COLOR_BLACK_ON_GREY 4
#define BOX_COLOR_BLACK_ON_GREEN 5
+#define BOX_COLOR_YELLOW_ON_BLACK 6
+#define BOX_COLOR_WHITE_ON_BLACK 7
class Colors {
private:
diff --git a/src/square/CommandWindow.h b/src/square/CommandWindow.h
index 02757b836..736f6fa99 100755
--- a/src/square/CommandWindow.h
+++ b/src/square/CommandWindow.h
@@ -1,6 +1,6 @@
#pragma once
-#include "stdafx.h"
+#include "curses_config.h"
#include "BorderedWindow.h"
#include "OutputWindow.h"
#include
diff --git a/src/square/IScrollAdapter.h b/src/square/IScrollAdapter.h
index e43543a53..2ae4f56c0 100755
--- a/src/square/IScrollAdapter.h
+++ b/src/square/IScrollAdapter.h
@@ -1,7 +1,6 @@
#pragma once
#include "stdafx.h"
-#include
class IScrollAdapter {
public:
@@ -10,3 +9,4 @@ class IScrollAdapter {
virtual size_t GetEntryCount() = 0;
virtual void DrawPage(WINDOW* window, size_t index) = 0;
};
+
diff --git a/src/square/LogWindow.cpp b/src/square/LogWindow.cpp
index f9fc730ad..7dced1da2 100755
--- a/src/square/LogWindow.cpp
+++ b/src/square/LogWindow.cpp
@@ -7,8 +7,8 @@
#include
LogWindow::LogWindow() {
- this->SetColor(BOX_COLOR_WHITE_ON_BLUE);
- this->SetSize(Screen::GetWidth() / 2, Screen::GetHeight());
+ this->SetContentColor(BOX_COLOR_WHITE_ON_BLUE);
+ this->SetSize(Screen::GetWidth() / 2, Screen::GetHeight() - 3);
this->SetPosition(Screen::GetWidth() / 2, 0);
this->adapter = new SimpleScrollAdapter();
diff --git a/src/square/Main.cpp b/src/square/Main.cpp
index 0dccb4c1b..e7f8e757e 100644
--- a/src/square/Main.cpp
+++ b/src/square/Main.cpp
@@ -38,8 +38,7 @@
#include "CommandWindow.h"
#include "OutputWindow.h"
#include "TransportWindow.h"
-
-#include
+#include "ResourcesWindow.h"
#include
#include
@@ -82,7 +81,7 @@ int main(int argc, char* argv[])
curs_set(0);
#ifdef __PDCURSES__
- PDC_set_title("♫ rect");
+ PDC_set_title("musikbox ♫");
#endif
{
@@ -92,6 +91,7 @@ int main(int argc, char* argv[])
Colors::Init();
LogWindow logs;
OutputWindow output;
+ ResourcesWindow resources;
CommandWindow command(tp, output);
TransportWindow transport(tp);
@@ -99,21 +99,28 @@ int main(int argc, char* argv[])
order.push_back(&logs);
order.push_back(&output);
- int index = 0;
+ size_t index = 0;
ScrollableWindow *scrollable = order.at(index);
+ scrollable->SetBorderColor(BOX_COLOR_YELLOW_ON_BLACK);
int ch;
timeout(500);
while (ch = getch()) {
if (ch == -1) { /* timeout */
logs.Update();
+ transport.Repaint();
+ resources.Repaint();
}
else if (ch == 9) { /* tab */
+ scrollable->SetBorderColor(BOX_COLOR_WHITE_ON_BLACK);
+
index++;
if (index >= order.size()) {
index = 0;
}
+
scrollable = order.at(index);
+ scrollable->SetBorderColor(BOX_COLOR_YELLOW_ON_BLACK);
}
else if (ch >= KEY_F(0) && ch <= KEY_F(12)) {
}
@@ -132,8 +139,6 @@ int main(int argc, char* argv[])
else {
command.WriteChar(ch);
}
-
- transport.Repaint();
}
}
diff --git a/src/square/OutputWindow.cpp b/src/square/OutputWindow.cpp
index a127c0878..069dc6fab 100755
--- a/src/square/OutputWindow.cpp
+++ b/src/square/OutputWindow.cpp
@@ -10,7 +10,7 @@ OutputWindow::OutputWindow()
{
this->SetSize(Screen::GetWidth() / 2, Screen::GetHeight() - 3 - 4);
this->SetPosition(0, 4);
- this->SetColor(BOX_COLOR_BLACK_ON_GREY);
+ this->SetContentColor(BOX_COLOR_BLACK_ON_GREY);
this->adapter = new SimpleScrollAdapter();
this->adapter->SetDisplaySize(this->GetContentWidth(), this->GetContentHeight());
diff --git a/src/square/OutputWindow.h b/src/square/OutputWindow.h
index af79004bc..c84b68ae9 100755
--- a/src/square/OutputWindow.h
+++ b/src/square/OutputWindow.h
@@ -1,6 +1,6 @@
#pragma once
-#include "stdafx.h"
+#include "curses_config.h"
#include "ScrollableWindow.h"
#include "SimpleScrollAdapter.h"
diff --git a/src/square/ResourcesWindow.cpp b/src/square/ResourcesWindow.cpp
new file mode 100755
index 000000000..ba72a0ba2
--- /dev/null
+++ b/src/square/ResourcesWindow.cpp
@@ -0,0 +1,44 @@
+#pragma once
+
+#include "stdafx.h"
+#include "ResourcesWindow.h"
+#include "Screen.h"
+#include "Colors.h"
+
+#include
+#include
+
+
+ResourcesWindow::ResourcesWindow() {
+
+ this->SetSize(Screen::GetWidth() / 2, 3);
+
+ this->SetPosition(
+ Screen::GetWidth() / 2,
+ Screen::GetHeight() - this->GetHeight());
+
+ this->systemInfo = SystemInfo::Create();
+ this->Create();
+}
+
+ResourcesWindow::~ResourcesWindow() {
+ delete this->systemInfo;
+}
+
+#define BYTES_PER_MEGABYTE 1048576.0f
+
+void ResourcesWindow::Repaint() {
+ this->Clear();
+
+ float virtualMemoryUsed = (float) systemInfo->GetUsedVirtualMemory() / BYTES_PER_MEGABYTE;
+ float physicalMemoryUsed = (float) systemInfo->GetUsedPhysicalMemory() / BYTES_PER_MEGABYTE;
+
+ wprintw(
+ this->GetContents(),
+ "cpu %.2f%% - virt %.2f (mb) - phys %.2f (mb)",
+ systemInfo->GetCpuUsage(),
+ virtualMemoryUsed,
+ physicalMemoryUsed);
+
+ BorderedWindow::Repaint();
+}
\ No newline at end of file
diff --git a/src/square/ResourcesWindow.h b/src/square/ResourcesWindow.h
new file mode 100755
index 000000000..503db284e
--- /dev/null
+++ b/src/square/ResourcesWindow.h
@@ -0,0 +1,17 @@
+#pragma once
+
+#include "curses_config.h"
+#include "BorderedWindow.h"
+#include "SystemInfo.h"
+
+class ResourcesWindow : public BorderedWindow {
+ public:
+ ResourcesWindow();
+ virtual ~ResourcesWindow();
+
+ virtual void Repaint();
+
+ private:
+
+ SystemInfo* systemInfo;
+};
\ No newline at end of file
diff --git a/src/square/Screen.cpp b/src/square/Screen.cpp
index f5a69c5c5..11eae9e9d 100755
--- a/src/square/Screen.cpp
+++ b/src/square/Screen.cpp
@@ -2,7 +2,6 @@
#include "stdafx.h"
#include "Screen.h"
-#include
Screen::Screen() {
}
diff --git a/src/square/Screen.h b/src/square/Screen.h
index d9fb29270..2a8f519bb 100755
--- a/src/square/Screen.h
+++ b/src/square/Screen.h
@@ -1,6 +1,6 @@
#pragma once
-#include "stdafx.h"
+#include "curses_config.h"
class Screen {
private:
diff --git a/src/square/ScrollableWindow.cpp b/src/square/ScrollableWindow.cpp
index 9d41a8e6a..7a8dc495c 100755
--- a/src/square/ScrollableWindow.cpp
+++ b/src/square/ScrollableWindow.cpp
@@ -32,7 +32,7 @@ size_t ScrollableWindow::GetFirstVisible() {
}
size_t ScrollableWindow::GetLastVisible() {
- int total = GetScrollAdapter().GetLineCount(this->GetContentWidth());
+ size_t total = GetScrollAdapter().GetLineCount(this->GetContentWidth());
return min(scrollPosition + this->GetContentHeight(), total);
}
diff --git a/src/square/ScrollableWindow.h b/src/square/ScrollableWindow.h
index 83d20bb44..4c8befe87 100755
--- a/src/square/ScrollableWindow.h
+++ b/src/square/ScrollableWindow.h
@@ -1,6 +1,6 @@
#pragma once
-#include "stdafx.h"
+#include "curses_config.h"
#include "BorderedWindow.h"
#include "IScrollAdapter.h"
diff --git a/src/square/SimpleScrollAdapter.cpp b/src/square/SimpleScrollAdapter.cpp
index c616b269a..60a5fe30e 100755
--- a/src/square/SimpleScrollAdapter.cpp
+++ b/src/square/SimpleScrollAdapter.cpp
@@ -81,7 +81,7 @@ void SimpleScrollAdapter::AddLine(const std::string& str, int64 attrs) {
this->lineCount += entry->GetLineCount();
}
-size_t SimpleScrollAdapter::FindEntryIndex(int lineNumber) {
+size_t SimpleScrollAdapter::FindEntryIndex(size_t lineNumber) {
if (lineCount == -1) {
Reindex();
}
@@ -190,7 +190,7 @@ inline static void breakIntoSubLines(
std::vector sanitizedWords;
for (size_t i = 0; i < words.size(); i++) {
std::string word = words.at(i);
- int len = std::distance(word.begin(), word.end());
+ size_t len = std::distance(word.begin(), word.end());
/* this word is fine, it'll easily fit on its own line of necessary */
diff --git a/src/square/SimpleScrollAdapter.h b/src/square/SimpleScrollAdapter.h
index a69be8419..26c562701 100755
--- a/src/square/SimpleScrollAdapter.h
+++ b/src/square/SimpleScrollAdapter.h
@@ -1,7 +1,6 @@
#pragma once
-#include "stdafx.h"
-
+#include "curses_config.h"
#include "IScrollAdapter.h";
class SimpleScrollAdapter : public IScrollAdapter {
@@ -44,8 +43,8 @@ class SimpleScrollAdapter : public IScrollAdapter {
void Reindex();
- size_t FindEntryIndex(int index);
+ size_t FindEntryIndex(size_t index);
EntryList entries;
size_t lineCount, width, height;
-};
\ No newline at end of file
+};
diff --git a/src/square/SystemInfo.cpp b/src/square/SystemInfo.cpp
new file mode 100755
index 000000000..9c005855b
--- /dev/null
+++ b/src/square/SystemInfo.cpp
@@ -0,0 +1,147 @@
+#include "stdafx.h"
+
+#include "SystemInfo.h"
+
+#include "windows.h"
+#include "psapi.h"
+#include "pdh.h"
+
+#ifdef WIN32
+class WindowsSystemInfo : public SystemInfo {
+ public:
+ WindowsSystemInfo();
+ virtual ~WindowsSystemInfo();
+
+ virtual int64 GetTotalVirtualMemory();
+ virtual int64 GetUsedVirtualMemory();
+ virtual int64 GetTotalPhysicalMemory();
+ virtual int64 GetUsedPhysicalMemory();
+ virtual double GetCpuUsage();
+
+ private:
+ ULARGE_INTEGER lastCpu, lastSysCpu, lastUserCpu;
+ int processorCount;
+ HANDLE self;
+ PDH_HQUERY cpuQuery;
+ PDH_HCOUNTER cpuTotal;
+};
+#endif
+
+SystemInfo* SystemInfo::Create() {
+#ifdef WIN32
+ return new WindowsSystemInfo();
+#else
+ return new SystemInfo();
+#endif
+}
+
+SystemInfo::SystemInfo() {
+
+}
+
+SystemInfo::~SystemInfo() {
+
+}
+
+int64 SystemInfo::GetTotalVirtualMemory() {
+ return 0;
+}
+
+int64 SystemInfo::GetUsedVirtualMemory() {
+ return 0;
+}
+
+int64 SystemInfo::GetTotalPhysicalMemory() {
+ return 0;
+}
+
+int64 SystemInfo::GetUsedPhysicalMemory() {
+ return 0;
+}
+
+double SystemInfo::GetCpuUsage() {
+ return 0;
+}
+
+
+#ifdef WIN32
+
+#define GET_MEMORY_STATUS \
+ MEMORYSTATUSEX memInfo; \
+ memInfo.dwLength = sizeof(MEMORYSTATUSEX); \
+ GlobalMemoryStatusEx(&memInfo); \
+
+#define GET_PROCESS_MEMORY_COUNTERS \
+ PROCESS_MEMORY_COUNTERS_EX pmc; \
+ GetProcessMemoryInfo(GetCurrentProcess(), (PROCESS_MEMORY_COUNTERS*)&pmc, sizeof(pmc)); \
+
+WindowsSystemInfo::WindowsSystemInfo() {
+ PdhOpenQuery(NULL, NULL, &cpuQuery);
+ PdhAddCounter(cpuQuery, "\\Processor(_Total)\\% Processor Time", NULL, &cpuTotal);
+ PdhCollectQueryData(cpuQuery);
+
+ SYSTEM_INFO sysInfo;
+ FILETIME ftime, fsys, fuser;
+
+ GetSystemInfo(&sysInfo);
+ processorCount = sysInfo.dwNumberOfProcessors;
+
+ GetSystemTimeAsFileTime(&ftime);
+ memcpy(&lastCpu, &ftime, sizeof(FILETIME));
+
+ self = GetCurrentProcess();
+ GetProcessTimes(self, &ftime, &ftime, &fsys, &fuser);
+ memcpy(&lastSysCpu, &fsys, sizeof(FILETIME));
+ memcpy(&lastUserCpu, &fuser, sizeof(FILETIME));
+}
+
+WindowsSystemInfo::~WindowsSystemInfo() {
+ PdhCloseQuery(cpuQuery);
+}
+
+int64 WindowsSystemInfo::GetTotalVirtualMemory() {
+ GET_MEMORY_STATUS
+ return memInfo.ullTotalPageFile;
+}
+
+int64 WindowsSystemInfo::GetUsedVirtualMemory() {
+ GET_PROCESS_MEMORY_COUNTERS
+ return pmc.PrivateUsage;
+}
+
+int64 WindowsSystemInfo::GetTotalPhysicalMemory() {
+ GET_MEMORY_STATUS
+ return memInfo.ullTotalPhys;
+}
+
+int64 WindowsSystemInfo::GetUsedPhysicalMemory() {
+ GET_PROCESS_MEMORY_COUNTERS
+ return pmc.WorkingSetSize;
+}
+
+double WindowsSystemInfo::GetCpuUsage() {
+ FILETIME ftime, fsys, fuser;
+ ULARGE_INTEGER now, sys, user;
+ double percent;
+
+ GetSystemTimeAsFileTime(&ftime);
+ memcpy(&now, &ftime, sizeof(FILETIME));
+
+ GetProcessTimes(self, &ftime, &ftime, &fsys, &fuser);
+ memcpy(&sys, &fsys, sizeof(FILETIME));
+ memcpy(&user, &fuser, sizeof(FILETIME));
+
+ percent =
+ (double) (sys.QuadPart - lastSysCpu.QuadPart) +
+ (double) (user.QuadPart - lastUserCpu.QuadPart);
+
+ percent /= (now.QuadPart - lastCpu.QuadPart);
+ percent /= processorCount;
+
+ lastCpu = now;
+ lastUserCpu = user;
+ lastSysCpu = sys;
+
+ return percent * 100;
+}
+#endif
\ No newline at end of file
diff --git a/src/square/SystemInfo.h b/src/square/SystemInfo.h
new file mode 100755
index 000000000..9c1cfc19f
--- /dev/null
+++ b/src/square/SystemInfo.h
@@ -0,0 +1,18 @@
+#include "stdafx.h"
+
+class SystemInfo {
+ public:
+ static SystemInfo* Create();
+
+ virtual ~SystemInfo();
+
+ protected:
+ SystemInfo();
+
+ public:
+ virtual int64 GetTotalVirtualMemory();
+ virtual int64 GetUsedVirtualMemory();
+ virtual int64 GetTotalPhysicalMemory();
+ virtual int64 GetUsedPhysicalMemory();
+ virtual double GetCpuUsage();
+};
\ No newline at end of file
diff --git a/src/square/TransportEvents.cpp b/src/square/TransportEvents.cpp
index 94d0a286c..ca9d54ea2 100644
--- a/src/square/TransportEvents.cpp
+++ b/src/square/TransportEvents.cpp
@@ -33,7 +33,6 @@
#include "stdafx.h"
#include "TransportEvents.h"
-
#include
using namespace musik::square;
diff --git a/src/square/TransportEvents.h b/src/square/TransportEvents.h
index b02118620..f72dbcc57 100644
--- a/src/square/TransportEvents.h
+++ b/src/square/TransportEvents.h
@@ -34,7 +34,6 @@
#pragma once
#include "stdafx.h"
-#include "config.h"
#include
#include
diff --git a/src/square/TransportWindow.cpp b/src/square/TransportWindow.cpp
index 70cb75007..e67954891 100755
--- a/src/square/TransportWindow.cpp
+++ b/src/square/TransportWindow.cpp
@@ -24,7 +24,7 @@ using musik::core::audio::Transport;
TransportWindow::TransportWindow(Transport& transport) {
this->SetSize(Screen::GetWidth() / 2, 4);
this->SetPosition(0, 0);
- this->SetColor(BOX_COLOR_BLACK_ON_GREEN);
+ this->SetContentColor(BOX_COLOR_BLACK_ON_GREEN);
this->transport = &transport;
this->paused = false;
this->Create();
@@ -37,10 +37,10 @@ void TransportWindow::Repaint() {
this->Clear();
WINDOW *c = this->GetContents();
- std::string volume = boost::str(boost::format(
- "volume: %1%\n") % this->transport->Volume());
+ int volume = (int) round(this->transport->Volume() * 100);
- wprintw(c, volume.c_str());
+ wprintw(c, "volume %d%%\n", volume);
wprintw(c, "filename: ");
+
BorderedWindow::Repaint();
}
\ No newline at end of file
diff --git a/src/square/TransportWindow.h b/src/square/TransportWindow.h
index b3a4fcf1a..5109e1cd4 100755
--- a/src/square/TransportWindow.h
+++ b/src/square/TransportWindow.h
@@ -1,6 +1,6 @@
#pragma once
-#include "stdafx.h"
+#include "curses_config.h"
#include "BorderedWindow.h"
#include "OutputWindow.h"
#include
diff --git a/src/square/Ui.h b/src/square/Ui.h
new file mode 100755
index 000000000..c5e8bdcd0
--- /dev/null
+++ b/src/square/Ui.h
@@ -0,0 +1,8 @@
+#pragma once
+
+#define PDC_WIDE
+#include
+
+#ifdef WIN32
+#undef MOUSE_MOVE
+#endif
\ No newline at end of file
diff --git a/src/square/config.h b/src/square/config.h
deleted file mode 100644
index 3fdef8881..000000000
--- a/src/square/config.h
+++ /dev/null
@@ -1,42 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// License Agreement:
-//
-// The following are Copyright © 2008, musikCube team
-//
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// * Redistributions of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistributions in binary form must reproduce the above copyright
-// notice, this list of conditions and the following disclaimer in the
-// documentation and/or other materials provided with the distribution.
-//
-// * Neither the name of the author nor the names of other contributors may
-// be used to endorse or promote products derived from this software
-// without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-// POSSIBILITY OF SUCH DAMAGE.
-//
-//////////////////////////////////////////////////////////////////////////////
-
-#ifndef SQUARE_CONFIG_H
-#define SQUARE_CONFIG_H
-
-#include
-
-#endif // SQUARE_CONFIG_H
diff --git a/src/square/curses_config.h b/src/square/curses_config.h
new file mode 100755
index 000000000..46f089e2d
--- /dev/null
+++ b/src/square/curses_config.h
@@ -0,0 +1,8 @@
+#pragma once
+
+#ifdef WIN32
+#define PDC_WIDE
+#undef MOUSE_MOVED
+#endif
+
+#include
diff --git a/src/square/player.vcxproj b/src/square/player.vcxproj
index 5a427f446..2da8dac32 100755
--- a/src/square/player.vcxproj
+++ b/src/square/player.vcxproj
@@ -11,7 +11,7 @@
- rect
+ musikbox
{C7102EB1-7311-4B36-A7FF-89DD7F077FF9}
square
Win32Proj
@@ -20,7 +20,7 @@
Application
- Unicode
+ MultiByte
true
v140
@@ -78,7 +78,8 @@
Windows
../../bin/$(Configuration)/mC2.lib
MachineX86
- pdcursesd.lib;%(AdditionalDependencies)
+ pdcursesd.lib;pdh.lib;psapi.lib;%(AdditionalDependencies)
+ false
copy "$(SolutionDir)\src\3rdparty\vld\*.*" "$(TargetDir)"
@@ -108,7 +109,8 @@
MachineX86
- pdcurses.lib;%(AdditionalDependencies)
+ pdcurses.lib;pdh.lib;psapi.lib;%(AdditionalDependencies)
+ true
@@ -118,9 +120,11 @@
+
+
@@ -132,13 +136,15 @@
-
+
+
+
diff --git a/src/square/player.vcxproj.filters b/src/square/player.vcxproj.filters
index fbe618a2f..6087c1bea 100755
--- a/src/square/player.vcxproj.filters
+++ b/src/square/player.vcxproj.filters
@@ -56,14 +56,17 @@
Source Files\curses
+
+ Source Files\windows
+
+
+ Source Files\windows
+
Source Files
-
- Source Files
-
Source Files
@@ -94,5 +97,14 @@
Source Files\curses
+
+ Source Files\curses
+
+
+ Source Files\windows
+
+
+ Source Files\windows
+
\ No newline at end of file
diff --git a/src/square/stdafx.h b/src/square/stdafx.h
index bfb5e84c3..64bca9382 100644
--- a/src/square/stdafx.h
+++ b/src/square/stdafx.h
@@ -1,13 +1,6 @@
#pragma once
-#ifdef WIN32
- #define WIN32_LEAN_AND_MEAN
- #include
- #include "config.h"
- #define PDC_WIDE
-#else
- #include
-#endif
-
-typedef __int64 int64;
+#include
+#include "curses_config.h"
+typedef __int64 int64;
\ No newline at end of file