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

Method _releaseVoice

Engine/source/sfx/sfxSound.cpp:345–390  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

343//-----------------------------------------------------------------------------
344
345bool SFXSound::_releaseVoice()
346{
347 if( !mVoice )
348 return true;
349
350 // Refuse to release a voice for a streaming buffer that
351 // is not coming from a profile. For streaming buffers, we will
352 // have to release the buffer, too, and without a profile we don't
353 // know how to recreate the stream.
354
355 if( isStreaming() && !mTrack )
356 return false;
357
358 // If we're currently playing, transfer our playback position
359 // to the playtimer so we can virtualize playback while not
360 // having a voice.
361
362 SFXStatus status = getLastStatus();
363 if( status == SFXStatusPlaying || status == SFXStatusBlocked )
364 {
365 // Sync up the play timer with the voice's current position to make
366 // sure we handle any lag that's cropped up.
367
368 mPlayTimer.setPosition( mVoice->getPosition() );
369
370 if( status == SFXStatusBlocked )
371 status = SFXStatusPlaying;
372 }
373
374 mVoice = NULL;
375
376 // If this is a streaming source, release our buffer, too.
377 // Otherwise the voice will stick around as it is uniquely assigned to
378 // the buffer. When we get reassigned a voice, we will have to do
379 // a full stream seek anyway, so it's no real loss here.
380
381 if( isStreaming() )
382 mBuffer = NULL;
383
384 #ifdef DEBUG_SPEW
385 Platform::outputDebugString( "[SFXSound] release voice for source '%i' (status: %s)",
386 getId(), SFXStatusToString( status ) );
387 #endif
388
389 return true;
390}
391
392//-----------------------------------------------------------------------------
393

Callers 2

deleteDeviceMethod · 0.80
_assignVoicesMethod · 0.80

Calls 3

SFXStatusToStringFunction · 0.85
setPositionMethod · 0.45
getPositionMethod · 0.45

Tested by

no test coverage detected