| OLD | NEW |
| 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/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 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "content/common/child_process.h" | 12 #include "content/common/child_process.h" |
| 13 #include "content/common/media/audio_messages.h" | 13 #include "content/common/media/audio_messages.h" |
| 14 #include "content/renderer/media/audio_hardware.h" |
| 14 #include "content/renderer/render_thread_impl.h" | 15 #include "content/renderer/render_thread_impl.h" |
| 15 #include "media/audio/audio_buffers_state.h" | 16 #include "media/audio/audio_buffers_state.h" |
| 16 #include "media/audio/audio_util.h" | 17 #include "media/audio/audio_util.h" |
| 17 #include "media/base/filter_host.h" | 18 #include "media/base/filter_host.h" |
| 18 | 19 |
| 19 AudioRendererImpl::AudioRendererImpl(media::AudioRendererSink* sink) | 20 AudioRendererImpl::AudioRendererImpl(media::AudioRendererSink* sink) |
| 20 : AudioRendererBase(), | 21 : AudioRendererBase(), |
| 21 bytes_per_second_(0), | 22 bytes_per_second_(0), |
| 22 stopped_(false), | 23 stopped_(false), |
| 23 sink_(sink), | 24 sink_(sink), |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 sample_rate, | 65 sample_rate, |
| 65 bits_per_channel, | 66 bits_per_channel, |
| 66 0); | 67 0); |
| 67 | 68 |
| 68 bytes_per_second_ = audio_parameters_.GetBytesPerSecond(); | 69 bytes_per_second_ = audio_parameters_.GetBytesPerSecond(); |
| 69 | 70 |
| 70 DCHECK(sink_.get()); | 71 DCHECK(sink_.get()); |
| 71 | 72 |
| 72 if (!is_initialized_) { | 73 if (!is_initialized_) { |
| 73 sink_->Initialize( | 74 sink_->Initialize( |
| 74 media::SelectSamplesPerPacket(sample_rate), | 75 audio_hardware::GetHighLatencyOutputBufferSize(sample_rate), |
| 75 audio_parameters_.channels, | 76 audio_parameters_.channels, |
| 76 audio_parameters_.sample_rate, | 77 audio_parameters_.sample_rate, |
| 77 audio_parameters_.format, | 78 audio_parameters_.format, |
| 78 this); | 79 this); |
| 79 | 80 |
| 80 sink_->Start(); | 81 sink_->Start(); |
| 81 is_initialized_ = true; | 82 is_initialized_ = true; |
| 82 return true; | 83 return true; |
| 83 } | 84 } |
| 84 | 85 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 | 228 |
| 228 void AudioRendererImpl::OnRenderError() { | 229 void AudioRendererImpl::OnRenderError() { |
| 229 host()->DisableAudioRenderer(); | 230 host()->DisableAudioRenderer(); |
| 230 } | 231 } |
| 231 | 232 |
| 232 void AudioRendererImpl::OnRenderEndOfStream() { | 233 void AudioRendererImpl::OnRenderEndOfStream() { |
| 233 // TODO(enal): schedule callback instead of polling. | 234 // TODO(enal): schedule callback instead of polling. |
| 234 if (base::Time::Now() >= earliest_end_time_) | 235 if (base::Time::Now() >= earliest_end_time_) |
| 235 SignalEndOfStream(); | 236 SignalEndOfStream(); |
| 236 } | 237 } |
| OLD | NEW |