Esempio n. 1
0
Ref<AudioBuffer> AudioBuffer::read(AudioContext& context, const std::string& sampleName)
{
  ResourceCache& cache = context.cache();

  std::string name;
  name += "sample:";
  name += sampleName;

  if (Ref<AudioBuffer> buffer = cache.find<AudioBuffer>(name))
    return buffer;

  Ref<Sample> data = Sample::read(cache, sampleName);
  if (!data)
  {
    logError("Failed to read sample for buffer %s", name.c_str());
    return nullptr;
  }

  return create(ResourceInfo(cache, name), context, *data);
}