Got musikSquare to compile and run :D. Now to make it do things...

This commit is contained in:
urioxis 2011-01-27 16:51:14 +00:00
parent 66c63bc9ee
commit ca4e7068d1
8 changed files with 70 additions and 49 deletions

View File

@ -64,5 +64,5 @@ add_subdirectory(src/3rdparty)
add_subdirectory(src/core) add_subdirectory(src/core)
add_subdirectory(src/contrib) add_subdirectory(src/contrib)
#add_subdirectory(src/server) #add_subdirectory(src/server)
#add_subdirectory(src/square) add_subdirectory(src/square)
#add_subdirectory(src/cube) #add_subdirectory(src/cube)

View File

@ -42,9 +42,10 @@
#include <core/IPlugin.h> #include <core/IPlugin.h>
#include <core/PluginFactory.h> #include <core/PluginFactory.h>
using namespace std;
using namespace musik::square; using namespace musik::square;
//enum audioEventHandler;
ConsoleUI::ConsoleUI() ConsoleUI::ConsoleUI()
: shouldQuit(false) : shouldQuit(false)
, audioEventHandler(this) , audioEventHandler(this)
@ -55,10 +56,12 @@ ConsoleUI::ConsoleUI()
// this->transport.EventPlaybackStoppedOk.connect(&audioEventHandler, &DummyAudioEventHandler::OnPlaybackStoppedOk); // this->transport.EventPlaybackStoppedOk.connect(&audioEventHandler, &DummyAudioEventHandler::OnPlaybackStoppedOk);
// this->transport.EventPlaybackStoppedFail.connect(&audioEventHandler, &DummyAudioEventHandler::OnPlaybackStoppedFail); // this->transport.EventPlaybackStoppedFail.connect(&audioEventHandler, &DummyAudioEventHandler::OnPlaybackStoppedFail);
this->transport.EventVolumeChangedOk.connect(&audioEventHandler, &DummyAudioEventHandler::OnVolumeChangedOk); // this->transport.EventVolumeChangedOk.connect(&audioEventHandler, &DummyAudioEventHandler::OnVolumeChangedOk);
this->transport.EventVolumeChangedFail.connect(&audioEventHandler, &DummyAudioEventHandler::OnVolumeChangedFail); // 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() ConsoleUI::~ConsoleUI()
@ -71,7 +74,7 @@ void ConsoleUI::Print(utfstring s)
utfcout << "\n*******************************\n\n"; utfcout << "\n*******************************\n\n";
utfcout << s; utfcout << s;
utfcout << "\n*******************************\n" << endl; utfcout << "\n*******************************\n" << std::endl;
} }
void ConsoleUI::Run() void ConsoleUI::Run()
@ -98,7 +101,7 @@ void ConsoleUI::PrintCommands()
utfcout << "\tlp: list loaded plugins\n"; utfcout << "\tlp: list loaded plugins\n";
utfcout << "\tv <p>: set volume to p%\n"; utfcout << "\tv <p>: set volume to p%\n";
utfcout << "\tq: quit"; utfcout << "\tq: quit";
utfcout << endl; utfcout << std::endl;
} }
void ConsoleUI::ProcessCommand(utfstring commandString) void ConsoleUI::ProcessCommand(utfstring commandString)
@ -109,30 +112,30 @@ void ConsoleUI::ProcessCommand(utfstring commandString)
split(args, commandString, is_any_of(" ")); 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()); args.erase(args.begin());
if (command == _T("p")) if (command == UTF("p"))
{ {
this->PlayFile(args); this->PlayFile(args);
} }
else if (command == _T("s")) else if (command == UTF("s"))
{ {
this->Stop(args); this->Stop(args);
} }
else if (command == _T("l")) /*else if (command == UTF("l"))
{ {
this->ListPlaying(); this->ListPlaying();
} }*/
else if (command == _T("lp")) else if (command == UTF("lp"))
{ {
this->ListPlugins(); this->ListPlugins();
} }
else if (command == _T("v")) else if (command == UTF("v"))
{ {
this->SetVolume(args); this->SetVolume(args);
} }
else if (command == _T("q")) else if (command == UTF("q"))
{ {
this->Quit(); this->Quit();
} }
@ -151,7 +154,7 @@ void ConsoleUI::PlayFile(Args args)
} }
else 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; int repeat = 1;
@ -174,7 +177,7 @@ void ConsoleUI::PlayFile(Args args)
// transport.Start(filename.c_str()); //TODO: fix to use TrackPtr // transport.Start(filename.c_str()); //TODO: fix to use TrackPtr
if (delay) if (delay)
{ {
Sleep(delay); sleep(delay);
} }
} }
} }
@ -188,11 +191,12 @@ void ConsoleUI::Stop()
{ {
transport.Stop(); transport.Stop();
} }
/*
void ConsoleUI::ListPlaying() void ConsoleUI::ListPlaying()
{ {
AudioStreamOverview overview = transport.StreamsOverview(); /*AudioStreamOverview overview = transport.StreamsOverview();
AudioStreamOverviewIterator it; AudioStreamOverviewIterator it;
for (it = overview.begin(); it != overview.end(); ++it) for (it = overview.begin(); it != overview.end(); ++it)
{ {
@ -200,15 +204,15 @@ void ConsoleUI::ListPlaying()
} }
utfcout << "------------------\n"; utfcout << "------------------\n";
utfcout << transport.NumOfStreams() << " playing" << endl; utfcout << transport.NumOfStreams() << " playing" << std::std::endl;
} }*/
void ConsoleUI::ListPlugins() void ConsoleUI::ListPlugins()
{ {
using musik::core::IPlugin; using musik::core::IPlugin;
using musik::core::PluginFactory; using musik::core::PluginFactory;
typedef std::vector<boost::shared_ptr<IPlugin>> PluginList; typedef std::vector<boost::shared_ptr<IPlugin> > PluginList;
typedef PluginFactory::NullDeleter<IPlugin> Deleter; typedef PluginFactory::NullDeleter<IPlugin> Deleter;
PluginList plugins = PluginList plugins =
@ -247,6 +251,7 @@ void ConsoleUI::ShutDown()
{ {
} }
#ifdef WIN32
/*static*/ DWORD WINAPI ConsoleUI::ThreadRun(LPVOID param) /*static*/ DWORD WINAPI ConsoleUI::ThreadRun(LPVOID param)
{ {
ConsoleUI* instance = (ConsoleUI*)param; ConsoleUI* instance = (ConsoleUI*)param;
@ -254,9 +259,10 @@ void ConsoleUI::ShutDown()
delete instance; delete instance;
return 0; return 0;
} }
#endif
void ConsoleUI::StartNew() void ConsoleUI::StartNew()
{ {
Args a; Args a;
this->PlayFile(a); this->PlayFile(a);
} }

View File

@ -81,7 +81,10 @@ private: DummyAudioEventHandler audioEventHandler;
private: boost::mutex mutex; private: boost::mutex mutex;
private: void ShutDown(); private: void ShutDown();
#ifdef WIN32
public: static DWORD WINAPI ThreadRun(LPVOID param); public: static DWORD WINAPI ThreadRun(LPVOID param);
#endif
public: void StartNew(); public: void StartNew();
}; };
@ -97,4 +100,4 @@ bool convertString(T& t, const utfstring& s)
std::utfistringstream iss(s); std::utfistringstream iss(s);
return !(iss >> t).fail(); return !(iss >> t).fail();
} }

