MCPcopy Create free account
hub / github.com/axmolengine/axmol / getWriteVector

Method getWriteVector

3rdparty/openal/common/ringbuffer.cpp:194–223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192}
193
194auto RingBuffer::getWriteVector() const noexcept -> DataPair
195{
196 DataPair ret;
197
198 std::size_t w{mWritePtr.load(std::memory_order_acquire)};
199 std::size_t r{mReadPtr.load(std::memory_order_acquire) + mWriteSize - mSizeMask};
200 w &= mSizeMask;
201 r &= mSizeMask;
202 const std::size_t free_cnt{(r-w-1) & mSizeMask};
203
204 const std::size_t cnt2{w + free_cnt};
205 if(cnt2 > mSizeMask+1)
206 {
207 /* Two part vector: the rest of the buffer after the current write ptr,
208 * plus some from the start of the buffer. */
209 ret.first.buf = const_cast<std::byte*>(mBuffer.data() + w*mElemSize);
210 ret.first.len = mSizeMask+1 - w;
211 ret.second.buf = const_cast<std::byte*>(mBuffer.data());
212 ret.second.len = cnt2 & mSizeMask;
213 }
214 else
215 {
216 ret.first.buf = const_cast<std::byte*>(mBuffer.data() + w*mElemSize);
217 ret.first.len = free_cnt;
218 ret.second.buf = nullptr;
219 ret.second.len = 0;
220 }
221
222 return ret;
223}

Callers 14

StopEventThrdFunction · 0.80
SendSourceStoppedEventFunction · 0.80
voice.cppFile · 0.80
CalcEffectSlotParamsFunction · 0.80
SendSourceStateEventFunction · 0.80
handleDisconnectMethod · 0.80
mixerProcMethod · 0.80
recordProcMethod · 0.80
availableSamplesMethod · 0.80
mixerProcMethod · 0.80
openMethod · 0.80
resetMethod · 0.80

Calls 2

loadMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected