• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #include "ppapi/c/pp_errors.h"
6 #include "ppapi/c/ppb_audio.h"
7 #include "ppapi/shared_impl/tracked_callback.h"
8 #include "ppapi/thunk/enter.h"
9 #include "ppapi/thunk/ppb_audio_api.h"
10 #include "ppapi/thunk/ppb_instance_api.h"
11 #include "ppapi/thunk/resource_creation_api.h"
12 #include "ppapi/thunk/thunk.h"
13 
14 namespace ppapi {
15 namespace thunk {
16 
17 namespace {
18 
Create_1_0(PP_Instance instance,PP_Resource config,PPB_Audio_Callback_1_0 audio_callback,void * user_data)19 PP_Resource Create_1_0(PP_Instance instance,
20                       PP_Resource config,
21                       PPB_Audio_Callback_1_0 audio_callback,
22                       void* user_data) {
23   VLOG(4) << "PPB_Audio::Create()";
24   EnterResourceCreation enter(instance);
25   if (enter.failed())
26     return 0;
27   return enter.functions()->CreateAudio1_0(instance,
28                                            config,
29                                            audio_callback,
30                                            user_data);
31 }
32 
Create(PP_Instance instance,PP_Resource config,PPB_Audio_Callback audio_callback,void * user_data)33 PP_Resource Create(PP_Instance instance,
34                    PP_Resource config,
35                    PPB_Audio_Callback audio_callback,
36                    void* user_data) {
37   VLOG(4) << "PPB_Audio::Create()";
38   EnterResourceCreation enter(instance);
39   if (enter.failed())
40     return 0;
41   return enter.functions()->CreateAudio(instance,
42                                         config,
43                                         audio_callback,
44                                         user_data);
45 }
46 
IsAudio(PP_Resource resource)47 PP_Bool IsAudio(PP_Resource resource) {
48   VLOG(4) << "PPB_Audio::IsAudio()";
49   EnterResource<PPB_Audio_API> enter(resource, false);
50   return PP_FromBool(enter.succeeded());
51 }
52 
GetCurrentConfig(PP_Resource audio)53 PP_Resource GetCurrentConfig(PP_Resource audio) {
54   VLOG(4) << "PPB_Audio::GetCurrentConfig()";
55   EnterResource<PPB_Audio_API> enter(audio, true);
56   if (enter.failed())
57     return 0;
58   return enter.object()->GetCurrentConfig();
59 }
60 
StartPlayback(PP_Resource audio)61 PP_Bool StartPlayback(PP_Resource audio) {
62   VLOG(4) << "PPB_Audio::StartPlayback()";
63   EnterResource<PPB_Audio_API> enter(audio, true);
64   if (enter.failed())
65     return PP_FALSE;
66   return enter.object()->StartPlayback();
67 }
68 
StopPlayback(PP_Resource audio)69 PP_Bool StopPlayback(PP_Resource audio) {
70   VLOG(4) << "PPB_Audio::StopPlayback()";
71   EnterResource<PPB_Audio_API> enter(audio, true);
72   if (enter.failed())
73     return PP_FALSE;
74   return enter.object()->StopPlayback();
75 }
76 
77 const PPB_Audio_1_0 g_ppb_audio_thunk_1_0 = {
78   &Create_1_0,
79   &IsAudio,
80   &GetCurrentConfig,
81   &StartPlayback,
82   &StopPlayback
83 };
84 
85 const PPB_Audio_1_1 g_ppb_audio_thunk_1_1 = {
86   &Create,
87   &IsAudio,
88   &GetCurrentConfig,
89   &StartPlayback,
90   &StopPlayback
91 };
92 
93 }  // namespace
94 
GetPPB_Audio_1_0_Thunk()95 const PPB_Audio_1_0* GetPPB_Audio_1_0_Thunk() {
96   return &g_ppb_audio_thunk_1_0;
97 }
98 
GetPPB_Audio_1_1_Thunk()99 const PPB_Audio_1_1* GetPPB_Audio_1_1_Thunk() {
100   return &g_ppb_audio_thunk_1_1;
101 }
102 
103 }  // namespace thunk
104 }  // namespace ppapi
105