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

Side by Side Diff: content/renderer/media/audio_track_recorder.cc

Issue 2245043002: Remove unnecessary DCHECK(encoder_thread_.IsRunning()) from AudioRecorder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 : track_(track), 288 : track_(track),
289 encoder_(new AudioEncoder(media::BindToCurrentLoop(on_encoded_audio_cb), 289 encoder_(new AudioEncoder(media::BindToCurrentLoop(on_encoded_audio_cb),
290 bits_per_second)), 290 bits_per_second)),
291 encoder_thread_("AudioEncoderThread") { 291 encoder_thread_("AudioEncoderThread") {
292 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 292 DCHECK(main_render_thread_checker_.CalledOnValidThread());
293 DCHECK(!track_.isNull()); 293 DCHECK(!track_.isNull());
294 DCHECK(MediaStreamAudioTrack::From(track_)); 294 DCHECK(MediaStreamAudioTrack::From(track_));
295 295
296 // Start the |encoder_thread_|. From this point on, |encoder_| should work 296 // Start the |encoder_thread_|. From this point on, |encoder_| should work
297 // only on |encoder_thread_|, as enforced by DCHECKs. 297 // only on |encoder_thread_|, as enforced by DCHECKs.
298 DCHECK(!encoder_thread_.IsRunning());
299 encoder_thread_.Start(); 298 encoder_thread_.Start();
300 299
301 // Connect the source provider to the track as a sink. 300 // Connect the source provider to the track as a sink.
302 MediaStreamAudioSink::AddToAudioTrack(this, track_); 301 MediaStreamAudioSink::AddToAudioTrack(this, track_);
303 } 302 }
304 303
305 AudioTrackRecorder::~AudioTrackRecorder() { 304 AudioTrackRecorder::~AudioTrackRecorder() {
306 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 305 DCHECK(main_render_thread_checker_.CalledOnValidThread());
307 MediaStreamAudioSink::RemoveFromAudioTrack(this, track_); 306 MediaStreamAudioSink::RemoveFromAudioTrack(this, track_);
308 } 307 }
309 308
310 void AudioTrackRecorder::OnSetFormat(const media::AudioParameters& params) { 309 void AudioTrackRecorder::OnSetFormat(const media::AudioParameters& params) {
311 DCHECK(encoder_thread_.IsRunning());
312 // If the source is restarted, might have changed to another capture thread. 310 // If the source is restarted, might have changed to another capture thread.
313 capture_thread_checker_.DetachFromThread(); 311 capture_thread_checker_.DetachFromThread();
314 DCHECK(capture_thread_checker_.CalledOnValidThread()); 312 DCHECK(capture_thread_checker_.CalledOnValidThread());
315 313
316 encoder_thread_.task_runner()->PostTask( 314 encoder_thread_.task_runner()->PostTask(
317 FROM_HERE, base::Bind(&AudioEncoder::OnSetFormat, encoder_, params)); 315 FROM_HERE, base::Bind(&AudioEncoder::OnSetFormat, encoder_, params));
318 } 316 }
319 317
320 void AudioTrackRecorder::OnData(const media::AudioBus& audio_bus, 318 void AudioTrackRecorder::OnData(const media::AudioBus& audio_bus,
321 base::TimeTicks capture_time) { 319 base::TimeTicks capture_time) {
322 DCHECK(encoder_thread_.IsRunning());
323 DCHECK(capture_thread_checker_.CalledOnValidThread()); 320 DCHECK(capture_thread_checker_.CalledOnValidThread());
324 DCHECK(!capture_time.is_null()); 321 DCHECK(!capture_time.is_null());
325 322
326 std::unique_ptr<media::AudioBus> audio_data = 323 std::unique_ptr<media::AudioBus> audio_data =
327 media::AudioBus::Create(audio_bus.channels(), audio_bus.frames()); 324 media::AudioBus::Create(audio_bus.channels(), audio_bus.frames());
328 audio_bus.CopyTo(audio_data.get()); 325 audio_bus.CopyTo(audio_data.get());
329 326
330 encoder_thread_.task_runner()->PostTask( 327 encoder_thread_.task_runner()->PostTask(
331 FROM_HERE, base::Bind(&AudioEncoder::EncodeAudio, encoder_, 328 FROM_HERE, base::Bind(&AudioEncoder::EncodeAudio, encoder_,
332 base::Passed(&audio_data), capture_time)); 329 base::Passed(&audio_data), capture_time));
333 } 330 }
334 331
335 void AudioTrackRecorder::Pause() { 332 void AudioTrackRecorder::Pause() {
336 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 333 DCHECK(main_render_thread_checker_.CalledOnValidThread());
337 DCHECK(encoder_); 334 DCHECK(encoder_);
338 encoder_thread_.task_runner()->PostTask( 335 encoder_thread_.task_runner()->PostTask(
339 FROM_HERE, base::Bind(&AudioEncoder::set_paused, encoder_, true)); 336 FROM_HERE, base::Bind(&AudioEncoder::set_paused, encoder_, true));
340 } 337 }
341 338
342 void AudioTrackRecorder::Resume() { 339 void AudioTrackRecorder::Resume() {
343 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 340 DCHECK(main_render_thread_checker_.CalledOnValidThread());
344 DCHECK(encoder_); 341 DCHECK(encoder_);
345 encoder_thread_.task_runner()->PostTask( 342 encoder_thread_.task_runner()->PostTask(
346 FROM_HERE, base::Bind(&AudioEncoder::set_paused, encoder_, false)); 343 FROM_HERE, base::Bind(&AudioEncoder::set_paused, encoder_, false));
347 } 344 }
348 345
349 } // namespace content 346 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698