just re-using this push function for torch incomming audio data. it empties the buffer in case torchlight stopped emitting instead of draining it over time
This commit is contained in:
parent
a02af1a297
commit
009962f120
@ -962,7 +962,7 @@ void CVoice::OnDataReceived(CClient *pClient, int16_t *pData, size_t Samples)
|
||||
Samples -= DataStartsAt;
|
||||
}
|
||||
|
||||
if(!m_Buffer.Push(pData, Samples))
|
||||
if(!m_Buffer.PushTorch(pData, Samples))
|
||||
{
|
||||
smutils->LogError(myself, "Buffer push failed!!! Samples: %u, Free: %u\n", Samples, m_Buffer.CurrentFree());
|
||||
return;
|
||||
@ -1065,7 +1065,7 @@ void CVoice::HandleVoiceData()
|
||||
smutils->LogError(myself, "Opus encode failed: %s", opus_strerror(nbBytes));
|
||||
return;
|
||||
}
|
||||
BroadcastVoiceDataCelt(pClient, aBuffer, SamplesPerChannel);
|
||||
BroadcastVoiceDataTorchlightCelt(pClient, aBuffer, SamplesPerChannel);
|
||||
|
||||
// Write frame size
|
||||
*pFrameSize = (uint16_t)nbBytes;
|
||||
@ -1120,7 +1120,7 @@ void CVoice::HandleVoiceData()
|
||||
}
|
||||
}
|
||||
|
||||
void CVoice::BroadcastVoiceDataCelt(IClient *pClient, int16_t *pPCM, int nSamples)
|
||||
void CVoice::BroadcastVoiceDataTorchlightCelt(IClient *pClient, int16_t *pPCM, int nSamples)
|
||||
{
|
||||
// pPCM is stereo interleaved at 48000 Hz (SamplesPerChannel * 2 total samples)
|
||||
// Downsample to mono 22050 Hz and accumulate into m_torchMonoAccum
|
||||
@ -1172,7 +1172,7 @@ void CVoice::BroadcastVoiceDataCelt(IClient *pClient, int16_t *pPCM, int nSample
|
||||
}
|
||||
else
|
||||
{
|
||||
smutils->LogError(myself, "BroadcastVoiceDataCelt: celt_encode failed: %d", celtBytes);
|
||||
smutils->LogError(myself, "BroadcastVoiceDataTorchlightCelt: celt_encode failed: %d", celtBytes);
|
||||
}
|
||||
|
||||
m_torchMonoAccumLen -= CELT_FRAME_SIZE;
|
||||
|
||||
@ -140,7 +140,7 @@ public:
|
||||
|
||||
void ListenSocket();
|
||||
void PushPlayerVoiceData(int playerSlot, int nBytes, char *data);
|
||||
void BroadcastVoiceDataCelt(IClient *pClient, int16_t *pPCM, int nSamples);
|
||||
void BroadcastVoiceDataTorchlightCelt(IClient *pClient, int16_t *pPCM, int nSamples);
|
||||
void TranscodeNoSteamToSteam(int playerSlot, int nBytes, char *data);
|
||||
void HandlePlayerVoiceData(int playerSlot);
|
||||
|
||||
|
||||
@ -65,8 +65,7 @@ void CRingBuffer::Mix(int16_t *pData, size_t Samples)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
bool CRingBuffer::Push(int16_t *pData, size_t Samples)
|
||||
bool CRingBuffer::PushTorch(int16_t *pData, size_t Samples)
|
||||
{
|
||||
if(Samples > CurrentFree())
|
||||
return false;
|
||||
@ -127,7 +126,6 @@ bool CRingBuffer::Push(int16_t *pData, size_t Samples)
|
||||
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
bool CRingBuffer::Push(int16_t *pData, size_t Samples)
|
||||
{
|
||||
|
||||
@ -12,6 +12,7 @@ public:
|
||||
|
||||
bool Pop(int16_t *pData, size_t Samples);
|
||||
bool Push(int16_t *pData, size_t BufLen);
|
||||
bool PushTorch(int16_t *pData, size_t BufLen);
|
||||
|
||||
size_t TotalLength();
|
||||
size_t TotalFree();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user