MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Source_Stop

Method Source_Stop

Source/Engine/Audio/XAudio2/AudioBackendXAudio2.cpp:460–480  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

458}
459
460void AudioBackendXAudio2::Source_Stop(uint32 sourceID)
461{
462 auto aSource = XAudio2::GetSource(sourceID);
463 if (aSource && aSource->Voice)
464 {
465 aSource->StartTimeForQueueBuffer = 0.0f;
466 aSource->LastBufferStartTime = 0.0f;
467
468 // Pause
469 HRESULT hr = aSource->Voice->Stop();
470 XAUDIO2_CHECK_ERROR(Stop);
471 aSource->IsPlaying = false;
472
473 // Unset streaming buffers to rewind
474 hr = aSource->Voice->FlushSourceBuffers();
475 XAUDIO2_CHECK_ERROR(FlushSourceBuffers);
476 Platform::Sleep(10); // TODO: find a better way to handle case when VoiceCallback::OnBufferEnd is called after source was stopped thus BuffersProcessed != 0, probably via buffers contexts ptrs
477 aSource->BuffersProcessed = 0;
478 aSource->Callback.PeekSamples();
479 }
480}
481
482void AudioBackendXAudio2::Source_SetCurrentBufferTime(uint32 sourceID, float value)
483{

Callers

nothing calls this directly

Calls 3

GetSourceFunction · 0.85
PeekSamplesMethod · 0.80
StopMethod · 0.45

Tested by

no test coverage detected