From: Thomas Pietrzak Date: Tue, 24 May 2011 14:25:32 +0000 (+0000) Subject: debug X-Git-Url: https://git.thomaspietrzak.com/?a=commitdiff_plain;h=a6419a3f93c115be2aac30a47ad522758af2d7f0;p=hapticmetronome.git debug git-svn-id: svn+ssh://thomaspietrzak.com/var/svn/rep@15 47cf9a05-e0a8-4ed5-9e9b-101a649bc004 --- diff --git a/Haptic Metronome/Haptic Metronome.suo b/Haptic Metronome/Haptic Metronome.suo index 5f9e0c5..d2e0b35 100644 Binary files a/Haptic Metronome/Haptic Metronome.suo and b/Haptic Metronome/Haptic Metronome.suo differ diff --git a/Haptic Metronome/Haptic Metronome/Haptic Metronome.vcxproj b/Haptic Metronome/Haptic Metronome/Haptic Metronome.vcxproj index 04cb9c5..81f38c5 100644 --- a/Haptic Metronome/Haptic Metronome/Haptic Metronome.vcxproj +++ b/Haptic Metronome/Haptic Metronome/Haptic Metronome.vcxproj @@ -37,11 +37,16 @@ - ..\..\lib;..\..\lib\SDL_mixer-1.3\include;..\..\lib\wiiuse_v0.12_win;..\..\lib\glew-1.5.8\include;..\..\include;..\..\lib\SDL_image-1.3\include;..\..\lib\SDL-1.3\include;$(IncludePath) + ..\..\include;$(IncludePath) - ..\..\lib\SDL_mixer-1.3\lib;..\..\lib\wiiuse_v0.12_win;..\..\lib\glew-1.5.8\lib;..\..\lib\SDL-1.3\lib;..\..\lib\SDL_image-1.3\lib;$(LibraryPath) + $(LibraryPath) + ../../src;../../include;$(SourcePath) + + + ..\..\lib;..\..\lib\SDL_mixer-1.3\include;..\..\lib\wiiuse_v0.12_win;..\..\lib\glew-1.5.8\include;..\..\include;..\..\lib\SDL_image-1.3\include;..\..\lib\SDL-1.3\include;$(IncludePath) ../../src;../../include;$(SourcePath) + ..\..\lib\SDL_mixer-1.3\lib;..\..\lib\wiiuse_v0.12_win;..\..\lib\glew-1.5.8\lib;..\..\lib\SDL-1.3\lib;..\..\lib\SDL_image-1.3\lib;$(LibraryPath) @@ -53,6 +58,7 @@ true SDL.lib;SDLmain.lib;SDL_image.lib;SDL_mixer.lib;glew32.lib;opengl32.lib;glu32.lib;wiiuse.lib;Winmm.lib;%(AdditionalDependencies) Windows + msvcrt.lib @@ -61,11 +67,14 @@ MaxSpeed true true + _MBCS;%(PreprocessorDefinitions);WIN32 - true + false true true + SDL.lib;SDLmain.lib;SDL_image.lib;SDL_mixer.lib;glew32.lib;opengl32.lib;glu32.lib;wiiuse.lib;Winmm.lib;%(AdditionalDependencies) + Windows diff --git a/include/MetronomeAudio.hpp b/include/MetronomeAudio.hpp index 6d6bb67..8956755 100644 --- a/include/MetronomeAudio.hpp +++ b/include/MetronomeAudio.hpp @@ -5,12 +5,10 @@ #ifdef WIN32 #include -#include -#include -#else +#endif + #include #include -#endif class MetronomeAudio : public Metronome { diff --git a/include/MetronomeHaptic.hpp b/include/MetronomeHaptic.hpp index 361a005..72eff23 100644 --- a/include/MetronomeHaptic.hpp +++ b/include/MetronomeHaptic.hpp @@ -5,12 +5,10 @@ #ifdef WIN32 #include -#include -#include -#else +#endif + #include #include -#endif #include "Serial.hpp" diff --git a/include/Mixer.hpp b/include/Mixer.hpp index 64cb5c5..ba49c2e 100644 --- a/include/Mixer.hpp +++ b/include/Mixer.hpp @@ -30,10 +30,9 @@ #ifdef __APPLE__ #include -#elif WIN32 -#include #else #include +#include #endif class Mixer @@ -74,6 +73,7 @@ class Mixer int _musicVolume, _soundVolume; static Mixer *_minstance; + static SDL_mutex *_mutex; }; #endif diff --git a/include/Sound.hpp b/include/Sound.hpp index fbe81f1..8fae0af 100644 --- a/include/Sound.hpp +++ b/include/Sound.hpp @@ -25,8 +25,6 @@ #ifdef __APPLE__ #include -#elif WIN32 -#include #else #include #endif diff --git a/include/Texture.hpp b/include/Texture.hpp index e2a2ec3..ee7058a 100644 --- a/include/Texture.hpp +++ b/include/Texture.hpp @@ -22,11 +22,7 @@ #define __TEXTURE__ #include -#ifdef WIN32 -#include -#else #include -#endif // #include #include "String.hpp" diff --git a/src/MetronomeAudio.cpp b/src/MetronomeAudio.cpp index 0f2bea0..7d4de30 100644 --- a/src/MetronomeAudio.cpp +++ b/src/MetronomeAudio.cpp @@ -18,8 +18,8 @@ extern FILE*logfile; MetronomeAudio::MetronomeAudio(const Track *track, uint32_t nbbeats, uint32_t tempo, bool activated) :Metronome(track, nbbeats, tempo, activated), thread(NULL) { - Mixer::getInstance()->addSound("bip","bip10.ogg"); - Mixer::getInstance()->addSound("bip2","bip2.ogg"); + Mixer::getInstance()->addSound("bip","bip10.wav"); + Mixer::getInstance()->addSound("bip2","bip2.wav"); } MetronomeAudio::~MetronomeAudio() diff --git a/src/Mixer.cpp b/src/Mixer.cpp index 575e716..2c22ee7 100644 --- a/src/Mixer.cpp +++ b/src/Mixer.cpp @@ -26,6 +26,7 @@ Mix_Music *Mixer::_music = NULL; Mixer *Mixer::_minstance = NULL; int *Mixer::_soundChannels = NULL; +SDL_mutex *Mixer::_mutex = SDL_CreateMutex(); Mixer::Mixer() :/*_music(NULL), *//*_soundChannels(new int[MAXSOUNDS]),*/ _musicVolume(-1), _soundVolume(-1) @@ -56,6 +57,7 @@ Mixer::~Mixer() //for the moment we never unload Sounds... if (_music) stopMusic(); + SDL_DestroyMutex(_mutex); } @@ -93,6 +95,7 @@ void Mixer::playMusic(const String &filename) if (buffer != "") { + SDL_mutexP(_mutex); _music = Mix_LoadMUS(buffer.c_str()); if(_music==NULL) fprintf(stderr, "cannot load music %s\n",buffer.c_str()); @@ -101,6 +104,7 @@ void Mixer::playMusic(const String &filename) Mix_PlayMusic(_music, -1); Mix_HookMusicFinished(stopMusic); } + SDL_mutexV(_mutex); } else fprintf(stderr, "music file %s not found\n",filename.c_str()); @@ -129,7 +133,11 @@ bool Mixer::addSound(const String &s, const String &filename) snd = _sounds[s]; } - return snd->addSound(filename); + SDL_mutexP(_mutex); + bool res = snd->addSound(filename); + SDL_mutexV(_mutex); + + return res; } void Mixer::playSound(const String &s) diff --git a/src/PaintGame.cpp b/src/PaintGame.cpp index 8e89292..bec5368 100644 --- a/src/PaintGame.cpp +++ b/src/PaintGame.cpp @@ -7,17 +7,14 @@ #include "MetronomeHaptic.hpp" #include +#include +#include +#include #ifdef WIN32 -#include -#include -#include struct { int tv_sec, tv_usec; } start; #else struct timeval start; -#include -#include -#include #endif #include @@ -32,8 +29,8 @@ int resolution_x, resolution_y; Config fromKeyboard; extern FILE*logfile; - -#if SDL_VERSION_ATLEAST(1,3,0) + +#if SDL_VERSION_ATLEAST(1,3,0) SDL_Window *window; SDL_Renderer *renderer; #endif @@ -79,7 +76,7 @@ void init() for (i=0 ; modes[i] ; i++) { cout << "Resolution available: " << modes[i]->w << "x" << modes[i]->h << endl; - if (modes[i]->w > resolution_x)//== 1280 && modes[i]->h == 1024) + if (modes[i]->w== 1600 && modes[i]->h == 900) //> resolution_x)// { resolution_x = modes[i]->w; resolution_y = modes[i]->h; @@ -93,12 +90,12 @@ void init() resolution_y = 768; }*/ } - -#if 0//SDL_VERSION_ATLEAST(1,3,0) - if ((window = SDL_CreateWindow("Haptic Metronome", - SDL_WINDOWPOS_CENTERED, - SDL_WINDOWPOS_CENTERED, - resolution_x, resolution_y, + +#if 0//SDL_VERSION_ATLEAST(1,3,0) + if ((window = SDL_CreateWindow("Haptic Metronome", + SDL_WINDOWPOS_CENTERED, + SDL_WINDOWPOS_CENTERED, + resolution_x, resolution_y, SDL_WINDOW_OPENGL|SDL_WINDOW_SHOWN)) == NULL) throw "Unable to create the window"; @@ -130,8 +127,6 @@ void init() SDL_GL_SetAttribute(SDL_GL_ACCUM_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_ACCUM_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_ACCUM_ALPHA_SIZE, 8); - - int flags = SDL_OPENGL | SDL_OPENGL | SDL_HWSURFACE | SDL_FULLSCREEN; glEnable(GL_MULTISAMPLE); @@ -140,13 +135,17 @@ void init() throw "Impossible to initialize SDL_GL_MULTISAMPLEBUFFERS"; // Nombre de tampons utilisés pour l'anti-aliasing (la valeur utilisée dépend de la carte graphique) - if (SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 8) == -1) + if (SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 16) == -1) throw "Impossible to initialize SDL_GL_MULTISAMPLESAMPLES"; - + // int flags = SDL_OPENGL | SDL_OPENGLBLIT | SDL_SWSURFACE | SDL_FULLSCREEN; + int flags = SDL_OPENGL | SDL_FULLSCREEN; SDL_Surface * screen; - if (!(screen = SDL_SetVideoMode(resolution_x, resolution_y, 0, flags))) +// if (!(screen = SDL_SetVideoMode(resolution_x, resolution_y, 0, flags))) + if (!(screen = SDL_SetVideoMode(0, 0, 0, flags))) throw "Impossible to change the video mode"; + resolution_x = 1600; + resolution_y = 900; GLdouble ratio = (GLdouble) screen->w / screen->h; @@ -523,7 +522,7 @@ bool processEvents() break; case SDL_KEYDOWN: -#if SDL_VERSION_ATLEAST(1,3,0) +#if SDL_VERSION_ATLEAST(1,3,0) keystate = SDL_GetKeyboardState(NULL); handleKeys(keystate[SDL_SCANCODE_F1], keystate[SDL_SCANCODE_F2], keystate[SDL_SCANCODE_F3], keystate[SDL_SCANCODE_F4], keystate[SDL_SCANCODE_F5], currenttime); #else @@ -605,7 +604,7 @@ bool processEvents() default: break; } -#if SDL_VERSION_ATLEAST(1,3,0) +#if SDL_VERSION_ATLEAST(1,3,0) keystate = SDL_GetKeyboardState(NULL); handleKeys(keystate[SDL_SCANCODE_F1], keystate[SDL_SCANCODE_F2], keystate[SDL_SCANCODE_F3], keystate[SDL_SCANCODE_F4], keystate[SDL_SCANCODE_F5], currenttime); #else @@ -708,7 +707,7 @@ void loop(const Track &tr, const String &songname) if (iswiimoteconnected) mw->handleEvents(); // cout << "pause" << endl; -// SDL_Delay(10); + SDL_Delay(10); // check metronome events // tr.checkMetronome(currenttime, m); } diff --git a/src/SerialWindows.cpp b/src/SerialWindows.cpp index 927cfae..2b6d4d8 100644 --- a/src/SerialWindows.cpp +++ b/src/SerialWindows.cpp @@ -4,11 +4,10 @@ using namespace std; #ifdef WIN32 -#include #include -#else -#include #endif + +#include SerialWindows::SerialWindows(char *portName) :Serial(portName) diff --git a/src/Texture.cpp b/src/Texture.cpp index 9da81f5..85605e2 100644 --- a/src/Texture.cpp +++ b/src/Texture.cpp @@ -24,8 +24,6 @@ // #include #ifdef __APPLE__ #include -#elif WIN32 -#include #else #include #endif @@ -70,7 +68,7 @@ Texture::Texture(const String &filename, const bool &rep) if (buffer != "") surface = IMG_Load(buffer.c_str()); - else + else cerr << "Could not open texture " << filename << endl; if (surface) diff --git a/src/Tools.cpp b/src/Tools.cpp index a09e915..bb23adc 100644 --- a/src/Tools.cpp +++ b/src/Tools.cpp @@ -20,11 +20,7 @@ */ #include "Tools.hpp" -#ifdef WIN32 -#include -#else #include -#endif #include #include diff --git a/src/main.cpp b/src/main.cpp index 5df6946..f21bc77 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,13 +7,12 @@ #ifdef WIN32 #include -#include #include #else #include +#endif #include -#endif #ifdef WIN32 @@ -31,8 +30,6 @@ float SECONDSIZE = 0.050f; FILE *logfile = NULL; -//list bips; -//list::iterator cb; void handleStrokeOff() {