further attempts at improving the voice chat quality for nosteamers from steam players, but still not good
This commit is contained in:
@@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user