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 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 } | 54 } |
55 | 55 |
56 bool AudioRendererImpl::OnInitialize(int bits_per_channel, | 56 bool AudioRendererImpl::OnInitialize(int bits_per_channel, |
57 ChannelLayout channel_layout, | 57 ChannelLayout channel_layout, |
58 int sample_rate) { | 58 int sample_rate) { |
59 // We use the AUDIO_PCM_LINEAR flag because AUDIO_PCM_LOW_LATENCY | 59 // We use the AUDIO_PCM_LINEAR flag because AUDIO_PCM_LOW_LATENCY |
60 // does not currently support all the sample-rates that we require. | 60 // does not currently support all the sample-rates that we require. |
61 // Please see: http://code.google.com/p/chromium/issues/detail?id=103627 | 61 // Please see: http://code.google.com/p/chromium/issues/detail?id=103627 |
62 // for more details. | 62 // for more details. |
63 audio_parameters_.Reset( | 63 audio_parameters_.Reset( |
64 AudioParameters::AUDIO_PCM_LINEAR, | 64 media::AudioParameters::AUDIO_PCM_LINEAR, |
65 channel_layout, sample_rate, bits_per_channel, | 65 channel_layout, sample_rate, bits_per_channel, |
66 audio_hardware::GetHighLatencyOutputBufferSize(sample_rate)); | 66 audio_hardware::GetHighLatencyOutputBufferSize(sample_rate)); |
67 | 67 |
68 bytes_per_second_ = audio_parameters_.GetBytesPerSecond(); | 68 bytes_per_second_ = audio_parameters_.GetBytesPerSecond(); |
69 | 69 |
70 DCHECK(sink_.get()); | 70 DCHECK(sink_.get()); |
71 | 71 |
72 if (!is_initialized_) { | 72 if (!is_initialized_) { |
73 sink_->Initialize(audio_parameters_, this); | 73 sink_->Initialize(audio_parameters_, this); |
74 | 74 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 | 220 |
221 void AudioRendererImpl::OnRenderError() { | 221 void AudioRendererImpl::OnRenderError() { |
222 host()->DisableAudioRenderer(); | 222 host()->DisableAudioRenderer(); |
223 } | 223 } |
224 | 224 |
225 void AudioRendererImpl::OnRenderEndOfStream() { | 225 void AudioRendererImpl::OnRenderEndOfStream() { |
226 // TODO(enal): schedule callback instead of polling. | 226 // TODO(enal): schedule callback instead of polling. |
227 if (base::Time::Now() >= earliest_end_time_) | 227 if (base::Time::Now() >= earliest_end_time_) |
228 SignalEndOfStream(); | 228 SignalEndOfStream(); |
229 } | 229 } |
OLD | NEW |