#include "audio/stream_sound_source.hpp"
#include "util/log.hpp"
-#ifdef NDEBUG
-/** Older openal versions often miss this function and it isn't that vital for
- * supertux...
- */
-#ifdef alcGetString
-# undef alcGetString
-#endif
-# define alcGetString(x,y) ""
-#endif
-
SoundManager::SoundManager() :
device(0),
context(0),
OpenALSoundSource*
SoundManager::intern_create_sound_source(const std::string& filename)
{
- if(!sound_enabled)
- throw std::runtime_error("sound disabled");
+ assert(sound_enabled);
std::auto_ptr<OpenALSoundSource> source (new OpenALSoundSource());
std::auto_ptr<OpenALSoundSource> source
(intern_create_sound_source(filename));
- if(pos == Vector(-1, -1)) {
- source->set_rollof_factor(0);
+ if(pos.x < 0 || pos.y < 0) {
+ source->set_relative(true);
} else {
source->set_position(pos);
}
try {
std::auto_ptr<StreamSoundSource> newmusic (new StreamSoundSource());
- alSourcef(newmusic->source, AL_ROLLOFF_FACTOR, 0);
newmusic->set_sound_file(load_sound_file(filename));
newmusic->set_looping(true);
+ newmusic->set_relative(true);
if(fade)
newmusic->set_fading(StreamSoundSource::FadingOn, .5f);
newmusic->play();