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/fake_audio_input_stream.h" | 5 #include "media/audio/fake_audio_input_stream.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 } | 91 } |
92 | 92 |
93 void FakeAudioInputStream::ReadAudioFromSource() { | 93 void FakeAudioInputStream::ReadAudioFromSource() { |
94 DCHECK(audio_manager_->GetWorkerTaskRunner()->BelongsToCurrentThread()); | 94 DCHECK(audio_manager_->GetWorkerTaskRunner()->BelongsToCurrentThread()); |
95 DCHECK(callback_); | 95 DCHECK(callback_); |
96 | 96 |
97 if (!audio_source_) | 97 if (!audio_source_) |
98 audio_source_ = ChooseSource(); | 98 audio_source_ = ChooseSource(); |
99 | 99 |
100 const int kNoDelay = 0; | 100 const int kNoDelay = 0; |
101 audio_source_->OnMoreData(audio_bus_.get(), kNoDelay); | 101 audio_source_->OnMoreData(audio_bus_.get(), kNoDelay, 0); |
102 callback_->OnData(this, audio_bus_.get(), 0, 1.0); | 102 callback_->OnData(this, audio_bus_.get(), 0, 1.0); |
103 } | 103 } |
104 | 104 |
105 using AudioSourceCallback = AudioOutputStream::AudioSourceCallback; | 105 using AudioSourceCallback = AudioOutputStream::AudioSourceCallback; |
106 scoped_ptr<AudioSourceCallback> FakeAudioInputStream::ChooseSource() { | 106 scoped_ptr<AudioSourceCallback> FakeAudioInputStream::ChooseSource() { |
107 DCHECK(audio_manager_->GetWorkerTaskRunner()->BelongsToCurrentThread()); | 107 DCHECK(audio_manager_->GetWorkerTaskRunner()->BelongsToCurrentThread()); |
108 | 108 |
109 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 109 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
110 switches::kUseFileForFakeAudioCapture)) { | 110 switches::kUseFileForFakeAudioCapture)) { |
111 base::FilePath path_to_wav_file = | 111 base::FilePath path_to_wav_file = |
112 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( | 112 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( |
113 switches::kUseFileForFakeAudioCapture); | 113 switches::kUseFileForFakeAudioCapture); |
114 CHECK(!path_to_wav_file.empty()) | 114 CHECK(!path_to_wav_file.empty()) |
115 << "You must pass the file to use as argument to --" | 115 << "You must pass the file to use as argument to --" |
116 << switches::kUseFileForFakeAudioCapture << "."; | 116 << switches::kUseFileForFakeAudioCapture << "."; |
117 | 117 |
118 return make_scoped_ptr(new FileSource(params_, path_to_wav_file)); | 118 return make_scoped_ptr(new FileSource(params_, path_to_wav_file)); |
119 } | 119 } |
120 return make_scoped_ptr(new BeepingSource(params_)); | 120 return make_scoped_ptr(new BeepingSource(params_)); |
121 } | 121 } |
122 | 122 |
123 void FakeAudioInputStream::BeepOnce() { | 123 void FakeAudioInputStream::BeepOnce() { |
124 BeepingSource::BeepOnce(); | 124 BeepingSource::BeepOnce(); |
125 } | 125 } |
126 | 126 |
127 } // namespace media | 127 } // namespace media |
OLD | NEW |