From ca4e7068d1d6c78f5ad3c4fc3a1cca620acaef40 Mon Sep 17 00:00:00 2001 From: urioxis Date: Thu, 27 Jan 2011 16:51:14 +0000 Subject: [PATCH] Got musikSquare to compile and run :D. Now to make it do things... --- CMakeLists.txt | 2 +- src/square/ConsoleUI.cpp | 50 +++++++++++++++------------ src/square/ConsoleUI.h | 5 ++- src/square/DummyAudioEventHandler.cpp | 6 ++-- src/square/DummyAudioEventHandler.h | 26 +++++++------- src/square/config.h | 18 +++++----- src/square/player.cpp | 4 +++ src/square/stdafx.h | 8 ++++- 8 files changed, 70 insertions(+), 49 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 43879b59a..2675c9fd4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,5 +64,5 @@ add_subdirectory(src/3rdparty) add_subdirectory(src/core) add_subdirectory(src/contrib) #add_subdirectory(src/server) -#add_subdirectory(src/square) +add_subdirectory(src/square) #add_subdirectory(src/cube) diff --git a/src/square/ConsoleUI.cpp b/src/square/ConsoleUI.cpp index f3dea78b9..b38624892 100644 --- a/src/square/ConsoleUI.cpp +++ b/src/square/ConsoleUI.cpp @@ -42,9 +42,10 @@ #include #include -using namespace std; using namespace musik::square; +//enum audioEventHandler; + ConsoleUI::ConsoleUI() : shouldQuit(false) , audioEventHandler(this) @@ -55,10 +56,12 @@ ConsoleUI::ConsoleUI() // this->transport.EventPlaybackStoppedOk.connect(&audioEventHandler, &DummyAudioEventHandler::OnPlaybackStoppedOk); // this->transport.EventPlaybackStoppedFail.connect(&audioEventHandler, &DummyAudioEventHandler::OnPlaybackStoppedFail); - this->transport.EventVolumeChangedOk.connect(&audioEventHandler, &DummyAudioEventHandler::OnVolumeChangedOk); - this->transport.EventVolumeChangedFail.connect(&audioEventHandler, &DummyAudioEventHandler::OnVolumeChangedFail); + // this->transport.EventVolumeChangedOk.connect(&audioEventHandler, &DummyAudioEventHandler::OnVolumeChangedOk); + // this->transport.EventVolumeChangedFail.connect(&audioEventHandler, &DummyAudioEventHandler::OnVolumeChangedFail); - this->transport.EventMixpointReached.connect(&audioEventHandler, &DummyAudioEventHandler::OnMixpointReached); + // this->transport.EventMixpointReached.connect(&audioEventHandler, &DummyAudioEventHandler::OnMixpointReached); + + this->transport.PlaybackStarted.connect(&this->audioEventHandler, &DummyAudioEventHandler::OnPlaybackStartedOk); } ConsoleUI::~ConsoleUI() @@ -71,7 +74,7 @@ void ConsoleUI::Print(utfstring s) utfcout << "\n*******************************\n\n"; utfcout << s; - utfcout << "\n*******************************\n" << endl; + utfcout << "\n*******************************\n" << std::endl; } void ConsoleUI::Run() @@ -98,7 +101,7 @@ void ConsoleUI::PrintCommands() utfcout << "\tlp: list loaded plugins\n"; utfcout << "\tv

