MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / WSSLoadFile

Function WSSLoadFile

engine/Poseidon/Audio/Streaming/WaveLoaders.cpp:29–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27};
28
29WaveStream* WSSLoadFile(const char* name)
30{
31 QIFStream in;
32 GFileServer->Open(in, name);
33 if (in.fail() || in.eof())
34 {
35 return nullptr;
36 }
37 WSSHeader wHeader;
38 WAVEFORMATEX header;
39 in.read(reinterpret_cast<char*>(&wHeader), sizeof(wHeader));
40 if (wHeader.magic != WSSMagic)
41 {
42 in.seekg(-static_cast<int>(sizeof(wHeader)), QIOS::cur); // Intentional: seek backward
43 wHeader.deltaPack = 0;
44 }
45 int deltaPack = wHeader.deltaPack;
46 in.read(reinterpret_cast<char*>(&header), sizeof(header));
47 if (in.fail() || in.eof())
48 {
49 return nullptr;
50 }
51 header.cbSize = 0;
52 IFileBuffer* fBuffer = in.GetBuffer();
53
54 if (in.fail() || in.eof())
55 {
56 return nullptr;
57 }
58 if (in.rest() <= 0)
59 {
60 return nullptr;
61 }
62 // Return part of file buffer
63
64 WaveBuffer buffer(fBuffer, header, in.tellg(), in.rest(), deltaPack);
65 return new WaveStreamPlain(buffer);
66}
67
68} // namespace Poseidon

Callers 2

SoundLoadFileFunction · 0.85

Calls 8

seekgMethod · 0.80
restMethod · 0.80
tellgMethod · 0.80
OpenMethod · 0.45
failMethod · 0.45
eofMethod · 0.45
readMethod · 0.45
GetBufferMethod · 0.45

Tested by

no test coverage detected