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

Method check

src/SFML/Audio/SoundFileReaderFlac.cpp:260–290  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

258
259////////////////////////////////////////////////////////////
260bool SoundFileReaderFlac::check(InputStream& stream)
261{
262 // Create a decoder
263 FLAC__StreamDecoder* decoder = FLAC__stream_decoder_new();
264 if (!decoder)
265 return false;
266
267 // Initialize the decoder with our callbacks
268 ClientData data;
269 data.stream = &stream;
270 data.error = false;
271 FLAC__stream_decoder_init_stream(decoder,
272 &streamRead,
273 &streamSeek,
274 &streamTell,
275 &streamLength,
276 &streamEof,
277 &streamWrite,
278 nullptr,
279 &streamError,
280 &data);
281
282 // Read the header
283 const bool valid = FLAC__stream_decoder_process_until_end_of_metadata(decoder) != 0;
284
285 // Destroy the decoder
286 FLAC__stream_decoder_finish(decoder);
287 FLAC__stream_decoder_delete(decoder);
288
289 return valid && !data.error;
290}
291
292
293////////////////////////////////////////////////////////////

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected