From 324d9c9a86e2fa331234eb0fa227845fde9f0317 Mon Sep 17 00:00:00 2001 From: henrika Date: Mon, 20 Jul 2015 13:09:23 +0200 Subject: [PATCH] Avoids error message about unknown selected data source for Port iPhone Microphone TBR=tkchin BUG=webrtc:4845 TEST=modules_unittests Review URL: https://codereview.webrtc.org/1237233003 . Cr-Commit-Position: refs/heads/master@{#9602} --- .../audio_device/ios/audio_device_ios.mm | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/webrtc/modules/audio_device/ios/audio_device_ios.mm b/webrtc/modules/audio_device/ios/audio_device_ios.mm index cb15032544..1d3c8e31d0 100644 --- a/webrtc/modules/audio_device/ios/audio_device_ios.mm +++ b/webrtc/modules/audio_device/ios/audio_device_ios.mm @@ -28,18 +28,6 @@ namespace webrtc { using ios::CheckAndLogError; -#if !defined(NDEBUG) -static void LogDeviceInfo() { - LOG(LS_INFO) << "LogDeviceInfo"; - @autoreleasepool { - LOG(LS_INFO) << " system name: " << ios::GetSystemName(); - LOG(LS_INFO) << " system version: " << ios::GetSystemVersion(); - LOG(LS_INFO) << " device type: " << ios::GetDeviceType(); - LOG(LS_INFO) << " device name: " << ios::GetDeviceName(); - } -} -#endif - static void ActivateAudioSession(AVAudioSession* session, bool activate) { LOG(LS_INFO) << "ActivateAudioSession(" << activate << ")"; @autoreleasepool { @@ -121,6 +109,18 @@ static void GetHardwareAudioParameters(AudioParameters* playout_parameters, } } +#if !defined(NDEBUG) +static void LogDeviceInfo() { + LOG(LS_INFO) << "LogDeviceInfo"; + @autoreleasepool { + LOG(LS_INFO) << " system name: " << ios::GetSystemName(); + LOG(LS_INFO) << " system version: " << ios::GetSystemVersion(); + LOG(LS_INFO) << " device type: " << ios::GetDeviceType(); + LOG(LS_INFO) << " device name: " << ios::GetDeviceName(); + } +} +#endif + AudioDeviceIOS::AudioDeviceIOS() : audio_device_buffer_(nullptr), _critSect(*CriticalSectionWrapper::CreateCriticalSection()), @@ -249,7 +249,7 @@ int32_t AudioDeviceIOS::InitPlayout() { } int32_t AudioDeviceIOS::InitRecording() { - LOGI() << "InitPlayout"; + LOGI() << "InitRecording"; DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(_initialized); DCHECK(!_recIsInitialized); @@ -666,9 +666,6 @@ int32_t AudioDeviceIOS::InitPlayOrRecord() { // files. _audioInterruptionObserver = (__bridge_retained void*)observer; - // Deactivate the audio session. - ActivateAudioSession(session, false); - return 0; } @@ -698,6 +695,10 @@ int32_t AudioDeviceIOS::ShutdownPlayOrRecord() { _auVoiceProcessing = nullptr; } + // All I/O should be stopped or paused prior to deactivating the audio + // session, hence we deactivate as last action. + AVAudioSession* session = [AVAudioSession sharedInstance]; + ActivateAudioSession(session, false); return 0; }