OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/renderer/media/audio_hardware.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "content/common/view_messages.h" |
| 9 #include "content/renderer/render_thread_impl.h" |
| 10 |
| 11 static double output_sample_rate = 0.0; |
| 12 static double input_sample_rate = 0.0; |
| 13 static size_t output_buffer_size = 0; |
| 14 |
| 15 namespace audio_hardware { |
| 16 |
| 17 double GetOutputSampleRate() { |
| 18 DCHECK(RenderThreadImpl::current() != NULL); |
| 19 |
| 20 if (!output_sample_rate) { |
| 21 RenderThreadImpl::current()->Send( |
| 22 new ViewHostMsg_GetHardwareSampleRate(&output_sample_rate)); |
| 23 } |
| 24 return output_sample_rate; |
| 25 } |
| 26 |
| 27 double GetInputSampleRate() { |
| 28 DCHECK(RenderThreadImpl::current() != NULL); |
| 29 |
| 30 if (!input_sample_rate) { |
| 31 RenderThreadImpl::current()->Send( |
| 32 new ViewHostMsg_GetHardwareInputSampleRate(&input_sample_rate)); |
| 33 } |
| 34 return input_sample_rate; |
| 35 } |
| 36 |
| 37 size_t GetOutputBufferSize() { |
| 38 DCHECK(RenderThreadImpl::current() != NULL); |
| 39 |
| 40 if (!output_buffer_size) { |
| 41 uint32 buffer_size = 0; |
| 42 RenderThreadImpl::current()->Send( |
| 43 new ViewHostMsg_GetHardwareBufferSize(&buffer_size)); |
| 44 output_buffer_size = buffer_size; |
| 45 } |
| 46 |
| 47 return output_buffer_size; |
| 48 } |
| 49 |
| 50 void ResetCache() { |
| 51 DCHECK(RenderThreadImpl::current() != NULL); |
| 52 |
| 53 output_sample_rate = 0.0; |
| 54 input_sample_rate = 0.0; |
| 55 output_buffer_size = 0; |
| 56 } |
| 57 |
| 58 } // namespace audio_hardware |
OLD | NEW |