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

Method load

Source/Cache/AudioCache.cpp:44–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42}
43
44AudioFile* AudioCache::load(String filename) {
45 std::string fullPath = SharedContent.getFullPath(filename);
46 auto it = _audioFiles.find(fullPath);
47 if (it != _audioFiles.end()) {
48 return it->second;
49 }
50 auto data = SharedContent.load(fullPath);
51 if (!data.first) {
52 Error("failed to load sound file \"{}\".", filename.toString());
53 return nullptr;
54 }
55 AudioFile* audioFile = nullptr;
56 if (shouldStream(filename, data.second)) {
57 audioFile = WavStream::create(std::move(data.first), data.second);
58 } else {
59 audioFile = WavFile::create(std::move(data.first), data.second);
60 }
61 if (audioFile) {
62 _audioFiles[fullPath] = audioFile;
63 return audioFile;
64 } else {
65 Error("failed to load audio file \"{}\".", filename.toString());
66 return nullptr;
67 }
68}
69
70void AudioCache::loadAsync(String filename, const std::function<void(AudioFile*)>& handler) {
71 std::string fullPath = SharedContent.getFullPath(filename);

Callers

nothing calls this directly

Calls 9

shouldStreamFunction · 0.85
moveFunction · 0.85
getFullPathMethod · 0.80
findMethod · 0.65
loadMethod · 0.65
toStringMethod · 0.65
ErrorEnum · 0.50
createFunction · 0.50
endMethod · 0.45

Tested by

no test coverage detected