MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / load

Method load

src/Core/Audio/AudioManager.cpp:24–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22 }
23
24 Sound AudioManager::load(const System::Path& path, LoadPolicy loadPolicy)
25 {
26 const std::string filePath = path.find(System::PathType::File);
27 Debug::Log->debug("<AudioManager> Loading Audio at '{}'", filePath);
28 if (filePath.empty())
29 {
30 throw Exceptions::AudioFileNotFound(
31 path.toString(), System::MountablePath::StringPaths(), EXC_INFO);
32 }
33
34 if (loadPolicy == LoadPolicy::Cache && m_cache.find(filePath) == m_cache.end())
35 {
36 std::shared_ptr<SoLoud::Wav> sample = std::make_shared<SoLoud::Wav>();
37 sample->load(filePath.c_str());
38 m_cache[filePath] = sample;
39 }
40 std::shared_ptr<SoLoud::AudioSource> sample;
41 if (m_cache.find(filePath) != m_cache.end())
42 {
43 sample = m_cache[filePath];
44 }
45 else
46 {
47 if (loadPolicy == LoadPolicy::Stream)
48 {
49 sample = std::make_shared<SoLoud::WavStream>();
50 dynamic_cast<SoLoud::WavStream*>(sample.get())->load(filePath.c_str());
51 }
52 else
53 {
54 sample = std::make_shared<SoLoud::Wav>();
55 dynamic_cast<SoLoud::Wav*>(sample.get())->load(filePath.c_str());
56 }
57 }
58 return Sound(m_engine, std::move(sample));
59 }
60}

Callers

nothing calls this directly

Calls 9

AudioFileNotFoundClass · 0.85
debugMethod · 0.80
SoundClass · 0.50
findMethod · 0.45
emptyMethod · 0.45
toStringMethod · 0.45
endMethod · 0.45
c_strMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected