diff --git a/extension.cpp b/extension.cpp index 7b75f6a..7b64cab 100644 --- a/extension.cpp +++ b/extension.cpp @@ -55,7 +55,6 @@ // sensible limit of 8 packets per frame = 552 bytes -> 185.76ms of voice data per frame //#define NET_MAX_VOICE_BYTES_FRAME (8 * (5 + 64)) #define NET_MAX_VOICE_BYTES_FRAME (10 * (5 + 64)) -#define NET_MAX_VOICE_BYTES_FRAME_TORCHLIGHT (22 * (5 + 64)) ConVar g_SmVoiceAddr("sm_voice_addr", "127.0.0.1", FCVAR_PROTECTED, "Voice server listen ip address."); ConVar g_SmVoicePort("sm_voice_port", "27020", FCVAR_PROTECTED, "Voice server listen port.", true, 1025.0, true, 65535.0); @@ -140,7 +139,7 @@ int g_aFrameVoiceBytes[SM_MAXPLAYERS + 1]; DETOUR_DECL_STATIC4(SV_BroadcastVoiceData, void, IClient *, pClient, int, nBytes, char *, data, int64, xuid) { - if(g_Interface.OnBroadcastVoiceData(pClient, nBytes, data, false)) + if(g_Interface.OnBroadcastVoiceData(pClient, nBytes, data)) DETOUR_STATIC_CALL(SV_BroadcastVoiceData)(pClient, nBytes, data, xuid); } @@ -153,7 +152,7 @@ DETOUR_DECL_STATIC2(SV_BroadcastVoiceData_LTCG, void, char *, data, int64, xuid) __asm mov pClient, ecx; __asm mov nBytes, edx; - bool ret = g_Interface.OnBroadcastVoiceData(pClient, nBytes, data, false); + bool ret = g_Interface.OnBroadcastVoiceData(pClient, nBytes, data); __asm mov ecx, pClient; __asm mov edx, nBytes; @@ -310,7 +309,7 @@ bool CVoice::SDK_OnLoad(char *error, size_t maxlength, bool late) return false; } - opus_encoder_ctl(m_OpusEncoder, OPUS_SET_BITRATE(510000)); + opus_encoder_ctl(m_OpusEncoder, OPUS_SET_BITRATE(128000)); opus_encoder_ctl(m_OpusEncoder, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_FULLBAND)); opus_encoder_ctl(m_OpusEncoder, OPUS_SET_SIGNAL(OPUS_SIGNAL_MUSIC)); //MDCT mode opus_encoder_ctl(m_OpusEncoder, OPUS_SET_LSB_DEPTH(16)); @@ -490,7 +489,7 @@ void CVoice::OnGameFrame(bool simulating) memset(g_aFrameVoiceBytes, 0, sizeof(g_aFrameVoiceBytes)); } -bool CVoice::OnBroadcastVoiceData(IClient *pClient, int nBytes, char *data, bool isSourceTV) +bool CVoice::OnBroadcastVoiceData(IClient *pClient, int nBytes, char *data) { // Reject empty packets if(nBytes < 1) @@ -502,18 +501,10 @@ bool CVoice::OnBroadcastVoiceData(IClient *pClient, int nBytes, char *data, bool // 5 = SVC_VoiceData header/overhead g_aFrameVoiceBytes[client] += 5 + nBytes; - if (!isSourceTV && g_aFrameVoiceBytes[client] > NET_MAX_VOICE_BYTES_FRAME) + if (g_aFrameVoiceBytes[client] > NET_MAX_VOICE_BYTES_FRAME) { return false; } - if (isSourceTV) - { - if (g_aFrameVoiceBytes[client] > NET_MAX_VOICE_BYTES_FRAME_TORCHLIGHT) - { - smutils->LogMessage(myself, "inside interface BroadcastVoiceData with torchlight. g_aFrameVoiceBytes[client]: %d. NET_MAX_VOICE_BYTES_FRAME_TORCHLIGHT: %d", g_aFrameVoiceBytes[client], NET_MAX_VOICE_BYTES_FRAME_TORCHLIGHT); - return false; - } - } g_fLastVoiceData[client] = gpGlobals->curtime; @@ -711,7 +702,7 @@ void CVoice::HandleVoiceData() if(!FramesAvailable) return; - //int FramesMax = 5; //used to be 5 + //int FramesMax = 5; int FramesMax = 2; //used to be 5 bool reset_state = false; if (FramesAvailable <= FramesMax) @@ -821,7 +812,7 @@ void CVoice::HandleVoiceData() uint32_t crc32_value = UTIL_CRC32(aFinal, FinalSize); memcpy(&aFinal[FinalSize], &crc32_value, sizeof(uint32_t)); FinalSize += sizeof(uint32_t); - + BroadcastVoiceData(pClient, FinalSize, aFinal); if (m_AvailableTime < getTime()) @@ -842,9 +833,6 @@ void CVoice::BroadcastVoiceData(IClient *pClient, int nBytes, unsigned char *pDa DETOUR_STATIC_CALL(SV_BroadcastVoiceData_LTCG)((char *)pData, 0); #else - if (g_Interface.OnBroadcastVoiceData(pClient, nBytes, (char *)pData, true)) - { - DETOUR_STATIC_CALL(SV_BroadcastVoiceData)(pClient, nBytes, (char *)pData, 0); - } + DETOUR_STATIC_CALL(SV_BroadcastVoiceData)(pClient, nBytes, (char *)pData, 0); #endif } diff --git a/extension.h b/extension.h index cffd029..32f7b9a 100644 --- a/extension.h +++ b/extension.h @@ -136,7 +136,7 @@ public: // IConCommandBaseAccessor public: CVoice(); void OnGameFrame(bool simulating); - bool OnBroadcastVoiceData(IClient *pClient, int nBytes, char *data, bool isSourceTV); + bool OnBroadcastVoiceData(IClient *pClient, int nBytes, char *data); void ListenSocket();