| OLD | NEW |
| (Empty) |
| 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 | |
| 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 using media::ChannelLayout; | |
| 12 using media::CHANNEL_LAYOUT_NONE; | |
| 13 | |
| 14 static int output_sample_rate = 0; | |
| 15 static int input_sample_rate = 0; | |
| 16 static size_t output_buffer_size = 0; | |
| 17 static ChannelLayout input_channel_layout = CHANNEL_LAYOUT_NONE; | |
| 18 | |
| 19 namespace content { | |
| 20 | |
| 21 int GetAudioOutputSampleRate() { | |
| 22 DCHECK(RenderThreadImpl::current() != NULL); | |
| 23 | |
| 24 if (!output_sample_rate) { | |
| 25 RenderThreadImpl::current()->Send( | |
| 26 new ViewHostMsg_GetHardwareSampleRate(&output_sample_rate)); | |
| 27 } | |
| 28 return output_sample_rate; | |
| 29 } | |
| 30 | |
| 31 int GetAudioInputSampleRate() { | |
| 32 DCHECK(RenderThreadImpl::current() != NULL); | |
| 33 | |
| 34 if (!input_sample_rate) { | |
| 35 RenderThreadImpl::current()->Send( | |
| 36 new ViewHostMsg_GetHardwareInputSampleRate(&input_sample_rate)); | |
| 37 } | |
| 38 return input_sample_rate; | |
| 39 } | |
| 40 | |
| 41 size_t GetAudioOutputBufferSize() { | |
| 42 DCHECK(RenderThreadImpl::current() != NULL); | |
| 43 | |
| 44 if (!output_buffer_size) { | |
| 45 uint32 buffer_size = 0; | |
| 46 RenderThreadImpl::current()->Send( | |
| 47 new ViewHostMsg_GetHardwareBufferSize(&buffer_size)); | |
| 48 output_buffer_size = buffer_size; | |
| 49 } | |
| 50 | |
| 51 return output_buffer_size; | |
| 52 } | |
| 53 | |
| 54 ChannelLayout GetAudioInputChannelLayout() { | |
| 55 DCHECK(RenderThreadImpl::current() != NULL); | |
| 56 | |
| 57 if (input_channel_layout == CHANNEL_LAYOUT_NONE) { | |
| 58 ChannelLayout layout = CHANNEL_LAYOUT_NONE; | |
| 59 RenderThreadImpl::current()->Send( | |
| 60 new ViewHostMsg_GetHardwareInputChannelLayout(&layout)); | |
| 61 input_channel_layout = layout; | |
| 62 } | |
| 63 | |
| 64 return input_channel_layout; | |
| 65 } | |
| 66 | |
| 67 void ResetAudioCache() { | |
| 68 DCHECK(RenderThreadImpl::current() != NULL); | |
| 69 | |
| 70 output_sample_rate = 0.0; | |
| 71 input_sample_rate = 0.0; | |
| 72 output_buffer_size = 0; | |
| 73 input_channel_layout = CHANNEL_LAYOUT_NONE; | |
| 74 } | |
| 75 | |
| 76 } // namespace content | |
| OLD | NEW |