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"
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
);
23 return enter
.functions()->CreateAudioConfig(instance
, sample_rate
,
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
);
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);
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);
65 return enter
.object()->GetSampleFrameCount();
68 PP_AudioSampleRate
RecommendSampleRate(PP_Instance instance
) {
69 VLOG(4) << "PPB_AudioConfig::RecommendSampleRate()";
70 EnterInstance
enter(instance
);
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
= {
78 &RecommendSampleFrameCount_1_0
,
84 const PPB_AudioConfig_1_1 g_ppb_audio_config_thunk_1_1
= {
86 &RecommendSampleFrameCount_1_1
,
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
;