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

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

Issue 1806313003: Pass task runners to AudioManager constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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
OLDNEW
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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/environment.h" 7 #include "base/environment.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/test/test_timeouts.h" 10 #include "base/test/test_timeouts.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 private: 100 private:
101 media::SeekableBuffer buffer_; 101 media::SeekableBuffer buffer_;
102 FILE* file_; 102 FILE* file_;
103 int bytes_to_write_; 103 int bytes_to_write_;
104 }; 104 };
105 105
106 class MacAudioInputTest : public testing::Test { 106 class MacAudioInputTest : public testing::Test {
107 protected: 107 protected:
108 MacAudioInputTest() 108 MacAudioInputTest()
109 : message_loop_(base::MessageLoop::TYPE_UI), 109 : message_loop_(base::MessageLoop::TYPE_UI),
110 audio_manager_(AudioManager::CreateForTesting()) { 110 audio_manager_(
111 AudioManager::CreateForTesting(message_loop_.task_runner())) {
111 // Wait for the AudioManager to finish any initialization on the audio loop. 112 // Wait for the AudioManager to finish any initialization on the audio loop.
112 base::RunLoop().RunUntilIdle(); 113 base::RunLoop().RunUntilIdle();
113 } 114 }
114 115
115 ~MacAudioInputTest() override { base::RunLoop().RunUntilIdle(); } 116 ~MacAudioInputTest() override { base::RunLoop().RunUntilIdle(); }
116 117
117 bool InputDevicesAvailable() { 118 bool InputDevicesAvailable() {
118 return audio_manager_->HasAudioInputDevices(); 119 return audio_manager_->HasAudioInputDevices();
119 } 120 }
120 121
(...skipping 18 matching lines...) Expand all
139 int samples_per_packet = fs / 100; 140 int samples_per_packet = fs / 100;
140 AudioInputStream* ais = audio_manager_->MakeAudioInputStream( 141 AudioInputStream* ais = audio_manager_->MakeAudioInputStream(
141 AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, 142 AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY,
142 channel_layout, fs, 16, samples_per_packet), 143 channel_layout, fs, 16, samples_per_packet),
143 AudioManagerBase::kDefaultDeviceId); 144 AudioManagerBase::kDefaultDeviceId);
144 EXPECT_TRUE(ais); 145 EXPECT_TRUE(ais);
145 return ais; 146 return ais;
146 } 147 }
147 148
148 base::MessageLoop message_loop_; 149 base::MessageLoop message_loop_;
149 scoped_ptr<AudioManager> audio_manager_; 150 ScopedAudioManagerPtr audio_manager_;
150 }; 151 };
151 152
152 // Test Create(), Close(). 153 // Test Create(), Close().
153 TEST_F(MacAudioInputTest, AUAudioInputStreamCreateAndClose) { 154 TEST_F(MacAudioInputTest, AUAudioInputStreamCreateAndClose) {
154 ABORT_AUDIO_TEST_IF_NOT(InputDevicesAvailable()); 155 ABORT_AUDIO_TEST_IF_NOT(InputDevicesAvailable());
155 AudioInputStream* ais = CreateDefaultAudioInputStream(); 156 AudioInputStream* ais = CreateDefaultAudioInputStream();
156 ais->Close(); 157 ais->Close();
157 } 158 }
158 159
159 // Test Open(), Close(). 160 // Test Open(), Close().
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 WriteToFileAudioSink file_sink(file_name); 264 WriteToFileAudioSink file_sink(file_name);
264 fprintf(stderr, " >> Speak into the mic while recording...\n"); 265 fprintf(stderr, " >> Speak into the mic while recording...\n");
265 ais->Start(&file_sink); 266 ais->Start(&file_sink);
266 base::PlatformThread::Sleep(TestTimeouts::action_timeout()); 267 base::PlatformThread::Sleep(TestTimeouts::action_timeout());
267 ais->Stop(); 268 ais->Stop();
268 fprintf(stderr, " >> Recording has stopped.\n"); 269 fprintf(stderr, " >> Recording has stopped.\n");
269 ais->Close(); 270 ais->Close();
270 } 271 }
271 272
272 } // namespace media 273 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698