diff options
author | Joerg Mueller <nexyon@gmail.com> | 2012-11-05 18:24:35 +0400 |
---|---|---|
committer | Joerg Mueller <nexyon@gmail.com> | 2012-11-05 18:24:35 +0400 |
commit | 5a8d5f77af84d3f790d749dfd2d76a3b487eb06a (patch) | |
tree | 22326dd7033689c8e33dd59a265874ca5249bf14 /source/gameengine | |
parent | 0f9559fe714b582039677de9dea5a3956dcdc4aa (diff) |
Audaspace:
Replacing AUD_Reference with boost::shared_ptr.
Diffstat (limited to 'source/gameengine')
-rw-r--r-- | source/gameengine/Converter/KX_ConvertActuators.cpp | 8 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_SoundActuator.cpp | 72 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_SoundActuator.h | 8 |
3 files changed, 44 insertions, 44 deletions
diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 24d321730eb..06399642edd 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -387,7 +387,7 @@ void BL_ConvertActuators(const char* maggiename, { bSound* sound = soundact->sound; bool is3d = soundact->flag & ACT_SND_3D_SOUND ? true : false; - AUD_Reference<AUD_IFactory> snd_sound; + boost::shared_ptr<AUD_IFactory> snd_sound; KX_3DSoundSettings settings; settings.cone_inner_angle = soundact->sound3D.cone_inner_angle; settings.cone_outer_angle = soundact->sound3D.cone_outer_angle; @@ -406,21 +406,21 @@ void BL_ConvertActuators(const char* maggiename, } else { - snd_sound = *reinterpret_cast<AUD_Reference<AUD_IFactory>*>(sound->playback_handle); + snd_sound = *reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(sound->playback_handle); // if sound shall be 3D but isn't mono, we have to make it mono! if (is3d) { try { - AUD_Reference<AUD_IReader> reader = snd_sound->createReader(); + boost::shared_ptr<AUD_IReader> reader = snd_sound->createReader(); if (reader->getSpecs().channels != AUD_CHANNELS_MONO) { AUD_DeviceSpecs specs; specs.channels = AUD_CHANNELS_MONO; specs.rate = AUD_RATE_INVALID; specs.format = AUD_FORMAT_INVALID; - snd_sound = new AUD_ChannelMapperFactory(snd_sound, specs); + snd_sound = boost::shared_ptr<AUD_IFactory>(new AUD_ChannelMapperFactory(snd_sound, specs)); } } catch(AUD_Exception&) diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp index f76f94aa81d..2a4f2b3e7d9 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.cpp +++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp @@ -53,7 +53,7 @@ /* Native functions */ /* ------------------------------------------------------------------------- */ KX_SoundActuator::KX_SoundActuator(SCA_IObject* gameobj, - AUD_Reference<AUD_IFactory> sound, + boost::shared_ptr<AUD_IFactory> sound, float volume, float pitch, bool is3d, @@ -74,20 +74,20 @@ KX_SoundActuator::KX_SoundActuator(SCA_IObject* gameobj, KX_SoundActuator::~KX_SoundActuator() { - if (!m_handle.isNull()) + if (m_handle.get()) m_handle->stop(); } void KX_SoundActuator::play() { - if (!m_handle.isNull()) + if (m_handle.get()) m_handle->stop(); - if (m_sound.isNull()) + if (!m_sound.get()) return; // this is the sound that will be played and not deleted afterwards - AUD_Reference<AUD_IFactory> sound = m_sound; + boost::shared_ptr<AUD_IFactory> sound = m_sound; bool loop = false; @@ -95,7 +95,7 @@ void KX_SoundActuator::play() { case KX_SOUNDACT_LOOPBIDIRECTIONAL: case KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP: - sound = new AUD_PingPongFactory(sound); + sound = boost::shared_ptr<AUD_IFactory>(new AUD_PingPongFactory(sound)); // fall through case KX_SOUNDACT_LOOPEND: case KX_SOUNDACT_LOOPSTOP: @@ -117,9 +117,9 @@ void KX_SoundActuator::play() return; } - AUD_Reference<AUD_I3DHandle> handle3d = AUD_Reference<AUD_I3DHandle>(m_handle); + boost::shared_ptr<AUD_I3DHandle> handle3d = boost::dynamic_pointer_cast<AUD_I3DHandle>(m_handle); - if (m_is3d && !handle3d.isNull()) + if (m_is3d && handle3d.get()) { handle3d->setRelative(true); handle3d->setVolumeMaximum(m_3d.max_gain); @@ -149,7 +149,7 @@ CValue* KX_SoundActuator::GetReplica() void KX_SoundActuator::ProcessReplica() { SCA_IActuator::ProcessReplica(); - m_handle = AUD_Reference<AUD_IHandle>(); + m_handle = boost::shared_ptr<AUD_IHandle>(); } bool KX_SoundActuator::Update(double curtime, bool frame) @@ -164,11 +164,11 @@ bool KX_SoundActuator::Update(double curtime, bool frame) RemoveAllEvents(); - if (m_sound.isNull()) + if (!m_sound.get()) return false; // actual audio device playing state - bool isplaying = m_handle.isNull() ? false : (m_handle->getStatus() == AUD_STATUS_PLAYING); + bool isplaying = m_handle.get() ? (m_handle->getStatus() == AUD_STATUS_PLAYING) : false; if (bNegativeEvent) { @@ -182,9 +182,9 @@ bool KX_SoundActuator::Update(double curtime, bool frame) case KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP: { // stop immediately - if (!m_handle.isNull()) + if (m_handle.get()) m_handle->stop(); - m_handle = AUD_Reference<AUD_IHandle>(); + m_handle = boost::shared_ptr<AUD_IHandle>(); break; } case KX_SOUNDACT_PLAYEND: @@ -196,7 +196,7 @@ bool KX_SoundActuator::Update(double curtime, bool frame) case KX_SOUNDACT_LOOPBIDIRECTIONAL: { // stop the looping so that the sound stops when it finished - if (!m_handle.isNull()) + if (m_handle.get()) m_handle->setLoopCount(0); break; } @@ -223,13 +223,13 @@ bool KX_SoundActuator::Update(double curtime, bool frame) play(); } // verify that the sound is still playing - isplaying = m_handle.isNull() ? false : (m_handle->getStatus() == AUD_STATUS_PLAYING); + isplaying = m_handle.get() ? (m_handle->getStatus() == AUD_STATUS_PLAYING) : false; if (isplaying) { - AUD_Reference<AUD_I3DHandle> handle3d = AUD_Reference<AUD_I3DHandle>(m_handle); + boost::shared_ptr<AUD_I3DHandle> handle3d = boost::dynamic_pointer_cast<AUD_I3DHandle>(m_handle); - if (m_is3d && !handle3d.isNull()) + if (m_is3d && handle3d.get()) { KX_Camera* cam = KX_GetActiveScene()->GetActiveCamera(); if (cam) @@ -325,7 +325,7 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, startSound, "startSound()\n" "\tStarts the sound.\n") { - switch (m_handle.isNull() ? AUD_STATUS_INVALID : m_handle->getStatus()) { + switch (m_handle.get() ? m_handle->getStatus() : AUD_STATUS_INVALID) { case AUD_STATUS_PLAYING: break; case AUD_STATUS_PAUSED: @@ -341,7 +341,7 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, pauseSound, "pauseSound()\n" "\tPauses the sound.\n") { - if (!m_handle.isNull()) + if (m_handle.get()) m_handle->pause(); Py_RETURN_NONE; } @@ -350,9 +350,9 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, stopSound, "stopSound()\n" "\tStops the sound.\n") { - if (!m_handle.isNull()) + if (m_handle.get()) m_handle->stop(); - m_handle = AUD_Reference<AUD_IHandle>(); + m_handle = boost::shared_ptr<AUD_IHandle>(); Py_RETURN_NONE; } @@ -400,7 +400,7 @@ PyObject *KX_SoundActuator::pyattr_get_audposition(void *self, const struct KX_P KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self); float position = 0.0; - if (!actuator->m_handle.isNull()) + if (actuator->m_handle.get()) position = actuator->m_handle->getPosition(); PyObject *result = PyFloat_FromDouble(position); @@ -431,7 +431,7 @@ PyObject *KX_SoundActuator::pyattr_get_pitch(void *self, const struct KX_PYATTRI PyObject *KX_SoundActuator::pyattr_get_sound(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) { KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self); - if (!actuator->m_sound.isNull()) + if (actuator->m_sound.get()) return (PyObject *)AUD_getPythonFactory(&actuator->m_sound); else Py_RETURN_NONE; @@ -446,49 +446,49 @@ int KX_SoundActuator::pyattr_set_3d_property(void *self, const struct KX_PYATTRI if (!PyArg_Parse(value, "f", &prop_value)) return PY_SET_ATTR_FAIL; - AUD_Reference<AUD_I3DHandle> handle3d = AUD_Reference<AUD_I3DHandle>(actuator->m_handle); + boost::shared_ptr<AUD_I3DHandle> handle3d = boost::dynamic_pointer_cast<AUD_I3DHandle>(actuator->m_handle); // if sound is working and 3D, set the new setting if (!actuator->m_is3d) return PY_SET_ATTR_FAIL; if (!strcmp(prop, "volume_maximum")) { actuator->m_3d.max_gain = prop_value; - if (!handle3d.isNull()) + if (handle3d.get()) handle3d->setVolumeMaximum(prop_value); } else if (!strcmp(prop, "volume_minimum")) { actuator->m_3d.min_gain = prop_value; - if (!handle3d.isNull()) + if (handle3d.get()) handle3d->setVolumeMinimum(prop_value); } else if (!strcmp(prop, "distance_reference")) { actuator->m_3d.reference_distance = prop_value; - if (!handle3d.isNull()) + if (handle3d.get()) handle3d->setDistanceReference(prop_value); } else if (!strcmp(prop, "distance_maximum")) { actuator->m_3d.max_distance = prop_value; - if (!handle3d.isNull()) + if (handle3d.get()) handle3d->setDistanceMaximum(prop_value); } else if (!strcmp(prop, "attenuation")) { actuator->m_3d.rolloff_factor = prop_value; - if (!handle3d.isNull()) + if (handle3d.get()) handle3d->setAttenuation(prop_value); } else if (!!strcmp(prop, "cone_angle_inner")) { actuator->m_3d.cone_inner_angle = prop_value; - if (!handle3d.isNull()) + if (handle3d.get()) handle3d->setConeAngleInner(prop_value); } else if (!strcmp(prop, "cone_angle_outer")) { actuator->m_3d.cone_outer_angle = prop_value; - if (!handle3d.isNull()) + if (handle3d.get()) handle3d->setConeAngleOuter(prop_value); } else if (!strcmp(prop, "cone_volume_outer")) { actuator->m_3d.cone_outer_gain = prop_value; - if (!handle3d.isNull()) + if (handle3d.get()) handle3d->setConeVolumeOuter(prop_value); } else { @@ -506,7 +506,7 @@ int KX_SoundActuator::pyattr_set_audposition(void *self, const struct KX_PYATTRI if (!PyArg_Parse(value, "f", &position)) return PY_SET_ATTR_FAIL; - if (!actuator->m_handle.isNull()) + if (actuator->m_handle.get()) actuator->m_handle->seek(position); return PY_SET_ATTR_SUCCESS; } @@ -519,7 +519,7 @@ int KX_SoundActuator::pyattr_set_gain(void *self, const struct KX_PYATTRIBUTE_DE return PY_SET_ATTR_FAIL; actuator->m_volume = gain; - if (!actuator->m_handle.isNull()) + if (actuator->m_handle.get()) actuator->m_handle->setVolume(gain); return PY_SET_ATTR_SUCCESS; @@ -533,7 +533,7 @@ int KX_SoundActuator::pyattr_set_pitch(void *self, const struct KX_PYATTRIBUTE_D return PY_SET_ATTR_FAIL; actuator->m_pitch = pitch; - if (!actuator->m_handle.isNull()) + if (actuator->m_handle.get()) actuator->m_handle->setPitch(pitch); return PY_SET_ATTR_SUCCESS; @@ -546,7 +546,7 @@ int KX_SoundActuator::pyattr_set_sound(void *self, const struct KX_PYATTRIBUTE_D if (!PyArg_Parse(value, "O", &sound)) return PY_SET_ATTR_FAIL; - AUD_Reference<AUD_IFactory>* snd = reinterpret_cast<AUD_Reference<AUD_IFactory>*>(AUD_getPythonSound((void *)sound)); + boost::shared_ptr<AUD_IFactory>* snd = reinterpret_cast<boost::shared_ptr<AUD_IFactory>*>(AUD_getPythonSound((void *)sound)); if (snd) { actuator->m_sound = *snd; diff --git a/source/gameengine/Ketsji/KX_SoundActuator.h b/source/gameengine/Ketsji/KX_SoundActuator.h index 1ce44e942e8..68eff56797b 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.h +++ b/source/gameengine/Ketsji/KX_SoundActuator.h @@ -36,9 +36,9 @@ #ifdef WITH_AUDASPACE # include "AUD_C-API.h" -# include "AUD_Reference.h" # include "AUD_IFactory.h" # include "AUD_IHandle.h" +# include <boost/shared_ptr.hpp> #endif #include "BKE_sound.h" @@ -58,12 +58,12 @@ class KX_SoundActuator : public SCA_IActuator { Py_Header bool m_isplaying; - AUD_Reference<AUD_IFactory> m_sound; + boost::shared_ptr<AUD_IFactory> m_sound; float m_volume; float m_pitch; bool m_is3d; KX_3DSoundSettings m_3d; - AUD_Reference<AUD_IHandle> m_handle; + boost::shared_ptr<AUD_IHandle> m_handle; void play(); @@ -84,7 +84,7 @@ public: KX_SOUNDACT_TYPE m_type; KX_SoundActuator(SCA_IObject* gameobj, - AUD_Reference<AUD_IFactory> sound, + boost::shared_ptr<AUD_IFactory> sound, float volume, float pitch, bool is3d, |