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

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

Issue 1323403005: Allow AudioOutputDevice objects to be initialized with a specific hardware output device and store … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Split permissions check and device-ID translation for clarity Created 5 years, 3 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) 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 "content/renderer/media/webrtc_audio_renderer.h" 5 #include "content/renderer/media/webrtc_audio_renderer.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 int frame_duration_milliseconds = base::Time::kMillisecondsPerSecond / 266 int frame_duration_milliseconds = base::Time::kMillisecondsPerSecond /
267 static_cast<double>(source_params.sample_rate()); 267 static_cast<double>(source_params.sample_rate());
268 fifo_delay_milliseconds_ = (sink_params_.frames_per_buffer() - 268 fifo_delay_milliseconds_ = (sink_params_.frames_per_buffer() -
269 source_params.frames_per_buffer()) * frame_duration_milliseconds; 269 source_params.frames_per_buffer()) * frame_duration_milliseconds;
270 } 270 }
271 } 271 }
272 272
273 source_ = source; 273 source_ = source;
274 274
275 // Configure the audio rendering client and start rendering. 275 // Configure the audio rendering client and start rendering.
276 sink_ = AudioDeviceFactory::NewOutputDevice(source_render_frame_id_);
277
278 DCHECK_GE(session_id_, 0); 276 DCHECK_GE(session_id_, 0);
279 sink_->InitializeWithSessionId(sink_params_, this, session_id_); 277 sink_ =
278 AudioDeviceFactory::NewOutputDevice(source_render_frame_id_, session_id_);
279 sink_->Initialize(sink_params_, this);
280 280
281 sink_->Start(); 281 sink_->Start();
282 282
283 // User must call Play() before any audio can be heard. 283 // User must call Play() before any audio can be heard.
284 state_ = PAUSED; 284 state_ = PAUSED;
285 285
286 return true; 286 return true;
287 } 287 }
288 288
289 scoped_refptr<MediaStreamAudioRenderer> 289 scoped_refptr<MediaStreamAudioRenderer>
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 } 433 }
434 434
435 void WebRtcAudioRenderer::OnRenderError() { 435 void WebRtcAudioRenderer::OnRenderError() {
436 NOTIMPLEMENTED(); 436 NOTIMPLEMENTED();
437 LOG(ERROR) << "OnRenderError()"; 437 LOG(ERROR) << "OnRenderError()";
438 } 438 }
439 439
440 // Called by AudioPullFifo when more data is necessary. 440 // Called by AudioPullFifo when more data is necessary.
441 void WebRtcAudioRenderer::SourceCallback( 441 void WebRtcAudioRenderer::SourceCallback(
442 int fifo_frame_delay, media::AudioBus* audio_bus) { 442 int fifo_frame_delay, media::AudioBus* audio_bus) {
443 base::TimeTicks start_time = base::TimeTicks::Now() ; 443 base::TimeTicks start_time = base::TimeTicks::Now();
444 DVLOG(2) << "WebRtcAudioRenderer::SourceCallback(" 444 DVLOG(2) << "WebRtcAudioRenderer::SourceCallback("
445 << fifo_frame_delay << ", " 445 << fifo_frame_delay << ", "
446 << audio_bus->frames() << ")"; 446 << audio_bus->frames() << ")";
447 447
448 int output_delay_milliseconds = audio_delay_milliseconds_; 448 int output_delay_milliseconds = audio_delay_milliseconds_;
449 output_delay_milliseconds += fifo_delay_milliseconds_; 449 output_delay_milliseconds += fifo_delay_milliseconds_;
450 DVLOG(2) << "output_delay_milliseconds: " << output_delay_milliseconds; 450 DVLOG(2) << "output_delay_milliseconds: " << output_delay_milliseconds;
451 451
452 // We need to keep render data for the |source_| regardless of |state_|, 452 // We need to keep render data for the |source_| regardless of |state_|,
453 // otherwise the data will be buffered up inside |source_|. 453 // otherwise the data will be buffered up inside |source_|.
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 if (RemovePlayingState(source, state)) 553 if (RemovePlayingState(source, state))
554 EnterPauseState(); 554 EnterPauseState();
555 } else if (AddPlayingState(source, state)) { 555 } else if (AddPlayingState(source, state)) {
556 EnterPlayState(); 556 EnterPlayState();
557 } 557 }
558 UpdateSourceVolume(source); 558 UpdateSourceVolume(source);
559 } 559 }
560 } 560 }
561 561
562 } // namespace content 562 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698