AudioFormat CAudioFormat::getFormatFromFilePath(const FilePath& path) const { if (!path.isEmpty()) { const String extension = FileSystem::Extension(path); for (const auto& audioFormat : m_audioFormats) { if (audioFormat->possibleExtexsions().includes(extension)) { return audioFormat->format(); } } } return AudioFormat::Unknown; }
Array<std::unique_ptr<IAudioFormat>>::const_iterator CAudioFormat::findFormat(const IReader& reader, const FilePath& pathHint) const { if (!reader.isOpened()) { return m_audioFormats.end(); } if (!reader.supportsLookahead()) { return m_audioFormats.end(); } uint8 header[16] = {}; if (!reader.lookahead(header)) { return m_audioFormats.end(); } for (auto it = m_audioFormats.begin(); it != m_audioFormats.end(); ++it) { if ((*it)->isHeader(header)) { return it; } } if (!pathHint.isEmpty()) { const String extension = FileSystem::Extension(pathHint); for (auto it = m_audioFormats.begin(); it != m_audioFormats.end(); ++it) { if ((*it)->possibleExtexsions().includes(extension)) { return it; } } } return m_audioFormats.end(); }