| 8 | } |
| 9 | |
| 10 | void HapticsBuffer::AddSamples(const ovrHapticsBuffer* buffer) |
| 11 | { |
| 12 | uint8_t* samples = (uint8_t*)buffer->Samples; |
| 13 | |
| 14 | for (int i = 0; i < buffer->SamplesCount; i++) |
| 15 | { |
| 16 | if (m_WriteIndex == m_ReadIndex) |
| 17 | return; |
| 18 | |
| 19 | m_Buffer[m_WriteIndex] = samples[i]; |
| 20 | |
| 21 | // We increment the atomic here as a memory barrier |
| 22 | // Index will overflow correctly, so no need for a modulo operator |
| 23 | m_WriteIndex++; |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | float HapticsBuffer::GetSample() |
| 28 | { |