OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ppapi/thunk/thunk.h" | 5 // From ppb_audio.idl modified Tue Dec 4 10:41:02 2012. |
| 6 |
| 7 #include "ppapi/c/pp_errors.h" |
| 8 #include "ppapi/c/ppb_audio.h" |
| 9 #include "ppapi/shared_impl/tracked_callback.h" |
6 #include "ppapi/thunk/enter.h" | 10 #include "ppapi/thunk/enter.h" |
7 #include "ppapi/thunk/ppb_audio_api.h" | 11 #include "ppapi/thunk/ppb_audio_api.h" |
| 12 #include "ppapi/thunk/ppb_instance_api.h" |
8 #include "ppapi/thunk/resource_creation_api.h" | 13 #include "ppapi/thunk/resource_creation_api.h" |
| 14 #include "ppapi/thunk/thunk.h" |
9 | 15 |
10 namespace ppapi { | 16 namespace ppapi { |
11 namespace thunk { | 17 namespace thunk { |
12 | 18 |
13 namespace { | 19 namespace { |
14 | 20 |
15 typedef EnterResource<PPB_Audio_API> EnterAudio; | |
16 | |
17 PP_Resource Create(PP_Instance instance, | 21 PP_Resource Create(PP_Instance instance, |
18 PP_Resource config_id, | 22 PP_Resource config, |
19 PPB_Audio_Callback callback, | 23 PPB_Audio_Callback audio_callback, |
20 void* user_data) { | 24 void* user_data) { |
21 EnterResourceCreation enter(instance); | 25 EnterResourceCreation enter(instance); |
22 if (enter.failed()) | 26 if (enter.failed()) |
23 return 0; | 27 return 0; |
24 return enter.functions()->CreateAudio(instance, config_id, | 28 return enter.functions()->CreateAudio(instance, |
25 callback, user_data); | 29 config, |
| 30 audio_callback, |
| 31 user_data); |
26 } | 32 } |
27 | 33 |
28 PP_Bool IsAudio(PP_Resource resource) { | 34 PP_Bool IsAudio(PP_Resource resource) { |
29 EnterAudio enter(resource, false); | 35 EnterResource<PPB_Audio_API> enter(resource, false); |
30 return enter.succeeded() ? PP_TRUE : PP_FALSE; | 36 return PP_FromBool(enter.succeeded()); |
31 } | 37 } |
32 | 38 |
33 PP_Resource GetCurrentConfiguration(PP_Resource audio_id) { | 39 PP_Resource GetCurrentConfig(PP_Resource audio) { |
34 EnterAudio enter(audio_id, true); | 40 EnterResource<PPB_Audio_API> enter(audio, true); |
35 if (enter.failed()) | 41 if (enter.failed()) |
36 return 0; | 42 return 0; |
37 return enter.object()->GetCurrentConfig(); | 43 return enter.object()->GetCurrentConfig(); |
38 } | 44 } |
39 | 45 |
40 PP_Bool StartPlayback(PP_Resource audio_id) { | 46 PP_Bool StartPlayback(PP_Resource audio) { |
41 EnterAudio enter(audio_id, true); | 47 EnterResource<PPB_Audio_API> enter(audio, true); |
42 if (enter.failed()) | 48 if (enter.failed()) |
43 return PP_FALSE; | 49 return PP_FALSE; |
44 return enter.object()->StartPlayback(); | 50 return enter.object()->StartPlayback(); |
45 } | 51 } |
46 | 52 |
47 PP_Bool StopPlayback(PP_Resource audio_id) { | 53 PP_Bool StopPlayback(PP_Resource audio) { |
48 EnterAudio enter(audio_id, true); | 54 EnterResource<PPB_Audio_API> enter(audio, true); |
49 if (enter.failed()) | 55 if (enter.failed()) |
50 return PP_FALSE; | 56 return PP_FALSE; |
51 return enter.object()->StopPlayback(); | 57 return enter.object()->StopPlayback(); |
52 } | 58 } |
53 | 59 |
54 const PPB_Audio g_ppb_audio_thunk = { | 60 const PPB_Audio_1_0 g_ppb_audio_thunk_1_0 = { |
55 &Create, | 61 &Create, |
56 &IsAudio, | 62 &IsAudio, |
57 &GetCurrentConfiguration, | 63 &GetCurrentConfig, |
58 &StartPlayback, | 64 &StartPlayback, |
59 &StopPlayback | 65 &StopPlayback, |
60 }; | 66 }; |
61 | 67 |
62 } // namespace | 68 } // namespace |
63 | 69 |
64 const PPB_Audio_1_0* GetPPB_Audio_1_0_Thunk() { | 70 const PPB_Audio_1_0* GetPPB_Audio_1_0_Thunk() { |
65 return &g_ppb_audio_thunk; | 71 return &g_ppb_audio_thunk_1_0; |
66 } | 72 } |
67 | 73 |
68 } // namespace thunk | 74 } // namespace thunk |
69 } // namespace ppapi | 75 } // namespace ppapi |
OLD | NEW |