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