WebRTC crash while plug/unplug audio headset.

Skip to first unread message

Joe Q

May 15, 2024, 12:01:01 PMMay 15
to discuss-webrtc

We are seeing a crash that is correlated with audio headset plug/unplug event. The following code is accessing a nullptr audio_client_ object.

bool CoreAudioOutput::OnDataCallback(uint64_t device_frequency) {
  UINT32 num_unread_frames = 0;
  _com_error error = audio_client_->GetCurrentPadding(&num_unread_frames); 


Here is our theory. The CoreAudioOutput::StopPlayout() can be invoked by the internal audio thread while handling CoreAudioOutput::HandleStreamDisconnected() during the unplug event with the restarting flag is set to true. At the same time, if our application also calls StopPlayout(), which sees audio object is restarting, it doesn't stop the audio thread, but still arbitrarily clears all the com object in the following code.
bool CoreAudioBase::Stop() {
  // Stop audio streaming.
  _com_error error = audio_client_->Stop();
  if (!IsRestarting()) {
  // Release all allocated COM interfaces to allow for a restart without
  // intermediate destruction.

  return true;

Would you please confirm if this is a webrtc bug?  Thanks.
Reply all
Reply to author
0 new messages