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

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

Issue 16045004: Fixing the webrtc local audio renderer timer between Stop() and Start(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
« 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 (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_local_audio_renderer.h" 5 #include "content/renderer/media/webrtc_local_audio_renderer.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop_proxy.h" 9 #include "base/message_loop_proxy.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
(...skipping 10 matching lines...) Expand all
21 media::AudioBus* audio_bus, int audio_delay_milliseconds) { 21 media::AudioBus* audio_bus, int audio_delay_milliseconds) {
22 base::AutoLock auto_lock(thread_lock_); 22 base::AutoLock auto_lock(thread_lock_);
23 23
24 if (!playing_) { 24 if (!playing_) {
25 audio_bus->Zero(); 25 audio_bus->Zero();
26 return 0; 26 return 0;
27 } 27 }
28 28
29 TRACE_EVENT0("audio", "WebRtcLocalAudioRenderer::Render"); 29 TRACE_EVENT0("audio", "WebRtcLocalAudioRenderer::Render");
30 30
31 base::Time now = base::Time::Now();
32 total_render_time_ += now - last_render_time_;
33 last_render_time_ = now;
34
35 DCHECK(loopback_fifo_.get() != NULL); 31 DCHECK(loopback_fifo_.get() != NULL);
36 32
37 // Provide data by reading from the FIFO if the FIFO contains enough 33 // Provide data by reading from the FIFO if the FIFO contains enough
38 // to fulfill the request. 34 // to fulfill the request.
39 if (loopback_fifo_->frames() >= audio_bus->frames()) { 35 if (loopback_fifo_->frames() >= audio_bus->frames()) {
40 loopback_fifo_->Consume(audio_bus, 0, audio_bus->frames()); 36 loopback_fifo_->Consume(audio_bus, 0, audio_bus->frames());
41 } else { 37 } else {
42 audio_bus->Zero(); 38 audio_bus->Zero();
43 // This warning is perfectly safe if it happens for the first audio 39 // This warning is perfectly safe if it happens for the first audio
44 // frames. It should not happen in a steady-state mode. 40 // frames. It should not happen in a steady-state mode.
(...skipping 22 matching lines...) Expand all
67 // Push captured audio to FIFO so it can be read by a local sink. 63 // Push captured audio to FIFO so it can be read by a local sink.
68 if (loopback_fifo_) { 64 if (loopback_fifo_) {
69 if (loopback_fifo_->frames() + number_of_frames <= 65 if (loopback_fifo_->frames() + number_of_frames <=
70 loopback_fifo_->max_frames()) { 66 loopback_fifo_->max_frames()) {
71 scoped_ptr<media::AudioBus> audio_source = media::AudioBus::Create( 67 scoped_ptr<media::AudioBus> audio_source = media::AudioBus::Create(
72 number_of_channels, number_of_frames); 68 number_of_channels, number_of_frames);
73 audio_source->FromInterleaved(audio_data, 69 audio_source->FromInterleaved(audio_data,
74 audio_source->frames(), 70 audio_source->frames(),
75 sizeof(audio_data[0])); 71 sizeof(audio_data[0]));
76 loopback_fifo_->Push(audio_source.get()); 72 loopback_fifo_->Push(audio_source.get());
73
74 base::Time now = base::Time::Now();
75 total_render_time_ += now - last_render_time_;
76 last_render_time_ = now;
77 } else { 77 } else {
78 DVLOG(1) << "FIFO is full"; 78 DVLOG(1) << "FIFO is full";
79 } 79 }
80 } 80 }
81 } 81 }
82 82
83 void WebRtcLocalAudioRenderer::SetCaptureFormat( 83 void WebRtcLocalAudioRenderer::SetCaptureFormat(
84 const media::AudioParameters& params) { 84 const media::AudioParameters& params) {
85 audio_params_ = params; 85 audio_params_ = params;
86 } 86 }
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 if (!sink_) 218 if (!sink_)
219 return base::TimeDelta(); 219 return base::TimeDelta();
220 return total_render_time(); 220 return total_render_time();
221 } 221 }
222 222
223 bool WebRtcLocalAudioRenderer::IsLocalRenderer() const { 223 bool WebRtcLocalAudioRenderer::IsLocalRenderer() const {
224 return true; 224 return true;
225 } 225 }
226 226
227 } // namespace content 227 } // 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