From e997249d53ecc8427eae3d6c5d4f3dc7351baff5 Mon Sep 17 00:00:00 2001 From: pkv Date: Tue, 21 May 2024 17:58:13 +0000 Subject: [PATCH] alloy: Fix audio capturer crash on exit (fixes #3689) --- libcef/browser/audio_capturer.cc | 5 ++++- tests/ceftests/audio_output_unittest.cc | 13 ++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/libcef/browser/audio_capturer.cc b/libcef/browser/audio_capturer.cc index c569b3621..9fd11f7bf 100644 --- a/libcef/browser/audio_capturer.cc +++ b/libcef/browser/audio_capturer.cc @@ -117,7 +117,10 @@ void CefAudioCapturer::OnCaptureError( media::AudioCapturerSource::ErrorCode code, const std::string& message) { audio_handler_->OnAudioStreamError(browser_, message); - StopStream(); + + if (code != media::AudioCapturerSource::ErrorCode::kSocketError) { + StopStream(); + } } void CefAudioCapturer::StopStream() { diff --git a/tests/ceftests/audio_output_unittest.cc b/tests/ceftests/audio_output_unittest.cc index 4d93b53ab..fd1c0d784 100644 --- a/tests/ceftests/audio_output_unittest.cc +++ b/tests/ceftests/audio_output_unittest.cc @@ -934,9 +934,14 @@ class AudioTestHandler : public TestHandler, public CefAudioHandler { void OnAudioStreamError(CefRefPtr browser, const CefString& message) override { - LOG(WARNING) << "OnAudioStreamError: message = " << message << "."; - got_on_audio_stream_error_.yes(); - DestroyTest(); + // Since 7c88225, when Chromium closes a socket, the following error is + // propagated to the audio capturer. Ignore this error for test destruction. + const CefString& socket_error("Socket closed unexpectedly"); + if (message.compare(socket_error) != 0) { + LOG(WARNING) << "OnAudioStreamError: message = " << message << "."; + got_on_audio_stream_error_.yes(); + DestroyTest(); + } } protected: @@ -945,8 +950,6 @@ class AudioTestHandler : public TestHandler, public CefAudioHandler { EXPECT_TRUE(got_audio_parameters_); EXPECT_TRUE(got_on_audio_stream_started_); EXPECT_TRUE(got_on_audio_stream_packet_); - EXPECT_TRUE(got_on_audio_stream_stopped_); - EXPECT_FALSE(got_on_audio_stream_error_); TestHandler::DestroyTest(); }