OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "ppapi/thunk/thunk.h" |
6 #include "ppapi/thunk/enter.h" | 6 #include "ppapi/thunk/enter.h" |
7 #include "ppapi/thunk/ppb_audio_api.h" | 7 #include "ppapi/thunk/ppb_audio_api.h" |
8 #include "ppapi/thunk/resource_creation_api.h" | 8 #include "ppapi/thunk/resource_creation_api.h" |
9 | 9 |
10 namespace ppapi { | 10 namespace ppapi { |
11 namespace thunk { | 11 namespace thunk { |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
| 15 typedef EnterResource<PPB_Audio_API> EnterAudio; |
| 16 |
15 PP_Resource Create(PP_Instance instance, | 17 PP_Resource Create(PP_Instance instance, |
16 PP_Resource config_id, | 18 PP_Resource config_id, |
17 PPB_Audio_Callback callback, | 19 PPB_Audio_Callback callback, |
18 void* user_data) { | 20 void* user_data) { |
19 EnterFunction<ResourceCreationAPI> enter(instance, true); | 21 EnterFunction<ResourceCreationAPI> enter(instance, true); |
20 if (enter.failed()) | 22 if (enter.failed()) |
21 return 0; | 23 return 0; |
22 return enter.functions()->CreateAudio(instance, config_id, | 24 return enter.functions()->CreateAudio(instance, config_id, |
23 callback, user_data); | 25 callback, user_data); |
24 } | 26 } |
25 | 27 |
26 PP_Bool IsAudio(PP_Resource resource) { | 28 PP_Bool IsAudio(PP_Resource resource) { |
27 EnterResource<PPB_Audio_API> enter(resource, false); | 29 EnterAudio enter(resource, false); |
28 return enter.succeeded() ? PP_TRUE : PP_FALSE; | 30 return enter.succeeded() ? PP_TRUE : PP_FALSE; |
29 } | 31 } |
30 | 32 |
31 PP_Resource GetCurrentConfiguration(PP_Resource audio_id) { | 33 PP_Resource GetCurrentConfiguration(PP_Resource audio_id) { |
32 EnterResource<PPB_Audio_API> enter(audio_id, true); | 34 EnterAudio enter(audio_id, true); |
33 if (enter.failed()) | 35 if (enter.failed()) |
34 return 0; | 36 return 0; |
35 return enter.object()->GetCurrentConfig(); | 37 return enter.object()->GetCurrentConfig(); |
36 } | 38 } |
37 | 39 |
38 PP_Bool StartPlayback(PP_Resource audio_id) { | 40 PP_Bool StartPlayback(PP_Resource audio_id) { |
39 EnterResource<PPB_Audio_API> enter(audio_id, true); | 41 EnterAudio enter(audio_id, true); |
40 if (enter.failed()) | 42 if (enter.failed()) |
41 return PP_FALSE; | 43 return PP_FALSE; |
42 return enter.object()->StartPlayback(); | 44 return enter.object()->StartPlayback(); |
43 } | 45 } |
44 | 46 |
45 PP_Bool StopPlayback(PP_Resource audio_id) { | 47 PP_Bool StopPlayback(PP_Resource audio_id) { |
46 EnterResource<PPB_Audio_API> enter(audio_id, true); | 48 EnterAudio enter(audio_id, true); |
47 if (enter.failed()) | 49 if (enter.failed()) |
48 return PP_FALSE; | 50 return PP_FALSE; |
49 return enter.object()->StopPlayback(); | 51 return enter.object()->StopPlayback(); |
50 } | 52 } |
51 | 53 |
52 const PPB_Audio g_ppb_audio_thunk = { | 54 const PPB_Audio g_ppb_audio_thunk = { |
53 &Create, | 55 &Create, |
54 &IsAudio, | 56 &IsAudio, |
55 &GetCurrentConfiguration, | 57 &GetCurrentConfiguration, |
56 &StartPlayback, | 58 &StartPlayback, |
57 &StopPlayback | 59 &StopPlayback |
58 }; | 60 }; |
59 | 61 |
60 } // namespace | 62 } // namespace |
61 | 63 |
62 const PPB_Audio* GetPPB_Audio_Thunk() { | 64 const PPB_Audio* GetPPB_Audio_Thunk() { |
63 return &g_ppb_audio_thunk; | 65 return &g_ppb_audio_thunk; |
64 } | 66 } |
65 | 67 |
66 } // namespace thunk | 68 } // namespace thunk |
67 } // namespace ppapi | 69 } // namespace ppapi |
OLD | NEW |