Avoids audio crash in combination with invalid audio session on iOS.
Bug: b/70899226 Change-Id: Ie4f92bb1477a29d6b18647e7667f760837a8f1c0 Reviewed-on: https://webrtc-review.googlesource.com/37201 Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org> Commit-Queue: Henrik Andreassson <henrika@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21522}
This commit is contained in:
parent
9a0a17fb7a
commit
e6aca637ce
@ -643,10 +643,10 @@ void AudioDeviceIOS::UpdateAudioDeviceBuffer() {
|
||||
// AttachAudioBuffer() is called at construction by the main class but check
|
||||
// just in case.
|
||||
RTC_DCHECK(audio_device_buffer_) << "AttachAudioBuffer must be called first";
|
||||
RTC_CHECK_GT(playout_parameters_.sample_rate(), 0);
|
||||
RTC_CHECK_GT(record_parameters_.sample_rate(), 0);
|
||||
RTC_CHECK_EQ(playout_parameters_.channels(), 1);
|
||||
RTC_CHECK_EQ(record_parameters_.channels(), 1);
|
||||
RTC_DCHECK_GT(playout_parameters_.sample_rate(), 0);
|
||||
RTC_DCHECK_GT(record_parameters_.sample_rate(), 0);
|
||||
RTC_DCHECK_EQ(playout_parameters_.channels(), 1);
|
||||
RTC_DCHECK_EQ(record_parameters_.channels(), 1);
|
||||
// Inform the audio device buffer (ADB) about the new audio format.
|
||||
audio_device_buffer_->SetPlayoutSampleRate(playout_parameters_.sample_rate());
|
||||
audio_device_buffer_->SetPlayoutChannels(playout_parameters_.channels());
|
||||
@ -860,16 +860,22 @@ bool AudioDeviceIOS::InitPlayOrRecord() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If we are ready to play or record, initialize the audio unit.
|
||||
// If we are ready to play or record, and if the audio session can be
|
||||
// configured, then initialize the audio unit.
|
||||
if (session.canPlayOrRecord) {
|
||||
ConfigureAudioSession();
|
||||
if (!ConfigureAudioSession()) {
|
||||
// One possible reason for failure is if an attempt was made to use the
|
||||
// audio session during or after a Media Services failure.
|
||||
// See AVAudioSessionErrorCodeMediaServicesFailed for details.
|
||||
[session unlockForConfiguration];
|
||||
return false;
|
||||
}
|
||||
SetupAudioBuffersForActiveAudioSession();
|
||||
audio_unit_->Initialize(playout_parameters_.sample_rate());
|
||||
}
|
||||
|
||||
// Release the lock.
|
||||
[session unlockForConfiguration];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user