diff options
| author | Luke Street <luke@street.dev> | 2026-03-01 15:35:36 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-01 14:35:36 -0800 |
| commit | 9649319ec4926457ef85e6094f8207474c977c2d (patch) | |
| tree | 1c5cd4c7cc4c1aee03f28921213da47f2775444d /libs/JSystem/src/JAudio2/JAIStreamMgr.cpp | |
| parent | 6e149819e13b1f70ecbf8a4c66b030c17ffed2bb (diff) | |
Reorganize library code into `libs/` (#3119)
* Reorganize files into libs/{dolphin,JSystem,PowerPC_EABI_Support,revolution,TRK_MINNOW_DOLPHIN}
* Update configure.py and project.py for new libs structure
* Refactor `#include <dolphin/x.h>` -> `<x.h>`
* Remove `__REVOLUTION_SDK__` forwards from dolphin
* Fix dolphin/ references in revolution
* Wrap `#include <dolphin.h>` in `!__REVOLUTION_SDK__`
* Always build TRK against dolphin headers
* Resolve revolution SDK header resolution issues
Diffstat (limited to 'libs/JSystem/src/JAudio2/JAIStreamMgr.cpp')
| -rw-r--r-- | libs/JSystem/src/JAudio2/JAIStreamMgr.cpp | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/libs/JSystem/src/JAudio2/JAIStreamMgr.cpp b/libs/JSystem/src/JAudio2/JAIStreamMgr.cpp new file mode 100644 index 0000000000..b775e09c86 --- /dev/null +++ b/libs/JSystem/src/JAudio2/JAIStreamMgr.cpp @@ -0,0 +1,125 @@ +#include "JSystem/JSystem.h" // IWYU pragma: keep + +#include "JSystem/JAudio2/JAIStreamMgr.h" +#include "JSystem/JAudio2/JAISoundHandles.h" +#include "JSystem/JAudio2/JAIStreamDataMgr.h" +#include "JSystem/JAudio2/JAISoundInfo.h" + +JAIStreamMgr::JAIStreamMgr(bool setInstance) : JASGlobalInstance<JAIStreamMgr>(setInstance) { + streamDataMgr_ = NULL; + mStreamAramMgr = NULL; + field_0x6c = NULL; + mAudience = NULL; + mParams.init(); + mActivity.init(); +} + +bool JAIStreamMgr::startSound(JAISoundID id, JAISoundHandle* handle, const JGeometry::TVec3<f32>* posPtr) { + JUT_ASSERT(37, streamDataMgr_); + if (handle != NULL && *handle) { + (*handle)->stop(); + } + + s32 streamFileEntry = streamDataMgr_->getStreamFileEntry(id); + if (streamFileEntry < 0) { + JUT_WARN(46, "Cannot find the stream file entry for ID:%08x\n", id.id_.composite_) + return false; + } + + JAIStream* stream = newStream_(); + JAISoundInfo* soundInfo = JASGlobalInstance<JAISoundInfo>::getInstance(); + + int category = -1; + if (soundInfo != NULL) { + category = soundInfo->getCategory(id); + } + + if (stream == NULL) { + return false; + } + + stream->JAIStreamMgr_startID_(id, streamFileEntry, posPtr, mAudience, category); + if (soundInfo != NULL) { + soundInfo->getStreamInfo(id, stream); + } + + if (handle != NULL) { + stream->attachHandle(handle); + } + + return false; +} + +void JAIStreamMgr::freeDeadStream_() { + JSULink<JAIStream>* i = mStreamList.getFirst(); + while (i != NULL) { + JAIStream* stream = i->getObject(); + JSULink<JAIStream>* next = i->getNext(); + if (stream->status_.isDead()) { + mStreamList.remove(i); + void* aramAddr = stream->JAIStreamMgr_getAramAddr_(); + if (aramAddr != NULL) { + bool result = mStreamAramMgr->deleteStreamAram((u32)aramAddr); + JUT_ASSERT(105, result); + } + + delete stream; + } + i = next; + } +} + +void JAIStreamMgr::calc() { + JSULink<JAIStream>* i; + mParams.calc(); + for (i = mStreamList.getFirst(); i != NULL; i = i->getNext()) { + i->getObject()->JAIStreamMgr_calc_(); + } + freeDeadStream_(); +} + +void JAIStreamMgr::stop() { + JSULink<JAIStream>* i; + for (i = mStreamList.getFirst(); i != NULL; i = i->getNext()) { + i->getObject()->stop(); + } +} + +void JAIStreamMgr::stop(u32 fadeTime) { + JSULink<JAIStream>* i; + for (i = mStreamList.getFirst(); i != NULL; i = i->getNext()) { + i->getObject()->stop(fadeTime); + } +} + +void JAIStreamMgr::stopSoundID(JAISoundID id) { + JSULink<JAIStream>* i; + for (i = mStreamList.getFirst(); i != NULL; i = i->getNext()) { + if ((u32)i->getObject()->getID() == (u32)id) { + i->getObject()->stop(); + } + } +} + +void JAIStreamMgr::mixOut() { + JSULink<JAIStream>* i; + for (i = mStreamList.getFirst(); i != NULL; i = i->getNext()) { + i->getObject()->JAIStreamMgr_mixOut_(mParams.params_, mActivity); + } +} + +JAIStream* JAIStreamMgr::newStream_() { + if (mStreamAramMgr == NULL) { + JUT_WARN(229, "%s", "JAIStreamAramMgr must be set.\n"); + return NULL; + } + + JAIStream* stream = new JAIStream(this, field_0x6c); + if (stream == NULL) { + JUT_WARN(235, "%s", "JASPoolAllocObject::<JAIStream>::operator new failed .\n"); + return NULL; + } + + mStreamList.append(stream); + return stream; +} |
