///////////////////////////////////////////////////////
| 101 | |
| 102 | //////////////////////////////////////////////////////////// |
| 103 | std::unique_ptr<SoundFileReader> SoundFileFactory::createReaderFromStream(InputStream& stream) |
| 104 | { |
| 105 | // Test the stream for all the registered factories |
| 106 | for (const auto& [fpCreate, fpCheck] : getReaderFactoryMap()) |
| 107 | { |
| 108 | if (!stream.seek(0).has_value()) |
| 109 | { |
| 110 | err() << "Failed to seek sound stream" << std::endl; |
| 111 | return nullptr; |
| 112 | } |
| 113 | |
| 114 | if (fpCheck(stream)) |
| 115 | return fpCreate(); |
| 116 | } |
| 117 | |
| 118 | // No suitable reader found |
| 119 | err() << "Failed to open sound file from stream (format not supported)" << std::endl; |
| 120 | return nullptr; |
| 121 | } |
| 122 | |
| 123 | |
| 124 | //////////////////////////////////////////////////////////// |