23 |
23 |
24 #include "SDL.h" |
24 #include "SDL.h" |
25 #include "SDL_mixer.h" |
25 #include "SDL_mixer.h" |
26 |
26 |
27 #include "HWApplication.h" |
27 #include "HWApplication.h" |
|
28 #include "hwform.h" /* you know, we could just put a config singleton lookup function in gameuiconfig or something... */ |
|
29 #include "gameuiconfig.h" |
28 |
30 |
29 #include "SDLInteraction.h" |
31 #include "SDLInteraction.h" |
30 |
32 |
31 #include "physfsrwops.h" |
33 #include "physfsrwops.h" |
32 |
34 |
184 // don't init again |
186 // don't init again |
185 if (m_audioInitialized) |
187 if (m_audioInitialized) |
186 return; |
188 return; |
187 |
189 |
188 SDL_Init(SDL_INIT_AUDIO); |
190 SDL_Init(SDL_INIT_AUDIO); |
189 Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024); |
191 if(!Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024)) /* should we keep trying, or just turn off permanently? */ |
190 m_audioInitialized = true; |
192 m_audioInitialized = true; |
191 } |
193 } |
192 |
194 |
193 |
195 |
194 void SDLInteraction::playSoundFile(const QString & soundFile) |
196 void SDLInteraction::playSoundFile(const QString & soundFile) |
195 { |
197 { |
|
198 if (!HWForm::config || !HWForm::config->isFrontendSoundEnabled()) return; |
196 SDLAudioInit(); |
199 SDLAudioInit(); |
|
200 if (!m_audioInitialized) return; |
197 if (!m_soundMap->contains(soundFile)) |
201 if (!m_soundMap->contains(soundFile)) |
198 m_soundMap->insert(soundFile, Mix_LoadWAV_RW(PHYSFSRWOPS_openRead(soundFile.toLocal8Bit().constData()), 1)); |
202 m_soundMap->insert(soundFile, Mix_LoadWAV_RW(PHYSFSRWOPS_openRead(soundFile.toLocal8Bit().constData()), 1)); |
199 |
203 |
200 //FIXME: this is a hack, but works as long as we have few concurrent playing sounds |
204 //FIXME: this is a hack, but works as long as we have few concurrent playing sounds |
201 if (Mix_Playing(lastchannel) == false) |
205 if (Mix_Playing(lastchannel) == false) |