blob: f0ff73668773a1fa2edf9608594913bf9613e531 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/renderer/media/audio_hardware.h"
#include "base/logging.h"
#include "content/common/view_messages.h"
#include "content/renderer/render_thread_impl.h"
using media::ChannelLayout;
using media::CHANNEL_LAYOUT_NONE;
static int output_sample_rate = 0;
static int input_sample_rate = 0;
static size_t output_buffer_size = 0;
static ChannelLayout input_channel_layout = CHANNEL_LAYOUT_NONE;
namespace audio_hardware {
int GetOutputSampleRate() {
DCHECK(RenderThreadImpl::current() != NULL);
if (!output_sample_rate) {
RenderThreadImpl::current()->Send(
new ViewHostMsg_GetHardwareSampleRate(&output_sample_rate));
}
return output_sample_rate;
}
int GetInputSampleRate() {
DCHECK(RenderThreadImpl::current() != NULL);
if (!input_sample_rate) {
RenderThreadImpl::current()->Send(
new ViewHostMsg_GetHardwareInputSampleRate(&input_sample_rate));
}
return input_sample_rate;
}
size_t GetOutputBufferSize() {
DCHECK(RenderThreadImpl::current() != NULL);
if (!output_buffer_size) {
uint32 buffer_size = 0;
RenderThreadImpl::current()->Send(
new ViewHostMsg_GetHardwareBufferSize(&buffer_size));
output_buffer_size = buffer_size;
}
return output_buffer_size;
}
ChannelLayout GetInputChannelLayout() {
DCHECK(RenderThreadImpl::current() != NULL);
if (input_channel_layout == CHANNEL_LAYOUT_NONE) {
ChannelLayout layout = CHANNEL_LAYOUT_NONE;
RenderThreadImpl::current()->Send(
new ViewHostMsg_GetHardwareInputChannelLayout(&layout));
input_channel_layout = layout;
}
return input_channel_layout;
}
void ResetCache() {
DCHECK(RenderThreadImpl::current() != NULL);
output_sample_rate = 0.0;
input_sample_rate = 0.0;
output_buffer_size = 0;
input_channel_layout = CHANNEL_LAYOUT_NONE;
}
} // namespace audio_hardware
|