Increase MessageAttachmentSet::kMaxDescriptorsPerMessage to 128
[chromium-blink-merge.git] / ppapi / cpp / audio_config.cc
blobeaf019c2278244d2c29a293c5b230023fb9cf50d
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.
5 #include "ppapi/cpp/audio_config.h"
7 #include "ppapi/cpp/instance_handle.h"
8 #include "ppapi/cpp/module.h"
9 #include "ppapi/cpp/module_impl.h"
11 namespace pp {
13 namespace {
15 template <> const char* interface_name<PPB_AudioConfig_1_1>() {
16 return PPB_AUDIO_CONFIG_INTERFACE_1_1;
19 template <> const char* interface_name<PPB_AudioConfig_1_0>() {
20 return PPB_AUDIO_CONFIG_INTERFACE_1_0;
23 } // namespace
25 AudioConfig::AudioConfig()
26 : sample_rate_(PP_AUDIOSAMPLERATE_NONE),
27 sample_frame_count_(0) {
30 AudioConfig::AudioConfig(const InstanceHandle& instance,
31 PP_AudioSampleRate sample_rate,
32 uint32_t sample_frame_count)
33 : sample_rate_(sample_rate),
34 sample_frame_count_(sample_frame_count) {
35 if (has_interface<PPB_AudioConfig_1_1>()) {
36 PassRefFromConstructor(
37 get_interface<PPB_AudioConfig_1_1>()->CreateStereo16Bit(
38 instance.pp_instance(), sample_rate, sample_frame_count));
39 } else if (has_interface<PPB_AudioConfig_1_0>()) {
40 PassRefFromConstructor(
41 get_interface<PPB_AudioConfig_1_0>()->CreateStereo16Bit(
42 instance.pp_instance(), sample_rate, sample_frame_count));
46 // static
47 PP_AudioSampleRate AudioConfig::RecommendSampleRate(
48 const InstanceHandle& instance) {
49 if (has_interface<PPB_AudioConfig_1_1>()) {
50 return get_interface<PPB_AudioConfig_1_1>()->
51 RecommendSampleRate(instance.pp_instance());
53 return PP_AUDIOSAMPLERATE_NONE;
56 // static
57 uint32_t AudioConfig::RecommendSampleFrameCount(
58 const InstanceHandle& instance,
59 PP_AudioSampleRate sample_rate,
60 uint32_t requested_sample_frame_count) {
61 if (has_interface<PPB_AudioConfig_1_1>()) {
62 return get_interface<PPB_AudioConfig_1_1>()->
63 RecommendSampleFrameCount(instance.pp_instance(),
64 sample_rate,
65 requested_sample_frame_count);
67 if (has_interface<PPB_AudioConfig_1_0>()) {
68 return get_interface<PPB_AudioConfig_1_0>()->
69 RecommendSampleFrameCount(sample_rate,
70 requested_sample_frame_count);
72 return 0;
75 } // namespace pp