| 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_hardware.h" | 5 #include "content/renderer/media/audio_hardware.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "content/common/view_messages.h" | 8 #include "content/common/view_messages.h" |
| 9 #include "content/renderer/render_thread_impl.h" | 9 #include "content/renderer/render_thread_impl.h" |
| 10 | 10 |
| 11 static double output_sample_rate = 0.0; | 11 static double output_sample_rate = 0.0; |
| 12 static double input_sample_rate = 0.0; | 12 static double input_sample_rate = 0.0; |
| 13 static size_t output_buffer_size = 0; | 13 static size_t output_buffer_size = 0; |
| 14 static uint32 input_channel_count = 0; |
| 14 | 15 |
| 15 namespace audio_hardware { | 16 namespace audio_hardware { |
| 16 | 17 |
| 17 double GetOutputSampleRate() { | 18 double GetOutputSampleRate() { |
| 18 DCHECK(RenderThreadImpl::current() != NULL); | 19 DCHECK(RenderThreadImpl::current() != NULL); |
| 19 | 20 |
| 20 if (!output_sample_rate) { | 21 if (!output_sample_rate) { |
| 21 RenderThreadImpl::current()->Send( | 22 RenderThreadImpl::current()->Send( |
| 22 new ViewHostMsg_GetHardwareSampleRate(&output_sample_rate)); | 23 new ViewHostMsg_GetHardwareSampleRate(&output_sample_rate)); |
| 23 } | 24 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 40 if (!output_buffer_size) { | 41 if (!output_buffer_size) { |
| 41 uint32 buffer_size = 0; | 42 uint32 buffer_size = 0; |
| 42 RenderThreadImpl::current()->Send( | 43 RenderThreadImpl::current()->Send( |
| 43 new ViewHostMsg_GetHardwareBufferSize(&buffer_size)); | 44 new ViewHostMsg_GetHardwareBufferSize(&buffer_size)); |
| 44 output_buffer_size = buffer_size; | 45 output_buffer_size = buffer_size; |
| 45 } | 46 } |
| 46 | 47 |
| 47 return output_buffer_size; | 48 return output_buffer_size; |
| 48 } | 49 } |
| 49 | 50 |
| 51 uint32 GetInputChannelCount() { |
| 52 DCHECK(RenderThreadImpl::current() != NULL); |
| 53 |
| 54 if (!input_channel_count) { |
| 55 uint32 channels = 0; |
| 56 RenderThreadImpl::current()->Send( |
| 57 new ViewHostMsg_GetHardwareInputChannelCount(&channels)); |
| 58 input_channel_count = channels; |
| 59 } |
| 60 |
| 61 return input_channel_count; |
| 62 } |
| 63 |
| 50 void ResetCache() { | 64 void ResetCache() { |
| 51 DCHECK(RenderThreadImpl::current() != NULL); | 65 DCHECK(RenderThreadImpl::current() != NULL); |
| 52 | 66 |
| 53 output_sample_rate = 0.0; | 67 output_sample_rate = 0.0; |
| 54 input_sample_rate = 0.0; | 68 input_sample_rate = 0.0; |
| 55 output_buffer_size = 0; | 69 output_buffer_size = 0; |
| 70 input_channel_count = 0; |
| 56 } | 71 } |
| 57 | 72 |
| 58 } // namespace audio_hardware | 73 } // namespace audio_hardware |
| OLD | NEW |