: set volume to p%\n"; utfcout << "\tq: quit"; - utfcout << endl; + utfcout << std::endl; } void ConsoleUI::ProcessCommand(utfstring commandString) @@ -109,30 +112,30 @@ void ConsoleUI::ProcessCommand(utfstring commandString) split(args, commandString, is_any_of(" ")); - utfstring command = args.size() > 0 ? args[0] : _T(""); + utfstring command = args.size() > 0 ? args[0] : UTF(""); args.erase(args.begin()); - if (command == _T("p")) + if (command == UTF("p")) { this->PlayFile(args); } - else if (command == _T("s")) + else if (command == UTF("s")) { this->Stop(args); } - else if (command == _T("l")) + /*else if (command == UTF("l")) { this->ListPlaying(); - } - else if (command == _T("lp")) + }*/ + else if (command == UTF("lp")) { this->ListPlugins(); } - else if (command == _T("v")) + else if (command == UTF("v")) { this->SetVolume(args); } - else if (command == _T("q")) + else if (command == UTF("q")) { this->Quit(); } @@ -151,7 +154,7 @@ void ConsoleUI::PlayFile(Args args) } else { - filename = _T("C:\\temp\\musik\\ding.mp3"); //TODO: remove. For quick testing only + filename = UTF("C:\\temp\\musik\\ding.mp3"); //TODO: remove. For quick testing only } int repeat = 1; @@ -174,7 +177,7 @@ void ConsoleUI::PlayFile(Args args) // transport.Start(filename.c_str()); //TODO: fix to use TrackPtr if (delay) { - Sleep(delay); + sleep(delay); } } } @@ -188,11 +191,12 @@ void ConsoleUI::Stop() { transport.Stop(); } - +/* void ConsoleUI::ListPlaying() { - AudioStreamOverview overview = transport.StreamsOverview(); + /*AudioStreamOverview overview = transport.StreamsOverview(); AudioStreamOverviewIterator it; + for (it = overview.begin(); it != overview.end(); ++it) { @@ -200,15 +204,15 @@ void ConsoleUI::ListPlaying() } utfcout << "------------------\n"; - utfcout << transport.NumOfStreams() << " playing" << endl; -} + utfcout << transport.NumOfStreams() << " playing" << std::std::endl; +}*/ void ConsoleUI::ListPlugins() { using musik::core::IPlugin; using musik::core::PluginFactory; - typedef std::vector> PluginList; + typedef std::vector > PluginList; typedef PluginFactory::NullDeleter Deleter; PluginList plugins = @@ -247,6 +251,7 @@ void ConsoleUI::ShutDown() { } +#ifdef WIN32 /*static*/ DWORD WINAPI ConsoleUI::ThreadRun(LPVOID param) { ConsoleUI* instance = (ConsoleUI*)param; @@ -254,9 +259,10 @@ void ConsoleUI::ShutDown() delete instance; return 0; } +#endif void ConsoleUI::StartNew() { Args a; this->PlayFile(a); -} \ No newline at end of file +} diff --git a/src/square/ConsoleUI.h b/src/square/ConsoleUI.h index 22a6fd50f..34f625c88 100644 --- a/src/square/ConsoleUI.h +++ b/src/square/ConsoleUI.h @@ -81,7 +81,10 @@ private: DummyAudioEventHandler audioEventHandler; private: boost::mutex mutex; private: void ShutDown(); + +#ifdef WIN32 public: static DWORD WINAPI ThreadRun(LPVOID param); +#endif public: void StartNew(); }; @@ -97,4 +100,4 @@ bool convertString(T& t, const utfstring& s) std::utfistringstream iss(s); return !(iss >> t).fail(); -} \ No newline at end of file +} diff --git a/src/square/DummyAudioEventHandler.cpp b/src/square/DummyAudioEventHandler.cpp index 98a12281a..d085b981c 100644 --- a/src/square/DummyAudioEventHandler.cpp +++ b/src/square/DummyAudioEventHandler.cpp @@ -50,11 +50,11 @@ DummyAudioEventHandler::~DummyAudioEventHandler() void DummyAudioEventHandler::PrintEvent(utfstring s) { - this->cui->Print(_T("EVENT: " + s + _T("\n"))); + this->cui->Print(UTF("EVENT: " + s + UTF("\n"))); } void DummyAudioEventHandler::OnMixpointReached() { - this->PrintEvent(_T("Mix point reached")); + this->PrintEvent(UTF("Mix point reached")); //this->cui->StartNew(); // Endless test loop -} \ No newline at end of file +} diff --git a/src/square/DummyAudioEventHandler.h b/src/square/DummyAudioEventHandler.h index ee8df868e..54f13e4dd 100644 --- a/src/square/DummyAudioEventHandler.h +++ b/src/square/DummyAudioEventHandler.h @@ -35,6 +35,8 @@ #include "stdafx.h" +#include "config.h" + #include #include @@ -43,7 +45,7 @@ namespace musik { namespace square { class ConsoleUI; -enum AudioStreamEvent; +//enum AudioStreamEvent; class DummyAudioEventHandler : public sigslot::has_slots<> { @@ -54,18 +56,18 @@ private: ConsoleUI* cui; // TODO: should probably be interface private: void PrintEvent(utfstring s); // Slots -public: void OnPlaybackStartedOk() { this->PrintEvent(_T("Playback started OK")); }; -public: void OnPlaybackStartedFail() { this->PrintEvent(_T("Playback started FAIL")); }; -public: void OnPlaybackStoppedOk() { this->PrintEvent(_T("Playback stopped OK")); }; -public: void OnPlaybackStoppedFail() { this->PrintEvent(_T("Playback stopped FAIL")); }; -public: void OnPlaybackInterrupted() { this->PrintEvent(_T("Playback interrupted")); }; -public: void OnVolumeChangedOk() { this->PrintEvent(_T("Volume changed OK")); }; -public: void OnVolumeChangedFail() { this->PrintEvent(_T("Volume changed FAIL")); }; -public: void OnStreamOpenOk() { this->PrintEvent(_T("Stream open OK")); }; -public: void OnStreamOpenFail() { this->PrintEvent(_T("Stream open FAIL")); }; +public: void OnPlaybackStartedOk() { this->PrintEvent(UTF("Playback started OK")); }; +public: void OnPlaybackStartedFail() { this->PrintEvent(UTF("Playback started FAIL")); }; +public: void OnPlaybackStoppedOk() { this->PrintEvent(UTF("Playback stopped OK")); }; +public: void OnPlaybackStoppedFail() { this->PrintEvent(UTF("Playback stopped FAIL")); }; +public: void OnPlaybackInterrupted() { this->PrintEvent(UTF("Playback interrupted")); }; +public: void OnVolumeChangedOk() { this->PrintEvent(UTF("Volume changed OK")); }; +public: void OnVolumeChangedFail() { this->PrintEvent(UTF("Volume changed FAIL")); }; +public: void OnStreamOpenOk() { this->PrintEvent(UTF("Stream open OK")); }; +public: void OnStreamOpenFail() { this->PrintEvent(UTF("Stream open FAIL")); }; public: void OnMixpointReached() ; -public: void OnSetPositionOk() { this->PrintEvent(_T("Set position OK")); }; -public: void OnSetPositionFail() { this->PrintEvent(_T("Set position FAIL")); }; +public: void OnSetPositionOk() { this->PrintEvent(UTF("Set position OK")); }; +public: void OnSetPositionFail() { this->PrintEvent(UTF("Set position FAIL")); }; }; }} // NS diff --git a/src/square/config.h b/src/square/config.h index 185cf9dea..d182792bf 100644 --- a/src/square/config.h +++ b/src/square/config.h @@ -44,19 +44,19 @@ namespace std { #if defined UNICODE || defined _UNICODE -# define utfcerr wcerr -# define utfcin wcin -# define utfclog wclog -# define utfcout wcout +# define utfcerr std::wcerr +# define utfcin std::wcin +# define utfclog std::wclog +# define utfcout std::wcout #else // defined UNICODE || defined _UNICODE -# define utfcerr cerr -# define utfcin cin -# define utfclog clog -# define utfcout cout +# define utfcerr std::cerr +# define utfcin std::cin +# define utfclog std::clog +# define utfcout std::cout #endif // defined UNICODE || defined _UNICODE } // namespace std -#endif // SQUARE_CONFIG_H \ No newline at end of file +#endif // SQUARE_CONFIG_H diff --git a/src/square/player.cpp b/src/square/player.cpp index 1ee9cf5a5..7ac7d6580 100644 --- a/src/square/player.cpp +++ b/src/square/player.cpp @@ -37,7 +37,11 @@ using namespace musik::square; +#ifdef WIN32 int _tmain(int argc, _TCHAR* argv[]) +#else +int main(int argc, char* argv[]) +#endif { ConsoleUI* instance = new ConsoleUI(); instance->Run(); diff --git a/src/square/stdafx.h b/src/square/stdafx.h index f3ad7f776..6dc66a84e 100644 --- a/src/square/stdafx.h +++ b/src/square/stdafx.h @@ -5,9 +5,15 @@ #pragma once +#ifdef WIN32 + #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #include #include -#include "config.h" \ No newline at end of file +#include "config.h" + +#else +#include +#endif