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;
|
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());
|
smutils->LogError(myself, "Buffer push failed!!! Samples: %u, Free: %u\n", Samples, m_Buffer.CurrentFree());
|
||||||
return;
|
return;
|
||||||
@ -1065,7 +1065,7 @@ void CVoice::HandleVoiceData()
|
|||||||
smutils->LogError(myself, "Opus encode failed: %s", opus_strerror(nbBytes));
|
smutils->LogError(myself, "Opus encode failed: %s", opus_strerror(nbBytes));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BroadcastVoiceDataCelt(pClient, aBuffer, SamplesPerChannel);
|
BroadcastVoiceDataTorchlightCelt(pClient, aBuffer, SamplesPerChannel);
|
||||||
|
|
||||||
// Write frame size
|
// Write frame size
|
||||||
*pFrameSize = (uint16_t)nbBytes;
|
*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)
|
// pPCM is stereo interleaved at 48000 Hz (SamplesPerChannel * 2 total samples)
|
||||||
// Downsample to mono 22050 Hz and accumulate into m_torchMonoAccum
|
// 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
|
else
|
||||||
{
|
{
|
||||||
smutils->LogError(myself, "BroadcastVoiceDataCelt: celt_encode failed: %d", celtBytes);
|
smutils->LogError(myself, "BroadcastVoiceDataTorchlightCelt: celt_encode failed: %d", celtBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_torchMonoAccumLen -= CELT_FRAME_SIZE;
|
m_torchMonoAccumLen -= CELT_FRAME_SIZE;
|
||||||
|
|||||||
@ -140,7 +140,7 @@ public:
|
|||||||
|
|
||||||
void ListenSocket();
|
void ListenSocket();
|
||||||
void PushPlayerVoiceData(int playerSlot, int nBytes, char *data);
|
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 TranscodeNoSteamToSteam(int playerSlot, int nBytes, char *data);
|
||||||
void HandlePlayerVoiceData(int playerSlot);
|
void HandlePlayerVoiceData(int playerSlot);
|
||||||
|
|
||||||
|
|||||||
@ -65,8 +65,7 @@ void CRingBuffer::Mix(int16_t *pData, size_t Samples)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
bool CRingBuffer::PushTorch(int16_t *pData, size_t Samples)
|
||||||
bool CRingBuffer::Push(int16_t *pData, size_t Samples)
|
|
||||||
{
|
{
|
||||||
if(Samples > CurrentFree())
|
if(Samples > CurrentFree())
|
||||||
return false;
|
return false;
|
||||||
@ -127,7 +126,6 @@ bool CRingBuffer::Push(int16_t *pData, size_t Samples)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
bool CRingBuffer::Push(int16_t *pData, size_t Samples)
|
bool CRingBuffer::Push(int16_t *pData, size_t Samples)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -12,6 +12,7 @@ public:
|
|||||||
|
|
||||||
bool Pop(int16_t *pData, size_t Samples);
|
bool Pop(int16_t *pData, size_t Samples);
|
||||||
bool Push(int16_t *pData, size_t BufLen);
|
bool Push(int16_t *pData, size_t BufLen);
|
||||||
|
bool PushTorch(int16_t *pData, size_t BufLen);
|
||||||
|
|
||||||
size_t TotalLength();
|
size_t TotalLength();
|
||||||
size_t TotalFree();
|
size_t TotalFree();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user