alloy: Fix audio capturer crash on exit (fixes #3689)

This commit is contained in:
pkv 2024-05-21 17:58:13 +00:00 committed by Marshall Greenblatt
parent 3ccd305f6d
commit e997249d53
2 changed files with 12 additions and 6 deletions

View File

@ -117,7 +117,10 @@ void CefAudioCapturer::OnCaptureError(
media::AudioCapturerSource::ErrorCode code, media::AudioCapturerSource::ErrorCode code,
const std::string& message) { const std::string& message) {
audio_handler_->OnAudioStreamError(browser_, message); audio_handler_->OnAudioStreamError(browser_, message);
StopStream();
if (code != media::AudioCapturerSource::ErrorCode::kSocketError) {
StopStream();
}
} }
void CefAudioCapturer::StopStream() { void CefAudioCapturer::StopStream() {

View File

@ -934,9 +934,14 @@ class AudioTestHandler : public TestHandler, public CefAudioHandler {
void OnAudioStreamError(CefRefPtr<CefBrowser> browser, void OnAudioStreamError(CefRefPtr<CefBrowser> browser,
const CefString& message) override { const CefString& message) override {
LOG(WARNING) << "OnAudioStreamError: message = " << message << "."; // Since 7c88225, when Chromium closes a socket, the following error is
got_on_audio_stream_error_.yes(); // propagated to the audio capturer. Ignore this error for test destruction.
DestroyTest(); 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: protected:
@ -945,8 +950,6 @@ class AudioTestHandler : public TestHandler, public CefAudioHandler {
EXPECT_TRUE(got_audio_parameters_); EXPECT_TRUE(got_audio_parameters_);
EXPECT_TRUE(got_on_audio_stream_started_); EXPECT_TRUE(got_on_audio_stream_started_);
EXPECT_TRUE(got_on_audio_stream_packet_); EXPECT_TRUE(got_on_audio_stream_packet_);
EXPECT_TRUE(got_on_audio_stream_stopped_);
EXPECT_FALSE(got_on_audio_stream_error_);
TestHandler::DestroyTest(); TestHandler::DestroyTest();
} }