1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
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;
}
|