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_input_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_audio_input_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ppapi/c/dev/ppb_audio_input_dev.h" | 8 #include "ppapi/c/dev/ppb_audio_input_dev.h" |
9 #include "ppapi/c/pp_completion_callback.h" | 9 #include "ppapi/c/pp_completion_callback.h" |
10 #include "ppapi/c/ppb_audio_config.h" | 10 #include "ppapi/c/ppb_audio_config.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 // until ShutDown returns, StreamCreated may still be called. This will be | 37 // until ShutDown returns, StreamCreated may still be called. This will be |
38 // OK since we'll just immediately clean up the data it stored later in this | 38 // OK since we'll just immediately clean up the data it stored later in this |
39 // destructor. | 39 // destructor. |
40 if (audio_input_) { | 40 if (audio_input_) { |
41 audio_input_->ShutDown(); | 41 audio_input_->ShutDown(); |
42 audio_input_ = NULL; | 42 audio_input_ = NULL; |
43 } | 43 } |
44 } | 44 } |
45 | 45 |
46 // static | 46 // static |
47 PP_Resource PPB_AudioInput_Impl::Create(PP_Instance instance, | 47 PP_Resource PPB_AudioInput_Impl::Create( |
48 PP_Resource config, | 48 PP_Instance instance, |
49 PPB_AudioInput_Callback audio_input_callback, | 49 PP_Resource config, |
50 void* user_data) { | 50 PPB_AudioInput_Callback audio_input_callback, |
| 51 void* user_data) { |
51 scoped_refptr<PPB_AudioInput_Impl> | 52 scoped_refptr<PPB_AudioInput_Impl> |
52 audio_input(new PPB_AudioInput_Impl(instance)); | 53 audio_input(new PPB_AudioInput_Impl(instance)); |
53 if (!audio_input->Init(config, audio_input_callback, user_data)) | 54 if (!audio_input->Init(config, audio_input_callback, user_data)) |
54 return 0; | 55 return 0; |
55 return audio_input->GetReference(); | 56 return audio_input->GetReference(); |
56 } | 57 } |
57 | 58 |
58 PPB_AudioInput_API* PPB_AudioInput_Impl::AsPPB_AudioInput_API() { | 59 PPB_AudioInput_API* PPB_AudioInput_Impl::AsPPB_AudioInput_API() { |
59 return this; | 60 return this; |
60 } | 61 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 if (!audio_input_) | 105 if (!audio_input_) |
105 return PP_FALSE; | 106 return PP_FALSE; |
106 if (!capturing()) | 107 if (!capturing()) |
107 return PP_TRUE; | 108 return PP_TRUE; |
108 if (!audio_input_->StopCapture()) | 109 if (!audio_input_->StopCapture()) |
109 return PP_FALSE; | 110 return PP_FALSE; |
110 SetStopCaptureState(); | 111 SetStopCaptureState(); |
111 return PP_TRUE; | 112 return PP_TRUE; |
112 } | 113 } |
113 | 114 |
114 int32_t PPB_AudioInput_Impl::OpenTrusted(PP_Resource config, | 115 int32_t PPB_AudioInput_Impl::OpenTrusted( |
| 116 PP_Resource config, |
115 PP_CompletionCallback create_callback) { | 117 PP_CompletionCallback create_callback) { |
116 // Validate the config and keep a reference to it. | 118 // Validate the config and keep a reference to it. |
117 EnterResourceNoLock<PPB_AudioConfig_API> enter(config, true); | 119 EnterResourceNoLock<PPB_AudioConfig_API> enter(config, true); |
118 if (enter.failed()) | 120 if (enter.failed()) |
119 return PP_ERROR_FAILED; | 121 return PP_ERROR_FAILED; |
120 config_ = config; | 122 config_ = config; |
121 | 123 |
122 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); | 124 PluginDelegate* plugin_delegate = ResourceHelper::GetPluginDelegate(this); |
123 if (!plugin_delegate) | 125 if (!plugin_delegate) |
124 return PP_ERROR_FAILED; | 126 return PP_ERROR_FAILED; |
(...skipping 26 matching lines...) Expand all Loading... |
151 | 153 |
152 void PPB_AudioInput_Impl::OnSetStreamInfo( | 154 void PPB_AudioInput_Impl::OnSetStreamInfo( |
153 base::SharedMemoryHandle shared_memory_handle, | 155 base::SharedMemoryHandle shared_memory_handle, |
154 size_t shared_memory_size, | 156 size_t shared_memory_size, |
155 base::SyncSocket::Handle socket_handle) { | 157 base::SyncSocket::Handle socket_handle) { |
156 SetStreamInfo(shared_memory_handle, shared_memory_size, socket_handle); | 158 SetStreamInfo(shared_memory_handle, shared_memory_size, socket_handle); |
157 } | 159 } |
158 | 160 |
159 } // namespace ppapi | 161 } // namespace ppapi |
160 } // namespace webkit | 162 } // namespace webkit |
OLD | NEW |