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 "native_client/src/shared/ppapi_proxy/plugin_ppb_audio.h" | 5 #include "native_client/src/shared/ppapi_proxy/plugin_ppb_audio.h" |
6 | 6 |
7 #include <pthread.h> | 7 #include <pthread.h> |
8 #include <stdio.h> | 8 #include <stdio.h> |
9 #include <string.h> | 9 #include <string.h> |
10 #include <sys/errno.h> | 10 #include <sys/errno.h> |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 // Start of untrusted PPB_Audio functions | 167 // Start of untrusted PPB_Audio functions |
168 namespace { | 168 namespace { |
169 | 169 |
170 PP_Resource Create(PP_Instance instance, | 170 PP_Resource Create(PP_Instance instance, |
171 PP_Resource config, | 171 PP_Resource config, |
172 PPB_Audio_Callback user_callback, | 172 PPB_Audio_Callback user_callback, |
173 void* user_data) { | 173 void* user_data) { |
174 DebugPrintf("PPB_Audio::Create: instance=%"NACL_PRId32" config=%"NACL_PRId32 | 174 DebugPrintf("PPB_Audio::Create: instance=%"NACL_PRId32" config=%"NACL_PRId32 |
175 " user_callback=%p user_data=%p\n", | 175 " user_callback=%p user_data=%p\n", |
176 instance, config, user_callback, user_data); | 176 instance, config, user_callback, user_data); |
| 177 if (NULL == user_callback) { |
| 178 return kInvalidResourceId; |
| 179 } |
177 PP_Resource audio_resource; | 180 PP_Resource audio_resource; |
178 // Proxy to browser Create, get audio PP_Resource | 181 // Proxy to browser Create, get audio PP_Resource |
179 NaClSrpcError srpc_result = PpbAudioRpcClient::PPB_Audio_Create( | 182 NaClSrpcError srpc_result = PpbAudioRpcClient::PPB_Audio_Create( |
180 GetMainSrpcChannel(), | 183 GetMainSrpcChannel(), |
181 instance, | 184 instance, |
182 config, | 185 config, |
183 &audio_resource); | 186 &audio_resource); |
184 DebugPrintf("PPB_Audio::Create: %s\n", NaClSrpcErrorString(srpc_result)); | 187 DebugPrintf("PPB_Audio::Create: %s\n", NaClSrpcErrorString(srpc_result)); |
185 if (NACL_SRPC_RESULT_OK != srpc_result) { | 188 if (NACL_SRPC_RESULT_OK != srpc_result) { |
186 return kInvalidResourceId; | 189 return kInvalidResourceId; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 GetAs<ppapi_proxy::PluginAudio>(audio_resource); | 329 GetAs<ppapi_proxy::PluginAudio>(audio_resource); |
327 if (NULL == audio.get()) { | 330 if (NULL == audio.get()) { |
328 // Ignore if no audio_resource -> audio_instance mapping exists, | 331 // Ignore if no audio_resource -> audio_instance mapping exists, |
329 // the app may have shutdown audio before StreamCreated() invoked. | 332 // the app may have shutdown audio before StreamCreated() invoked. |
330 rpc->result = NACL_SRPC_RESULT_OK; | 333 rpc->result = NACL_SRPC_RESULT_OK; |
331 return; | 334 return; |
332 } | 335 } |
333 audio->StreamCreated(sync_socket, shm, shm_size); | 336 audio->StreamCreated(sync_socket, shm, shm_size); |
334 rpc->result = NACL_SRPC_RESULT_OK; | 337 rpc->result = NACL_SRPC_RESULT_OK; |
335 } | 338 } |
OLD | NEW |