MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / getPosition

Method getPosition

Engine/source/sfx/sfxVoice.cpp:263–289  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

261//-----------------------------------------------------------------------------
262
263U32 SFXVoice::getPosition() const
264{
265 // When stopped, always return 0.
266
267 if( getStatus() == SFXStatusStopped )
268 return 0;
269
270 // It depends on the device if and when it will return a count of the total samples
271 // played so far. With streaming buffers, all devices will do that. With non-streaming
272 // buffers, some may do for looping voices thus returning a number that exceeds the actual
273 // source stream size. So, clamp things into range here and also take care of any offsetting
274 // resulting from a setPosition() call.
275
276 U32 pos = _tell() + mOffset;
277 const U32 numStreamSamples = mBuffer->getFormat().getSampleCount( mBuffer->getDuration() );
278
279 if( mBuffer->mIsLooping )
280 pos %= numStreamSamples;
281 else if( pos > numStreamSamples )
282 {
283 // Ensure we never report out-of-range positions even if the device does.
284
285 pos = numStreamSamples;
286 }
287
288 return pos;
289}
290
291//-----------------------------------------------------------------------------
292

Callers 10

NetDelayEventMethod · 0.45
sendPacketMethod · 0.45
startDemoRecordMethod · 0.45
_assignVoicesMethod · 0.45
getElapsedPlayTimeMethod · 0.45
_onParameterEventMethod · 0.45
_scatterTransformMethod · 0.45
SFXAsyncStreamMethod · 0.45
updateMethod · 0.45

Calls 3

getSampleCountMethod · 0.45
getFormatMethod · 0.45
getDurationMethod · 0.45

Tested by

no test coverage detected