#include "oodle.h" CSoundSystem::CSoundSystem(int chunksize, int frequency, int channels, Uint16 format) { SDL_InitSubSystem(SDL_INIT_AUDIO); soundAvailable = true; if (Mix_OpenAudio(frequency, format, channels, chunksize)) { soundAvailable = false; LOG("Failed to load sound subsystem \"CSoundSystem\".", 1, LOG_ERROR); LOG("You will not have any sound during the game.", 1, LOG_INFO); } } void CSoundSystem::playSound(CSound &snd) const { if (soundAvailable) snd.setChannel( Mix_PlayChannel(-1, snd.getChunk(), 0) ); } void CSoundSystem::stopSound(const CSound &snd) const { if (soundAvailable) Mix_HaltChannel(snd.getChannel()); } CSoundSystem::~CSoundSystem() { if (soundAvailable) Mix_CloseAudio(); }