Skip to content
Permalink
Browse files

Fix /voiceptt crash

  • Loading branch information...
botder committed Sep 26, 2018
1 parent 0476323 commit d5e5d46e7afb62173ca329198a96294c183ed7b0
@@ -197,14 +197,14 @@ eSampleRate CVoiceRecorder::convertServerSampleRate(unsigned int uiServerSampleR
return SAMPLERATE_WIDEBAND;
}

void CVoiceRecorder::UpdatePTTState(unsigned int uiState)
void CVoiceRecorder::SetPTTState(bool bState)
{
if (!m_bEnabled)
return;

m_CS.Lock();

if (uiState == 1)
if (bState)
{
if (m_VoiceState == VOICESTATE_AWAITING_INPUT)
{
@@ -224,7 +224,7 @@ void CVoiceRecorder::UpdatePTTState(unsigned int uiState)
}
}
}
else if (uiState == 0)
else
{
if (m_VoiceState == VOICESTATE_RECORDING)
{
@@ -240,9 +240,15 @@ void CVoiceRecorder::UpdatePTTState(unsigned int uiState)
}
}
}

m_CS.Unlock();
}

bool CVoiceRecorder::GetPTTState()
{
return m_VoiceState == VOICESTATE_RECORDING;
}

void CVoiceRecorder::DoPulse(void)
{
m_CS.Lock();
@@ -58,7 +58,8 @@ class CVoiceRecorder

void DoPulse(void);

void UpdatePTTState(unsigned int uiState);
void SetPTTState(bool bState);
bool GetPTTState();

unsigned int GetSampleRate(void) { return m_SampleRate; }
unsigned char GetSampleQuality(void) { return m_ucQuality; }
@@ -732,8 +732,17 @@ void COMMAND_ShowSyncData(const char* szCmdLine)

void COMMAND_VoicePushToTalk(const char* szCmdLine)
{
if (g_pClientGame->GetVoiceRecorder()->IsEnabled())
g_pClientGame->GetVoiceRecorder()->UpdatePTTState(atoi(szCmdLine));
CVoiceRecorder* const pVoiceRecorder = g_pClientGame->GetVoiceRecorder();

if (pVoiceRecorder->IsEnabled())
{
if (!szCmdLine)
pVoiceRecorder->SetPTTState(!pVoiceRecorder->GetPTTState());
else if (szCmdLine[0] == '0')
pVoiceRecorder->SetPTTState(false);
else if (szCmdLine[0] == '1')
pVoiceRecorder->SetPTTState(true);
}
else
{
// Show warning only once per server

0 comments on commit d5e5d46

Please sign in to comment.
You can’t perform that action at this time.