Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2050)

Unified Diff: webrtc/modules/audio_device/ios/audio_device_ios.mm

Issue 2063733002: Resolves issue with bad audio using BT headsets on iOS (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: style fixes Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webrtc/modules/audio_device/ios/objc/RTCAudioSession.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/audio_device/ios/audio_device_ios.mm
diff --git a/webrtc/modules/audio_device/ios/audio_device_ios.mm b/webrtc/modules/audio_device/ios/audio_device_ios.mm
index e564540595537a79126a865e29682d2d1f4161b5..0bb997db53c425ec03cf84811cef7891063e870f 100644
--- a/webrtc/modules/audio_device/ios/audio_device_ios.mm
+++ b/webrtc/modules/audio_device/ios/audio_device_ios.mm
@@ -431,6 +431,20 @@ OSStatus AudioDeviceIOS::OnGetPlayoutData(AudioUnitRenderActionFlags* flags,
memset(destination, 0, size_in_bytes);
return noErr;
}
+ // Produce silence and log a warning message for the case when Core Audio is
+ // asking for an invalid number of audio frames. I don't expect this to happen
+ // but it is done as a safety measure to avoid bad audio if such as case would
+ // ever be triggered e.g. in combination with BT devices.
+ const size_t frames_per_buffer = playout_parameters_.frames_per_buffer();
+ if (num_frames != frames_per_buffer) {
+ RTCLogWarning(@"Expected %u frames but got %u",
+ static_cast<unsigned int>(frames_per_buffer),
+ static_cast<unsigned int>(num_frames));
+ *flags |= kAudioUnitRenderAction_OutputIsSilence;
+ memset(destination, 0, size_in_bytes);
+ return noErr;
+ }
+
// Read decoded 16-bit PCM samples from WebRTC (using a size that matches
// the native I/O audio unit) to a preallocated intermediate buffer and
// copy the result to the audio buffer in the |io_data| destination.
« no previous file with comments | « no previous file | webrtc/modules/audio_device/ios/objc/RTCAudioSession.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698