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_config.h" | 5 #include "native_client/src/shared/ppapi_proxy/plugin_ppb_audio_config.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <string.h> | 8 #include <string.h> |
9 #include "srpcgen/ppb_rpc.h" | 9 #include "srpcgen/ppb_rpc.h" |
10 #include "native_client/src/include/portability.h" | 10 #include "native_client/src/include/portability.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 config, | 44 config, |
45 &sample_frame_count); | 45 &sample_frame_count); |
46 DebugPrintf("PPB_AudioConfig::GetSampleFrameCount: %s\n", | 46 DebugPrintf("PPB_AudioConfig::GetSampleFrameCount: %s\n", |
47 NaClSrpcErrorString(srpc_result)); | 47 NaClSrpcErrorString(srpc_result)); |
48 if (NACL_SRPC_RESULT_OK == srpc_result) { | 48 if (NACL_SRPC_RESULT_OK == srpc_result) { |
49 return static_cast<uint32_t>(sample_frame_count); | 49 return static_cast<uint32_t>(sample_frame_count); |
50 } | 50 } |
51 return 0; | 51 return 0; |
52 } | 52 } |
53 | 53 |
54 uint32_t RecommendSampleFrameCount(PP_AudioSampleRate sample_rate, | 54 uint32_t RecommendSampleFrameCount(PP_Instance instance, |
| 55 PP_AudioSampleRate sample_rate, |
55 uint32_t request_sample_frame_count) { | 56 uint32_t request_sample_frame_count) { |
56 DebugPrintf("PPB_AudioConfig::RecommendSampleFrameCount"); | 57 DebugPrintf("PPB_AudioConfig::RecommendSampleFrameCount"); |
57 int32_t out_sample_frame_count; | 58 int32_t out_sample_frame_count; |
58 NaClSrpcError srpc_result = | 59 NaClSrpcError srpc_result = |
59 PpbAudioConfigRpcClient::PPB_AudioConfig_RecommendSampleFrameCount( | 60 PpbAudioConfigRpcClient::PPB_AudioConfig_RecommendSampleFrameCount( |
60 GetMainSrpcChannel(), | 61 GetMainSrpcChannel(), |
| 62 instance, |
61 static_cast<int32_t>(sample_rate), | 63 static_cast<int32_t>(sample_rate), |
62 static_cast<int32_t>(request_sample_frame_count), | 64 static_cast<int32_t>(request_sample_frame_count), |
63 &out_sample_frame_count); | 65 &out_sample_frame_count); |
64 DebugPrintf("PPB_AudioConfig::RecommendSampleFrameCount: %s\n", | 66 DebugPrintf("PPB_AudioConfig::RecommendSampleFrameCount: %s\n", |
65 NaClSrpcErrorString(srpc_result)); | 67 NaClSrpcErrorString(srpc_result)); |
66 if (NACL_SRPC_RESULT_OK == srpc_result) { | 68 if (NACL_SRPC_RESULT_OK == srpc_result) { |
67 return static_cast<uint32_t>(out_sample_frame_count); | 69 return static_cast<uint32_t>(out_sample_frame_count); |
68 } | 70 } |
69 return 0; | 71 return 0; |
70 } | 72 } |
(...skipping 28 matching lines...) Expand all Loading... |
99 static_cast<int32_t>(sample_rate), | 101 static_cast<int32_t>(sample_rate), |
100 static_cast<int32_t>(sample_frame_count), | 102 static_cast<int32_t>(sample_frame_count), |
101 &resource); | 103 &resource); |
102 DebugPrintf("PPB_AudioConfig::CreateStereo16Bit: %s\n", | 104 DebugPrintf("PPB_AudioConfig::CreateStereo16Bit: %s\n", |
103 NaClSrpcErrorString(srpc_result)); | 105 NaClSrpcErrorString(srpc_result)); |
104 if (NACL_SRPC_RESULT_OK == srpc_result) { | 106 if (NACL_SRPC_RESULT_OK == srpc_result) { |
105 return resource; | 107 return resource; |
106 } | 108 } |
107 return kInvalidResourceId; | 109 return kInvalidResourceId; |
108 } | 110 } |
| 111 |
| 112 PP_AudioSampleRate RecommendSampleRate(PP_Instance instance) { |
| 113 DebugPrintf("PPB_AudioConfig::RecommendSampleRate"); |
| 114 int32_t out_sample_rate; |
| 115 NaClSrpcError srpc_result = |
| 116 PpbAudioConfigRpcClient::PPB_AudioConfig_RecommendSampleRate( |
| 117 GetMainSrpcChannel(), |
| 118 instance, |
| 119 &out_sample_rate); |
| 120 DebugPrintf("PPB_AudioConfig::RecommendSampleRate: %s\n", |
| 121 NaClSrpcErrorString(srpc_result)); |
| 122 if (NACL_SRPC_RESULT_OK == srpc_result) { |
| 123 return static_cast<PP_AudioSampleRate>(out_sample_rate); |
| 124 } |
| 125 return PP_AUDIOSAMPLERATE_NONE; |
| 126 } |
| 127 |
109 } // namespace | 128 } // namespace |
110 | 129 |
111 const PPB_AudioConfig* PluginAudioConfig::GetInterface() { | 130 const PPB_AudioConfig* PluginAudioConfig::GetInterface() { |
112 static const PPB_AudioConfig audio_config_interface = { | 131 static const PPB_AudioConfig audio_config_interface = { |
113 CreateStereo16Bit, | 132 CreateStereo16Bit, |
114 RecommendSampleFrameCount, | 133 RecommendSampleFrameCount, |
115 IsAudioConfig, | 134 IsAudioConfig, |
116 GetSampleRate, | 135 GetSampleRate, |
117 GetSampleFrameCount, | 136 GetSampleFrameCount, |
| 137 RecommendSampleRate |
118 }; | 138 }; |
119 return &audio_config_interface; | 139 return &audio_config_interface; |
120 } | 140 } |
121 } // namespace ppapi_proxy | 141 } // namespace ppapi_proxy |
OLD | NEW |