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,8 +117,11 @@ void CefAudioCapturer::OnCaptureError(
media::AudioCapturerSource::ErrorCode code,
const std::string& message) {
audio_handler_->OnAudioStreamError(browser_, message);
if (code != media::AudioCapturerSource::ErrorCode::kSocketError) {
StopStream();
}
}
void CefAudioCapturer::StopStream() {
if (audio_input_device_) {

View File

@ -934,10 +934,15 @@ class AudioTestHandler : public TestHandler, public CefAudioHandler {
void OnAudioStreamError(CefRefPtr<CefBrowser> browser,
const CefString& message) override {
// 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:
void DestroyTest() override {
@ -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();
}