Adds workaround for audio not restarting after interruption

Bug: webrtc:8126
Change-Id: I9499e7bf06cad598fd4406b590354d695fa1a9d6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/129927
Reviewed-by: Henrik Andreassson <henrika@webrtc.org>
Commit-Queue: Kári Helgason <kthelgason@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27337}
This commit is contained in:
Kári Tristan Helgason 2019-03-28 11:03:27 +01:00 committed by Commit Bot
parent e5cc85b5c5
commit f49429d507
2 changed files with 15 additions and 0 deletions

View File

@ -277,6 +277,7 @@ if (is_ios || is_mac) {
"../rtc_base",
"../rtc_base:checks",
"../rtc_base/system:fallthrough",
"../system_wrappers:field_trial",
"../system_wrappers:metrics",
]

View File

@ -26,6 +26,7 @@
#include "rtc_base/thread.h"
#include "rtc_base/thread_annotations.h"
#include "rtc_base/time_utils.h"
#include "system_wrappers/include/field_trial.h"
#include "system_wrappers/include/metrics.h"
#import "base/RTCLogging.h"
@ -517,6 +518,19 @@ void AudioDeviceIOS::HandleInterruptionEnd() {
"Updating audio unit state.",
is_interrupted_);
is_interrupted_ = false;
if (webrtc::field_trial::IsEnabled("WebRTC-Audio-iOS-Holding")) {
// Work around an issue where audio does not restart properly after an interruption
// by restarting the audio unit when the interruption ends.
if (audio_unit_->GetState() == VoiceProcessingAudioUnit::kStarted) {
audio_unit_->Stop();
PrepareForNewStart();
}
if (audio_unit_->GetState() == VoiceProcessingAudioUnit::kInitialized) {
audio_unit_->Uninitialize();
}
// Allocate new buffers given the potentially new stream format.
SetupAudioBuffersForActiveAudioSession();
}
UpdateAudioUnit([RTCAudioSession sharedInstance].canPlayOrRecord);
}