Add a voice flag to indicate a voice has a pending stop

Pending/asynchronous stops to be implemented soon.
This commit is contained in:
Chris Robinson
2020-02-20 19:18:07 -08:00
parent 642ef4edc9
commit acf7f6f74e
2 changed files with 11 additions and 6 deletions
+4 -2
View File
@@ -2682,7 +2682,8 @@ START_API_FUNC
auto count_free_voices = [](const ALuint count, const ALvoice &voice) noexcept -> ALuint
{
if(voice.mPlayState.load(std::memory_order_acquire) == ALvoice::Stopped
&& voice.mSourceID.load(std::memory_order_relaxed) == 0u)
&& voice.mSourceID.load(std::memory_order_relaxed) == 0u
&& voice.mPendingStop.load(std::memory_order_relaxed) == false)
return count + 1;
return count;
};
@@ -2760,7 +2761,8 @@ START_API_FUNC
auto find_voice = [](const ALvoice &v) noexcept -> bool
{
return v.mPlayState.load(std::memory_order_acquire) == ALvoice::Stopped
&& v.mSourceID.load(std::memory_order_relaxed) == 0u;
&& v.mSourceID.load(std::memory_order_relaxed) == 0u
&& v.mPendingStop.load(std::memory_order_relaxed) == false;
};
auto voices_end = context->mVoices.data() + context->mVoices.size();
voice = std::find_if(context->mVoices.data(), voices_end, find_voice);
+7 -4
View File
@@ -199,10 +199,11 @@ struct ALvoice {
std::atomic<ALvoiceProps*> mUpdate{nullptr};
ALvoicePropsBase mProps;
std::atomic<ALuint> mSourceID{0u};
std::atomic<State> mPlayState{Stopped};
ALvoicePropsBase mProps;
std::atomic<bool> mPendingStop{false};
/**
* Source offset in samples, relative to the currently playing buffer, NOT
@@ -268,11 +269,13 @@ struct ALvoice {
mUpdate.store(rhs.mUpdate.exchange(old_update, std::memory_order_relaxed),
std::memory_order_relaxed);
mProps = rhs.mProps;
mSourceID.store(rhs.mSourceID.load(std::memory_order_relaxed), std::memory_order_relaxed);
mPlayState.store(rhs.mPlayState.load(std::memory_order_relaxed),
std::memory_order_relaxed);
mProps = rhs.mProps;
mPendingStop.store(rhs.mPendingStop.load(std::memory_order_relaxed),
std::memory_order_relaxed);
mPosition.store(rhs.mPosition.load(std::memory_order_relaxed), std::memory_order_relaxed);
mPositionFrac.store(rhs.mPositionFrac.load(std::memory_order_relaxed),