Do not assume that the orientation is PORTRAIT by default.
[chromium-blink-merge.git] / ppapi / thunk / ppb_audio_config_thunk.cc
blobb06affd5c0df66ced7a6e2594933ee98da2c6133
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/shared_impl/ppb_audio_config_shared.h"
6 #include "ppapi/thunk/thunk.h"
7 #include "ppapi/thunk/enter.h"
8 #include "ppapi/thunk/ppb_audio_config_api.h"
9 #include "ppapi/thunk/resource_creation_api.h"
11 namespace ppapi {
12 namespace thunk {
14 namespace {
16 PP_Resource CreateStereo16bit(PP_Instance instance,
17 PP_AudioSampleRate sample_rate,
18 uint32_t sample_frame_count) {
19 VLOG(4) << "PPB_AudioConfig::CreateStereo16Bit()";
20 EnterResourceCreation enter(instance);
21 if (enter.failed())
22 return 0;
23 return enter.functions()->CreateAudioConfig(instance, sample_rate,
24 sample_frame_count);
27 uint32_t RecommendSampleFrameCount_1_0(PP_AudioSampleRate sample_rate,
28 uint32_t requested_sample_frame_count) {
29 VLOG(4) << "PPB_AudioConfig::RecommendSampleFrameCount()";
30 return PPB_AudioConfig_Shared::RecommendSampleFrameCount_1_0(sample_rate,
31 requested_sample_frame_count);
34 uint32_t RecommendSampleFrameCount_1_1(PP_Instance instance,
35 PP_AudioSampleRate sample_rate,
36 uint32_t requested_sample_frame_count) {
37 VLOG(4) << "PPB_AudioConfig::RecommendSampleFrameCount()";
38 EnterInstance enter(instance);
39 if (enter.failed())
40 return 0;
41 return PPB_AudioConfig_Shared::RecommendSampleFrameCount_1_1(instance,
42 sample_rate, requested_sample_frame_count);
46 PP_Bool IsAudioConfig(PP_Resource resource) {
47 VLOG(4) << "PPB_AudioConfig::IsAudioConfig()";
48 EnterResource<PPB_AudioConfig_API> enter(resource, false);
49 return PP_FromBool(enter.succeeded());
52 PP_AudioSampleRate GetSampleRate(PP_Resource config_id) {
53 VLOG(4) << "PPB_AudioConfig::GetSampleRate()";
54 EnterResource<PPB_AudioConfig_API> enter(config_id, true);
55 if (enter.failed())
56 return PP_AUDIOSAMPLERATE_NONE;
57 return enter.object()->GetSampleRate();
60 uint32_t GetSampleFrameCount(PP_Resource config_id) {
61 VLOG(4) << "PPB_AudioConfig::GetSampleFrameCount()";
62 EnterResource<PPB_AudioConfig_API> enter(config_id, true);
63 if (enter.failed())
64 return 0;
65 return enter.object()->GetSampleFrameCount();
68 PP_AudioSampleRate RecommendSampleRate(PP_Instance instance) {
69 VLOG(4) << "PPB_AudioConfig::RecommendSampleRate()";
70 EnterInstance enter(instance);
71 if (enter.failed())
72 return PP_AUDIOSAMPLERATE_NONE;
73 return PPB_AudioConfig_Shared::RecommendSampleRate(instance);
76 const PPB_AudioConfig_1_0 g_ppb_audio_config_thunk_1_0 = {
77 &CreateStereo16bit,
78 &RecommendSampleFrameCount_1_0,
79 &IsAudioConfig,
80 &GetSampleRate,
81 &GetSampleFrameCount
84 const PPB_AudioConfig_1_1 g_ppb_audio_config_thunk_1_1 = {
85 &CreateStereo16bit,
86 &RecommendSampleFrameCount_1_1,
87 &IsAudioConfig,
88 &GetSampleRate,
89 &GetSampleFrameCount,
90 &RecommendSampleRate
94 } // namespace
96 const PPB_AudioConfig_1_0* GetPPB_AudioConfig_1_0_Thunk() {
97 return &g_ppb_audio_config_thunk_1_0;
100 const PPB_AudioConfig_1_1* GetPPB_AudioConfig_1_1_Thunk() {
101 return &g_ppb_audio_config_thunk_1_1;
104 } // namespace thunk
105 } // namespace ppapi