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/proxy/ppb_audio_proxy.h" | 5 #include "ppapi/proxy/ppb_audio_proxy.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/threading/simple_thread.h" | 8 #include "base/threading/simple_thread.h" |
9 #include "ppapi/c/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
10 #include "ppapi/c/ppb_audio.h" | 10 #include "ppapi/c/ppb_audio.h" |
11 #include "ppapi/c/ppb_audio_config.h" | 11 #include "ppapi/c/ppb_audio_config.h" |
12 #include "ppapi/c/ppb_var.h" | 12 #include "ppapi/c/ppb_var.h" |
13 #include "ppapi/c/trusted/ppb_audio_trusted.h" | 13 #include "ppapi/c/trusted/ppb_audio_trusted.h" |
14 #include "ppapi/proxy/enter_proxy.h" | 14 #include "ppapi/proxy/enter_proxy.h" |
15 #include "ppapi/proxy/interface_id.h" | 15 #include "ppapi/proxy/interface_id.h" |
16 #include "ppapi/proxy/plugin_dispatcher.h" | 16 #include "ppapi/proxy/plugin_dispatcher.h" |
17 #include "ppapi/proxy/ppapi_messages.h" | 17 #include "ppapi/proxy/ppapi_messages.h" |
18 #include "ppapi/shared_impl/audio_impl.h" | 18 #include "ppapi/shared_impl/audio_impl.h" |
19 #include "ppapi/shared_impl/ppapi_globals.h" | |
20 #include "ppapi/shared_impl/resource.h" | 19 #include "ppapi/shared_impl/resource.h" |
21 #include "ppapi/thunk/ppb_audio_config_api.h" | 20 #include "ppapi/thunk/ppb_audio_config_api.h" |
22 #include "ppapi/thunk/enter.h" | 21 #include "ppapi/thunk/enter.h" |
23 #include "ppapi/thunk/resource_creation_api.h" | 22 #include "ppapi/thunk/resource_creation_api.h" |
24 #include "ppapi/thunk/thunk.h" | 23 #include "ppapi/thunk/thunk.h" |
25 | 24 |
26 using ppapi::thunk::EnterResourceNoLock; | 25 using ppapi::thunk::EnterResourceNoLock; |
27 using ppapi::thunk::PPB_Audio_API; | 26 using ppapi::thunk::PPB_Audio_API; |
28 using ppapi::thunk::PPB_AudioConfig_API; | 27 using ppapi::thunk::PPB_AudioConfig_API; |
29 | 28 |
(...skipping 28 matching lines...) Expand all Loading... |
58 DISALLOW_COPY_AND_ASSIGN(Audio); | 57 DISALLOW_COPY_AND_ASSIGN(Audio); |
59 }; | 58 }; |
60 | 59 |
61 Audio::Audio(const HostResource& audio_id, | 60 Audio::Audio(const HostResource& audio_id, |
62 PP_Resource config_id, | 61 PP_Resource config_id, |
63 PPB_Audio_Callback callback, | 62 PPB_Audio_Callback callback, |
64 void* user_data) | 63 void* user_data) |
65 : Resource(audio_id), | 64 : Resource(audio_id), |
66 config_(config_id) { | 65 config_(config_id) { |
67 SetCallback(callback, user_data); | 66 SetCallback(callback, user_data); |
68 PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(config_); | 67 PluginResourceTracker::GetInstance()->AddRefResource(config_); |
69 } | 68 } |
70 | 69 |
71 Audio::~Audio() { | 70 Audio::~Audio() { |
72 PpapiGlobals::Get()->GetResourceTracker()->ReleaseResource(config_); | 71 PluginResourceTracker::GetInstance()->ReleaseResource(config_); |
73 } | 72 } |
74 | 73 |
75 PPB_Audio_API* Audio::AsPPB_Audio_API() { | 74 PPB_Audio_API* Audio::AsPPB_Audio_API() { |
76 return this; | 75 return this; |
77 } | 76 } |
78 | 77 |
79 PP_Resource Audio::GetCurrentConfig() { | 78 PP_Resource Audio::GetCurrentConfig() { |
80 // AddRef for the caller. | 79 // AddRef for the caller. |
81 PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(config_); | 80 PluginResourceTracker::GetInstance()->AddRefResource(config_); |
82 return config_; | 81 return config_; |
83 } | 82 } |
84 | 83 |
85 PP_Bool Audio::StartPlayback() { | 84 PP_Bool Audio::StartPlayback() { |
86 if (playing()) | 85 if (playing()) |
87 return PP_TRUE; | 86 return PP_TRUE; |
88 SetStartPlaybackState(); | 87 SetStartPlaybackState(); |
89 PluginDispatcher::GetForResource(this)->Send( | 88 PluginDispatcher::GetForResource(this)->Send( |
90 new PpapiHostMsg_PPBAudio_StartOrStop( | 89 new PpapiHostMsg_PPBAudio_StartOrStop( |
91 INTERFACE_ID_PPB_AUDIO, host_resource(), true)); | 90 INTERFACE_ID_PPB_AUDIO, host_resource(), true)); |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 *foreign_shared_memory_handle = dispatcher()->ShareHandleWithRemote( | 319 *foreign_shared_memory_handle = dispatcher()->ShareHandleWithRemote( |
321 IntToPlatformFile(shared_memory_handle), false); | 320 IntToPlatformFile(shared_memory_handle), false); |
322 if (*foreign_shared_memory_handle == IPC::InvalidPlatformFileForTransit()) | 321 if (*foreign_shared_memory_handle == IPC::InvalidPlatformFileForTransit()) |
323 return PP_ERROR_FAILED; | 322 return PP_ERROR_FAILED; |
324 | 323 |
325 return PP_OK; | 324 return PP_OK; |
326 } | 325 } |
327 | 326 |
328 } // namespace proxy | 327 } // namespace proxy |
329 } // namespace ppapi | 328 } // namespace ppapi |
OLD | NEW |