OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013, The Linux Foundation. All rights reserved. |
| 2 // |
| 3 // Redistribution and use in source and binary forms, with or without |
| 4 // modification, are permitted provided that the following conditions are |
| 5 // met: |
| 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided |
| 11 // with the distribution. |
| 12 // * Neither the name of The Linux Foundation nor the names of its |
| 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. |
| 15 // |
| 16 // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| 17 // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 18 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| 19 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 20 // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 21 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 22 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 23 // BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 24 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 25 // OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 26 // IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 |
| 28 #include <android/asset_manager.h> |
| 29 #include <android/asset_manager_jni.h> |
| 30 |
| 31 #include <string.h> |
| 32 |
| 33 #include "base/android/jni_android.h" |
| 34 #include "base/android/jni_string.h" |
| 35 #include "base/basictypes.h" |
| 36 #include "base/logging.h" |
| 37 #include "webkit/media/android/webaudio_assets_impl_android.h" |
| 38 |
| 39 using base::android::AttachCurrentThread; |
| 40 using base::android::GetApplicationContext; |
| 41 using base::android::CheckException; |
| 42 using base::android::ClearException; |
| 43 using base::android::GetClass; |
| 44 using base::android::JavaRef; |
| 45 using base::android::MethodID; |
| 46 using base::android::ScopedJavaLocalRef; |
| 47 |
| 48 static const char* gWebAudioResourceFiles[] = |
| 49 { |
| 50 "webkit/webaudio/IRC_Composite_C_R0195_T000_P000.wav", |
| 51 "webkit/webaudio/IRC_Composite_C_R0195_T000_P015.wav", |
| 52 "webkit/webaudio/IRC_Composite_C_R0195_T000_P030.wav", |
| 53 "webkit/webaudio/IRC_Composite_C_R0195_T000_P045.wav", |
| 54 "webkit/webaudio/IRC_Composite_C_R0195_T000_P060.wav", |
| 55 "webkit/webaudio/IRC_Composite_C_R0195_T000_P075.wav", |
| 56 "webkit/webaudio/IRC_Composite_C_R0195_T000_P090.wav", |
| 57 "webkit/webaudio/IRC_Composite_C_R0195_T000_P315.wav", |
| 58 "webkit/webaudio/IRC_Composite_C_R0195_T000_P330.wav", |
| 59 "webkit/webaudio/IRC_Composite_C_R0195_T000_P345.wav", |
| 60 "webkit/webaudio/IRC_Composite_C_R0195_T015_P000.wav", |
| 61 "webkit/webaudio/IRC_Composite_C_R0195_T015_P015.wav", |
| 62 "webkit/webaudio/IRC_Composite_C_R0195_T015_P030.wav", |
| 63 "webkit/webaudio/IRC_Composite_C_R0195_T015_P045.wav", |
| 64 "webkit/webaudio/IRC_Composite_C_R0195_T015_P060.wav", |
| 65 "webkit/webaudio/IRC_Composite_C_R0195_T015_P075.wav", |
| 66 "webkit/webaudio/IRC_Composite_C_R0195_T015_P090.wav", |
| 67 "webkit/webaudio/IRC_Composite_C_R0195_T015_P315.wav", |
| 68 "webkit/webaudio/IRC_Composite_C_R0195_T015_P330.wav", |
| 69 "webkit/webaudio/IRC_Composite_C_R0195_T015_P345.wav", |
| 70 "webkit/webaudio/IRC_Composite_C_R0195_T030_P000.wav", |
| 71 "webkit/webaudio/IRC_Composite_C_R0195_T030_P015.wav", |
| 72 "webkit/webaudio/IRC_Composite_C_R0195_T030_P030.wav", |
| 73 "webkit/webaudio/IRC_Composite_C_R0195_T030_P045.wav", |
| 74 "webkit/webaudio/IRC_Composite_C_R0195_T030_P060.wav", |
| 75 "webkit/webaudio/IRC_Composite_C_R0195_T030_P075.wav", |
| 76 "webkit/webaudio/IRC_Composite_C_R0195_T030_P090.wav", |
| 77 "webkit/webaudio/IRC_Composite_C_R0195_T030_P315.wav", |
| 78 "webkit/webaudio/IRC_Composite_C_R0195_T030_P330.wav", |
| 79 "webkit/webaudio/IRC_Composite_C_R0195_T030_P345.wav", |
| 80 "webkit/webaudio/IRC_Composite_C_R0195_T045_P000.wav", |
| 81 "webkit/webaudio/IRC_Composite_C_R0195_T045_P015.wav", |
| 82 "webkit/webaudio/IRC_Composite_C_R0195_T045_P030.wav", |
| 83 "webkit/webaudio/IRC_Composite_C_R0195_T045_P045.wav", |
| 84 "webkit/webaudio/IRC_Composite_C_R0195_T045_P060.wav", |
| 85 "webkit/webaudio/IRC_Composite_C_R0195_T045_P075.wav", |
| 86 "webkit/webaudio/IRC_Composite_C_R0195_T045_P090.wav", |
| 87 "webkit/webaudio/IRC_Composite_C_R0195_T045_P315.wav", |
| 88 "webkit/webaudio/IRC_Composite_C_R0195_T045_P330.wav", |
| 89 "webkit/webaudio/IRC_Composite_C_R0195_T045_P345.wav", |
| 90 "webkit/webaudio/IRC_Composite_C_R0195_T060_P000.wav", |
| 91 "webkit/webaudio/IRC_Composite_C_R0195_T060_P015.wav", |
| 92 "webkit/webaudio/IRC_Composite_C_R0195_T060_P030.wav", |
| 93 "webkit/webaudio/IRC_Composite_C_R0195_T060_P045.wav", |
| 94 "webkit/webaudio/IRC_Composite_C_R0195_T060_P060.wav", |
| 95 "webkit/webaudio/IRC_Composite_C_R0195_T060_P075.wav", |
| 96 "webkit/webaudio/IRC_Composite_C_R0195_T060_P090.wav", |
| 97 "webkit/webaudio/IRC_Composite_C_R0195_T060_P315.wav", |
| 98 "webkit/webaudio/IRC_Composite_C_R0195_T060_P330.wav", |
| 99 "webkit/webaudio/IRC_Composite_C_R0195_T060_P345.wav", |
| 100 "webkit/webaudio/IRC_Composite_C_R0195_T075_P000.wav", |
| 101 "webkit/webaudio/IRC_Composite_C_R0195_T075_P015.wav", |
| 102 "webkit/webaudio/IRC_Composite_C_R0195_T075_P030.wav", |
| 103 "webkit/webaudio/IRC_Composite_C_R0195_T075_P045.wav", |
| 104 "webkit/webaudio/IRC_Composite_C_R0195_T075_P060.wav", |
| 105 "webkit/webaudio/IRC_Composite_C_R0195_T075_P075.wav", |
| 106 "webkit/webaudio/IRC_Composite_C_R0195_T075_P090.wav", |
| 107 "webkit/webaudio/IRC_Composite_C_R0195_T075_P315.wav", |
| 108 "webkit/webaudio/IRC_Composite_C_R0195_T075_P330.wav", |
| 109 "webkit/webaudio/IRC_Composite_C_R0195_T075_P345.wav", |
| 110 "webkit/webaudio/IRC_Composite_C_R0195_T090_P000.wav", |
| 111 "webkit/webaudio/IRC_Composite_C_R0195_T090_P015.wav", |
| 112 "webkit/webaudio/IRC_Composite_C_R0195_T090_P030.wav", |
| 113 "webkit/webaudio/IRC_Composite_C_R0195_T090_P045.wav", |
| 114 "webkit/webaudio/IRC_Composite_C_R0195_T090_P060.wav", |
| 115 "webkit/webaudio/IRC_Composite_C_R0195_T090_P075.wav", |
| 116 "webkit/webaudio/IRC_Composite_C_R0195_T090_P090.wav", |
| 117 "webkit/webaudio/IRC_Composite_C_R0195_T090_P315.wav", |
| 118 "webkit/webaudio/IRC_Composite_C_R0195_T090_P330.wav", |
| 119 "webkit/webaudio/IRC_Composite_C_R0195_T090_P345.wav", |
| 120 "webkit/webaudio/IRC_Composite_C_R0195_T105_P000.wav", |
| 121 "webkit/webaudio/IRC_Composite_C_R0195_T105_P015.wav", |
| 122 "webkit/webaudio/IRC_Composite_C_R0195_T105_P030.wav", |
| 123 "webkit/webaudio/IRC_Composite_C_R0195_T105_P045.wav", |
| 124 "webkit/webaudio/IRC_Composite_C_R0195_T105_P060.wav", |
| 125 "webkit/webaudio/IRC_Composite_C_R0195_T105_P075.wav", |
| 126 "webkit/webaudio/IRC_Composite_C_R0195_T105_P090.wav", |
| 127 "webkit/webaudio/IRC_Composite_C_R0195_T105_P315.wav", |
| 128 "webkit/webaudio/IRC_Composite_C_R0195_T105_P330.wav", |
| 129 "webkit/webaudio/IRC_Composite_C_R0195_T105_P345.wav", |
| 130 "webkit/webaudio/IRC_Composite_C_R0195_T120_P000.wav", |
| 131 "webkit/webaudio/IRC_Composite_C_R0195_T120_P015.wav", |
| 132 "webkit/webaudio/IRC_Composite_C_R0195_T120_P030.wav", |
| 133 "webkit/webaudio/IRC_Composite_C_R0195_T120_P045.wav", |
| 134 "webkit/webaudio/IRC_Composite_C_R0195_T120_P060.wav", |
| 135 "webkit/webaudio/IRC_Composite_C_R0195_T120_P075.wav", |
| 136 "webkit/webaudio/IRC_Composite_C_R0195_T120_P090.wav", |
| 137 "webkit/webaudio/IRC_Composite_C_R0195_T120_P315.wav", |
| 138 "webkit/webaudio/IRC_Composite_C_R0195_T120_P330.wav", |
| 139 "webkit/webaudio/IRC_Composite_C_R0195_T120_P345.wav", |
| 140 "webkit/webaudio/IRC_Composite_C_R0195_T135_P000.wav", |
| 141 "webkit/webaudio/IRC_Composite_C_R0195_T135_P015.wav", |
| 142 "webkit/webaudio/IRC_Composite_C_R0195_T135_P030.wav", |
| 143 "webkit/webaudio/IRC_Composite_C_R0195_T135_P045.wav", |
| 144 "webkit/webaudio/IRC_Composite_C_R0195_T135_P060.wav", |
| 145 "webkit/webaudio/IRC_Composite_C_R0195_T135_P075.wav", |
| 146 "webkit/webaudio/IRC_Composite_C_R0195_T135_P090.wav", |
| 147 "webkit/webaudio/IRC_Composite_C_R0195_T135_P315.wav", |
| 148 "webkit/webaudio/IRC_Composite_C_R0195_T135_P330.wav", |
| 149 "webkit/webaudio/IRC_Composite_C_R0195_T135_P345.wav", |
| 150 "webkit/webaudio/IRC_Composite_C_R0195_T150_P000.wav", |
| 151 "webkit/webaudio/IRC_Composite_C_R0195_T150_P015.wav", |
| 152 "webkit/webaudio/IRC_Composite_C_R0195_T150_P030.wav", |
| 153 "webkit/webaudio/IRC_Composite_C_R0195_T150_P045.wav", |
| 154 "webkit/webaudio/IRC_Composite_C_R0195_T150_P060.wav", |
| 155 "webkit/webaudio/IRC_Composite_C_R0195_T150_P075.wav", |
| 156 "webkit/webaudio/IRC_Composite_C_R0195_T150_P090.wav", |
| 157 "webkit/webaudio/IRC_Composite_C_R0195_T150_P315.wav", |
| 158 "webkit/webaudio/IRC_Composite_C_R0195_T150_P330.wav", |
| 159 "webkit/webaudio/IRC_Composite_C_R0195_T150_P345.wav", |
| 160 "webkit/webaudio/IRC_Composite_C_R0195_T165_P000.wav", |
| 161 "webkit/webaudio/IRC_Composite_C_R0195_T165_P015.wav", |
| 162 "webkit/webaudio/IRC_Composite_C_R0195_T165_P030.wav", |
| 163 "webkit/webaudio/IRC_Composite_C_R0195_T165_P045.wav", |
| 164 "webkit/webaudio/IRC_Composite_C_R0195_T165_P060.wav", |
| 165 "webkit/webaudio/IRC_Composite_C_R0195_T165_P075.wav", |
| 166 "webkit/webaudio/IRC_Composite_C_R0195_T165_P090.wav", |
| 167 "webkit/webaudio/IRC_Composite_C_R0195_T165_P315.wav", |
| 168 "webkit/webaudio/IRC_Composite_C_R0195_T165_P330.wav", |
| 169 "webkit/webaudio/IRC_Composite_C_R0195_T165_P345.wav", |
| 170 "webkit/webaudio/IRC_Composite_C_R0195_T180_P000.wav", |
| 171 "webkit/webaudio/IRC_Composite_C_R0195_T180_P015.wav", |
| 172 "webkit/webaudio/IRC_Composite_C_R0195_T180_P030.wav", |
| 173 "webkit/webaudio/IRC_Composite_C_R0195_T180_P045.wav", |
| 174 "webkit/webaudio/IRC_Composite_C_R0195_T180_P060.wav", |
| 175 "webkit/webaudio/IRC_Composite_C_R0195_T180_P075.wav", |
| 176 "webkit/webaudio/IRC_Composite_C_R0195_T180_P090.wav", |
| 177 "webkit/webaudio/IRC_Composite_C_R0195_T180_P315.wav", |
| 178 "webkit/webaudio/IRC_Composite_C_R0195_T180_P330.wav", |
| 179 "webkit/webaudio/IRC_Composite_C_R0195_T180_P345.wav", |
| 180 "webkit/webaudio/IRC_Composite_C_R0195_T195_P000.wav", |
| 181 "webkit/webaudio/IRC_Composite_C_R0195_T195_P015.wav", |
| 182 "webkit/webaudio/IRC_Composite_C_R0195_T195_P030.wav", |
| 183 "webkit/webaudio/IRC_Composite_C_R0195_T195_P045.wav", |
| 184 "webkit/webaudio/IRC_Composite_C_R0195_T195_P060.wav", |
| 185 "webkit/webaudio/IRC_Composite_C_R0195_T195_P075.wav", |
| 186 "webkit/webaudio/IRC_Composite_C_R0195_T195_P090.wav", |
| 187 "webkit/webaudio/IRC_Composite_C_R0195_T195_P315.wav", |
| 188 "webkit/webaudio/IRC_Composite_C_R0195_T195_P330.wav", |
| 189 "webkit/webaudio/IRC_Composite_C_R0195_T195_P345.wav", |
| 190 "webkit/webaudio/IRC_Composite_C_R0195_T210_P000.wav", |
| 191 "webkit/webaudio/IRC_Composite_C_R0195_T210_P015.wav", |
| 192 "webkit/webaudio/IRC_Composite_C_R0195_T210_P030.wav", |
| 193 "webkit/webaudio/IRC_Composite_C_R0195_T210_P045.wav", |
| 194 "webkit/webaudio/IRC_Composite_C_R0195_T210_P060.wav", |
| 195 "webkit/webaudio/IRC_Composite_C_R0195_T210_P075.wav", |
| 196 "webkit/webaudio/IRC_Composite_C_R0195_T210_P090.wav", |
| 197 "webkit/webaudio/IRC_Composite_C_R0195_T210_P315.wav", |
| 198 "webkit/webaudio/IRC_Composite_C_R0195_T210_P330.wav", |
| 199 "webkit/webaudio/IRC_Composite_C_R0195_T210_P345.wav", |
| 200 "webkit/webaudio/IRC_Composite_C_R0195_T225_P000.wav", |
| 201 "webkit/webaudio/IRC_Composite_C_R0195_T225_P015.wav", |
| 202 "webkit/webaudio/IRC_Composite_C_R0195_T225_P030.wav", |
| 203 "webkit/webaudio/IRC_Composite_C_R0195_T225_P045.wav", |
| 204 "webkit/webaudio/IRC_Composite_C_R0195_T225_P060.wav", |
| 205 "webkit/webaudio/IRC_Composite_C_R0195_T225_P075.wav", |
| 206 "webkit/webaudio/IRC_Composite_C_R0195_T225_P090.wav", |
| 207 "webkit/webaudio/IRC_Composite_C_R0195_T225_P315.wav", |
| 208 "webkit/webaudio/IRC_Composite_C_R0195_T225_P330.wav", |
| 209 "webkit/webaudio/IRC_Composite_C_R0195_T225_P345.wav", |
| 210 "webkit/webaudio/IRC_Composite_C_R0195_T240_P000.wav", |
| 211 "webkit/webaudio/IRC_Composite_C_R0195_T240_P015.wav", |
| 212 "webkit/webaudio/IRC_Composite_C_R0195_T240_P030.wav", |
| 213 "webkit/webaudio/IRC_Composite_C_R0195_T240_P045.wav", |
| 214 "webkit/webaudio/IRC_Composite_C_R0195_T240_P060.wav", |
| 215 "webkit/webaudio/IRC_Composite_C_R0195_T240_P075.wav", |
| 216 "webkit/webaudio/IRC_Composite_C_R0195_T240_P090.wav", |
| 217 "webkit/webaudio/IRC_Composite_C_R0195_T240_P315.wav", |
| 218 "webkit/webaudio/IRC_Composite_C_R0195_T240_P330.wav", |
| 219 "webkit/webaudio/IRC_Composite_C_R0195_T240_P345.wav", |
| 220 "webkit/webaudio/IRC_Composite_C_R0195_T255_P000.wav", |
| 221 "webkit/webaudio/IRC_Composite_C_R0195_T255_P015.wav", |
| 222 "webkit/webaudio/IRC_Composite_C_R0195_T255_P030.wav", |
| 223 "webkit/webaudio/IRC_Composite_C_R0195_T255_P045.wav", |
| 224 "webkit/webaudio/IRC_Composite_C_R0195_T255_P060.wav", |
| 225 "webkit/webaudio/IRC_Composite_C_R0195_T255_P075.wav", |
| 226 "webkit/webaudio/IRC_Composite_C_R0195_T255_P090.wav", |
| 227 "webkit/webaudio/IRC_Composite_C_R0195_T255_P315.wav", |
| 228 "webkit/webaudio/IRC_Composite_C_R0195_T255_P330.wav", |
| 229 "webkit/webaudio/IRC_Composite_C_R0195_T255_P345.wav", |
| 230 "webkit/webaudio/IRC_Composite_C_R0195_T270_P000.wav", |
| 231 "webkit/webaudio/IRC_Composite_C_R0195_T270_P015.wav", |
| 232 "webkit/webaudio/IRC_Composite_C_R0195_T270_P030.wav", |
| 233 "webkit/webaudio/IRC_Composite_C_R0195_T270_P045.wav", |
| 234 "webkit/webaudio/IRC_Composite_C_R0195_T270_P060.wav", |
| 235 "webkit/webaudio/IRC_Composite_C_R0195_T270_P075.wav", |
| 236 "webkit/webaudio/IRC_Composite_C_R0195_T270_P090.wav", |
| 237 "webkit/webaudio/IRC_Composite_C_R0195_T270_P315.wav", |
| 238 "webkit/webaudio/IRC_Composite_C_R0195_T270_P330.wav", |
| 239 "webkit/webaudio/IRC_Composite_C_R0195_T270_P345.wav", |
| 240 "webkit/webaudio/IRC_Composite_C_R0195_T285_P000.wav", |
| 241 "webkit/webaudio/IRC_Composite_C_R0195_T285_P015.wav", |
| 242 "webkit/webaudio/IRC_Composite_C_R0195_T285_P030.wav", |
| 243 "webkit/webaudio/IRC_Composite_C_R0195_T285_P045.wav", |
| 244 "webkit/webaudio/IRC_Composite_C_R0195_T285_P060.wav", |
| 245 "webkit/webaudio/IRC_Composite_C_R0195_T285_P075.wav", |
| 246 "webkit/webaudio/IRC_Composite_C_R0195_T285_P090.wav", |
| 247 "webkit/webaudio/IRC_Composite_C_R0195_T285_P315.wav", |
| 248 "webkit/webaudio/IRC_Composite_C_R0195_T285_P330.wav", |
| 249 "webkit/webaudio/IRC_Composite_C_R0195_T285_P345.wav", |
| 250 "webkit/webaudio/IRC_Composite_C_R0195_T300_P000.wav", |
| 251 "webkit/webaudio/IRC_Composite_C_R0195_T300_P015.wav", |
| 252 "webkit/webaudio/IRC_Composite_C_R0195_T300_P030.wav", |
| 253 "webkit/webaudio/IRC_Composite_C_R0195_T300_P045.wav", |
| 254 "webkit/webaudio/IRC_Composite_C_R0195_T300_P060.wav", |
| 255 "webkit/webaudio/IRC_Composite_C_R0195_T300_P075.wav", |
| 256 "webkit/webaudio/IRC_Composite_C_R0195_T300_P090.wav", |
| 257 "webkit/webaudio/IRC_Composite_C_R0195_T300_P315.wav", |
| 258 "webkit/webaudio/IRC_Composite_C_R0195_T300_P330.wav", |
| 259 "webkit/webaudio/IRC_Composite_C_R0195_T300_P345.wav", |
| 260 "webkit/webaudio/IRC_Composite_C_R0195_T315_P000.wav", |
| 261 "webkit/webaudio/IRC_Composite_C_R0195_T315_P015.wav", |
| 262 "webkit/webaudio/IRC_Composite_C_R0195_T315_P030.wav", |
| 263 "webkit/webaudio/IRC_Composite_C_R0195_T315_P045.wav", |
| 264 "webkit/webaudio/IRC_Composite_C_R0195_T315_P060.wav", |
| 265 "webkit/webaudio/IRC_Composite_C_R0195_T315_P075.wav", |
| 266 "webkit/webaudio/IRC_Composite_C_R0195_T315_P090.wav", |
| 267 "webkit/webaudio/IRC_Composite_C_R0195_T315_P315.wav", |
| 268 "webkit/webaudio/IRC_Composite_C_R0195_T315_P330.wav", |
| 269 "webkit/webaudio/IRC_Composite_C_R0195_T315_P345.wav", |
| 270 "webkit/webaudio/IRC_Composite_C_R0195_T330_P000.wav", |
| 271 "webkit/webaudio/IRC_Composite_C_R0195_T330_P015.wav", |
| 272 "webkit/webaudio/IRC_Composite_C_R0195_T330_P030.wav", |
| 273 "webkit/webaudio/IRC_Composite_C_R0195_T330_P045.wav", |
| 274 "webkit/webaudio/IRC_Composite_C_R0195_T330_P060.wav", |
| 275 "webkit/webaudio/IRC_Composite_C_R0195_T330_P075.wav", |
| 276 "webkit/webaudio/IRC_Composite_C_R0195_T330_P090.wav", |
| 277 "webkit/webaudio/IRC_Composite_C_R0195_T330_P315.wav", |
| 278 "webkit/webaudio/IRC_Composite_C_R0195_T330_P330.wav", |
| 279 "webkit/webaudio/IRC_Composite_C_R0195_T330_P345.wav", |
| 280 "webkit/webaudio/IRC_Composite_C_R0195_T345_P000.wav", |
| 281 "webkit/webaudio/IRC_Composite_C_R0195_T345_P015.wav", |
| 282 "webkit/webaudio/IRC_Composite_C_R0195_T345_P030.wav", |
| 283 "webkit/webaudio/IRC_Composite_C_R0195_T345_P045.wav", |
| 284 "webkit/webaudio/IRC_Composite_C_R0195_T345_P060.wav", |
| 285 "webkit/webaudio/IRC_Composite_C_R0195_T345_P075.wav", |
| 286 "webkit/webaudio/IRC_Composite_C_R0195_T345_P090.wav", |
| 287 "webkit/webaudio/IRC_Composite_C_R0195_T345_P315.wav", |
| 288 "webkit/webaudio/IRC_Composite_C_R0195_T345_P330.wav", |
| 289 "webkit/webaudio/IRC_Composite_C_R0195_T345_P345.wav" |
| 290 }; |
| 291 |
| 292 |
| 293 namespace webkit_media { |
| 294 |
| 295 static const size_t kExpectedSpatializationNameLength = 31; |
| 296 |
| 297 // The resource index values go through the elevations first, then azimuths. |
| 298 static const int kAngleSpacing = 15; |
| 299 |
| 300 static const int kNumberOfElevations = 10; |
| 301 static const int kNumberOfAudioResources = 240; |
| 302 static const int kIDRAudioSpatializationT000P000 = 0; |
| 303 |
| 304 const char* webAudioAssetFileName(const char* name) |
| 305 { |
| 306 LOG(INFO) << "webAudioAssetFileName : name: " << name; |
| 307 |
| 308 if (strlen(name) != kExpectedSpatializationNameLength) { |
| 309 LOG(ERROR) << "webAudioAssetFileName : invalid name length"; |
| 310 return 0; |
| 311 } |
| 312 |
| 313 // Extract the azimuth and elevation from the resource name. |
| 314 int azimuth = 0; |
| 315 int elevation = 0; |
| 316 int values_parsed = sscanf(name, "IRC_Composite_C_R0195_T%3d_P%3d", &azimuth,
&elevation); |
| 317 if (values_parsed != 2) { |
| 318 LOG(ERROR) << "webAudioAssetFileName : parse error - values_parsed" << value
s_parsed; |
| 319 return 0; |
| 320 } |
| 321 |
| 322 // 0 <= elevation <= 90 (or 315 <= elevation <= 345) |
| 323 // in increments of 15 degrees. |
| 324 int elevation_index = elevation <= 90 ? elevation / kAngleSpacing : 7 + (elev
ation - 315) / kAngleSpacing; |
| 325 bool is_elevation_index_good = 0 <= elevation_index && elevation_index < 10; |
| 326 |
| 327 // 0 <= azimuth < 360 in increments of 15 degrees. |
| 328 int azimuth_index = azimuth / kAngleSpacing; |
| 329 bool is_azimuth_index_good = (0 <= azimuth_index) && (azimuth_index < 24); |
| 330 |
| 331 int resource_index = kNumberOfElevations * azimuth_index + elevation_index; |
| 332 bool is_resource_index_good = (0 <= resource_index) && (resource_index < kNumb
erOfAudioResources); |
| 333 |
| 334 if (is_azimuth_index_good && is_elevation_index_good && is_resource_index_good
) |
| 335 return gWebAudioResourceFiles[kIDRAudioSpatializationT000P000 + resource_ind
ex]; |
| 336 |
| 337 LOG(ERROR) << "webAudioAssetFileName : parse error - azimuth_index: "<< azimut
h_index |
| 338 << ", elevation_index: "<< elevation_index |
| 339 << ", resource_index: "<< resource_index; |
| 340 |
| 341 return 0; |
| 342 } |
| 343 |
| 344 |
| 345 bool webAudioAsset(const char* data,int* fd_asset,long* start_offset,long* size
) |
| 346 { |
| 347 |
| 348 DCHECK(data); |
| 349 |
| 350 JNIEnv* env = AttachCurrentThread(); |
| 351 CHECK(env); |
| 352 |
| 353 // Get the context class. |
| 354 ScopedJavaLocalRef<jclass> context_class( |
| 355 GetClass(env, "android/content/Context")); |
| 356 |
| 357 jobject j_context = GetApplicationContext(); |
| 358 DCHECK(j_context); |
| 359 |
| 360 // Get the getAssets method |
| 361 jmethodID get_assets = MethodID::Get<MethodID::TYPE_INSTANCE>( |
| 362 env, context_class.obj(), |
| 363 "getAssets", |
| 364 "()Landroid/content/res/AssetManager;"); |
| 365 |
| 366 ScopedJavaLocalRef<jobject> assetMgr(env, env->CallObjectMethod(j_context,get_
assets)); |
| 367 DCHECK(!assetMgr.is_null()); |
| 368 |
| 369 AAssetManager* mgr = AAssetManager_fromJava(env, assetMgr.obj()); |
| 370 |
| 371 ClearException(env); |
| 372 |
| 373 if (mgr != NULL) { |
| 374 AAsset* asset = AAssetManager_open(mgr, data, AASSET_MODE_UNKNOWN); |
| 375 if (asset == NULL) { |
| 376 LOG(ERROR) << "webAudioAsset: Asset not found: " << data; |
| 377 return false; |
| 378 } |
| 379 |
| 380 off_t start, length; |
| 381 int fd = AAsset_openFileDescriptor(asset, &start, &length); |
| 382 DCHECK(0 <= fd); |
| 383 AAsset_close(asset); |
| 384 |
| 385 *fd_asset = fd; |
| 386 *start_offset = start; |
| 387 *size = length; |
| 388 |
| 389 return true; |
| 390 } |
| 391 |
| 392 LOG(ERROR) << "webAudioAsset: No Java object"; |
| 393 return false; |
| 394 } |
| 395 |
| 396 } // namespace webkit_media |
OLD | NEW |