| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 std::max(kTestTimeOutInMilliseconds, 1000 * kMeasureLatencyTimeInSec)); | 818 std::max(kTestTimeOutInMilliseconds, 1000 * kMeasureLatencyTimeInSec)); |
| 819 StopPlayout(); | 819 StopPlayout(); |
| 820 StopRecording(); | 820 StopRecording(); |
| 821 // Verify that the correct number of transmitted impulses are detected. | 821 // Verify that the correct number of transmitted impulses are detected. |
| 822 EXPECT_EQ(latency_audio_stream->num_latency_values(), | 822 EXPECT_EQ(latency_audio_stream->num_latency_values(), |
| 823 static_cast<size_t>( | 823 static_cast<size_t>( |
| 824 kImpulseFrequencyInHz * kMeasureLatencyTimeInSec - 1)); | 824 kImpulseFrequencyInHz * kMeasureLatencyTimeInSec - 1)); |
| 825 latency_audio_stream->PrintResults(); | 825 latency_audio_stream->PrintResults(); |
| 826 } | 826 } |
| 827 | 827 |
| 828 // Verifies that the AudioDeviceIOS is_interrupted_ flag is reset correctly |
| 829 // after an iOS AVAudioSessionInterruptionTypeEnded notification event. |
| 830 // When AudioDeviceIOS is interrupted, is_interrupted_ is set to true. |
| 831 // When the audio device is stopped, the AudioDeviceIOS's |
| 832 // audio_session_observer_ is removed from RTCAudioSession's delegate list. |
| 833 // Then when the iOS AVAudioSessionInterruptionTypeEnded notification is |
| 834 // received by RTCAudioSession, RTCAudioSession can't propagate the event |
| 835 // back to AudioDeviceIOS as AudioDeviceIOS's audio_session_observer_ is no |
| 836 // longer in RTCAudioSession's delegate list. |
| 837 // The fix is to set AudioDeviceIOS's is_interrupted_ flag to RTCAudioSession's |
| 838 // isInterrupted flag when AudioDeviceIOS is initialized the next time audio |
| 839 // is to be started. |
| 828 TEST_F(AudioDeviceTest, testInterruptedAudioSession) { | 840 TEST_F(AudioDeviceTest, testInterruptedAudioSession) { |
| 829 RTCAudioSession *session = [RTCAudioSession sharedInstance]; | 841 RTCAudioSession *session = [RTCAudioSession sharedInstance]; |
| 830 std::unique_ptr<webrtc::AudioDeviceIOS> audio_device; | 842 std::unique_ptr<webrtc::AudioDeviceIOS> audio_device; |
| 831 audio_device.reset(new webrtc::AudioDeviceIOS()); | 843 audio_device.reset(new webrtc::AudioDeviceIOS()); |
| 832 std::unique_ptr<webrtc::AudioDeviceBuffer> audio_buffer; | 844 std::unique_ptr<webrtc::AudioDeviceBuffer> audio_buffer; |
| 833 audio_buffer.reset(new webrtc::AudioDeviceBuffer()); | 845 audio_buffer.reset(new webrtc::AudioDeviceBuffer()); |
| 834 audio_device->AttachAudioBuffer(audio_buffer.get()); | 846 audio_device->AttachAudioBuffer(audio_buffer.get()); |
| 835 audio_device->Init(); | 847 audio_device->Init(); |
| 836 audio_device->InitPlayout(); | 848 audio_device->InitPlayout(); |
| 837 // Force interruption. | 849 // Force interruption. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 851 // Wait for notification to propagate. | 863 // Wait for notification to propagate. |
| 852 rtc::MessageQueueManager::ProcessAllMessageQueues(); | 864 rtc::MessageQueueManager::ProcessAllMessageQueues(); |
| 853 EXPECT_TRUE(audio_device->is_interrupted_); | 865 EXPECT_TRUE(audio_device->is_interrupted_); |
| 854 | 866 |
| 855 audio_device->Init(); | 867 audio_device->Init(); |
| 856 audio_device->InitPlayout(); | 868 audio_device->InitPlayout(); |
| 857 EXPECT_FALSE(audio_device->is_interrupted_); | 869 EXPECT_FALSE(audio_device->is_interrupted_); |
| 858 } | 870 } |
| 859 | 871 |
| 860 } // namespace webrtc | 872 } // namespace webrtc |
| OLD | NEW |