QTfrontend/SDLs.cpp
changeset 2402 edd12b259e7c
parent 2399 ddde0ac1472b
child 2418 538a777f90c4
--- a/QTfrontend/SDLs.cpp	Fri Oct 02 18:44:37 2009 +0000
+++ b/QTfrontend/SDLs.cpp	Fri Oct 02 18:56:54 2009 +0000
@@ -21,13 +21,13 @@
 #include "SDL.h"
 #include "hwconsts.h"
 
+bool hardware;
+
 SDLInteraction::SDLInteraction(bool hardware_snd)
 {
 	music = -1;
-
+	hardware = hardware_snd;
 	SDL_Init(SDL_INIT_VIDEO);
-        openal_init(hardware_snd ? 1 : 0, 5);
-
 }
 
 SDLInteraction::~SDLInteraction()
@@ -59,6 +59,7 @@
 
 void SDLInteraction::StartMusic()
 {
+	OpenAL_Init();
 	if (music < 0) {
 		music = openal_loadfile(QString(datadir->absolutePath() + "/Music/main theme.ogg").toLocal8Bit().constData());
 		openal_toggleloop(music);
@@ -72,3 +73,12 @@
 {
 	if (music >= 0) openal_fadeout(music, 40);
 }
+
+//we need thjs wrapper because of some issues with windows drivers
+//beware that this cause a slight delay when playing the first sound
+void OpenAL_Init()
+{
+	if (!openal_ready())
+        	openal_init(hardware ? 1 : 0, 5);
+}
+