MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / loadSample

Method loadSample

framework/data.cpp:328–358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

326}
327
328sp<Sample> DataImpl::loadSample(UString path)
329{
330 std::lock_guard<std::recursive_mutex> l(this->sampleCacheLock);
331
332 auto alias = this->sampleAliases.find(path);
333 if (alias != this->sampleAliases.end())
334 {
335 LogInfo("Using alias \"%s\" for \"%s\"", path, alias->second);
336 return this->loadSample(alias->second);
337 }
338
339 UString cacheKey = to_upper(path);
340 sp<Sample> sample = this->sampleCache[cacheKey].lock();
341 if (sample)
342 return sample;
343
344 for (auto &loader : this->sampleLoaders)
345 {
346 sample = loader->loadSample(path);
347 if (sample)
348 break;
349 }
350 if (!sample)
351 {
352 LogInfo("Failed to load sample \"%s\"", path);
353 return nullptr;
354 }
355 this->sampleCache[cacheKey] = sample;
356 sample->path = path;
357 return sample;
358}
359
360sp<MusicTrack> DataImpl::loadMusic(const UString &path)
361{

Callers 11

serializeInFunction · 0.45
extractAgentTypesMethod · 0.45
extractAgentEquipmentMethod · 0.45
getFromLuaFunction · 0.45
TriStateBoxMethod · 0.45
GraphicButtonMethod · 0.45
ScrollBarMethod · 0.45
CheckBoxMethod · 0.45
TextButtonMethod · 0.45

Calls 2

to_upperFunction · 0.85
endMethod · 0.80

Tested by

no test coverage detected