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

Side by Side Diff: media/audio/android/audio_android_unittest.cc

Issue 730083002: [media/audio] Convert VLOGs to DVLOGs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 | media/audio/audio_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/android/build_info.h" 5 #include "base/android/build_info.h"
6 #include "base/basictypes.h" 6 #include "base/basictypes.h"
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 static double ExpectedTimeBetweenCallbacks(AudioParameters params) { 85 static double ExpectedTimeBetweenCallbacks(AudioParameters params) {
86 return (base::TimeDelta::FromMicroseconds( 86 return (base::TimeDelta::FromMicroseconds(
87 params.frames_per_buffer() * base::Time::kMicrosecondsPerSecond / 87 params.frames_per_buffer() * base::Time::kMicrosecondsPerSecond /
88 static_cast<double>(params.sample_rate()))).InMillisecondsF(); 88 static_cast<double>(params.sample_rate()))).InMillisecondsF();
89 } 89 }
90 90
91 // Helper method which verifies that the device list starts with a valid 91 // Helper method which verifies that the device list starts with a valid
92 // default device name followed by non-default device names. 92 // default device name followed by non-default device names.
93 static void CheckDeviceNames(const AudioDeviceNames& device_names) { 93 static void CheckDeviceNames(const AudioDeviceNames& device_names) {
94 VLOG(2) << "Got " << device_names.size() << " audio devices."; 94 DVLOG(2) << "Got " << device_names.size() << " audio devices.";
95 if (device_names.empty()) { 95 if (device_names.empty()) {
96 // Log a warning so we can see the status on the build bots. No need to 96 // Log a warning so we can see the status on the build bots. No need to
97 // break the test though since this does successfully test the code and 97 // break the test though since this does successfully test the code and
98 // some failure cases. 98 // some failure cases.
99 LOG(WARNING) << "No input devices detected"; 99 LOG(WARNING) << "No input devices detected";
100 return; 100 return;
101 } 101 }
102 102
103 AudioDeviceNames::const_iterator it = device_names.begin(); 103 AudioDeviceNames::const_iterator it = device_names.begin();
104 104
105 // The first device in the list should always be the default device. 105 // The first device in the list should always be the default device.
106 EXPECT_EQ(std::string(AudioManagerBase::kDefaultDeviceName), 106 EXPECT_EQ(std::string(AudioManagerBase::kDefaultDeviceName),
107 it->device_name); 107 it->device_name);
108 EXPECT_EQ(std::string(AudioManagerBase::kDefaultDeviceId), it->unique_id); 108 EXPECT_EQ(std::string(AudioManagerBase::kDefaultDeviceId), it->unique_id);
109 ++it; 109 ++it;
110 110
111 // Other devices should have non-empty name and id and should not contain 111 // Other devices should have non-empty name and id and should not contain
112 // default name or id. 112 // default name or id.
113 while (it != device_names.end()) { 113 while (it != device_names.end()) {
114 EXPECT_FALSE(it->device_name.empty()); 114 EXPECT_FALSE(it->device_name.empty());
115 EXPECT_FALSE(it->unique_id.empty()); 115 EXPECT_FALSE(it->unique_id.empty());
116 VLOG(2) << "Device ID(" << it->unique_id 116 DVLOG(2) << "Device ID(" << it->unique_id
117 << "), label: " << it->device_name; 117 << "), label: " << it->device_name;
118 EXPECT_NE(std::string(AudioManagerBase::kDefaultDeviceName), 118 EXPECT_NE(std::string(AudioManagerBase::kDefaultDeviceName),
119 it->device_name); 119 it->device_name);
120 EXPECT_NE(std::string(AudioManagerBase::kDefaultDeviceId), 120 EXPECT_NE(std::string(AudioManagerBase::kDefaultDeviceId),
121 it->unique_id); 121 it->unique_id);
122 ++it; 122 ++it;
123 } 123 }
124 } 124 }
125 125
126 // We clear the data bus to ensure that the test does not cause noise. 126 // We clear the data bus to ensure that the test does not cause noise.
127 static int RealOnMoreData(AudioBus* dest, uint32 total_bytes_delay) { 127 static int RealOnMoreData(AudioBus* dest, uint32 total_bytes_delay) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 class FileAudioSource : public AudioOutputStream::AudioSourceCallback { 162 class FileAudioSource : public AudioOutputStream::AudioSourceCallback {
163 public: 163 public:
164 explicit FileAudioSource(base::WaitableEvent* event, const std::string& name) 164 explicit FileAudioSource(base::WaitableEvent* event, const std::string& name)
165 : event_(event), pos_(0) { 165 : event_(event), pos_(0) {
166 // Reads a test file from media/test/data directory and stores it in 166 // Reads a test file from media/test/data directory and stores it in
167 // a DecoderBuffer. 167 // a DecoderBuffer.
168 file_ = ReadTestDataFile(name); 168 file_ = ReadTestDataFile(name);
169 169
170 // Log the name of the file which is used as input for this test. 170 // Log the name of the file which is used as input for this test.
171 base::FilePath file_path = GetTestDataFilePath(name); 171 base::FilePath file_path = GetTestDataFilePath(name);
172 VLOG(0) << "Reading from file: " << file_path.value().c_str(); 172 DVLOG(0) << "Reading from file: " << file_path.value().c_str();
173 } 173 }
174 174
175 virtual ~FileAudioSource() {} 175 virtual ~FileAudioSource() {}
176 176
177 // AudioOutputStream::AudioSourceCallback implementation. 177 // AudioOutputStream::AudioSourceCallback implementation.
178 178
179 // Use samples read from a data file and fill up the audio buffer 179 // Use samples read from a data file and fill up the audio buffer
180 // provided to us in the callback. 180 // provided to us in the callback.
181 virtual int OnMoreData(AudioBus* audio_bus, 181 virtual int OnMoreData(AudioBus* audio_bus,
182 uint32 total_bytes_delay) override { 182 uint32 total_bytes_delay) override {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 // Allocate space for ~10 seconds of data. 233 // Allocate space for ~10 seconds of data.
234 const int kMaxBufferSize = 10 * params.GetBytesPerSecond(); 234 const int kMaxBufferSize = 10 * params.GetBytesPerSecond();
235 buffer_.reset(new media::SeekableBuffer(0, kMaxBufferSize)); 235 buffer_.reset(new media::SeekableBuffer(0, kMaxBufferSize));
236 236
237 // Open up the binary file which will be written to in the destructor. 237 // Open up the binary file which will be written to in the destructor.
238 base::FilePath file_path; 238 base::FilePath file_path;
239 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &file_path)); 239 EXPECT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &file_path));
240 file_path = file_path.AppendASCII(file_name.c_str()); 240 file_path = file_path.AppendASCII(file_name.c_str());
241 binary_file_ = base::OpenFile(file_path, "wb"); 241 binary_file_ = base::OpenFile(file_path, "wb");
242 DLOG_IF(ERROR, !binary_file_) << "Failed to open binary PCM data file."; 242 DLOG_IF(ERROR, !binary_file_) << "Failed to open binary PCM data file.";
243 VLOG(0) << "Writing to file: " << file_path.value().c_str(); 243 DVLOG(0) << "Writing to file: " << file_path.value().c_str();
244 } 244 }
245 245
246 virtual ~FileAudioSink() { 246 virtual ~FileAudioSink() {
247 int bytes_written = 0; 247 int bytes_written = 0;
248 while (bytes_written < buffer_->forward_capacity()) { 248 while (bytes_written < buffer_->forward_capacity()) {
249 const uint8* chunk; 249 const uint8* chunk;
250 int chunk_size; 250 int chunk_size;
251 251
252 // Stop writing if no more data is available. 252 // Stop writing if no more data is available.
253 if (!buffer_->GetCurrentChunk(&chunk, &chunk_size)) 253 if (!buffer_->GetCurrentChunk(&chunk, &chunk_size))
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 OpenAndStartAudioOutputStreamOnAudioThread(&source); 505 OpenAndStartAudioOutputStreamOnAudioThread(&source);
506 506
507 start_time_ = base::TimeTicks::Now(); 507 start_time_ = base::TimeTicks::Now();
508 loop()->Run(); 508 loop()->Run();
509 end_time_ = base::TimeTicks::Now(); 509 end_time_ = base::TimeTicks::Now();
510 510
511 StopAndCloseAudioOutputStreamOnAudioThread(); 511 StopAndCloseAudioOutputStreamOnAudioThread();
512 512
513 double average_time_between_callbacks_ms = 513 double average_time_between_callbacks_ms =
514 AverageTimeBetweenCallbacks(num_callbacks); 514 AverageTimeBetweenCallbacks(num_callbacks);
515 VLOG(0) << "expected time between callbacks: " 515 DVLOG(0) << "expected time between callbacks: "
516 << expected_time_between_callbacks_ms << " ms"; 516 << expected_time_between_callbacks_ms << " ms";
517 VLOG(0) << "average time between callbacks: " 517 DVLOG(0) << "average time between callbacks: "
518 << average_time_between_callbacks_ms << " ms"; 518 << average_time_between_callbacks_ms << " ms";
519 EXPECT_GE(average_time_between_callbacks_ms, 519 EXPECT_GE(average_time_between_callbacks_ms,
520 0.70 * expected_time_between_callbacks_ms); 520 0.70 * expected_time_between_callbacks_ms);
521 EXPECT_LE(average_time_between_callbacks_ms, 521 EXPECT_LE(average_time_between_callbacks_ms,
522 1.50 * expected_time_between_callbacks_ms); 522 1.50 * expected_time_between_callbacks_ms);
523 } 523 }
524 524
525 void GetDefaultOutputStreamParameters() { 525 void GetDefaultOutputStreamParameters() {
526 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); 526 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread());
527 audio_output_parameters_ = 527 audio_output_parameters_ =
528 audio_manager()->GetDefaultOutputStreamParameters(); 528 audio_manager()->GetDefaultOutputStreamParameters();
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 OpenAndStartAudioInputStreamOnAudioThread(&sink); 659 OpenAndStartAudioInputStreamOnAudioThread(&sink);
660 660
661 start_time_ = base::TimeTicks::Now(); 661 start_time_ = base::TimeTicks::Now();
662 loop()->Run(); 662 loop()->Run();
663 end_time_ = base::TimeTicks::Now(); 663 end_time_ = base::TimeTicks::Now();
664 664
665 StopAndCloseAudioInputStreamOnAudioThread(); 665 StopAndCloseAudioInputStreamOnAudioThread();
666 666
667 double average_time_between_callbacks_ms = 667 double average_time_between_callbacks_ms =
668 AverageTimeBetweenCallbacks(num_callbacks); 668 AverageTimeBetweenCallbacks(num_callbacks);
669 VLOG(0) << "expected time between callbacks: " 669 DVLOG(0) << "expected time between callbacks: "
670 << expected_time_between_callbacks_ms << " ms"; 670 << expected_time_between_callbacks_ms << " ms";
671 VLOG(0) << "average time between callbacks: " 671 DVLOG(0) << "average time between callbacks: "
672 << average_time_between_callbacks_ms << " ms"; 672 << average_time_between_callbacks_ms << " ms";
673 EXPECT_GE(average_time_between_callbacks_ms, 673 EXPECT_GE(average_time_between_callbacks_ms,
674 0.70 * expected_time_between_callbacks_ms); 674 0.70 * expected_time_between_callbacks_ms);
675 EXPECT_LE(average_time_between_callbacks_ms, 675 EXPECT_LE(average_time_between_callbacks_ms,
676 1.30 * expected_time_between_callbacks_ms); 676 1.30 * expected_time_between_callbacks_ms);
677 } 677 }
678 678
679 void GetDefaultInputStreamParameters() { 679 void GetDefaultInputStreamParameters() {
680 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread()); 680 DCHECK(audio_manager()->GetTaskRunner()->BelongsToCurrentThread());
681 audio_input_parameters_ = audio_manager()->GetInputStreamParameters( 681 audio_input_parameters_ = audio_manager()->GetInputStreamParameters(
682 AudioManagerBase::kDefaultDeviceId); 682 AudioManagerBase::kDefaultDeviceId);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 private: 715 private:
716 DISALLOW_COPY_AND_ASSIGN(AudioAndroidInputTest); 716 DISALLOW_COPY_AND_ASSIGN(AudioAndroidInputTest);
717 }; 717 };
718 718
719 // Get the default audio input parameters and log the result. 719 // Get the default audio input parameters and log the result.
720 TEST_P(AudioAndroidInputTest, GetDefaultInputStreamParameters) { 720 TEST_P(AudioAndroidInputTest, GetDefaultInputStreamParameters) {
721 // We don't go through AudioAndroidInputTest::GetInputStreamParameters() here 721 // We don't go through AudioAndroidInputTest::GetInputStreamParameters() here
722 // so that we can log the real (non-overridden) values of the effects. 722 // so that we can log the real (non-overridden) values of the effects.
723 GetDefaultInputStreamParametersOnAudioThread(); 723 GetDefaultInputStreamParametersOnAudioThread();
724 EXPECT_TRUE(audio_input_parameters().IsValid()); 724 EXPECT_TRUE(audio_input_parameters().IsValid());
725 VLOG(1) << audio_input_parameters(); 725 DVLOG(1) << audio_input_parameters();
726 } 726 }
727 727
728 // Get the default audio output parameters and log the result. 728 // Get the default audio output parameters and log the result.
729 TEST_F(AudioAndroidOutputTest, GetDefaultOutputStreamParameters) { 729 TEST_F(AudioAndroidOutputTest, GetDefaultOutputStreamParameters) {
730 GetDefaultOutputStreamParametersOnAudioThread(); 730 GetDefaultOutputStreamParametersOnAudioThread();
731 VLOG(1) << audio_output_parameters(); 731 DVLOG(1) << audio_output_parameters();
732 } 732 }
733 733
734 // Verify input device enumeration. 734 // Verify input device enumeration.
735 TEST_F(AudioAndroidInputTest, GetAudioInputDeviceNames) { 735 TEST_F(AudioAndroidInputTest, GetAudioInputDeviceNames) {
736 if (!audio_manager()->HasAudioInputDevices()) 736 if (!audio_manager()->HasAudioInputDevices())
737 return; 737 return;
738 AudioDeviceNames devices; 738 AudioDeviceNames devices;
739 RunOnAudioThread( 739 RunOnAudioThread(
740 base::Bind(&AudioManager::GetAudioInputDeviceNames, 740 base::Bind(&AudioManager::GetAudioInputDeviceNames,
741 base::Unretained(audio_manager()), 741 base::Unretained(audio_manager()),
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 audio_output_parameters().sample_rate() / 100); 833 audio_output_parameters().sample_rate() / 100);
834 StartOutputStreamCallbacks(params); 834 StartOutputStreamCallbacks(params);
835 } 835 }
836 836
837 // Play out a PCM file segment in real time and allow the user to verify that 837 // Play out a PCM file segment in real time and allow the user to verify that
838 // the rendered audio sounds OK. 838 // the rendered audio sounds OK.
839 // NOTE: this test requires user interaction and is not designed to run as an 839 // NOTE: this test requires user interaction and is not designed to run as an
840 // automatized test on bots. 840 // automatized test on bots.
841 TEST_F(AudioAndroidOutputTest, DISABLED_RunOutputStreamWithFileAsSource) { 841 TEST_F(AudioAndroidOutputTest, DISABLED_RunOutputStreamWithFileAsSource) {
842 GetDefaultOutputStreamParametersOnAudioThread(); 842 GetDefaultOutputStreamParametersOnAudioThread();
843 VLOG(1) << audio_output_parameters(); 843 DVLOG(1) << audio_output_parameters();
844 MakeAudioOutputStreamOnAudioThread(audio_output_parameters()); 844 MakeAudioOutputStreamOnAudioThread(audio_output_parameters());
845 845
846 std::string file_name; 846 std::string file_name;
847 const AudioParameters params = audio_output_parameters(); 847 const AudioParameters params = audio_output_parameters();
848 if (params.sample_rate() == 48000 && params.channels() == 2) { 848 if (params.sample_rate() == 48000 && params.channels() == 2) {
849 file_name = kSpeechFile_16b_s_48k; 849 file_name = kSpeechFile_16b_s_48k;
850 } else if (params.sample_rate() == 48000 && params.channels() == 1) { 850 } else if (params.sample_rate() == 48000 && params.channels() == 1) {
851 file_name = kSpeechFile_16b_m_48k; 851 file_name = kSpeechFile_16b_m_48k;
852 } else if (params.sample_rate() == 44100 && params.channels() == 2) { 852 } else if (params.sample_rate() == 44100 && params.channels() == 2) {
853 file_name = kSpeechFile_16b_s_44k; 853 file_name = kSpeechFile_16b_s_44k;
854 } else if (params.sample_rate() == 44100 && params.channels() == 1) { 854 } else if (params.sample_rate() == 44100 && params.channels() == 1) {
855 file_name = kSpeechFile_16b_m_44k; 855 file_name = kSpeechFile_16b_m_44k;
856 } else { 856 } else {
857 FAIL() << "This test supports 44.1kHz and 48kHz mono/stereo only."; 857 FAIL() << "This test supports 44.1kHz and 48kHz mono/stereo only.";
858 return; 858 return;
859 } 859 }
860 860
861 base::WaitableEvent event(false, false); 861 base::WaitableEvent event(false, false);
862 FileAudioSource source(&event, file_name); 862 FileAudioSource source(&event, file_name);
863 863
864 OpenAndStartAudioOutputStreamOnAudioThread(&source); 864 OpenAndStartAudioOutputStreamOnAudioThread(&source);
865 VLOG(0) << ">> Verify that the file is played out correctly..."; 865 DVLOG(0) << ">> Verify that the file is played out correctly...";
866 EXPECT_TRUE(event.TimedWait(TestTimeouts::action_max_timeout())); 866 EXPECT_TRUE(event.TimedWait(TestTimeouts::action_max_timeout()));
867 StopAndCloseAudioOutputStreamOnAudioThread(); 867 StopAndCloseAudioOutputStreamOnAudioThread();
868 } 868 }
869 869
870 // Start input streaming and run it for ten seconds while recording to a 870 // Start input streaming and run it for ten seconds while recording to a
871 // local audio file. 871 // local audio file.
872 // NOTE: this test requires user interaction and is not designed to run as an 872 // NOTE: this test requires user interaction and is not designed to run as an
873 // automatized test on bots. 873 // automatized test on bots.
874 TEST_P(AudioAndroidInputTest, DISABLED_RunSimplexInputStreamWithFileAsSink) { 874 TEST_P(AudioAndroidInputTest, DISABLED_RunSimplexInputStreamWithFileAsSink) {
875 AudioParameters params = GetInputStreamParameters(); 875 AudioParameters params = GetInputStreamParameters();
876 VLOG(1) << params; 876 DVLOG(1) << params;
877 MakeAudioInputStreamOnAudioThread(params); 877 MakeAudioInputStreamOnAudioThread(params);
878 878
879 std::string file_name = base::StringPrintf("out_simplex_%d_%d_%d.pcm", 879 std::string file_name = base::StringPrintf("out_simplex_%d_%d_%d.pcm",
880 params.sample_rate(), 880 params.sample_rate(),
881 params.frames_per_buffer(), 881 params.frames_per_buffer(),
882 params.channels()); 882 params.channels());
883 883
884 base::WaitableEvent event(false, false); 884 base::WaitableEvent event(false, false);
885 FileAudioSink sink(&event, params, file_name); 885 FileAudioSink sink(&event, params, file_name);
886 886
887 OpenAndStartAudioInputStreamOnAudioThread(&sink); 887 OpenAndStartAudioInputStreamOnAudioThread(&sink);
888 VLOG(0) << ">> Speak into the microphone to record audio..."; 888 DVLOG(0) << ">> Speak into the microphone to record audio...";
889 EXPECT_TRUE(event.TimedWait(TestTimeouts::action_max_timeout())); 889 EXPECT_TRUE(event.TimedWait(TestTimeouts::action_max_timeout()));
890 StopAndCloseAudioInputStreamOnAudioThread(); 890 StopAndCloseAudioInputStreamOnAudioThread();
891 } 891 }
892 892
893 // Same test as RunSimplexInputStreamWithFileAsSink but this time output 893 // Same test as RunSimplexInputStreamWithFileAsSink but this time output
894 // streaming is active as well (reads zeros only). 894 // streaming is active as well (reads zeros only).
895 // NOTE: this test requires user interaction and is not designed to run as an 895 // NOTE: this test requires user interaction and is not designed to run as an
896 // automatized test on bots. 896 // automatized test on bots.
897 TEST_P(AudioAndroidInputTest, DISABLED_RunDuplexInputStreamWithFileAsSink) { 897 TEST_P(AudioAndroidInputTest, DISABLED_RunDuplexInputStreamWithFileAsSink) {
898 AudioParameters in_params = GetInputStreamParameters(); 898 AudioParameters in_params = GetInputStreamParameters();
899 VLOG(1) << in_params; 899 DVLOG(1) << in_params;
900 MakeAudioInputStreamOnAudioThread(in_params); 900 MakeAudioInputStreamOnAudioThread(in_params);
901 901
902 GetDefaultOutputStreamParametersOnAudioThread(); 902 GetDefaultOutputStreamParametersOnAudioThread();
903 VLOG(1) << audio_output_parameters(); 903 DVLOG(1) << audio_output_parameters();
904 MakeAudioOutputStreamOnAudioThread(audio_output_parameters()); 904 MakeAudioOutputStreamOnAudioThread(audio_output_parameters());
905 905
906 std::string file_name = base::StringPrintf("out_duplex_%d_%d_%d.pcm", 906 std::string file_name = base::StringPrintf("out_duplex_%d_%d_%d.pcm",
907 in_params.sample_rate(), 907 in_params.sample_rate(),
908 in_params.frames_per_buffer(), 908 in_params.frames_per_buffer(),
909 in_params.channels()); 909 in_params.channels());
910 910
911 base::WaitableEvent event(false, false); 911 base::WaitableEvent event(false, false);
912 FileAudioSink sink(&event, in_params, file_name); 912 FileAudioSink sink(&event, in_params, file_name);
913 MockAudioSourceCallback source; 913 MockAudioSourceCallback source;
914 914
915 EXPECT_CALL(source, OnMoreData(NotNull(), _)) 915 EXPECT_CALL(source, OnMoreData(NotNull(), _))
916 .WillRepeatedly(Invoke(RealOnMoreData)); 916 .WillRepeatedly(Invoke(RealOnMoreData));
917 EXPECT_CALL(source, OnError(audio_output_stream_)).Times(0); 917 EXPECT_CALL(source, OnError(audio_output_stream_)).Times(0);
918 918
919 OpenAndStartAudioInputStreamOnAudioThread(&sink); 919 OpenAndStartAudioInputStreamOnAudioThread(&sink);
920 OpenAndStartAudioOutputStreamOnAudioThread(&source); 920 OpenAndStartAudioOutputStreamOnAudioThread(&source);
921 VLOG(0) << ">> Speak into the microphone to record audio"; 921 DVLOG(0) << ">> Speak into the microphone to record audio";
922 EXPECT_TRUE(event.TimedWait(TestTimeouts::action_max_timeout())); 922 EXPECT_TRUE(event.TimedWait(TestTimeouts::action_max_timeout()));
923 StopAndCloseAudioOutputStreamOnAudioThread(); 923 StopAndCloseAudioOutputStreamOnAudioThread();
924 StopAndCloseAudioInputStreamOnAudioThread(); 924 StopAndCloseAudioInputStreamOnAudioThread();
925 } 925 }
926 926
927 // Start audio in both directions while feeding captured data into a FIFO so 927 // Start audio in both directions while feeding captured data into a FIFO so
928 // it can be read directly (in loopback) by the render side. A small extra 928 // it can be read directly (in loopback) by the render side. A small extra
929 // delay will be added by the FIFO and an estimate of this delay will be 929 // delay will be added by the FIFO and an estimate of this delay will be
930 // printed out during the test. 930 // printed out during the test.
931 // NOTE: this test requires user interaction and is not designed to run as an 931 // NOTE: this test requires user interaction and is not designed to run as an
932 // automatized test on bots. 932 // automatized test on bots.
933 TEST_P(AudioAndroidInputTest, 933 TEST_P(AudioAndroidInputTest,
934 DISABLED_RunSymmetricInputAndOutputStreamsInFullDuplex) { 934 DISABLED_RunSymmetricInputAndOutputStreamsInFullDuplex) {
935 // Get native audio parameters for the input side. 935 // Get native audio parameters for the input side.
936 AudioParameters default_input_params = GetInputStreamParameters(); 936 AudioParameters default_input_params = GetInputStreamParameters();
937 937
938 // Modify the parameters so that both input and output can use the same 938 // Modify the parameters so that both input and output can use the same
939 // parameters by selecting 10ms as buffer size. This will also ensure that 939 // parameters by selecting 10ms as buffer size. This will also ensure that
940 // the output stream will be a mono stream since mono is default for input 940 // the output stream will be a mono stream since mono is default for input
941 // audio on Android. 941 // audio on Android.
942 AudioParameters io_params(default_input_params.format(), 942 AudioParameters io_params(default_input_params.format(),
943 default_input_params.channel_layout(), 943 default_input_params.channel_layout(),
944 ChannelLayoutToChannelCount( 944 ChannelLayoutToChannelCount(
945 default_input_params.channel_layout()), 945 default_input_params.channel_layout()),
946 default_input_params.sample_rate(), 946 default_input_params.sample_rate(),
947 default_input_params.bits_per_sample(), 947 default_input_params.bits_per_sample(),
948 default_input_params.sample_rate() / 100, 948 default_input_params.sample_rate() / 100,
949 default_input_params.effects()); 949 default_input_params.effects());
950 VLOG(1) << io_params; 950 DVLOG(1) << io_params;
951 951
952 // Create input and output streams using the common audio parameters. 952 // Create input and output streams using the common audio parameters.
953 MakeAudioInputStreamOnAudioThread(io_params); 953 MakeAudioInputStreamOnAudioThread(io_params);
954 MakeAudioOutputStreamOnAudioThread(io_params); 954 MakeAudioOutputStreamOnAudioThread(io_params);
955 955
956 FullDuplexAudioSinkSource full_duplex(io_params); 956 FullDuplexAudioSinkSource full_duplex(io_params);
957 957
958 // Start a full duplex audio session and print out estimates of the extra 958 // Start a full duplex audio session and print out estimates of the extra
959 // delay we should expect from the FIFO. If real-time delay measurements are 959 // delay we should expect from the FIFO. If real-time delay measurements are
960 // performed, the result should be reduced by this extra delay since it is 960 // performed, the result should be reduced by this extra delay since it is
961 // something that has been added by the test. 961 // something that has been added by the test.
962 OpenAndStartAudioInputStreamOnAudioThread(&full_duplex); 962 OpenAndStartAudioInputStreamOnAudioThread(&full_duplex);
963 OpenAndStartAudioOutputStreamOnAudioThread(&full_duplex); 963 OpenAndStartAudioOutputStreamOnAudioThread(&full_duplex);
964 VLOG(1) << "HINT: an estimate of the extra FIFO delay will be updated " 964 DVLOG(1) << "HINT: an estimate of the extra FIFO delay will be updated "
965 << "once per second during this test."; 965 << "once per second during this test.";
966 VLOG(0) << ">> Speak into the mic and listen to the audio in loopback..."; 966 DVLOG(0) << ">> Speak into the mic and listen to the audio in loopback...";
967 fflush(stdout); 967 fflush(stdout);
968 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20)); 968 base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20));
969 printf("\n"); 969 printf("\n");
970 StopAndCloseAudioOutputStreamOnAudioThread(); 970 StopAndCloseAudioOutputStreamOnAudioThread();
971 StopAndCloseAudioInputStreamOnAudioThread(); 971 StopAndCloseAudioInputStreamOnAudioThread();
972 } 972 }
973 973
974 INSTANTIATE_TEST_CASE_P(AudioAndroidInputTest, AudioAndroidInputTest, 974 INSTANTIATE_TEST_CASE_P(AudioAndroidInputTest, AudioAndroidInputTest,
975 testing::ValuesIn(RunAudioRecordInputPathTests())); 975 testing::ValuesIn(RunAudioRecordInputPathTests()));
976 976
977 } // namespace media 977 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/audio/audio_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698