| 69 | } |
| 70 | |
| 71 | std::unique_ptr<AudioSeCache> AudioSeCache::Create(Filesystem_Stream::InputStream stream, std::string_view name) { |
| 72 | auto se = std::make_unique<AudioSeCache>(); |
| 73 | se->name = ToString(name); |
| 74 | |
| 75 | auto const it = cache.find(ToString(name)); |
| 76 | if (it == cache.end()) { |
| 77 | // Not in cache |
| 78 | if (!stream) { |
| 79 | return {}; |
| 80 | } |
| 81 | |
| 82 | se->audio_decoder = AudioDecoder::Create(stream, false); |
| 83 | |
| 84 | if (se->audio_decoder) { |
| 85 | if (!se->audio_decoder->Open(std::move(stream))) { |
| 86 | se->audio_decoder.reset(); |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | if (!se->audio_decoder) { |
| 91 | return {}; |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | return se; |
| 96 | } |
| 97 | |
| 98 | void AudioSeCache::GetFormat(int& frequency, AudioDecoder::Format& format, int& channels) const { |
| 99 | if (!audio_decoder) { |