MCPcopy Create free account
hub / github.com/axmolengine/axmol / wav_scan_chunk

Function wav_scan_chunk

core/audio/AudioDecoderWav.cpp:53–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51 {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
52
53static bool wav_scan_chunk(WAV_FILE* wavf, uint32_t chunkID, void* header, void* body, uint32_t bodySize)
54{
55 auto& fs = wavf->Stream;
56 auto h = (WAV_CHUNK_HEADER*)header;
57 for (; fs->read(h, WAV_HEADER_SIZE) == WAV_HEADER_SIZE;)
58 {
59 wavf->PcmDataOffset += WAV_HEADER_SIZE;
60 if (h->ChunkID == chunkID)
61 { // chunk found
62 if (body)
63 { // require read body?
64 auto readsize = (std::min)(bodySize, h->ChunkSize);
65 fs->read(body, readsize);
66 if (h->ChunkSize > bodySize)
67 fs->seek(h->ChunkSize - bodySize, SEEK_CUR);
68 wavf->PcmDataOffset += h->ChunkSize;
69 }
70 return true;
71 }
72 else
73 {
74 // Skip other non specified chunk
75 fs->seek(h->ChunkSize, SEEK_CUR);
76 wavf->PcmDataOffset += h->ChunkSize;
77 }
78 }
79 return false;
80}
81static bool wav_open(std::string_view fullPath, WAV_FILE* wavf)
82{
83 wavf->Stream = FileUtils::getInstance()->openFileStream(fullPath, IFileStream::Mode::READ);

Callers 1

wav_openFunction · 0.85

Calls 2

readMethod · 0.45
seekMethod · 0.45

Tested by

no test coverage detected