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 EnterResourceCreation
enter(instance
);
22 return enter
.functions()->CreateAudioConfig(instance
, sample_rate
,
26 uint32_t RecommendSampleFrameCount_1_0(PP_AudioSampleRate sample_rate
,
27 uint32_t requested_sample_frame_count
) {
28 return PPB_AudioConfig_Shared::RecommendSampleFrameCount_1_0(sample_rate
,
29 requested_sample_frame_count
);
32 uint32_t RecommendSampleFrameCount_1_1(PP_Instance instance
,
33 PP_AudioSampleRate sample_rate
,
34 uint32_t requested_sample_frame_count
) {
35 EnterInstance
enter(instance
);
38 return PPB_AudioConfig_Shared::RecommendSampleFrameCount_1_1(instance
,
39 sample_rate
, requested_sample_frame_count
);
43 PP_Bool
IsAudioConfig(PP_Resource resource
) {
44 EnterResource
<PPB_AudioConfig_API
> enter(resource
, false);
45 return PP_FromBool(enter
.succeeded());
48 PP_AudioSampleRate
GetSampleRate(PP_Resource config_id
) {
49 EnterResource
<PPB_AudioConfig_API
> enter(config_id
, true);
51 return PP_AUDIOSAMPLERATE_NONE
;
52 return enter
.object()->GetSampleRate();
55 uint32_t GetSampleFrameCount(PP_Resource config_id
) {
56 EnterResource
<PPB_AudioConfig_API
> enter(config_id
, true);
59 return enter
.object()->GetSampleFrameCount();
62 PP_AudioSampleRate
RecommendSampleRate(PP_Instance instance
) {
63 EnterInstance
enter(instance
);
65 return PP_AUDIOSAMPLERATE_NONE
;
66 return PPB_AudioConfig_Shared::RecommendSampleRate(instance
);
69 const PPB_AudioConfig_1_0 g_ppb_audio_config_thunk_1_0
= {
71 &RecommendSampleFrameCount_1_0
,
77 const PPB_AudioConfig_1_1 g_ppb_audio_config_thunk_1_1
= {
79 &RecommendSampleFrameCount_1_1
,
89 const PPB_AudioConfig_1_0
* GetPPB_AudioConfig_1_0_Thunk() {
90 return &g_ppb_audio_config_thunk_1_0
;
93 const PPB_AudioConfig_1_1
* GetPPB_AudioConfig_1_1_Thunk() {
94 return &g_ppb_audio_config_thunk_1_1
;