equal
deleted
inserted
replaced
19 #include "SDLs.h" |
19 #include "SDLs.h" |
20 |
20 |
21 #include "SDL.h" |
21 #include "SDL.h" |
22 #include "hwconsts.h" |
22 #include "hwconsts.h" |
23 |
23 |
|
24 bool hardware; |
|
25 |
24 SDLInteraction::SDLInteraction(bool hardware_snd) |
26 SDLInteraction::SDLInteraction(bool hardware_snd) |
25 { |
27 { |
26 music = -1; |
28 music = -1; |
27 |
29 hardware = hardware_snd; |
28 SDL_Init(SDL_INIT_VIDEO); |
30 SDL_Init(SDL_INIT_VIDEO); |
29 openal_init(hardware_snd ? 1 : 0, 5); |
|
30 |
|
31 } |
31 } |
32 |
32 |
33 SDLInteraction::~SDLInteraction() |
33 SDLInteraction::~SDLInteraction() |
34 { |
34 { |
35 SDL_Quit(); |
35 SDL_Quit(); |
57 return result; |
57 return result; |
58 } |
58 } |
59 |
59 |
60 void SDLInteraction::StartMusic() |
60 void SDLInteraction::StartMusic() |
61 { |
61 { |
|
62 OpenAL_Init(); |
62 if (music < 0) { |
63 if (music < 0) { |
63 music = openal_loadfile(QString(datadir->absolutePath() + "/Music/main theme.ogg").toLocal8Bit().constData()); |
64 music = openal_loadfile(QString(datadir->absolutePath() + "/Music/main theme.ogg").toLocal8Bit().constData()); |
64 openal_toggleloop(music); |
65 openal_toggleloop(music); |
65 |
66 |
66 } |
67 } |
70 |
71 |
71 void SDLInteraction::StopMusic() |
72 void SDLInteraction::StopMusic() |
72 { |
73 { |
73 if (music >= 0) openal_fadeout(music, 40); |
74 if (music >= 0) openal_fadeout(music, 40); |
74 } |
75 } |
|
76 |
|
77 //we need thjs wrapper because of some issues with windows drivers |
|
78 //beware that this cause a slight delay when playing the first sound |
|
79 void OpenAL_Init() |
|
80 { |
|
81 if (!openal_ready()) |
|
82 openal_init(hardware ? 1 : 0, 5); |
|
83 } |
|
84 |