| 244 | } |
| 245 | |
| 246 | WaveStream* 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 |
no test coverage detected