Thread checker fails when switching to/from bluetooth headset.
Made some minor changes to resolve the issue. Only affects Debug builds. NOTRY=TRUE Bug: webrtc:9310 Change-Id: Ieeeb57d24b559282b2eefd4d8785f7cfe4f44e40 Reviewed-on: https://webrtc-review.googlesource.com/79624 Commit-Queue: Henrik Andreassson <henrika@webrtc.org> Reviewed-by: Peter Hanspers <peterhanspers@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23434}
This commit is contained in:
@ -198,6 +198,9 @@ class AudioDeviceIOS : public AudioDeviceGeneric,
|
||||
// Closes and deletes the voice-processing I/O unit.
|
||||
void ShutdownPlayOrRecord();
|
||||
|
||||
// Resets thread-checkers before a call is restarted.
|
||||
void PrepareForNewStart();
|
||||
|
||||
// Ensures that methods are called from the same thread as this object is
|
||||
// created on.
|
||||
rtc::ThreadChecker thread_checker_;
|
||||
|
||||
@ -497,15 +497,7 @@ void AudioDeviceIOS::HandleInterruptionBegin() {
|
||||
if (!audio_unit_->Stop()) {
|
||||
RTCLogError(@"Failed to stop the audio unit for interruption begin.");
|
||||
} else {
|
||||
// The audio unit has been stopped but will be restarted when the
|
||||
// interruption ends in HandleInterruptionEnd(). It will result in audio
|
||||
// callbacks from a new native I/O thread which means that we must detach
|
||||
// thread checkers here to be prepared for an upcoming new audio stream.
|
||||
io_thread_checker_.DetachFromThread();
|
||||
// The audio device buffer must also be informed about the interrupted
|
||||
// state so it can detach its thread checkers as well.
|
||||
audio_device_buffer_->NativeAudioPlayoutInterrupted();
|
||||
audio_device_buffer_->NativeAudioRecordingInterrupted();
|
||||
PrepareForNewStart();
|
||||
}
|
||||
}
|
||||
is_interrupted_ = true;
|
||||
@ -587,6 +579,7 @@ void AudioDeviceIOS::HandleSampleRateChange(float sample_rate) {
|
||||
if (audio_unit_->GetState() == VoiceProcessingAudioUnit::kStarted) {
|
||||
audio_unit_->Stop();
|
||||
restart_audio_unit = true;
|
||||
PrepareForNewStart();
|
||||
}
|
||||
if (audio_unit_->GetState() == VoiceProcessingAudioUnit::kInitialized) {
|
||||
audio_unit_->Uninitialize();
|
||||
@ -907,6 +900,21 @@ void AudioDeviceIOS::ShutdownPlayOrRecord() {
|
||||
[session unlockForConfiguration];
|
||||
}
|
||||
|
||||
void AudioDeviceIOS::PrepareForNewStart() {
|
||||
LOGI() << "PrepareForNewStart";
|
||||
// The audio unit has been stopped and preparations are needed for an upcoming
|
||||
// restart. It will result in audio callbacks from a new native I/O thread
|
||||
// which means that we must detach thread checkers here to be prepared for an
|
||||
// upcoming new audio stream.
|
||||
io_thread_checker_.DetachFromThread();
|
||||
// The audio device buffer must also be informed about the interrupted
|
||||
// state so it can detach its thread checkers as well.
|
||||
if (audio_device_buffer_) {
|
||||
audio_device_buffer_->NativeAudioPlayoutInterrupted();
|
||||
audio_device_buffer_->NativeAudioRecordingInterrupted();
|
||||
}
|
||||
}
|
||||
|
||||
bool AudioDeviceIOS::IsInterrupted() {
|
||||
return is_interrupted_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user