further attempts at improving the voice chat quality for nosteamers from steam players, but still not good

This commit is contained in:
2026-06-01 01:37:09 +01:00
parent 2184fd917a
commit 7d46e3b9eb
3 changed files with 161 additions and 162 deletions
+30
View File
@@ -65,6 +65,7 @@ void CRingBuffer::Mix(int16_t *pData, size_t Samples)
}
}
/*
bool CRingBuffer::Push(int16_t *pData, size_t Samples)
{
if(Samples > CurrentFree())
@@ -126,6 +127,35 @@ bool CRingBuffer::Push(int16_t *pData, size_t Samples)
return true;
}
*/
bool CRingBuffer::Push(int16_t *pData, size_t Samples)
{
if(Samples > CurrentFree())
return false; // Safely drop if buffer overflows, preventing distortion
if(m_WriteIndex + Samples > m_BufferSize)
{
size_t TowardsEnd = m_BufferSize - m_WriteIndex;
memcpy(&m_aBuffer[m_WriteIndex], pData, TowardsEnd * sizeof(*m_aBuffer));
m_WriteIndex = 0;
size_t Left = Samples - TowardsEnd;
memcpy(m_aBuffer, &pData[TowardsEnd], Left * sizeof(*m_aBuffer));
m_WriteIndex = Left;
}
else
{
memcpy(&m_aBuffer[m_WriteIndex], pData, Samples * sizeof(*m_aBuffer));
m_WriteIndex += Samples;
}
if(m_WriteIndex == m_BufferSize)
m_WriteIndex = 0;
m_Length += Samples;
return true;
}
size_t CRingBuffer::TotalLength()
{