Skip to content

Fix voice memory and bitstream leaks, crashes, game loop stall - #5254

Open
Dutchman101 wants to merge 3 commits into
multitheftauto:masterfrom
Dutchman101:voice-stability-2
Open

Fix voice memory and bitstream leaks, crashes, game loop stall#5254
Dutchman101 wants to merge 3 commits into
multitheftauto:masterfrom
Dutchman101:voice-stability-2

Conversation

@Dutchman101

@Dutchman101 Dutchman101 commented Aug 21, 2026

Copy link
Copy Markdown
Member

Main benefits:

  • Server voice reconfiguration and disable/enable cycles no longer leak streams, codec state, or buffers.
  • Voice can no longer crash the client when Speex allocation fails or no microphone is present.
  • Disabling voice no longer stalls the game loop.
  • The enabled flag no longer races between the audio and game threads.

@Dutchman101
Dutchman101 marked this pull request as draft August 21, 2026 08:04
@Dutchman101
Dutchman101 marked this pull request as ready for review August 21, 2026 14:19
{
// Initialize our speex decoder
speex_decoder_ctl(m_pSpeexDecoderState, SPEEX_GET_FRAME_SIZE, &m_iSpeexIncomingFrameSampleCount);
int iQuality = ucQuality;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

auto quality = static_cast<std::uint32_t>(m_pVoiceRecorder->GetSampleQuality());

ucQuality is no longer used, so it can be removed

if (m_pSpeexEncoderState)
{
speex_encoder_ctl(m_pSpeexEncoderState, SPEEX_GET_FRAME_SIZE, &m_iSpeexOutgoingFrameSampleCount);
int iQuality = m_ucQuality;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, it's worth adding an explicit cast. Also, the result can't be negative, so it could be an unsigned int

@FileEX FileEX added the bugfix Solution to a bug of any kind label Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Solution to a bug of any kind

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants