| 326 | } |
| 327 | |
| 328 | sp<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 | |
| 360 | sp<MusicTrack> DataImpl::loadMusic(const UString &path) |
| 361 | { |
no test coverage detected