Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: content/browser/speech/speech_recognizer_impl.cc

Issue 2004283002: AudioConverter: Express delay in frames rather than msec. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Missed files & removed rounding Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/browser/speech/speech_recognizer_impl.h" 5 #include "content/browser/speech/speech_recognizer_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 30 matching lines...) Expand all
41 41
42 // Converts input audio |data| bus into an AudioChunk where the input format 42 // Converts input audio |data| bus into an AudioChunk where the input format
43 // is given by |input_parameters_| and the output format by 43 // is given by |input_parameters_| and the output format by
44 // |output_parameters_|. 44 // |output_parameters_|.
45 scoped_refptr<AudioChunk> Convert(const AudioBus* data); 45 scoped_refptr<AudioChunk> Convert(const AudioBus* data);
46 46
47 bool data_was_converted() const { return data_was_converted_; } 47 bool data_was_converted() const { return data_was_converted_; }
48 48
49 private: 49 private:
50 // media::AudioConverter::InputCallback implementation. 50 // media::AudioConverter::InputCallback implementation.
51 double ProvideInput(AudioBus* dest, base::TimeDelta buffer_delay) override; 51 double ProvideInput(AudioBus* dest, uint32_t frames_delayed) override;
52 52
53 // Handles resampling, buffering, and channel mixing between input and output 53 // Handles resampling, buffering, and channel mixing between input and output
54 // parameters. 54 // parameters.
55 AudioConverter audio_converter_; 55 AudioConverter audio_converter_;
56 56
57 std::unique_ptr<AudioBus> input_bus_; 57 std::unique_ptr<AudioBus> input_bus_;
58 std::unique_ptr<AudioBus> output_bus_; 58 std::unique_ptr<AudioBus> output_bus_;
59 const AudioParameters input_parameters_; 59 const AudioParameters input_parameters_;
60 const AudioParameters output_parameters_; 60 const AudioParameters output_parameters_;
61 bool data_was_converted_; 61 bool data_was_converted_;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 scoped_refptr<AudioChunk> chunk( 153 scoped_refptr<AudioChunk> chunk(
154 new AudioChunk(output_parameters_.GetBytesPerBuffer(), 154 new AudioChunk(output_parameters_.GetBytesPerBuffer(),
155 output_parameters_.bits_per_sample() / 8)); 155 output_parameters_.bits_per_sample() / 8));
156 output_bus_->ToInterleaved(output_bus_->frames(), 156 output_bus_->ToInterleaved(output_bus_->frames(),
157 output_parameters_.bits_per_sample() / 8, 157 output_parameters_.bits_per_sample() / 8,
158 chunk->writable_data()); 158 chunk->writable_data());
159 return chunk; 159 return chunk;
160 } 160 }
161 161
162 double SpeechRecognizerImpl::OnDataConverter::ProvideInput( 162 double SpeechRecognizerImpl::OnDataConverter::ProvideInput(
163 AudioBus* dest, base::TimeDelta buffer_delay) { 163 AudioBus* dest,
164 uint32_t frames_delayed) {
164 // Read from the input bus to feed the converter. 165 // Read from the input bus to feed the converter.
165 input_bus_->CopyTo(dest); 166 input_bus_->CopyTo(dest);
166 // Indicate that the recorded audio has in fact been used by the converter. 167 // Indicate that the recorded audio has in fact been used by the converter.
167 data_was_converted_ = true; 168 data_was_converted_ = true;
168 return 1; 169 return 1;
169 } 170 }
170 171
171 // SpeechRecognizerImpl implementation 172 // SpeechRecognizerImpl implementation
172 173
173 SpeechRecognizerImpl::SpeechRecognizerImpl( 174 SpeechRecognizerImpl::SpeechRecognizerImpl(
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 engine_error(SPEECH_RECOGNITION_ERROR_NONE) { 836 engine_error(SPEECH_RECOGNITION_ERROR_NONE) {
836 } 837 }
837 838
838 SpeechRecognizerImpl::FSMEventArgs::FSMEventArgs(const FSMEventArgs& other) = 839 SpeechRecognizerImpl::FSMEventArgs::FSMEventArgs(const FSMEventArgs& other) =
839 default; 840 default;
840 841
841 SpeechRecognizerImpl::FSMEventArgs::~FSMEventArgs() { 842 SpeechRecognizerImpl::FSMEventArgs::~FSMEventArgs() {
842 } 843 }
843 844
844 } // namespace content 845 } // namespace content
OLDNEW
« no previous file with comments | « chrome/renderer/media/cast_rtp_stream.cc ('k') | content/renderer/media/audio_track_recorder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698