MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / loadAsync

Method loadAsync

Source/Cache/AudioCache.cpp:70–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68}
69
70void AudioCache::loadAsync(String filename, const std::function<void(AudioFile*)>& handler) {
71 std::string fullPath = SharedContent.getFullPath(filename);
72 std::string file(filename.toString());
73 SharedContent.loadAsyncUnsafe(fullPath, [this, file, fullPath, handler](uint8_t* data, int64_t size) {
74 auto fileSize = s_cast<size_t>(size);
75 AudioFile* audioFile = nullptr;
76 if (shouldStream(fullPath, fileSize)) {
77 audioFile = WavStream::create(MakeOwnArray(data), fileSize);
78 } else {
79 audioFile = WavFile::create(MakeOwnArray(data), fileSize);
80 }
81 if (audioFile) {
82 _audioFiles[fullPath] = audioFile;
83 handler(audioFile);
84 } else {
85 Error("failed to load sound file \"{}\".", file);
86 handler(nullptr);
87 }
88 });
89}
90
91bool AudioCache::unload(AudioFile* audioFile) {
92 for (const auto& it : _audioFiles) {

Callers

nothing calls this directly

Calls 8

shouldStreamFunction · 0.85
MakeOwnArrayFunction · 0.85
handlerFunction · 0.85
getFullPathMethod · 0.80
loadAsyncUnsafeMethod · 0.80
toStringMethod · 0.65
createFunction · 0.50
ErrorEnum · 0.50

Tested by

no test coverage detected