Make the voice count unsigned

This commit is contained in:
Chris Robinson
2019-06-09 19:27:15 -07:00
parent bc8f206ee1
commit ec6fdff0c6
3 changed files with 5 additions and 5 deletions
+2 -2
View File
@@ -2606,7 +2606,7 @@ void AllocateVoices(ALCcontext *context, size_t num_voices)
voices.reset(new (ptr) al::FlexArray<ALvoice>{num_voices});
}
const ALsizei v_count{mini(context->VoiceCount.load(std::memory_order_relaxed), num_voices)};
const size_t v_count{minz(context->VoiceCount.load(std::memory_order_relaxed), num_voices)};
if(context->Voices)
{
/* Copy the old voice data to the new storage. */
@@ -2631,7 +2631,7 @@ void AllocateVoices(ALCcontext *context, size_t num_voices)
}
context->Voices = std::move(voices);
context->VoiceCount.store(v_count, std::memory_order_relaxed);
context->VoiceCount.store(static_cast<ALuint>(v_count), std::memory_order_relaxed);
}
+1 -1
View File
@@ -117,7 +117,7 @@ struct ALCcontext {
std::atomic<ALeffectslotProps*> FreeEffectslotProps{nullptr};
std::unique_ptr<al::FlexArray<ALvoice>> Voices{nullptr};
std::atomic<ALsizei> VoiceCount{0};
std::atomic<ALuint> VoiceCount{0u};
using ALeffectslotArray = al::FlexArray<ALeffectslot*>;
std::atomic<ALeffectslotArray*> ActiveAuxSlots{nullptr};
+2 -2
View File
@@ -58,7 +58,7 @@ using namespace std::placeholders;
inline ALvoice *GetSourceVoice(ALsource *source, ALCcontext *context)
{
ALint idx{source->VoiceIdx};
if(idx >= 0 && idx < context->VoiceCount.load(std::memory_order_relaxed))
if(idx >= 0 && static_cast<ALuint>(idx) < context->VoiceCount.load(std::memory_order_relaxed))
{
ALuint sid{source->id};
ALvoice &voice = (*context->Voices)[idx];
@@ -2799,7 +2799,7 @@ START_API_FUNC
{
/* Allocate more voices to get enough. */
const size_t alloc_count{need_voices - rem_voices};
if(UNLIKELY(context->Voices->size() > std::numeric_limits<size_t>::max()-alloc_count))
if(UNLIKELY(context->Voices->size() > std::numeric_limits<ALsizei>::max()-alloc_count))
SETERR_RETURN(context.get(), AL_OUT_OF_MEMORY,,
"Overflow increasing voice count to %zu + %zu", context->Voices->size(),
alloc_count);