MCPcopy Create free account
hub / github.com/crownengine/crown / EnsureSources

Function EnsureSources

3rdparty/openal/al/source.cpp:497–520  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

495
496
497bool EnsureSources(ALCcontext *context, size_t needed)
498{
499 size_t count{std::accumulate(context->mSourceList.cbegin(), context->mSourceList.cend(),
500 size_t{0},
501 [](size_t cur, const SourceSubList &sublist) noexcept -> size_t
502 { return cur + static_cast<ALuint>(POPCNT64(sublist.FreeMask)); }
503 )};
504
505 while(needed > count)
506 {
507 if UNLIKELY(context->mSourceList.size() >= 1<<25)
508 return false;
509
510 context->mSourceList.emplace_back();
511 auto sublist = context->mSourceList.end() - 1;
512 sublist->FreeMask = ~0_u64;
513 sublist->Sources = static_cast<ALsource*>(al_calloc(alignof(ALsource), sizeof(ALsource)*64));
514 if UNLIKELY(!sublist->Sources)
515 {
516 context->mSourceList.pop_back();
517 return false;
518 }
519 count += 64;
520 }
521 return true;
522}
523

Callers 1

source.cppFile · 0.85

Calls 7

al_callocFunction · 0.85
cbeginMethod · 0.45
cendMethod · 0.45
sizeMethod · 0.45
emplace_backMethod · 0.45
endMethod · 0.45
pop_backMethod · 0.45

Tested by

no test coverage detected