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 "webkit/plugins/ppapi/ppb_audio_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_audio_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ppapi/c/pp_completion_callback.h" | 8 #include "ppapi/c/pp_completion_callback.h" |
9 #include "ppapi/c/ppb_audio.h" | 9 #include "ppapi/c/ppb_audio.h" |
10 #include "ppapi/c/ppb_audio_config.h" | 10 #include "ppapi/c/ppb_audio_config.h" |
11 #include "ppapi/c/trusted/ppb_audio_trusted.h" | 11 #include "ppapi/c/trusted/ppb_audio_trusted.h" |
12 #include "ppapi/shared_impl/resource_tracker.h" | 12 #include "ppapi/shared_impl/resource_tracker.h" |
13 #include "ppapi/shared_impl/tracker_base.h" | 13 #include "ppapi/shared_impl/tracker_base.h" |
14 #include "ppapi/thunk/enter.h" | 14 #include "ppapi/thunk/enter.h" |
15 #include "ppapi/thunk/ppb_audio_config_api.h" | 15 #include "ppapi/thunk/ppb_audio_config_api.h" |
16 #include "ppapi/thunk/thunk.h" | 16 #include "ppapi/thunk/thunk.h" |
17 #include "webkit/plugins/ppapi/common.h" | 17 #include "webkit/plugins/ppapi/common.h" |
18 #include "webkit/plugins/ppapi/resource_helper.h" | 18 #include "webkit/plugins/ppapi/resource_helper.h" |
19 | 19 |
| 20 using ppapi::PpapiGlobals; |
20 using ppapi::thunk::EnterResourceNoLock; | 21 using ppapi::thunk::EnterResourceNoLock; |
21 using ppapi::thunk::PPB_Audio_API; | 22 using ppapi::thunk::PPB_Audio_API; |
22 using ppapi::thunk::PPB_AudioConfig_API; | 23 using ppapi::thunk::PPB_AudioConfig_API; |
23 | 24 |
24 namespace webkit { | 25 namespace webkit { |
25 namespace ppapi { | 26 namespace ppapi { |
26 | 27 |
27 // PPB_Audio_Impl -------------------------------------------------------------- | 28 // PPB_Audio_Impl -------------------------------------------------------------- |
28 | 29 |
29 PPB_Audio_Impl::PPB_Audio_Impl(PP_Instance instance) | 30 PPB_Audio_Impl::PPB_Audio_Impl(PP_Instance instance) |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 // When the stream is created, we'll get called back on StreamCreated(). | 88 // When the stream is created, we'll get called back on StreamCreated(). |
88 CHECK(!audio_); | 89 CHECK(!audio_); |
89 audio_ = plugin_delegate->CreateAudio(enter.object()->GetSampleRate(), | 90 audio_ = plugin_delegate->CreateAudio(enter.object()->GetSampleRate(), |
90 enter.object()->GetSampleFrameCount(), | 91 enter.object()->GetSampleFrameCount(), |
91 this); | 92 this); |
92 return audio_ != NULL; | 93 return audio_ != NULL; |
93 } | 94 } |
94 | 95 |
95 PP_Resource PPB_Audio_Impl::GetCurrentConfig() { | 96 PP_Resource PPB_Audio_Impl::GetCurrentConfig() { |
96 // AddRef on behalf of caller, while keeping a ref for ourselves. | 97 // AddRef on behalf of caller, while keeping a ref for ourselves. |
97 ::ppapi::TrackerBase::Get()->GetResourceTracker()->AddRefResource(config_); | 98 PpapiGlobals::Get()->GetResourceTracker()->AddRefResource(config_); |
98 return config_; | 99 return config_; |
99 } | 100 } |
100 | 101 |
101 PP_Bool PPB_Audio_Impl::StartPlayback() { | 102 PP_Bool PPB_Audio_Impl::StartPlayback() { |
102 if (!audio_) | 103 if (!audio_) |
103 return PP_FALSE; | 104 return PP_FALSE; |
104 if (playing()) | 105 if (playing()) |
105 return PP_TRUE; | 106 return PP_TRUE; |
106 SetStartPlaybackState(); | 107 SetStartPlaybackState(); |
107 return BoolToPPBool(audio_->StartPlayback()); | 108 return BoolToPPBool(audio_->StartPlayback()); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 // something more elaborate like an ACK from the plugin or post a task to | 200 // something more elaborate like an ACK from the plugin or post a task to |
200 // the I/O thread and back, but this extra complexity doesn't seem worth it | 201 // the I/O thread and back, but this extra complexity doesn't seem worth it |
201 // just to clean up these handles faster. | 202 // just to clean up these handles faster. |
202 } else { | 203 } else { |
203 SetStreamInfo(shared_memory_handle, shared_memory_size, socket_handle); | 204 SetStreamInfo(shared_memory_handle, shared_memory_size, socket_handle); |
204 } | 205 } |
205 } | 206 } |
206 | 207 |
207 } // namespace ppapi | 208 } // namespace ppapi |
208 } // namespace webkit | 209 } // namespace webkit |
OLD | NEW |