OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/renderer/media/speech_recognition_audio_sink.h" | 5 #include "content/renderer/media/speech_recognition_audio_sink.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 DVLOG(1) << "Failed sending buffer index to peer"; | 155 DVLOG(1) << "Failed sending buffer index to peer"; |
156 // We have discarded this buffer, but could still recover on the next one. | 156 // We have discarded this buffer, but could still recover on the next one. |
157 return; | 157 return; |
158 } | 158 } |
159 | 159 |
160 // Count the sent buffer. We expect the peer to do the same on their end. | 160 // Count the sent buffer. We expect the peer to do the same on their end. |
161 ++buffer_index_; | 161 ++buffer_index_; |
162 } | 162 } |
163 | 163 |
164 double SpeechRecognitionAudioSink::ProvideInput(media::AudioBus* audio_bus, | 164 double SpeechRecognitionAudioSink::ProvideInput(media::AudioBus* audio_bus, |
165 base::TimeDelta buffer_delay) { | 165 uint32_t frames_delayed) { |
166 DCHECK(capture_thread_checker_.CalledOnValidThread()); | 166 DCHECK(capture_thread_checker_.CalledOnValidThread()); |
167 if (fifo_->frames() >= audio_bus->frames()) | 167 if (fifo_->frames() >= audio_bus->frames()) |
168 fifo_->Consume(audio_bus, 0, audio_bus->frames()); | 168 fifo_->Consume(audio_bus, 0, audio_bus->frames()); |
169 else | 169 else |
170 audio_bus->Zero(); | 170 audio_bus->Zero(); |
171 | 171 |
172 // Return volume greater than zero to indicate we have more data. | 172 // Return volume greater than zero to indicate we have more data. |
173 return 1.0; | 173 return 1.0; |
174 } | 174 } |
175 | 175 |
176 media::AudioInputBuffer* | 176 media::AudioInputBuffer* |
177 SpeechRecognitionAudioSink::GetAudioInputBuffer() const { | 177 SpeechRecognitionAudioSink::GetAudioInputBuffer() const { |
178 DCHECK(capture_thread_checker_.CalledOnValidThread()); | 178 DCHECK(capture_thread_checker_.CalledOnValidThread()); |
179 DCHECK(shared_memory_.memory()); | 179 DCHECK(shared_memory_.memory()); |
180 return static_cast<media::AudioInputBuffer*>(shared_memory_.memory()); | 180 return static_cast<media::AudioInputBuffer*>(shared_memory_.memory()); |
181 } | 181 } |
182 | 182 |
183 } // namespace content | 183 } // namespace content |
OLD | NEW |