View File

@ -50,11 +50,11 @@ DummyAudioEventHandler::~DummyAudioEventHandler()
void DummyAudioEventHandler::PrintEvent(utfstring s) void DummyAudioEventHandler::PrintEvent(utfstring s)
{ {
this->cui->Print(_T("EVENT: " + s + _T("\n"))); this->cui->Print(UTF("EVENT: " + s + UTF("\n")));
} }
void DummyAudioEventHandler::OnMixpointReached() void DummyAudioEventHandler::OnMixpointReached()
{ {
this->PrintEvent(_T("Mix point reached")); this->PrintEvent(UTF("Mix point reached"));
//this->cui->StartNew(); // Endless test loop //this->cui->StartNew(); // Endless test loop
} }

View File

@ -35,6 +35,8 @@
#include "stdafx.h" #include "stdafx.h"
#include "config.h"
#include <vector> #include <vector>
#include <sigslot/sigslot.h> #include <sigslot/sigslot.h>
@ -43,7 +45,7 @@ namespace musik { namespace square {
class ConsoleUI; class ConsoleUI;
enum AudioStreamEvent; //enum AudioStreamEvent;
class DummyAudioEventHandler : public sigslot::has_slots<> class DummyAudioEventHandler : public sigslot::has_slots<>
{ {
@ -54,18 +56,18 @@ private: ConsoleUI* cui; // TODO: should probably be interface
private: void PrintEvent(utfstring s); private: void PrintEvent(utfstring s);
// Slots // Slots
public: void OnPlaybackStartedOk() { this->PrintEvent(_T("Playback started OK")); }; public: void OnPlaybackStartedOk() { this->PrintEvent(UTF("Playback started OK")); };
public: void OnPlaybackStartedFail() { this->PrintEvent(_T("Playback started FAIL")); }; public: void OnPlaybackStartedFail() { this->PrintEvent(UTF("Playback started FAIL")); };
public: void OnPlaybackStoppedOk() { this->PrintEvent(_T("Playback stopped OK")); }; public: void OnPlaybackStoppedOk() { this->PrintEvent(UTF("Playback stopped OK")); };
public: void OnPlaybackStoppedFail() { this->PrintEvent(_T("Playback stopped FAIL")); }; public: void OnPlaybackStoppedFail() { this->PrintEvent(UTF("Playback stopped FAIL")); };
public: void OnPlaybackInterrupted() { this->PrintEvent(_T("Playback interrupted")); }; public: void OnPlaybackInterrupted() { this->PrintEvent(UTF("Playback interrupted")); };
public: void OnVolumeChangedOk() { this->PrintEvent(_T("Volume changed OK")); }; public: void OnVolumeChangedOk() { this->PrintEvent(UTF("Volume changed OK")); };
public: void OnVolumeChangedFail() { this->PrintEvent(_T("Volume changed FAIL")); }; public: void OnVolumeChangedFail() { this->PrintEvent(UTF("Volume changed FAIL")); };
public: void OnStreamOpenOk() { this->PrintEvent(_T("Stream open OK")); }; public: void OnStreamOpenOk() { this->PrintEvent(UTF("Stream open OK")); };
public: void OnStreamOpenFail() { this->PrintEvent(_T("Stream open FAIL")); }; public: void OnStreamOpenFail() { this->PrintEvent(UTF("Stream open FAIL")); };
public: void OnMixpointReached() ; public: void OnMixpointReached() ;
public: void OnSetPositionOk() { this->PrintEvent(_T("Set position OK")); }; public: void OnSetPositionOk() { this->PrintEvent(UTF("Set position OK")); };
public: void OnSetPositionFail() { this->PrintEvent(_T("Set position FAIL")); }; public: void OnSetPositionFail() { this->PrintEvent(UTF("Set position FAIL")); };
}; };
}} // NS }} // NS

