Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_renderer_impl.h" | 5 #include "content/renderer/media/audio_renderer_impl.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 | 130 |
| 131 void AudioRendererImpl::NotifyDataAvailableIfNecessary() { | 131 void AudioRendererImpl::NotifyDataAvailableIfNecessary() { |
| 132 if (latency_type_ == kHighLatency) { | 132 if (latency_type_ == kHighLatency) { |
| 133 // Post a task to render thread to notify a packet reception. | 133 // Post a task to render thread to notify a packet reception. |
| 134 ChildProcess::current()->io_message_loop()->PostTask( | 134 ChildProcess::current()->io_message_loop()->PostTask( |
| 135 FROM_HERE, | 135 FROM_HERE, |
| 136 base::Bind(&AudioRendererImpl::NotifyPacketReadyTask, this)); | 136 base::Bind(&AudioRendererImpl::NotifyPacketReadyTask, this)); |
| 137 } | 137 } |
| 138 } | 138 } |
| 139 | 139 |
| 140 void AudioRendererImpl::ConsumeAudioSamples( | |
|
scherkus (not reviewing)
2011/12/07 05:25:12
enal: do you recall why this was needed?
I tested
enal
2011/12/15 22:51:26
No idea, it was before my time...
| |
| 141 scoped_refptr<media::Buffer> buffer_in) { | |
| 142 base::AutoLock auto_lock(lock_); | |
| 143 if (stopped_) | |
| 144 return; | |
| 145 | |
| 146 // TODO(hclam): handle end of stream here. | |
| 147 | |
| 148 // Use the base class to queue the buffer. | |
| 149 AudioRendererBase::ConsumeAudioSamples(buffer_in); | |
| 150 | |
| 151 NotifyDataAvailableIfNecessary(); | |
| 152 } | |
| 153 | |
| 154 void AudioRendererImpl::SetPlaybackRate(float rate) { | 140 void AudioRendererImpl::SetPlaybackRate(float rate) { |
| 155 DCHECK_LE(0.0f, rate); | 141 DCHECK_LE(0.0f, rate); |
| 156 | 142 |
| 157 base::AutoLock auto_lock(lock_); | 143 base::AutoLock auto_lock(lock_); |
| 158 // Handle the case where we stopped due to IO message loop dying. | 144 // Handle the case where we stopped due to IO message loop dying. |
| 159 if (stopped_) { | 145 if (stopped_) { |
| 160 AudioRendererBase::SetPlaybackRate(rate); | 146 AudioRendererBase::SetPlaybackRate(rate); |
| 161 return; | 147 return; |
| 162 } | 148 } |
| 163 | 149 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 292 void AudioRendererImpl::OnRequestPacket(AudioBuffersState buffers_state) { | 278 void AudioRendererImpl::OnRequestPacket(AudioBuffersState buffers_state) { |
| 293 DCHECK(MessageLoop::current() == ChildProcess::current()->io_message_loop()); | 279 DCHECK(MessageLoop::current() == ChildProcess::current()->io_message_loop()); |
| 294 DCHECK_EQ(kHighLatency, latency_type_); | 280 DCHECK_EQ(kHighLatency, latency_type_); |
| 295 { | 281 { |
| 296 base::AutoLock auto_lock(lock_); | 282 base::AutoLock auto_lock(lock_); |
| 297 DCHECK(!pending_request_); | 283 DCHECK(!pending_request_); |
| 298 pending_request_ = true; | 284 pending_request_ = true; |
| 299 request_buffers_state_ = buffers_state; | 285 request_buffers_state_ = buffers_state; |
| 300 } | 286 } |
| 301 | 287 |
| 302 // Try to fill in the fulfill the packet request. | 288 // Try to fulfill the packet request. |
| 303 NotifyPacketReadyTask(); | 289 NotifyPacketReadyTask(); |
| 304 } | 290 } |
| 305 | 291 |
| 306 void AudioRendererImpl::OnStateChanged(AudioStreamState state) { | 292 void AudioRendererImpl::OnStateChanged(AudioStreamState state) { |
| 307 DCHECK(MessageLoop::current() == ChildProcess::current()->io_message_loop()); | 293 DCHECK(MessageLoop::current() == ChildProcess::current()->io_message_loop()); |
| 308 | 294 |
| 309 base::AutoLock auto_lock(lock_); | 295 base::AutoLock auto_lock(lock_); |
| 310 if (stopped_) | 296 if (stopped_) |
| 311 return; | 297 return; |
| 312 | 298 |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 518 media::SetActualDataSizeInBytes(shared_memory_.get(), | 504 media::SetActualDataSizeInBytes(shared_memory_.get(), |
| 519 shared_memory_size_, | 505 shared_memory_size_, |
| 520 size); | 506 size); |
| 521 UpdateEarliestEndTime(size, request_delay, time_now); | 507 UpdateEarliestEndTime(size, request_delay, time_now); |
| 522 } | 508 } |
| 523 } | 509 } |
| 524 | 510 |
| 525 void AudioRendererImpl::Send(IPC::Message* message) { | 511 void AudioRendererImpl::Send(IPC::Message* message) { |
| 526 filter_->Send(message); | 512 filter_->Send(message); |
| 527 } | 513 } |
| OLD | NEW |