MCPcopy Create free account
hub / github.com/ddnet/ddnet / GetSampleCurrentTime

Method GetSampleCurrentTime

src/engine/client/sound.cpp:709–725  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

707}
708
709float CSound::GetSampleCurrentTime(int SampleId)
710{
711 dbg_assert(SampleId >= 0 && SampleId < NUM_SAMPLES, "SampleId invalid");
712
713 const CLockScope LockScope(m_SoundLock);
714 dbg_assert(m_aSamples[SampleId].IsLoaded(), "Sample not loaded");
715 CSample *pSample = &m_aSamples[SampleId];
716 for(auto &Voice : m_aVoices)
717 {
718 if(Voice.m_pSample == pSample)
719 {
720 return Voice.m_Tick / (float)pSample->m_Rate;
721 }
722 }
723
724 return pSample->m_PausedAt / (float)pSample->m_Rate;
725}
726
727void CSound::SetSampleCurrentTime(int SampleId, float Time)
728{

Callers 1

DoAudioPreviewMethod · 0.80

Calls 1

IsLoadedMethod · 0.45

Tested by

no test coverage detected