View File

@ -44,19 +44,19 @@
namespace std namespace std
{ {
#if defined UNICODE || defined _UNICODE #if defined UNICODE || defined _UNICODE
# define utfcerr wcerr # define utfcerr std::wcerr
# define utfcin wcin # define utfcin std::wcin
# define utfclog wclog # define utfclog std::wclog
# define utfcout wcout # define utfcout std::wcout
#else // defined UNICODE || defined _UNICODE #else // defined UNICODE || defined _UNICODE
# define utfcerr cerr # define utfcerr std::cerr
# define utfcin cin # define utfcin std::cin
# define utfclog clog # define utfclog std::clog
# define utfcout cout # define utfcout std::cout
#endif // defined UNICODE || defined _UNICODE #endif // defined UNICODE || defined _UNICODE
} // namespace std } // namespace std
#endif // SQUARE_CONFIG_H #endif // SQUARE_CONFIG_H

View File

@ -37,7 +37,11 @@
using namespace musik::square; using namespace musik::square;
#ifdef WIN32
int _tmain(int argc, _TCHAR* argv[]) int _tmain(int argc, _TCHAR* argv[])
#else
int main(int argc, char* argv[])
#endif
{ {
ConsoleUI* instance = new ConsoleUI(); ConsoleUI* instance = new ConsoleUI();
instance->Run(); instance->Run();

View File

@ -5,9 +5,15 @@
#pragma once #pragma once
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h> #include <windows.h>
#include <vld/vld.h> #include <vld/vld.h>
#include "config.h" #include "config.h"
#else
#include <unistd.h>
#endif