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

Method UnloadSample

src/engine/client/sound.cpp:667–698  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

665}
666
667void CSound::UnloadSample(int SampleId)
668{
669 if(SampleId == -1)
670 return;
671
672 dbg_assert(SampleId >= 0 && SampleId < NUM_SAMPLES, "SampleId invalid");
673 const CLockScope LockScope(m_SoundLock);
674 CSample &Sample = m_aSamples[SampleId];
675
676 if(Sample.IsLoaded())
677 {
678 // Stop voices using this sample
679 for(auto &Voice : m_aVoices)
680 {
681 if(Voice.m_pSample == &Sample)
682 {
683 Voice.m_pSample = nullptr;
684 }
685 }
686
687 // Free data
688 free(Sample.m_pData);
689 Sample.m_pData = nullptr;
690 }
691
692 // Free slot
693 if(Sample.m_NextFreeSampleIndex == SAMPLE_INDEX_USED)
694 {
695 Sample.m_NextFreeSampleIndex = m_FirstFreeSampleIndex;
696 m_FirstFreeSampleIndex = Sample.m_Index;
697 }
698}
699
700float CSound::GetSampleTotalTime(int SampleId)
701{

Callers 5

ClearMethod · 0.80
ReplaceSoundMethod · 0.80
OnDialogCloseMethod · 0.80
UpdateFilePreviewMethod · 0.80
~CEditorSoundMethod · 0.80

Calls 1

IsLoadedMethod · 0.45

Tested by

no test coverage detected