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

Side by Side Diff: content/renderer/media/audio_track_recorder.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/audio_track_recorder.h" 5 #include "content/renderer/media/audio_track_recorder.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 void set_paused(bool paused) { paused_ = paused; } 112 void set_paused(bool paused) { paused_ = paused; }
113 113
114 private: 114 private:
115 friend class base::RefCountedThreadSafe<AudioEncoder>; 115 friend class base::RefCountedThreadSafe<AudioEncoder>;
116 ~AudioEncoder() override; 116 ~AudioEncoder() override;
117 117
118 bool is_initialized() const { return !!opus_encoder_; } 118 bool is_initialized() const { return !!opus_encoder_; }
119 119
120 // media::AudioConverted::InputCallback implementation. 120 // media::AudioConverted::InputCallback implementation.
121 double ProvideInput(media::AudioBus* audio_bus, 121 double ProvideInput(media::AudioBus* audio_bus,
122 base::TimeDelta buffer_delay) override; 122 uint32_t frames_delayed) override;
123 123
124 void DestroyExistingOpusEncoder(); 124 void DestroyExistingOpusEncoder();
125 125
126 const OnEncodedAudioCB on_encoded_audio_cb_; 126 const OnEncodedAudioCB on_encoded_audio_cb_;
127 127
128 // Target bitrate for Opus. If 0, Opus provide automatic bitrate is used. 128 // Target bitrate for Opus. If 0, Opus provide automatic bitrate is used.
129 const int32_t bits_per_second_; 129 const int32_t bits_per_second_;
130 130
131 base::ThreadChecker encoder_thread_checker_; 131 base::ThreadChecker encoder_thread_checker_;
132 132
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 base::Time::kMicrosecondsPerSecond / 270 base::Time::kMicrosecondsPerSecond /
271 input_params_.sample_rate()); 271 input_params_.sample_rate());
272 on_encoded_audio_cb_.Run(output_params_, std::move(encoded_data), 272 on_encoded_audio_cb_.Run(output_params_, std::move(encoded_data),
273 capture_time_of_first_sample); 273 capture_time_of_first_sample);
274 } 274 }
275 } 275 }
276 } 276 }
277 277
278 double AudioTrackRecorder::AudioEncoder::ProvideInput( 278 double AudioTrackRecorder::AudioEncoder::ProvideInput(
279 media::AudioBus* audio_bus, 279 media::AudioBus* audio_bus,
280 base::TimeDelta buffer_delay) { 280 uint32_t frames_delayed) {
281 fifo_->Consume(audio_bus, 0, audio_bus->frames()); 281 fifo_->Consume(audio_bus, 0, audio_bus->frames());
282 return 1.0; // Return volume greater than zero to indicate we have more data. 282 return 1.0; // Return volume greater than zero to indicate we have more data.
283 } 283 }
284 284
285 void AudioTrackRecorder::AudioEncoder::DestroyExistingOpusEncoder() { 285 void AudioTrackRecorder::AudioEncoder::DestroyExistingOpusEncoder() {
286 // We don't DCHECK that we're on the encoder thread here, as this could be 286 // We don't DCHECK that we're on the encoder thread here, as this could be
287 // called from the dtor (main thread) or from OnSetFormat() (encoder thread). 287 // called from the dtor (main thread) or from OnSetFormat() (encoder thread).
288 if (opus_encoder_) { 288 if (opus_encoder_) {
289 opus_encoder_destroy(opus_encoder_); 289 opus_encoder_destroy(opus_encoder_);
290 opus_encoder_ = nullptr; 290 opus_encoder_ = nullptr;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 } 350 }
351 351
352 void AudioTrackRecorder::Resume() { 352 void AudioTrackRecorder::Resume() {
353 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 353 DCHECK(main_render_thread_checker_.CalledOnValidThread());
354 DCHECK(encoder_); 354 DCHECK(encoder_);
355 encoder_thread_.task_runner()->PostTask( 355 encoder_thread_.task_runner()->PostTask(
356 FROM_HERE, base::Bind(&AudioEncoder::set_paused, encoder_, false)); 356 FROM_HERE, base::Bind(&AudioEncoder::set_paused, encoder_, false));
357 } 357 }
358 358
359 } // namespace content 359 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/speech/speech_recognizer_impl.cc ('k') | content/renderer/media/speech_recognition_audio_sink.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698