| OLD | NEW |
| 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 <windows.h> | 5 #include <windows.h> |
| 6 #include <mmsystem.h> | 6 #include <mmsystem.h> |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/environment.h" | 9 #include "base/environment.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 | 82 |
| 83 private: | 83 private: |
| 84 media::SeekableBuffer buffer_; | 84 media::SeekableBuffer buffer_; |
| 85 FILE* file_; | 85 FILE* file_; |
| 86 size_t bytes_to_write_; | 86 size_t bytes_to_write_; |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 // Convenience method which ensures that we are not running on the build | 89 // Convenience method which ensures that we are not running on the build |
| 90 // bots and that at least one valid input device can be found. | 90 // bots and that at least one valid input device can be found. |
| 91 static bool CanRunAudioTests(AudioManager* audio_man) { | 91 static bool CanRunAudioTests(AudioManager* audio_man) { |
| 92 scoped_ptr<base::Environment> env(base::Environment::Create()); | |
| 93 if (env->HasVar("CHROME_HEADLESS")) | |
| 94 return false; | |
| 95 | |
| 96 // TODO(henrika): note that we use Wave today to query the number of | 92 // TODO(henrika): note that we use Wave today to query the number of |
| 97 // existing input devices. | 93 // existing input devices. |
| 98 return audio_man->HasAudioInputDevices(); | 94 bool input = audio_man->HasAudioInputDevices(); |
| 95 LOG_IF(WARNING, !input) << "No input device detected."; |
| 96 return input; |
| 99 } | 97 } |
| 100 | 98 |
| 101 // Convenience method which creates a default AudioInputStream object but | 99 // Convenience method which creates a default AudioInputStream object but |
| 102 // also allows the user to modify the default settings. | 100 // also allows the user to modify the default settings. |
| 103 class AudioInputStreamWrapper { | 101 class AudioInputStreamWrapper { |
| 104 public: | 102 public: |
| 105 explicit AudioInputStreamWrapper(AudioManager* audio_manager) | 103 explicit AudioInputStreamWrapper(AudioManager* audio_manager) |
| 106 : com_init_(ScopedCOMInitializer::kMTA), | 104 : com_init_(ScopedCOMInitializer::kMTA), |
| 107 audio_man_(audio_manager), | 105 audio_man_(audio_manager), |
| 108 format_(AudioParameters::AUDIO_PCM_LOW_LATENCY), | 106 format_(AudioParameters::AUDIO_PCM_LOW_LATENCY), |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 fprintf(stderr, " File name : %s\n", file_name); | 364 fprintf(stderr, " File name : %s\n", file_name); |
| 367 fprintf(stderr, " Sample rate: %d\n", aisw.sample_rate()); | 365 fprintf(stderr, " Sample rate: %d\n", aisw.sample_rate()); |
| 368 WriteToFileAudioSink file_sink(file_name); | 366 WriteToFileAudioSink file_sink(file_name); |
| 369 fprintf(stderr, " >> Speak into the mic while recording...\n"); | 367 fprintf(stderr, " >> Speak into the mic while recording...\n"); |
| 370 ais->Start(&file_sink); | 368 ais->Start(&file_sink); |
| 371 base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms()); | 369 base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms()); |
| 372 ais->Stop(); | 370 ais->Stop(); |
| 373 fprintf(stderr, " >> Recording has stopped.\n"); | 371 fprintf(stderr, " >> Recording has stopped.\n"); |
| 374 ais->Close(); | 372 ais->Close(); |
| 375 } | 373 } |
| OLD | NEW |