MCPcopy Create free account
hub / github.com/SFML/SFML / createReaderFromMemory

Method createReaderFromMemory

src/SFML/Audio/SoundFileFactory.cpp:78–99  ·  view source on GitHub ↗

///////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

76
77////////////////////////////////////////////////////////////
78std::unique_ptr<SoundFileReader> SoundFileFactory::createReaderFromMemory(const void* data, std::size_t sizeInBytes)
79{
80 // Wrap the memory file into a file stream
81 MemoryInputStream stream(data, sizeInBytes);
82
83 // Test the stream for all the registered factories
84 for (const auto& [fpCreate, fpCheck] : getReaderFactoryMap())
85 {
86 if (!stream.seek(0).has_value())
87 {
88 err() << "Failed to seek sound stream" << std::endl;
89 return nullptr;
90 }
91
92 if (fpCheck(stream))
93 return fpCreate();
94 }
95
96 // No suitable reader found
97 err() << "Failed to open sound file from memory (format not supported)" << std::endl;
98 return nullptr;
99}
100
101
102////////////////////////////////////////////////////////////

Callers

nothing calls this directly

Calls 1

seekMethod · 0.45

Tested by

no test coverage detected