| 1 |
#include "oodle.h" |
| 2 |
|
| 3 |
CSoundSystem::CSoundSystem(int chunksize, int frequency, int channels, Uint16 format) |
| 4 |
{ |
| 5 |
SDL_InitSubSystem(SDL_INIT_AUDIO); |
| •6 |
soundAvailable = true; |
| 7 |
if (Mix_OpenAudio(frequency, format, channels, chunksize)) |
| 8 |
{ |
| •9 |
soundAvailable = false; |
| 10 |
LOG("Failed to load sound subsystem \"CSoundSystem\".", 1, LOG_ERROR); |
| 11 |
LOG("You will not have any sound during the game.", 1, LOG_INFO); |
| 12 |
} |
| 13 |
} |
| 14 |
|
| 15 |
void CSoundSystem::playSound(CSound &snd) const |
| 16 |
{ |
| •17 |
if (soundAvailable) |
| 18 |
snd.setChannel( Mix_PlayChannel(-1, snd.getChunk(), 0) ); |
| 19 |
} |
| 20 |
void CSoundSystem::stopSound(const CSound &snd) const |
| 21 |
{ |
| •22 |
if (soundAvailable) |
| 23 |
Mix_HaltChannel(snd.getChannel()); |
| 24 |
} |
| 25 |
|
| 26 |
CSoundSystem::~CSoundSystem() |
| 27 |
{ |
| •28 |
if (soundAvailable) |
| 29 |
Mix_CloseAudio(); |
| 30 |
} |