| 281 | |
| 282 | |
| 283 | bool EnsureBuffers(ALCdevice *device, size_t needed) |
| 284 | { |
| 285 | size_t count{std::accumulate(device->BufferList.cbegin(), device->BufferList.cend(), size_t{0}, |
| 286 | [](size_t cur, const BufferSubList &sublist) noexcept -> size_t |
| 287 | { return cur + static_cast<ALuint>(POPCNT64(sublist.FreeMask)); } |
| 288 | )}; |
| 289 | |
| 290 | while(needed > count) |
| 291 | { |
| 292 | if UNLIKELY(device->BufferList.size() >= 1<<25) |
| 293 | return false; |
| 294 | |
| 295 | device->BufferList.emplace_back(); |
| 296 | auto sublist = device->BufferList.end() - 1; |
| 297 | sublist->FreeMask = ~0_u64; |
| 298 | sublist->Buffers = static_cast<ALbuffer*>(al_calloc(alignof(ALbuffer), sizeof(ALbuffer)*64)); |
| 299 | if UNLIKELY(!sublist->Buffers) |
| 300 | { |
| 301 | device->BufferList.pop_back(); |
| 302 | return false; |
| 303 | } |
| 304 | count += 64; |
| 305 | } |
| 306 | return true; |
| 307 | } |
| 308 |
no test coverage detected