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

Side by Side Diff: webrtc/modules/audio_device/ios/audio_device_unittest_ios.mm

Issue 2886183002: Updated comments for unit tests to validate iOS audio session isInterrupted flag does not get reset… (Closed)
Patch Set: fixed typo Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // AudioDeviceIOS listens to RTCAudioSession interrupted notifications by:
831 // - In AudioDeviceIOS.InitPlayOrRecord registers its audio_session_observer_
832 // callback with RTCAudioSession's delegate list.
833 // - When RTCAudioSession receives an iOS audio interrupted notification, it
834 // passes the notification to callbacks in its delegate list which sets
835 // AudioDeviceIOS's is_interrupted_ flag to true.
836 // - When AudioDeviceIOS.ShutdownPlayOrRecord is called, its
837 // audio_session_observer_ callback is removed from RTCAudioSessions's
838 // delegate list.
839 // So if RTCAudioSession receives an iOS end audio interruption notification,
840 // AudioDeviceIOS is not notified as its callback is not in RTCAudioSession's
841 // delegate list. This causes AudioDeviceIOS's is_interrupted_ flag to be in
842 // the wrong (true) state and the audio session will ignore audio changes.
843 // As RTCAudioSession keeps its own interrupted state, the fix is to initialize
844 // AudioDeviceIOS's is_interrupted_ flag to RTCAudioSession's isInterrupted
845 // flag in AudioDeviceIOS.InitPlayOrRecord.
828 TEST_F(AudioDeviceTest, testInterruptedAudioSession) { 846 TEST_F(AudioDeviceTest, testInterruptedAudioSession) {
829 RTCAudioSession *session = [RTCAudioSession sharedInstance]; 847 RTCAudioSession *session = [RTCAudioSession sharedInstance];
830 std::unique_ptr<webrtc::AudioDeviceIOS> audio_device; 848 std::unique_ptr<webrtc::AudioDeviceIOS> audio_device;
831 audio_device.reset(new webrtc::AudioDeviceIOS()); 849 audio_device.reset(new webrtc::AudioDeviceIOS());
832 std::unique_ptr<webrtc::AudioDeviceBuffer> audio_buffer; 850 std::unique_ptr<webrtc::AudioDeviceBuffer> audio_buffer;
833 audio_buffer.reset(new webrtc::AudioDeviceBuffer()); 851 audio_buffer.reset(new webrtc::AudioDeviceBuffer());
834 audio_device->AttachAudioBuffer(audio_buffer.get()); 852 audio_device->AttachAudioBuffer(audio_buffer.get());
835 audio_device->Init(); 853 audio_device->Init();
836 audio_device->InitPlayout(); 854 audio_device->InitPlayout();
837 // Force interruption. 855 // Force interruption.
(...skipping 13 matching lines...) Expand all
851 // Wait for notification to propagate. 869 // Wait for notification to propagate.
852 rtc::MessageQueueManager::ProcessAllMessageQueues(); 870 rtc::MessageQueueManager::ProcessAllMessageQueues();
853 EXPECT_TRUE(audio_device->is_interrupted_); 871 EXPECT_TRUE(audio_device->is_interrupted_);
854 872
855 audio_device->Init(); 873 audio_device->Init();
856 audio_device->InitPlayout(); 874 audio_device->InitPlayout();
857 EXPECT_FALSE(audio_device->is_interrupted_); 875 EXPECT_FALSE(audio_device->is_interrupted_);
858 } 876 }
859 877
860 } // namespace webrtc 878 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698