///////////////////////////////////////////////////////
| 46 | { |
| 47 | //////////////////////////////////////////////////////////// |
| 48 | std::unique_ptr<SoundFileReader> SoundFileFactory::createReaderFromFilename(const std::filesystem::path& filename) |
| 49 | { |
| 50 | // Wrap the input file into a file stream |
| 51 | FileInputStream stream; |
| 52 | if (!stream.open(filename)) |
| 53 | { |
| 54 | err() << "Failed to open sound file (couldn't open stream)\n" << formatDebugPathInfo(filename) << std::endl; |
| 55 | return nullptr; |
| 56 | } |
| 57 | |
| 58 | // Test the filename in all the registered factories |
| 59 | for (const auto& [fpCreate, fpCheck] : getReaderFactoryMap()) |
| 60 | { |
| 61 | if (!stream.seek(0).has_value()) |
| 62 | { |
| 63 | err() << "Failed to seek sound stream" << std::endl; |
| 64 | return nullptr; |
| 65 | } |
| 66 | |
| 67 | if (fpCheck(stream)) |
| 68 | return fpCreate(); |
| 69 | } |
| 70 | |
| 71 | // No suitable reader found |
| 72 | err() << "Failed to open sound file (format not supported)\n" << formatDebugPathInfo(filename) << std::endl; |
| 73 | return nullptr; |
| 74 | } |
| 75 | |
| 76 | |
| 77 | //////////////////////////////////////////////////////////// |
nothing calls this directly
no test coverage detected