MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / play

Method play

Source/Node/AudioSource.cpp:171–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

169}
170
171bool AudioSource::play(double delayTime) {
172 AssertIf(_flags.isOn(Node::Cleanup), "can not operate on an invalid AudioSource");
173 if (_handle != 0 && SharedAudio.isVoicePlaying(_handle)) {
174 return false;
175 }
176 _is3D = false;
177 if (auto audioFile = SharedAudioCache.load(_filename)) {
178 uint32_t busHandle = _bus ? _bus->getHandle() : 0;
179 auto soloud = SharedAudio.getSoLoud();
180 if (delayTime <= 0) {
181 _handle = soloud->play(*audioFile->getSource(), _volume, _pan, false, busHandle);
182 } else {
183 _handle = soloud->playClocked(delayTime, *audioFile->getSource(), _volume, _pan, busHandle);
184 }
185 if (_protected) {
186 soloud->setProtectVoice(_handle, true);
187 }
188 if (_playSpeed != 1.0f) {
189 soloud->setRelativePlaySpeed(_handle, _playSpeed);
190 }
191 if (_loopStartTime > 0.0) {
192 soloud->setLoopPoint(_handle, _loopStartTime);
193 }
194 WRef<AudioSource> self(this);
195 SharedAudio.addRef(_handle, audioFile, [self](uint32_t handle) {
196 if (self && self->_handle == handle) {
197 self->_handle = 0;
198 self->emit("AudioEnd"sv, handle);
199 if (self->_autoRemove) {
200 self->removeFromParent();
201 }
202 }
203 });
204 return true;
205 }
206 return false;
207}
208
209bool AudioSource::play3D(double delayTime) {
210 AssertIf(_flags.isOn(Node::Cleanup), "can not operate on an invalid AudioSource");

Callers

nothing calls this directly

Calls 13

isOnMethod · 0.80
isVoicePlayingMethod · 0.80
getSoLoudMethod · 0.80
setProtectVoiceMethod · 0.80
setRelativePlaySpeedMethod · 0.80
addRefMethod · 0.80
removeFromParentMethod · 0.80
loadMethod · 0.65
getHandleMethod · 0.45
getSourceMethod · 0.45
playClockedMethod · 0.45
setLoopPointMethod · 0.45

Tested by

no test coverage detected