File: CSoundSystem.cpp

package info (click to toggle)
blocks-of-the-undead 1.0-7
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 4,084 kB
  • sloc: cpp: 6,224; sh: 3,356; makefile: 171
file content (30 lines) | stat: -rw-r--r-- 729 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#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();
}