12 #include "../../Sound.h"
13 #include "../../Source.h"
14 #include "../../Listener.h"
46 nameLen(_name.length()),
50 bool isNull()
const {
return nameLen == 0; }
54 return (type < other.type) ||
55 ((type == other.type) && (
56 (nameLen < other.nameLen) ||
57 ((nameLen == other.nameLen) && (
65 return (type == other.type) &&
66 (nameLen == other.nameLen) &&
71 typedef std::map<SoundKey, SharedPtr<Sound> >
SoundMap;
90 return SharedPtr<Sound>();
121 it->second->unload();
128 throw Exception(
"Trying to open a device without closing the previous one first");
132 if (deviceSpecifier == NULL) {
134 deviceSpecifier =
"DirectSound3D";
137 deviceSpecifier =
"sdl";
154 throw Exception(
"Trying to close device without closing the previous one first");
167 throw Exception(
"Trying to open context without closing the previous one first");
169 throw Exception(
"Trying to open context without opening a device first");
174 ALC_FREQUENCY, format.sampleFrequency,
210 alcMakeContextCurrent(NULL);
233 using namespace __impl::OpenAL;
246 const std::string &name,
252 SharedPtr<Sound> sound = data->lookupSound(type,name);
253 if (!sound.get() || streaming) {
276 return !data->lookupSound(sound).isNull();
283 source->setRenderable( SharedPtr<RenderableSource>(
284 source->getSound()->isStreaming()
295 listener->setRenderable( SharedPtr<RenderableListener>(
303 source->setRenderable( SharedPtr<RenderableSource>() );
310 listener->setRenderable( SharedPtr<RenderableListener>() );
322 data->dirty.dopplerFactor = 1;
323 data->dirty.meterDistance = 1;
332 data->dirty.dopplerFactor = 1;
339 data->openDevice(NULL);
340 data->closeContext();
341 data->openContext(format);
349 data->openDevice(NULL);
350 if (!data->alContext) {
351 data->openContext(getOutputFormat());
361 if (data->dirty.dopplerFactor)
362 setupDopplerEffect();
375 alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED);
378 data->dirty.meterDistance = 1;
379 data->dirty.dopplerFactor = 1;
388 Scalar speedOfSound = 343.3f * getMeterDistance();
391 alDopplerFactor(getDopplerFactor());
393 alDopplerVelocity(speedOfSound);
395 alSpeedOfSound(speedOfSound);
398 data->dirty.dopplerFactor = 0;
408 data->alDevice = device;
410 data->alContext = context;
412 data->alContext = alcGetCurrentContext();
413 if (!device && data->alContext)
414 data->alDevice = alcGetContextsDevice(data->alContext);
421 data->alDevice = NULL;
422 data->alContext = NULL;