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

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: update 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
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), "default");
henrika (OOO until Aug 14) 2011/11/17 11:26:15 Use constant.
no longer working on chromium 2011/11/17 14:15:26 Done.
108 EXPECT_TRUE(ais); 108 EXPECT_TRUE(ais);
109 return ais; 109 return ais;
110 } 110 }
111 111
112 // Convenience method which creates an AudioInputStream object with a specified 112 // Convenience method which creates an AudioInputStream object with a specified
113 // channel layout. 113 // channel layout.
114 static AudioInputStream* CreateAudioInputStream(ChannelLayout channel_layout) { 114 static AudioInputStream* CreateAudioInputStream(ChannelLayout channel_layout) {
115 AudioManager* audio_man = AudioManager::GetAudioManager(); 115 AudioManager* audio_man = AudioManager::GetAudioManager();
116 int fs = static_cast<int>(AUAudioInputStream::HardwareSampleRate()); 116 int fs = static_cast<int>(AUAudioInputStream::HardwareSampleRate());
117 int samples_per_packet = fs / 100; 117 int samples_per_packet = fs / 100;
118 AudioInputStream* ais = audio_man->MakeAudioInputStream( 118 AudioInputStream* ais = audio_man->MakeAudioInputStream(
119 AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, 119 AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY,
120 channel_layout, fs, 16, samples_per_packet)); 120 channel_layout, fs, 16, samples_per_packet),
121 AudioManagerBase::kDefaultDeviceId);
121 EXPECT_TRUE(ais); 122 EXPECT_TRUE(ais);
122 return ais; 123 return ais;
123 } 124 }
124 125
125 126
126 // Test Create(), Close(). 127 // Test Create(), Close().
127 TEST(MacAudioInputTest, AUAudioInputStreamCreateAndClose) { 128 TEST(MacAudioInputTest, AUAudioInputStreamCreateAndClose) {
128 if (!CanRunAudioTests()) 129 if (!CanRunAudioTests())
129 return; 130 return;
130 AudioInputStream* ais = CreateDefaultAudioInputStream(); 131 AudioInputStream* ais = CreateDefaultAudioInputStream();
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 fprintf(stderr, " Sample rate: %d\n", fs); 285 fprintf(stderr, " Sample rate: %d\n", fs);
285 WriteToFileAudioSink file_sink(file_name); 286 WriteToFileAudioSink file_sink(file_name);
286 fprintf(stderr, " >> Speak into the mic while recording...\n"); 287 fprintf(stderr, " >> Speak into the mic while recording...\n");
287 ais->Start(&file_sink); 288 ais->Start(&file_sink);
288 base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms()); 289 base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms());
289 ais->Stop(); 290 ais->Stop();
290 fprintf(stderr, " >> Recording has stopped.\n"); 291 fprintf(stderr, " >> Recording has stopped.\n");
291 ais->Close(); 292 ais->Close();
292 } 293 }
293 294
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698