// // Generated By: dol2asm // Translation Unit: Z2SoundHandles // #include "Z2AudioLib/Z2SoundHandles.h" #include "JSystem/JAudio2/JAISoundInfo.h" Z2SoundHandles::Z2SoundHandles() { mNumHandles = 0; } Z2SoundHandles::~Z2SoundHandles() { deleteHandlesPool(); } void Z2SoundHandles::initHandlesPool(u8 pNumHandles) { mNumHandles = pNumHandles; } /* 802AB120-802AB200 2A5A60 00E0+00 1/1 1/1 0/0 .text deleteHandlesPool__14Z2SoundHandlesFv */ void Z2SoundHandles::deleteHandlesPool() { JSULink* link; while (link = getFirst(), link != NULL) { Z2SoundHandlePool* handle = link->getObject(); remove(handle); delete handle; } mNumHandles = 0; } Z2SoundHandlePool* Z2SoundHandles::getHandleSoundID(JAISoundID pSoundId) { JSULink* link; for (link = getFirst(); link != NULL; link = link->getNext()) { Z2SoundHandlePool* handle = link->getObject(); if (handle->isSoundAttached()) { if ((*handle)->getID() == pSoundId) { return handle; } } } return NULL; } Z2SoundHandlePool* Z2SoundHandles::getHandleUserData(u32 pUserData) { JSULink* link; for (link = getFirst(); link != NULL; link = link->getNext()) { Z2SoundHandlePool* handle = link->getObject(); if (handle->isSoundAttached()) { if ((*handle)->getUserData() == pUserData) { return handle; } } } return NULL; } /* 802AB2D8-802AB3D0 2A5C18 00F8+00 0/0 3/3 0/0 .text getFreeHandle__14Z2SoundHandlesFv */ Z2SoundHandlePool* Z2SoundHandles::getFreeHandle() { JSULink* link; for (link = getFirst(); link != NULL; link = link->getNext()) { Z2SoundHandlePool* handle = link->getObject(); if (!handle->isSoundAttached()) { return handle; } } if (getNumHandles() < mNumHandles) { Z2SoundHandlePool* handle = new Z2SoundHandlePool(); if (handle != NULL) { append(handle); return handle; } } return NULL; } /* 802AB3D0-802AB4A0 2A5D10 00D0+00 0/0 2/2 0/0 .text * getLowPrioSound__14Z2SoundHandlesF10JAISoundID */ Z2SoundHandlePool* Z2SoundHandles::getLowPrioSound(JAISoundID pSoundId) { JAISoundInfo* sound_info = JASGlobalInstance::getInstance(); Z2SoundHandlePool* handle; u32 low_prio = 0xffff; Z2SoundHandlePool* low_prio_handle = NULL; JSULink* link; for (link = getFirst(); link != NULL; link = link->getNext()) { handle = link->getObject(); if (!handle->isSoundAttached()) { return handle; } u32 prio = sound_info->getPriority(handle->getSound()->getID()); if (prio < low_prio) { low_prio = prio; low_prio_handle = handle; } } if (sound_info->getPriority(pSoundId) >= low_prio) { return low_prio_handle; } return NULL; } void Z2SoundHandles::stopAllSounds(u32 fadeout) { JSULink* link; for (link = getFirst(); link != NULL; link = link->getNext()) { JAISoundHandle* handle = link->getObject(); //! @meme: explicit operator bool call required to match and be similar //! to CHN_debug; could more concisely write handle->isSoundAttached //! (for some reason cast-to-bool doesn't work?) if (handle && handle->operator bool()) { (*handle)->stop(fadeout); } } } bool Z2SoundHandles::isActive() const { JSULink* link; for (link = getFirst(); link != NULL; link = link->getNext()) { if (link->getObject()->isSoundAttached()) { return true; } } return false; } /* 802AB538-802AB64C 2A5E78 0114+00 0/0 1/1 0/0 .text * setPos__14Z2SoundHandlesFRCQ29JGeometry8TVec3 */ void Z2SoundHandles::setPos(JGeometry::TVec3 const& param_0) { JSULink* link; for (link = getFirst(); link != NULL; link = link->getNext()) { Z2SoundHandlePool* handle = link->getObject(); if (handle->isSoundAttached()) { handle->getSound()->setPos(param_0); } else { remove(handle); delete handle; } } }