OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/environment.h" | 6 #include "base/environment.h" |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/test/test_timeouts.h" | 8 #include "base/test/test_timeouts.h" |
9 #include "base/threading/platform_thread.h" | 9 #include "base/threading/platform_thread.h" |
10 #include "media/audio/audio_io.h" | 10 #include "media/audio/audio_io.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 return has_input; | 105 return has_input; |
106 } | 106 } |
107 | 107 |
108 // Convenience method which creates a default AudioInputStream object using | 108 // Convenience method which creates a default AudioInputStream object using |
109 // a 10ms frame size and a sample rate which is set to the hardware sample | 109 // a 10ms frame size and a sample rate which is set to the hardware sample |
110 // rate. | 110 // rate. |
111 AudioInputStream* CreateDefaultAudioInputStream() { | 111 AudioInputStream* CreateDefaultAudioInputStream() { |
112 int fs = static_cast<int>(AUAudioInputStream::HardwareSampleRate()); | 112 int fs = static_cast<int>(AUAudioInputStream::HardwareSampleRate()); |
113 int samples_per_packet = fs / 100; | 113 int samples_per_packet = fs / 100; |
114 AudioInputStream* ais = audio_manager_->MakeAudioInputStream( | 114 AudioInputStream* ais = audio_manager_->MakeAudioInputStream( |
115 AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, | 115 AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, false, |
116 CHANNEL_LAYOUT_STEREO, fs, 16, samples_per_packet), | 116 CHANNEL_LAYOUT_STEREO, fs, 16, samples_per_packet), |
117 AudioManagerBase::kDefaultDeviceId); | 117 AudioManagerBase::kDefaultDeviceId); |
118 EXPECT_TRUE(ais); | 118 EXPECT_TRUE(ais); |
119 return ais; | 119 return ais; |
120 } | 120 } |
121 | 121 |
122 // Convenience method which creates an AudioInputStream object with a | 122 // Convenience method which creates an AudioInputStream object with a |
123 // specified channel layout. | 123 // specified channel layout. |
124 AudioInputStream* CreateAudioInputStream(ChannelLayout channel_layout) { | 124 AudioInputStream* CreateAudioInputStream(ChannelLayout channel_layout) { |
125 int fs = static_cast<int>(AUAudioInputStream::HardwareSampleRate()); | 125 int fs = static_cast<int>(AUAudioInputStream::HardwareSampleRate()); |
126 int samples_per_packet = fs / 100; | 126 int samples_per_packet = fs / 100; |
127 AudioInputStream* ais = audio_manager_->MakeAudioInputStream( | 127 AudioInputStream* ais = audio_manager_->MakeAudioInputStream( |
128 AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, | 128 AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, false, |
129 channel_layout, fs, 16, samples_per_packet), | 129 channel_layout, fs, 16, samples_per_packet), |
130 AudioManagerBase::kDefaultDeviceId); | 130 AudioManagerBase::kDefaultDeviceId); |
131 EXPECT_TRUE(ais); | 131 EXPECT_TRUE(ais); |
132 return ais; | 132 return ais; |
133 } | 133 } |
134 | 134 |
135 scoped_ptr<AudioManager> audio_manager_; | 135 scoped_ptr<AudioManager> audio_manager_; |
136 }; | 136 }; |
137 | 137 |
138 // Test Create(), Close(). | 138 // Test Create(), Close(). |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 fprintf(stderr, " Sample rate: %d\n", fs); | 300 fprintf(stderr, " Sample rate: %d\n", fs); |
301 WriteToFileAudioSink file_sink(file_name); | 301 WriteToFileAudioSink file_sink(file_name); |
302 fprintf(stderr, " >> Speak into the mic while recording...\n"); | 302 fprintf(stderr, " >> Speak into the mic while recording...\n"); |
303 ais->Start(&file_sink); | 303 ais->Start(&file_sink); |
304 base::PlatformThread::Sleep(TestTimeouts::action_timeout()); | 304 base::PlatformThread::Sleep(TestTimeouts::action_timeout()); |
305 ais->Stop(); | 305 ais->Stop(); |
306 fprintf(stderr, " >> Recording has stopped.\n"); | 306 fprintf(stderr, " >> Recording has stopped.\n"); |
307 ais->Close(); | 307 ais->Close(); |
308 } | 308 } |
309 | 309 |
OLD | NEW |