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

Function WaveLoadFile

engine/Poseidon/Audio/Core/Format/WaveFile.cpp:246–282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

244}
245
246WaveStream* WaveLoadFile(const char* filename)
247{
248 QIFStreamB file;
249 file.AutoOpen(filename);
250 WaveFile input;
251 input.Open(file);
252 if (input.GetError())
253 {
254 return nullptr;
255 }
256
257 // check file format
258
259 if (input.Format().wFormatTag == WAVE_FORMAT_PCM)
260 {
261 input.StartDataRead();
262 if (input.GetError())
263 {
264 return nullptr;
265 }
266
267 IFileBuffer* fBuffer = input.GetBuffer();
268 // return part of file buffer
269 WaveBuffer buffer(fBuffer, input.Format(), input.DataOffset(), input.DataSize(), 0);
270 return new WaveStreamPlain(buffer);
271 }
272 else
273 {
274#if ENABLE_ACM_CODECS
275 // pass it to Codec processing
276 return new WaveStreamCodec(file);
277#else
278 LOG_ERROR(Audio, "non-PCM format {}", input.Format().wFormatTag);
279 return nullptr;
280#endif
281 }
282}
283
284} // namespace Poseidon

Callers 2

SoundLoadFileFunction · 0.85
test_wave_file.cppFile · 0.85

Calls 7

AutoOpenMethod · 0.80
StartDataReadMethod · 0.80
DataOffsetMethod · 0.80
DataSizeMethod · 0.80
OpenMethod · 0.45
GetErrorMethod · 0.45
GetBufferMethod · 0.45

Tested by

no test coverage detected