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 |
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/render_thread_impl.h" | 14 #include "content/renderer/render_thread_impl.h" |
15 #include "media/audio/audio_buffers_state.h" | 15 #include "media/audio/audio_buffers_state.h" |
16 #include "media/audio/audio_util.h" | 16 #include "media/audio/audio_util.h" |
| 17 #include "media/base/filter_host.h" |
17 | 18 |
18 // We define GetBufferSizeForSampleRate() instead of using | 19 // We define GetBufferSizeForSampleRate() instead of using |
19 // GetAudioHardwareBufferSize() in audio_util because we're using | 20 // GetAudioHardwareBufferSize() in audio_util because we're using |
20 // the AUDIO_PCM_LINEAR flag, instead of AUDIO_PCM_LOW_LATENCY, | 21 // the AUDIO_PCM_LINEAR flag, instead of AUDIO_PCM_LOW_LATENCY, |
21 // which the audio_util functions assume. | 22 // which the audio_util functions assume. |
22 // | 23 // |
23 // See: http://code.google.com/p/chromium/issues/detail?id=103627 | 24 // See: http://code.google.com/p/chromium/issues/detail?id=103627 |
24 // for a more detailed description of the subtleties. | 25 // for a more detailed description of the subtleties. |
25 static size_t GetBufferSizeForSampleRate(int sample_rate) { | 26 static size_t GetBufferSizeForSampleRate(int sample_rate) { |
26 // kNominalBufferSize has been tested on Windows, Mac OS X, and Linux | 27 // kNominalBufferSize has been tested on Windows, Mac OS X, and Linux |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 // If FillBuffer() didn't give us enough data then zero out the remainder. | 241 // If FillBuffer() didn't give us enough data then zero out the remainder. |
241 if (filled_frames < number_of_frames) { | 242 if (filled_frames < number_of_frames) { |
242 int frames_to_zero = number_of_frames - filled_frames; | 243 int frames_to_zero = number_of_frames - filled_frames; |
243 memset(audio_data[channel_index] + filled_frames, | 244 memset(audio_data[channel_index] + filled_frames, |
244 0, | 245 0, |
245 sizeof(float) * frames_to_zero); | 246 sizeof(float) * frames_to_zero); |
246 } | 247 } |
247 } | 248 } |
248 return filled_frames; | 249 return filled_frames; |
249 } | 250 } |
| 251 |
| 252 void AudioRendererImpl::OnError() { |
| 253 host()->DisableAudioRenderer(); |
| 254 } |
OLD | NEW |