MCPcopy Create free account
hub / github.com/FastLED/FastLED / loadTestAudioFile

Function loadTestAudioFile

tests/fl/codec/vorbis.hpp:22–48  ·  view source on GitHub ↗

Helper function to load test audio file into memory

Source from the content-addressed store, hash-verified

20
21// Helper function to load test audio file into memory
22static fl::vector<fl::u8> loadTestAudioFile() {
23 fl::FILE* f = fl::fopen(TEST_AUDIO_PATH, "rb");
24 if (!f) {
25 return fl::vector<fl::u8>();
26 }
27
28 // Get file size
29 fl::fseek(f, 0, fl::io::seek_end);
30 long fileSize = fl::ftell(f);
31 fl::fseek(f, 0, fl::io::seek_set);
32
33 if (fileSize <= 0) {
34 fl::fclose(f);
35 return fl::vector<fl::u8>();
36 }
37
38 // Read file into vector
39 fl::vector<fl::u8> data(static_cast<fl::size>(fileSize));
40 fl::size bytesRead = fl::fread(data.data(), 1, static_cast<fl::size>(fileSize), f);
41 fl::fclose(f);
42
43 if (bytesRead != static_cast<fl::size>(fileSize)) {
44 return fl::vector<fl::u8>();
45 }
46
47 return data;
48}
49
50FL_TEST_CASE("Vorbis - factory creation") {
51 // Test that the factory can create a decoder

Callers 1

vorbis.hppFile · 0.85

Calls 6

fopenFunction · 0.85
fseekFunction · 0.85
ftellFunction · 0.85
fcloseFunction · 0.85
freadFunction · 0.85
dataMethod · 0.45

Tested by

no test coverage detected