| 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 "media/audio/win/audio_low_latency_input_win.h" | 5 #include "media/audio/win/audio_low_latency_input_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <mmsystem.h> | 8 #include <mmsystem.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 } | 195 } |
| 196 int bits_per_sample() const { return default_params_.bits_per_sample(); } | 196 int bits_per_sample() const { return default_params_.bits_per_sample(); } |
| 197 int sample_rate() const { return default_params_.sample_rate(); } | 197 int sample_rate() const { return default_params_.sample_rate(); } |
| 198 int frames_per_buffer() const { return frames_per_buffer_; } | 198 int frames_per_buffer() const { return frames_per_buffer_; } |
| 199 | 199 |
| 200 private: | 200 private: |
| 201 AudioInputStream* CreateInputStream() { | 201 AudioInputStream* CreateInputStream() { |
| 202 AudioParameters params = default_params_; | 202 AudioParameters params = default_params_; |
| 203 params.set_frames_per_buffer(frames_per_buffer_); | 203 params.set_frames_per_buffer(frames_per_buffer_); |
| 204 AudioInputStream* ais = audio_man_->MakeAudioInputStream( | 204 AudioInputStream* ais = audio_man_->MakeAudioInputStream( |
| 205 params, AudioDeviceDescription::kDefaultDeviceId, | 205 params, AudioDeviceDescription::kDefaultDeviceId); |
| 206 AudioManager::LogCallback()); | |
| 207 EXPECT_TRUE(ais); | 206 EXPECT_TRUE(ais); |
| 208 return ais; | 207 return ais; |
| 209 } | 208 } |
| 210 | 209 |
| 211 AudioManager* audio_man_; | 210 AudioManager* audio_man_; |
| 212 AudioParameters default_params_; | 211 AudioParameters default_params_; |
| 213 int frames_per_buffer_; | 212 int frames_per_buffer_; |
| 214 }; | 213 }; |
| 215 | 214 |
| 216 // Convenience method which creates a default AudioInputStream object. | 215 // Convenience method which creates a default AudioInputStream object. |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 AudioParameters params = audio_manager_->GetInputStreamParameters( | 433 AudioParameters params = audio_manager_->GetInputStreamParameters( |
| 435 AudioDeviceDescription::kLoopbackInputDeviceId); | 434 AudioDeviceDescription::kLoopbackInputDeviceId); |
| 436 EXPECT_EQ(params.effects(), 0); | 435 EXPECT_EQ(params.effects(), 0); |
| 437 | 436 |
| 438 AudioParameters output_params = | 437 AudioParameters output_params = |
| 439 audio_manager_->GetOutputStreamParameters(std::string()); | 438 audio_manager_->GetOutputStreamParameters(std::string()); |
| 440 EXPECT_EQ(params.sample_rate(), output_params.sample_rate()); | 439 EXPECT_EQ(params.sample_rate(), output_params.sample_rate()); |
| 441 EXPECT_EQ(params.channel_layout(), output_params.channel_layout()); | 440 EXPECT_EQ(params.channel_layout(), output_params.channel_layout()); |
| 442 | 441 |
| 443 ScopedAudioInputStream stream(audio_manager_->MakeAudioInputStream( | 442 ScopedAudioInputStream stream(audio_manager_->MakeAudioInputStream( |
| 444 params, AudioDeviceDescription::kLoopbackInputDeviceId, | 443 params, AudioDeviceDescription::kLoopbackInputDeviceId)); |
| 445 AudioManager::LogCallback())); | |
| 446 ASSERT_TRUE(stream->Open()); | 444 ASSERT_TRUE(stream->Open()); |
| 447 FakeAudioInputCallback sink; | 445 FakeAudioInputCallback sink; |
| 448 stream->Start(&sink); | 446 stream->Start(&sink); |
| 449 ASSERT_FALSE(sink.error()); | 447 ASSERT_FALSE(sink.error()); |
| 450 | 448 |
| 451 sink.WaitForData(); | 449 sink.WaitForData(); |
| 452 stream.Close(); | 450 stream.Close(); |
| 453 | 451 |
| 454 EXPECT_GT(sink.num_received_audio_frames(), 0); | 452 EXPECT_GT(sink.num_received_audio_frames(), 0); |
| 455 EXPECT_FALSE(sink.error()); | 453 EXPECT_FALSE(sink.error()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 477 WriteToFileAudioSink file_sink(file_name, aisw.bits_per_sample()); | 475 WriteToFileAudioSink file_sink(file_name, aisw.bits_per_sample()); |
| 478 VLOG(0) << ">> Speak into the default microphone while recording."; | 476 VLOG(0) << ">> Speak into the default microphone while recording."; |
| 479 ais->Start(&file_sink); | 477 ais->Start(&file_sink); |
| 480 base::PlatformThread::Sleep(TestTimeouts::action_timeout()); | 478 base::PlatformThread::Sleep(TestTimeouts::action_timeout()); |
| 481 ais->Stop(); | 479 ais->Stop(); |
| 482 VLOG(0) << ">> Recording has stopped."; | 480 VLOG(0) << ">> Recording has stopped."; |
| 483 ais.Close(); | 481 ais.Close(); |
| 484 } | 482 } |
| 485 | 483 |
| 486 } // namespace media | 484 } // namespace media |
| OLD | NEW |