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 <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/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 num_received_audio_frames_(0) {} | 55 num_received_audio_frames_(0) {} |
56 | 56 |
57 bool error() const { return error_; } | 57 bool error() const { return error_; } |
58 int num_received_audio_frames() const { return num_received_audio_frames_; } | 58 int num_received_audio_frames() const { return num_received_audio_frames_; } |
59 | 59 |
60 // Waits until OnData() is called on another thread. | 60 // Waits until OnData() is called on another thread. |
61 void WaitForData() { | 61 void WaitForData() { |
62 data_event_.Wait(); | 62 data_event_.Wait(); |
63 } | 63 } |
64 | 64 |
65 virtual void OnData(AudioInputStream* stream, | 65 void OnData(AudioInputStream* stream, |
66 const AudioBus* src, | 66 const AudioBus* src, |
67 uint32 hardware_delay_bytes, | 67 uint32 hardware_delay_bytes, |
68 double volume) override { | 68 double volume) override { |
69 EXPECT_NE(hardware_delay_bytes, 0u); | 69 EXPECT_NE(hardware_delay_bytes, 0u); |
70 num_received_audio_frames_ += src->frames(); | 70 num_received_audio_frames_ += src->frames(); |
71 data_event_.Signal(); | 71 data_event_.Signal(); |
72 } | 72 } |
73 | 73 |
74 virtual void OnError(AudioInputStream* stream) override { | 74 void OnError(AudioInputStream* stream) override { |
75 error_ = true; | 75 error_ = true; |
76 } | 76 } |
77 | 77 |
78 private: | 78 private: |
79 int num_received_audio_frames_; | 79 int num_received_audio_frames_; |
80 base::WaitableEvent data_event_; | 80 base::WaitableEvent data_event_; |
81 bool error_; | 81 bool error_; |
82 | 82 |
83 DISALLOW_COPY_AND_ASSIGN(FakeAudioInputCallback); | 83 DISALLOW_COPY_AND_ASSIGN(FakeAudioInputCallback); |
84 }; | 84 }; |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 WriteToFileAudioSink file_sink(file_name, aisw.bits_per_sample()); | 470 WriteToFileAudioSink file_sink(file_name, aisw.bits_per_sample()); |
471 VLOG(0) << ">> Speak into the default microphone while recording."; | 471 VLOG(0) << ">> Speak into the default microphone while recording."; |
472 ais->Start(&file_sink); | 472 ais->Start(&file_sink); |
473 base::PlatformThread::Sleep(TestTimeouts::action_timeout()); | 473 base::PlatformThread::Sleep(TestTimeouts::action_timeout()); |
474 ais->Stop(); | 474 ais->Stop(); |
475 VLOG(0) << ">> Recording has stopped."; | 475 VLOG(0) << ">> Recording has stopped."; |
476 ais.Close(); | 476 ais.Close(); |
477 } | 477 } |
478 | 478 |
479 } // namespace media | 479 } // namespace media |
OLD | NEW |