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

Side by Side Diff: media/audio/mac/audio_low_latency_input_mac_unittest.cc

Issue 8491044: Link things together and enable the device selection for linux and mac. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: rebase2 Created 9 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 | Annotate | Revision Log
« no previous file with comments | « media/audio/mac/audio_low_latency_input_mac.cc ('k') | media/audio/mac/audio_manager_mac.h » ('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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/test/test_timeouts.h" 7 #include "base/test/test_timeouts.h"
8 #include "base/threading/platform_thread.h" 8 #include "base/threading/platform_thread.h"
9 #include "media/audio/audio_io.h" 9 #include "media/audio/audio_io.h"
10 #include "media/audio/audio_manager.h" 10 #include "media/audio/audio_manager_base.h"
11 #include "media/audio/mac/audio_low_latency_input_mac.h" 11 #include "media/audio/mac/audio_low_latency_input_mac.h"
12 #include "media/base/seekable_buffer.h" 12 #include "media/base/seekable_buffer.h"
13 #include "testing/gmock/include/gmock/gmock.h" 13 #include "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 using ::testing::_; 16 using ::testing::_;
17 using ::testing::AnyNumber; 17 using ::testing::AnyNumber;
18 using ::testing::Between; 18 using ::testing::Between;
19 using ::testing::Ge; 19 using ::testing::Ge;
20 using ::testing::NotNull; 20 using ::testing::NotNull;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 } 97 }
98 98
99 // Convenience method which creates a default AudioInputStream object using 99 // Convenience method which creates a default AudioInputStream object using
100 // a 10ms frame size and a sample rate which is set to the hardware sample rate. 100 // a 10ms frame size and a sample rate which is set to the hardware sample rate.
101 static AudioInputStream* CreateDefaultAudioInputStream() { 101 static AudioInputStream* CreateDefaultAudioInputStream() {
102 AudioManager* audio_man = AudioManager::GetAudioManager(); 102 AudioManager* audio_man = AudioManager::GetAudioManager();
103 int fs = static_cast<int>(AUAudioInputStream::HardwareSampleRate()); 103 int fs = static_cast<int>(AUAudioInputStream::HardwareSampleRate());
104 int samples_per_packet = fs / 100; 104 int samples_per_packet = fs / 100;
105 AudioInputStream* ais = audio_man->MakeAudioInputStream( 105 AudioInputStream* ais = audio_man->MakeAudioInputStream(
106 AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, 106 AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY,
107 CHANNEL_LAYOUT_STEREO, fs, 16, samples_per_packet)); 107 CHANNEL_LAYOUT_STEREO, fs, 16, samples_per_packet),
108 AudioManagerBase::kDefaultDeviceId);
108 EXPECT_TRUE(ais); 109 EXPECT_TRUE(ais);
109 return ais; 110 return ais;
110 } 111 }
111 112
112 // Convenience method which creates an AudioInputStream object with a specified 113 // Convenience method which creates an AudioInputStream object with a specified
113 // channel layout. 114 // channel layout.
114 static AudioInputStream* CreateAudioInputStream(ChannelLayout channel_layout) { 115 static AudioInputStream* CreateAudioInputStream(ChannelLayout channel_layout) {
115 AudioManager* audio_man = AudioManager::GetAudioManager(); 116 AudioManager* audio_man = AudioManager::GetAudioManager();
116 int fs = static_cast<int>(AUAudioInputStream::HardwareSampleRate()); 117 int fs = static_cast<int>(AUAudioInputStream::HardwareSampleRate());
117 int samples_per_packet = fs / 100; 118 int samples_per_packet = fs / 100;
118 AudioInputStream* ais = audio_man->MakeAudioInputStream( 119 AudioInputStream* ais = audio_man->MakeAudioInputStream(
119 AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, 120 AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY,
120 channel_layout, fs, 16, samples_per_packet)); 121 channel_layout, fs, 16, samples_per_packet),
122 AudioManagerBase::kDefaultDeviceId);
121 EXPECT_TRUE(ais); 123 EXPECT_TRUE(ais);
122 return ais; 124 return ais;
123 } 125 }
124 126
125 127
126 // Test Create(), Close(). 128 // Test Create(), Close().
127 TEST(MacAudioInputTest, AUAudioInputStreamCreateAndClose) { 129 TEST(MacAudioInputTest, AUAudioInputStreamCreateAndClose) {
128 if (!CanRunAudioTests()) 130 if (!CanRunAudioTests())
129 return; 131 return;
130 AudioInputStream* ais = CreateDefaultAudioInputStream(); 132 AudioInputStream* ais = CreateDefaultAudioInputStream();
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 fprintf(stderr, " Sample rate: %d\n", fs); 286 fprintf(stderr, " Sample rate: %d\n", fs);
285 WriteToFileAudioSink file_sink(file_name); 287 WriteToFileAudioSink file_sink(file_name);
286 fprintf(stderr, " >> Speak into the mic while recording...\n"); 288 fprintf(stderr, " >> Speak into the mic while recording...\n");
287 ais->Start(&file_sink); 289 ais->Start(&file_sink);
288 base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms()); 290 base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms());
289 ais->Stop(); 291 ais->Stop();
290 fprintf(stderr, " >> Recording has stopped.\n"); 292 fprintf(stderr, " >> Recording has stopped.\n");
291 ais->Close(); 293 ais->Close();
292 } 294 }
293 295
OLDNEW
« no previous file with comments | « media/audio/mac/audio_low_latency_input_mac.cc ('k') | media/audio/mac/audio_manager_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698