this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

CoreAudio: Add and build auplay, auinfo, aurecord and auconvert (although they probably don't work yet)

+12961 -1
+3640
src/CoreAudio/AudioFileTools/AudioFileTools.xcodeproj/project.pbxproj
··· 1 + // !$*UTF8*$! 2 + { 3 + archiveVersion = 1; 4 + classes = { 5 + }; 6 + objectVersion = 42; 7 + objects = { 8 + 9 + /* Begin PBXAggregateTarget section */ 10 + 91C82D4C05CFF8B20042A20D = { 11 + isa = PBXAggregateTarget; 12 + buildConfigurationList = A9E883AB0874A59B00B2DFE8; 13 + buildPhases = ( 14 + ); 15 + buildSettings = { 16 + OTHER_CFLAGS = ""; 17 + OTHER_LDFLAGS = ""; 18 + OTHER_REZFLAGS = ""; 19 + PRODUCT_NAME = All; 20 + SECTORDER_FLAGS = ""; 21 + WARNING_CFLAGS = ( 22 + "-Wmost", 23 + "-Wno-four-char-constants", 24 + "-Wno-unknown-pragmas", 25 + ); 26 + }; 27 + dependencies = ( 28 + 91C82E0605CFF8B30042A20D, 29 + 91C82E0805CFF8B30042A20D, 30 + 91C82E0A05CFF8B30042A20D, 31 + 91C82E0C05CFF8B30042A20D, 32 + 91004357066E8609005A1EC3, 33 + A9E885A40874B31900B2DFE8, 34 + 915912E908F7230600A78EF3, 35 + ); 36 + name = All; 37 + productName = All; 38 + }; 39 + /* End PBXAggregateTarget section */ 40 + 41 + /* Begin PBXBuildFile section */ 42 + 910D345109057CCE00A0EDE6 = { 43 + isa = PBXBuildFile; 44 + fileRef = 91B0CA2406640DFD00B57457; 45 + }; 46 + 910D345209057CCE00A0EDE6 = { 47 + isa = PBXBuildFile; 48 + fileRef = 91B0CA2506640DFD00B57457; 49 + }; 50 + 910D345309057CD300A0EDE6 = { 51 + isa = PBXBuildFile; 52 + fileRef = 91B0CA2406640DFD00B57457; 53 + }; 54 + 910D345409057CD400A0EDE6 = { 55 + isa = PBXBuildFile; 56 + fileRef = 91B0CA2506640DFD00B57457; 57 + }; 58 + 9137C6020655A6EB00A1A3A2 = { 59 + isa = PBXBuildFile; 60 + fileRef = 9137C6000655A6EB00A1A3A2; 61 + }; 62 + 9137C6030655A6EB00A1A3A2 = { 63 + isa = PBXBuildFile; 64 + fileRef = 9137C6010655A6EB00A1A3A2; 65 + }; 66 + 9137C6040655A74F00A1A3A2 = { 67 + isa = PBXBuildFile; 68 + fileRef = B6D5206705B38F280077A2BA; 69 + }; 70 + 9137C6050655A75000A1A3A2 = { 71 + isa = PBXBuildFile; 72 + fileRef = B6D5206805B38F280077A2BA; 73 + }; 74 + 9137C6220655A76F00A1A3A2 = { 75 + isa = PBXBuildFile; 76 + fileRef = 9137C6200655A76F00A1A3A2; 77 + }; 78 + 9137C6230655A76F00A1A3A2 = { 79 + isa = PBXBuildFile; 80 + fileRef = 9137C6210655A76F00A1A3A2; 81 + }; 82 + 9138521207138D8100E6E381 = { 83 + isa = PBXBuildFile; 84 + fileRef = 9138521007138D8100E6E381; 85 + }; 86 + 9138521307138D8100E6E381 = { 87 + isa = PBXBuildFile; 88 + fileRef = 9138521107138D8100E6E381; 89 + }; 90 + 9143EEB606876B9300CA9919 = { 91 + isa = PBXBuildFile; 92 + fileRef = 9143EEB406876B9300CA9919; 93 + }; 94 + 9143EEB706876B9300CA9919 = { 95 + isa = PBXBuildFile; 96 + fileRef = 9143EEB506876B9300CA9919; 97 + }; 98 + 9143EEEC06876BAA00CA9919 = { 99 + isa = PBXBuildFile; 100 + fileRef = 9143EEEB06876BAA00CA9919; 101 + }; 102 + 9186C79B072033F000D7CA7A = { 103 + isa = PBXBuildFile; 104 + fileRef = 9186C799072033F000D7CA7A; 105 + }; 106 + 9186C79C072033F000D7CA7A = { 107 + isa = PBXBuildFile; 108 + fileRef = 9186C79A072033F000D7CA7A; 109 + }; 110 + 9186C79D0720343600D7CA7A = { 111 + isa = PBXBuildFile; 112 + fileRef = 9186C79A072033F000D7CA7A; 113 + }; 114 + 9186C79E0720343700D7CA7A = { 115 + isa = PBXBuildFile; 116 + fileRef = 9186C799072033F000D7CA7A; 117 + }; 118 + 9186C79F0720358400D7CA7A = { 119 + isa = PBXBuildFile; 120 + fileRef = 9186C79A072033F000D7CA7A; 121 + }; 122 + 9186C7A00720358500D7CA7A = { 123 + isa = PBXBuildFile; 124 + fileRef = 9186C799072033F000D7CA7A; 125 + }; 126 + 9186C7B30720363600D7CA7A = { 127 + isa = PBXBuildFile; 128 + fileRef = 9138521007138D8100E6E381; 129 + }; 130 + 9186C7B40720363700D7CA7A = { 131 + isa = PBXBuildFile; 132 + fileRef = 9138521107138D8100E6E381; 133 + }; 134 + 9186C7B90720365900D7CA7A = { 135 + isa = PBXBuildFile; 136 + fileRef = 9138521007138D8100E6E381; 137 + }; 138 + 9186C7BA0720365A00D7CA7A = { 139 + isa = PBXBuildFile; 140 + fileRef = 9138521107138D8100E6E381; 141 + }; 142 + 9186C7BC0720368B00D7CA7A = { 143 + isa = PBXBuildFile; 144 + fileRef = 9138521007138D8100E6E381; 145 + }; 146 + 9186C7BD0720368B00D7CA7A = { 147 + isa = PBXBuildFile; 148 + fileRef = 9138521107138D8100E6E381; 149 + }; 150 + 9186C7C70720378800D7CA7A = { 151 + isa = PBXBuildFile; 152 + fileRef = 9186C79A072033F000D7CA7A; 153 + }; 154 + 9186C7C80720378800D7CA7A = { 155 + isa = PBXBuildFile; 156 + fileRef = 9186C799072033F000D7CA7A; 157 + }; 158 + 9186C7C90720378D00D7CA7A = { 159 + isa = PBXBuildFile; 160 + fileRef = 9138521007138D8100E6E381; 161 + }; 162 + 9186C7CA0720378E00D7CA7A = { 163 + isa = PBXBuildFile; 164 + fileRef = 9138521107138D8100E6E381; 165 + }; 166 + 91AFB5E6071C988A004D7421 = { 167 + isa = PBXBuildFile; 168 + fileRef = 91AFB5E0071C95CF004D7421; 169 + }; 170 + 91AFB5E7071C988C004D7421 = { 171 + isa = PBXBuildFile; 172 + fileRef = 91AFB5DF071C95CF004D7421; 173 + }; 174 + 91AFB5E8071C9892004D7421 = { 175 + isa = PBXBuildFile; 176 + fileRef = 91AFB5E0071C95CF004D7421; 177 + }; 178 + 91AFB5E9071C9893004D7421 = { 179 + isa = PBXBuildFile; 180 + fileRef = 91AFB5DF071C95CF004D7421; 181 + }; 182 + 91AFB72F071CB5EF004D7421 = { 183 + isa = PBXBuildFile; 184 + fileRef = 91AFB5E0071C95CF004D7421; 185 + }; 186 + 91AFB730071CB5F0004D7421 = { 187 + isa = PBXBuildFile; 188 + fileRef = 91AFB5DF071C95CF004D7421; 189 + }; 190 + 91B0CA2606640DFD00B57457 = { 191 + isa = PBXBuildFile; 192 + fileRef = 91B0CA2406640DFD00B57457; 193 + }; 194 + 91B0CA2706640DFD00B57457 = { 195 + isa = PBXBuildFile; 196 + fileRef = 91B0CA2506640DFD00B57457; 197 + }; 198 + 91B0CAC206641DEB00B57457 = { 199 + isa = PBXBuildFile; 200 + fileRef = 91B0CA2406640DFD00B57457; 201 + }; 202 + 91B0CAC306641DEB00B57457 = { 203 + isa = PBXBuildFile; 204 + fileRef = 91B0CA2506640DFD00B57457; 205 + }; 206 + 91B0CAC406641E2500B57457 = { 207 + isa = PBXBuildFile; 208 + fileRef = 91B0CA2506640DFD00B57457; 209 + }; 210 + 91C82D5505CFF8B20042A20D = { 211 + isa = PBXBuildFile; 212 + fileRef = B6D5203A05B38D870077A2BA; 213 + }; 214 + 91C82D5705CFF8B20042A20D = { 215 + isa = PBXBuildFile; 216 + fileRef = B6D5204B05B38E2F0077A2BA; 217 + }; 218 + 91C82D5805CFF8B20042A20D = { 219 + isa = PBXBuildFile; 220 + fileRef = B6D5205505B38E750077A2BA; 221 + }; 222 + 91C82D5A05CFF8B20042A20D = { 223 + isa = PBXBuildFile; 224 + fileRef = B6D5206405B38F100077A2BA; 225 + }; 226 + 91C82D5B05CFF8B20042A20D = { 227 + isa = PBXBuildFile; 228 + fileRef = B6D5206805B38F280077A2BA; 229 + }; 230 + 91C82D5C05CFF8B20042A20D = { 231 + isa = PBXBuildFile; 232 + fileRef = B6D5206C05B38F3A0077A2BA; 233 + }; 234 + 91C82D5D05CFF8B20042A20D = { 235 + isa = PBXBuildFile; 236 + fileRef = B6D5207305B38F4E0077A2BA; 237 + }; 238 + 91C82D5F05CFF8B20042A20D = { 239 + isa = PBXBuildFile; 240 + fileRef = B6D5203705B38D750077A2BA; 241 + }; 242 + 91C82D6005CFF8B20042A20D = { 243 + isa = PBXBuildFile; 244 + fileRef = B6D5203905B38D870077A2BA; 245 + }; 246 + 91C82D6205CFF8B20042A20D = { 247 + isa = PBXBuildFile; 248 + fileRef = B6D5204A05B38E2F0077A2BA; 249 + }; 250 + 91C82D6305CFF8B20042A20D = { 251 + isa = PBXBuildFile; 252 + fileRef = B6D5205405B38E750077A2BA; 253 + }; 254 + 91C82D6505CFF8B20042A20D = { 255 + isa = PBXBuildFile; 256 + fileRef = B6D5206305B38F100077A2BA; 257 + }; 258 + 91C82D6605CFF8B20042A20D = { 259 + isa = PBXBuildFile; 260 + fileRef = B6D5206705B38F280077A2BA; 261 + }; 262 + 91C82D6705CFF8B20042A20D = { 263 + isa = PBXBuildFile; 264 + fileRef = B6D5206B05B38F3A0077A2BA; 265 + }; 266 + 91C82D6805CFF8B20042A20D = { 267 + isa = PBXBuildFile; 268 + fileRef = B6D5206D05B38F3A0077A2BA; 269 + }; 270 + 91C82D6905CFF8B20042A20D = { 271 + isa = PBXBuildFile; 272 + fileRef = B6D5207205B38F4E0077A2BA; 273 + }; 274 + 91C82D6B05CFF8B20042A20D = { 275 + isa = PBXBuildFile; 276 + fileRef = B6D5205D05B38EE80077A2BA; 277 + }; 278 + 91C82D6C05CFF8B20042A20D = { 279 + isa = PBXBuildFile; 280 + fileRef = B6D5205E05B38EE80077A2BA; 281 + }; 282 + 91C82D6D05CFF8B20042A20D = { 283 + isa = PBXBuildFile; 284 + fileRef = B6D5206105B38EFE0077A2BA; 285 + }; 286 + 91C82D7505CFF8B20042A20D = { 287 + isa = PBXBuildFile; 288 + fileRef = B6D5207305B38F4E0077A2BA; 289 + }; 290 + 91C82D7605CFF8B20042A20D = { 291 + isa = PBXBuildFile; 292 + fileRef = B6D5203A05B38D870077A2BA; 293 + }; 294 + 91C82D7705CFF8B20042A20D = { 295 + isa = PBXBuildFile; 296 + fileRef = B6D5206C05B38F3A0077A2BA; 297 + }; 298 + 91C82D7805CFF8B20042A20D = { 299 + isa = PBXBuildFile; 300 + fileRef = B6D5204B05B38E2F0077A2BA; 301 + }; 302 + 91C82D7905CFF8B20042A20D = { 303 + isa = PBXBuildFile; 304 + fileRef = B6D5206805B38F280077A2BA; 305 + }; 306 + 91C82D7B05CFF8B20042A20D = { 307 + isa = PBXBuildFile; 308 + fileRef = B6D5253505B38FEB0077A2BA; 309 + }; 310 + 91C82D7D05CFF8B20042A20D = { 311 + isa = PBXBuildFile; 312 + fileRef = B6D5207205B38F4E0077A2BA; 313 + }; 314 + 91C82D7E05CFF8B20042A20D = { 315 + isa = PBXBuildFile; 316 + fileRef = B6D5203905B38D870077A2BA; 317 + }; 318 + 91C82D7F05CFF8B20042A20D = { 319 + isa = PBXBuildFile; 320 + fileRef = B6D5206B05B38F3A0077A2BA; 321 + }; 322 + 91C82D8005CFF8B20042A20D = { 323 + isa = PBXBuildFile; 324 + fileRef = B6D5206D05B38F3A0077A2BA; 325 + }; 326 + 91C82D8105CFF8B20042A20D = { 327 + isa = PBXBuildFile; 328 + fileRef = B6D5204A05B38E2F0077A2BA; 329 + }; 330 + 91C82D8205CFF8B20042A20D = { 331 + isa = PBXBuildFile; 332 + fileRef = B6D5206705B38F280077A2BA; 333 + }; 334 + 91C82D8405CFF8B20042A20D = { 335 + isa = PBXBuildFile; 336 + fileRef = B6D5206105B38EFE0077A2BA; 337 + }; 338 + 91C82D8505CFF8B20042A20D = { 339 + isa = PBXBuildFile; 340 + fileRef = B6D5205D05B38EE80077A2BA; 341 + }; 342 + 91C82D8C05CFF8B20042A20D = { 343 + isa = PBXBuildFile; 344 + fileRef = B6D5255505B479680077A2BA; 345 + }; 346 + 91C82D8D05CFF8B20042A20D = { 347 + isa = PBXBuildFile; 348 + fileRef = B6D5255905B479680077A2BA; 349 + }; 350 + 91C82D8E05CFF8B20042A20D = { 351 + isa = PBXBuildFile; 352 + fileRef = B6D5255B05B479680077A2BA; 353 + }; 354 + 91C82D8F05CFF8B20042A20D = { 355 + isa = PBXBuildFile; 356 + fileRef = B6D5256505B4799F0077A2BA; 357 + }; 358 + 91C82D9005CFF8B20042A20D = { 359 + isa = PBXBuildFile; 360 + fileRef = B6D5256905B479C40077A2BA; 361 + }; 362 + 91C82D9105CFF8B20042A20D = { 363 + isa = PBXBuildFile; 364 + fileRef = B6D5256D05B479F50077A2BA; 365 + }; 366 + 91C82D9305CFF8B20042A20D = { 367 + isa = PBXBuildFile; 368 + fileRef = B6D5257A05B47A5C0077A2BA; 369 + }; 370 + 91C82D9405CFF8B20042A20D = { 371 + isa = PBXBuildFile; 372 + fileRef = B6D5206C05B38F3A0077A2BA; 373 + }; 374 + 91C82D9505CFF8B20042A20D = { 375 + isa = PBXBuildFile; 376 + fileRef = B6D5206405B38F100077A2BA; 377 + }; 378 + 91C82D9705CFF8B20042A20D = { 379 + isa = PBXBuildFile; 380 + fileRef = B6D5258705B47AB70077A2BA; 381 + }; 382 + 91C82D9805CFF8B20042A20D = { 383 + isa = PBXBuildFile; 384 + fileRef = B6D5204B05B38E2F0077A2BA; 385 + }; 386 + 91C82D9905CFF8B20042A20D = { 387 + isa = PBXBuildFile; 388 + fileRef = B6D5206805B38F280077A2BA; 389 + }; 390 + 91C82D9A05CFF8B20042A20D = { 391 + isa = PBXBuildFile; 392 + fileRef = B6D5207305B38F4E0077A2BA; 393 + }; 394 + 91C82D9B05CFF8B20042A20D = { 395 + isa = PBXBuildFile; 396 + fileRef = B6D5259105B47AEB0077A2BA; 397 + }; 398 + 91C82D9C05CFF8B20042A20D = { 399 + isa = PBXBuildFile; 400 + fileRef = B6D5259505B47B050077A2BA; 401 + }; 402 + 91C82D9E05CFF8B20042A20D = { 403 + isa = PBXBuildFile; 404 + fileRef = B6D5254D05B390A20077A2BA; 405 + }; 406 + 91C82D9F05CFF8B20042A20D = { 407 + isa = PBXBuildFile; 408 + fileRef = B6D5255405B479680077A2BA; 409 + }; 410 + 91C82DA005CFF8B20042A20D = { 411 + isa = PBXBuildFile; 412 + fileRef = B6D5255805B479680077A2BA; 413 + }; 414 + 91C82DA105CFF8B20042A20D = { 415 + isa = PBXBuildFile; 416 + fileRef = B6D5255A05B479680077A2BA; 417 + }; 418 + 91C82DA205CFF8B20042A20D = { 419 + isa = PBXBuildFile; 420 + fileRef = B6D5256405B4799F0077A2BA; 421 + }; 422 + 91C82DA305CFF8B20042A20D = { 423 + isa = PBXBuildFile; 424 + fileRef = B6D5256805B479C40077A2BA; 425 + }; 426 + 91C82DA405CFF8B20042A20D = { 427 + isa = PBXBuildFile; 428 + fileRef = B6D5256C05B479F50077A2BA; 429 + }; 430 + 91C82DA605CFF8B20042A20D = { 431 + isa = PBXBuildFile; 432 + fileRef = B6D5257905B47A5C0077A2BA; 433 + }; 434 + 91C82DA705CFF8B20042A20D = { 435 + isa = PBXBuildFile; 436 + fileRef = B6D5206B05B38F3A0077A2BA; 437 + }; 438 + 91C82DA805CFF8B20042A20D = { 439 + isa = PBXBuildFile; 440 + fileRef = B6D5206D05B38F3A0077A2BA; 441 + }; 442 + 91C82DA905CFF8B20042A20D = { 443 + isa = PBXBuildFile; 444 + fileRef = B6D5206305B38F100077A2BA; 445 + }; 446 + 91C82DAB05CFF8B20042A20D = { 447 + isa = PBXBuildFile; 448 + fileRef = B6D5258605B47AB70077A2BA; 449 + }; 450 + 91C82DAC05CFF8B20042A20D = { 451 + isa = PBXBuildFile; 452 + fileRef = B6D5204A05B38E2F0077A2BA; 453 + }; 454 + 91C82DAD05CFF8B20042A20D = { 455 + isa = PBXBuildFile; 456 + fileRef = B6D5206705B38F280077A2BA; 457 + }; 458 + 91C82DAE05CFF8B20042A20D = { 459 + isa = PBXBuildFile; 460 + fileRef = B6D5207205B38F4E0077A2BA; 461 + }; 462 + 91C82DAF05CFF8B20042A20D = { 463 + isa = PBXBuildFile; 464 + fileRef = B6D5259005B47AEB0077A2BA; 465 + }; 466 + 91C82DB005CFF8B20042A20D = { 467 + isa = PBXBuildFile; 468 + fileRef = B6D5259405B47B050077A2BA; 469 + }; 470 + 91C82DB205CFF8B20042A20D = { 471 + isa = PBXBuildFile; 472 + fileRef = B6D5257005B47A140077A2BA; 473 + }; 474 + 91C82DB305CFF8B20042A20D = { 475 + isa = PBXBuildFile; 476 + fileRef = B6D5206105B38EFE0077A2BA; 477 + }; 478 + 91C82DB405CFF8B20042A20D = { 479 + isa = PBXBuildFile; 480 + fileRef = B6D5205D05B38EE80077A2BA; 481 + }; 482 + 91C82DBC05CFF8B30042A20D = { 483 + isa = PBXBuildFile; 484 + fileRef = B6D5255705B479680077A2BA; 485 + }; 486 + 91C82DBD05CFF8B30042A20D = { 487 + isa = PBXBuildFile; 488 + fileRef = B6D5204B05B38E2F0077A2BA; 489 + }; 490 + 91C82DBE05CFF8B30042A20D = { 491 + isa = PBXBuildFile; 492 + fileRef = B6D5206C05B38F3A0077A2BA; 493 + }; 494 + 91C82DBF05CFF8B30042A20D = { 495 + isa = PBXBuildFile; 496 + fileRef = B6D5206805B38F280077A2BA; 497 + }; 498 + 91C82DC005CFF8B30042A20D = { 499 + isa = PBXBuildFile; 500 + fileRef = B6D5255905B479680077A2BA; 501 + }; 502 + 91C82DC105CFF8B30042A20D = { 503 + isa = PBXBuildFile; 504 + fileRef = B6D5257A05B47A5C0077A2BA; 505 + }; 506 + 91C82DC205CFF8B30042A20D = { 507 + isa = PBXBuildFile; 508 + fileRef = B6D5256905B479C40077A2BA; 509 + }; 510 + 91C82DC305CFF8B30042A20D = { 511 + isa = PBXBuildFile; 512 + fileRef = B6D5256505B4799F0077A2BA; 513 + }; 514 + 91C82DC405CFF8B30042A20D = { 515 + isa = PBXBuildFile; 516 + fileRef = B6D5259105B47AEB0077A2BA; 517 + }; 518 + 91C82DC505CFF8B30042A20D = { 519 + isa = PBXBuildFile; 520 + fileRef = B6D5206405B38F100077A2BA; 521 + }; 522 + 91C82DC605CFF8B30042A20D = { 523 + isa = PBXBuildFile; 524 + fileRef = B6D5207305B38F4E0077A2BA; 525 + }; 526 + 91C82DC805CFF8B30042A20D = { 527 + isa = PBXBuildFile; 528 + fileRef = B6D5259F05B47B580077A2BA; 529 + }; 530 + 91C82DCA05CFF8B30042A20D = { 531 + isa = PBXBuildFile; 532 + fileRef = B6D5255605B479680077A2BA; 533 + }; 534 + 91C82DCB05CFF8B30042A20D = { 535 + isa = PBXBuildFile; 536 + fileRef = B6D5204A05B38E2F0077A2BA; 537 + }; 538 + 91C82DCC05CFF8B30042A20D = { 539 + isa = PBXBuildFile; 540 + fileRef = B6D5206B05B38F3A0077A2BA; 541 + }; 542 + 91C82DCD05CFF8B30042A20D = { 543 + isa = PBXBuildFile; 544 + fileRef = B6D5206D05B38F3A0077A2BA; 545 + }; 546 + 91C82DCE05CFF8B30042A20D = { 547 + isa = PBXBuildFile; 548 + fileRef = B6D5206705B38F280077A2BA; 549 + }; 550 + 91C82DCF05CFF8B30042A20D = { 551 + isa = PBXBuildFile; 552 + fileRef = B6D5255805B479680077A2BA; 553 + }; 554 + 91C82DD005CFF8B30042A20D = { 555 + isa = PBXBuildFile; 556 + fileRef = B6D5257905B47A5C0077A2BA; 557 + }; 558 + 91C82DD105CFF8B30042A20D = { 559 + isa = PBXBuildFile; 560 + fileRef = B6D5256805B479C40077A2BA; 561 + }; 562 + 91C82DD205CFF8B30042A20D = { 563 + isa = PBXBuildFile; 564 + fileRef = B6D5256405B4799F0077A2BA; 565 + }; 566 + 91C82DD305CFF8B30042A20D = { 567 + isa = PBXBuildFile; 568 + fileRef = B6D5259005B47AEB0077A2BA; 569 + }; 570 + 91C82DD405CFF8B30042A20D = { 571 + isa = PBXBuildFile; 572 + fileRef = B6D5206305B38F100077A2BA; 573 + }; 574 + 91C82DD505CFF8B30042A20D = { 575 + isa = PBXBuildFile; 576 + fileRef = B6D5207205B38F4E0077A2BA; 577 + }; 578 + 91C82DD705CFF8B30042A20D = { 579 + isa = PBXBuildFile; 580 + fileRef = B6D5205D05B38EE80077A2BA; 581 + }; 582 + 91C82DD805CFF8B30042A20D = { 583 + isa = PBXBuildFile; 584 + fileRef = B6D5206105B38EFE0077A2BA; 585 + }; 586 + 91C82DD905CFF8B30042A20D = { 587 + isa = PBXBuildFile; 588 + fileRef = B6D5257005B47A140077A2BA; 589 + }; 590 + 91C82DDA05CFF8B30042A20D = { 591 + isa = PBXBuildFile; 592 + fileRef = B6D52FED05B47C070077A2BA; 593 + }; 594 + 91C82DE305CFF8B30042A20D = { 595 + isa = PBXBuildFile; 596 + fileRef = B6D5300A05B4817A0077A2BA; 597 + }; 598 + 91C82DE605CFF8B30042A20D = { 599 + isa = PBXBuildFile; 600 + fileRef = B6D5205D05B38EE80077A2BA; 601 + }; 602 + 91C82DE705CFF8B30042A20D = { 603 + isa = PBXBuildFile; 604 + fileRef = B6D5205E05B38EE80077A2BA; 605 + }; 606 + 91E2D39806641E7800F19278 = { 607 + isa = PBXBuildFile; 608 + fileRef = 91B0CA2406640DFD00B57457; 609 + }; 610 + 91FF724E07306039008E851B = { 611 + isa = PBXBuildFile; 612 + fileRef = 91FF724D07306039008E851B; 613 + }; 614 + 91FF72500730614D008E851B = { 615 + isa = PBXBuildFile; 616 + fileRef = 91FF724F0730614D008E851B; 617 + }; 618 + A929CDBA069E34840010B9C5 = { 619 + isa = PBXBuildFile; 620 + fileRef = B6D5204B05B38E2F0077A2BA; 621 + }; 622 + A929CDBC069E34840010B9C5 = { 623 + isa = PBXBuildFile; 624 + fileRef = B6D5206405B38F100077A2BA; 625 + }; 626 + A929CDBD069E34840010B9C5 = { 627 + isa = PBXBuildFile; 628 + fileRef = B6D5206805B38F280077A2BA; 629 + }; 630 + A929CDBE069E34840010B9C5 = { 631 + isa = PBXBuildFile; 632 + fileRef = B6D5206C05B38F3A0077A2BA; 633 + }; 634 + A929CDC5069E34840010B9C5 = { 635 + isa = PBXBuildFile; 636 + fileRef = B6D5204A05B38E2F0077A2BA; 637 + }; 638 + A929CDC7069E34840010B9C5 = { 639 + isa = PBXBuildFile; 640 + fileRef = B6D5206305B38F100077A2BA; 641 + }; 642 + A929CDC8069E34840010B9C5 = { 643 + isa = PBXBuildFile; 644 + fileRef = B6D5206705B38F280077A2BA; 645 + }; 646 + A929CDC9069E34840010B9C5 = { 647 + isa = PBXBuildFile; 648 + fileRef = B6D5206B05B38F3A0077A2BA; 649 + }; 650 + A929CDCA069E34840010B9C5 = { 651 + isa = PBXBuildFile; 652 + fileRef = B6D5206D05B38F3A0077A2BA; 653 + }; 654 + A929CDCE069E34840010B9C5 = { 655 + isa = PBXBuildFile; 656 + fileRef = B6D5205D05B38EE80077A2BA; 657 + }; 658 + A929CDCF069E34840010B9C5 = { 659 + isa = PBXBuildFile; 660 + fileRef = B6D5205E05B38EE80077A2BA; 661 + }; 662 + A929CDD0069E34840010B9C5 = { 663 + isa = PBXBuildFile; 664 + fileRef = B6D5206105B38EFE0077A2BA; 665 + }; 666 + A929CDD5069E34990010B9C5 = { 667 + isa = PBXBuildFile; 668 + fileRef = A929CDD4069E34990010B9C5; 669 + }; 670 + A929CDD6069E34B50010B9C5 = { 671 + isa = PBXBuildFile; 672 + fileRef = 9137C6000655A6EB00A1A3A2; 673 + }; 674 + A929CDD7069E34B60010B9C5 = { 675 + isa = PBXBuildFile; 676 + fileRef = 9137C6010655A6EB00A1A3A2; 677 + }; 678 + A929CDD8069E34C40010B9C5 = { 679 + isa = PBXBuildFile; 680 + fileRef = B6D5207305B38F4E0077A2BA; 681 + }; 682 + A929CDD9069E34C40010B9C5 = { 683 + isa = PBXBuildFile; 684 + fileRef = B6D5207205B38F4E0077A2BA; 685 + }; 686 + A929CDF3069E358A0010B9C5 = { 687 + isa = PBXBuildFile; 688 + fileRef = A929CDF1069E358A0010B9C5; 689 + }; 690 + A929CDF4069E358A0010B9C5 = { 691 + isa = PBXBuildFile; 692 + fileRef = A929CDF2069E358A0010B9C5; 693 + }; 694 + A929CDFB069E35CF0010B9C5 = { 695 + isa = PBXBuildFile; 696 + fileRef = B6D5257005B47A140077A2BA; 697 + }; 698 + A929CE12069E35DD0010B9C5 = { 699 + isa = PBXBuildFile; 700 + fileRef = 9137C6210655A76F00A1A3A2; 701 + }; 702 + A929CE18069E35DD0010B9C5 = { 703 + isa = PBXBuildFile; 704 + fileRef = 9137C6200655A76F00A1A3A2; 705 + }; 706 + A929CE1E069E35E00010B9C5 = { 707 + isa = PBXBuildFile; 708 + fileRef = B6D5258605B47AB70077A2BA; 709 + }; 710 + A929CE24069E35E10010B9C5 = { 711 + isa = PBXBuildFile; 712 + fileRef = B6D5258705B47AB70077A2BA; 713 + }; 714 + A929CE2A069E35E20010B9C5 = { 715 + isa = PBXBuildFile; 716 + fileRef = B6D5259405B47B050077A2BA; 717 + }; 718 + A929CE30069E35E30010B9C5 = { 719 + isa = PBXBuildFile; 720 + fileRef = B6D5259505B47B050077A2BA; 721 + }; 722 + A9E52CE108E1EB0C00A2A9EA = { 723 + isa = PBXBuildFile; 724 + fileRef = A9E52CE008E1EB0C00A2A9EA; 725 + }; 726 + A9E52CE208E1EB0C00A2A9EA = { 727 + isa = PBXBuildFile; 728 + fileRef = A9E52CE008E1EB0C00A2A9EA; 729 + }; 730 + A9E52CE308E1EB0C00A2A9EA = { 731 + isa = PBXBuildFile; 732 + fileRef = A9E52CE008E1EB0C00A2A9EA; 733 + }; 734 + A9E52CE408E1EB0C00A2A9EA = { 735 + isa = PBXBuildFile; 736 + fileRef = A9E52CE008E1EB0C00A2A9EA; 737 + }; 738 + A9E52CE508E1EB0C00A2A9EA = { 739 + isa = PBXBuildFile; 740 + fileRef = A9E52CE008E1EB0C00A2A9EA; 741 + }; 742 + A9E52CE608E1EB0C00A2A9EA = { 743 + isa = PBXBuildFile; 744 + fileRef = A9E52CE008E1EB0C00A2A9EA; 745 + }; 746 + A9E52CE708E1EB0C00A2A9EA = { 747 + isa = PBXBuildFile; 748 + fileRef = A9E52CE008E1EB0C00A2A9EA; 749 + }; 750 + A9F41D1D08F4B00200A2BC1C = { 751 + isa = PBXBuildFile; 752 + fileRef = B6D5204B05B38E2F0077A2BA; 753 + }; 754 + A9F41D1E08F4B00200A2BC1C = { 755 + isa = PBXBuildFile; 756 + fileRef = B6D5206405B38F100077A2BA; 757 + }; 758 + A9F41D1F08F4B00200A2BC1C = { 759 + isa = PBXBuildFile; 760 + fileRef = B6D5206805B38F280077A2BA; 761 + }; 762 + A9F41D2008F4B00200A2BC1C = { 763 + isa = PBXBuildFile; 764 + fileRef = B6D5206C05B38F3A0077A2BA; 765 + }; 766 + A9F41D2108F4B00200A2BC1C = { 767 + isa = PBXBuildFile; 768 + fileRef = 9137C6010655A6EB00A1A3A2; 769 + }; 770 + A9F41D2208F4B00200A2BC1C = { 771 + isa = PBXBuildFile; 772 + fileRef = B6D5207305B38F4E0077A2BA; 773 + }; 774 + A9F41D2308F4B00200A2BC1C = { 775 + isa = PBXBuildFile; 776 + fileRef = A929CDF2069E358A0010B9C5; 777 + }; 778 + A9F41D2408F4B00200A2BC1C = { 779 + isa = PBXBuildFile; 780 + fileRef = 9137C6210655A76F00A1A3A2; 781 + }; 782 + A9F41D2508F4B00200A2BC1C = { 783 + isa = PBXBuildFile; 784 + fileRef = B6D5258705B47AB70077A2BA; 785 + }; 786 + A9F41D2608F4B00200A2BC1C = { 787 + isa = PBXBuildFile; 788 + fileRef = B6D5259505B47B050077A2BA; 789 + }; 790 + A9F41D2708F4B00200A2BC1C = { 791 + isa = PBXBuildFile; 792 + fileRef = 9186C799072033F000D7CA7A; 793 + }; 794 + A9F41D2808F4B00200A2BC1C = { 795 + isa = PBXBuildFile; 796 + fileRef = 9138521107138D8100E6E381; 797 + }; 798 + A9F41D2908F4B00200A2BC1C = { 799 + isa = PBXBuildFile; 800 + fileRef = A9E52CE008E1EB0C00A2A9EA; 801 + }; 802 + A9F41D2B08F4B00200A2BC1C = { 803 + isa = PBXBuildFile; 804 + fileRef = B6D5204A05B38E2F0077A2BA; 805 + }; 806 + A9F41D2C08F4B00200A2BC1C = { 807 + isa = PBXBuildFile; 808 + fileRef = B6D5206305B38F100077A2BA; 809 + }; 810 + A9F41D2D08F4B00200A2BC1C = { 811 + isa = PBXBuildFile; 812 + fileRef = B6D5206705B38F280077A2BA; 813 + }; 814 + A9F41D2E08F4B00200A2BC1C = { 815 + isa = PBXBuildFile; 816 + fileRef = B6D5206B05B38F3A0077A2BA; 817 + }; 818 + A9F41D2F08F4B00200A2BC1C = { 819 + isa = PBXBuildFile; 820 + fileRef = B6D5206D05B38F3A0077A2BA; 821 + }; 822 + A9F41D3108F4B00200A2BC1C = { 823 + isa = PBXBuildFile; 824 + fileRef = 9137C6000655A6EB00A1A3A2; 825 + }; 826 + A9F41D3208F4B00200A2BC1C = { 827 + isa = PBXBuildFile; 828 + fileRef = B6D5207205B38F4E0077A2BA; 829 + }; 830 + A9F41D3308F4B00200A2BC1C = { 831 + isa = PBXBuildFile; 832 + fileRef = A929CDF1069E358A0010B9C5; 833 + }; 834 + A9F41D3408F4B00200A2BC1C = { 835 + isa = PBXBuildFile; 836 + fileRef = 9137C6200655A76F00A1A3A2; 837 + }; 838 + A9F41D3508F4B00200A2BC1C = { 839 + isa = PBXBuildFile; 840 + fileRef = B6D5258605B47AB70077A2BA; 841 + }; 842 + A9F41D3608F4B00200A2BC1C = { 843 + isa = PBXBuildFile; 844 + fileRef = B6D5259405B47B050077A2BA; 845 + }; 846 + A9F41D3708F4B00200A2BC1C = { 847 + isa = PBXBuildFile; 848 + fileRef = 9186C79A072033F000D7CA7A; 849 + }; 850 + A9F41D3808F4B00200A2BC1C = { 851 + isa = PBXBuildFile; 852 + fileRef = 9138521007138D8100E6E381; 853 + }; 854 + A9F41D3A08F4B00200A2BC1C = { 855 + isa = PBXBuildFile; 856 + fileRef = B6D5205D05B38EE80077A2BA; 857 + }; 858 + A9F41D3B08F4B00200A2BC1C = { 859 + isa = PBXBuildFile; 860 + fileRef = B6D5205E05B38EE80077A2BA; 861 + }; 862 + A9F41D3C08F4B00200A2BC1C = { 863 + isa = PBXBuildFile; 864 + fileRef = B6D5206105B38EFE0077A2BA; 865 + }; 866 + A9F41D3D08F4B00200A2BC1C = { 867 + isa = PBXBuildFile; 868 + fileRef = B6D5257005B47A140077A2BA; 869 + }; 870 + A9F41D4F08F4B0A100A2BC1C = { 871 + isa = PBXBuildFile; 872 + fileRef = A9F41D4E08F4B0A100A2BC1C; 873 + }; 874 + B6A359E70667D1BE00A3A2BB = { 875 + isa = PBXBuildFile; 876 + fileRef = 918B313006069285000691DF; 877 + }; 878 + B6A359EA0667D1D000A3A2BB = { 879 + isa = PBXBuildFile; 880 + fileRef = B6D5206705B38F280077A2BA; 881 + }; 882 + B6A359EB0667D1DB00A3A2BB = { 883 + isa = PBXBuildFile; 884 + fileRef = B6D5205D05B38EE80077A2BA; 885 + }; 886 + B6A359EC0667D1DD00A3A2BB = { 887 + isa = PBXBuildFile; 888 + fileRef = B6D5205E05B38EE80077A2BA; 889 + }; 890 + /* End PBXBuildFile section */ 891 + 892 + /* Begin PBXBuildStyle section */ 893 + 9171C2B107B060480067EEDA = { 894 + isa = PBXBuildStyle; 895 + buildSettings = { 896 + COPY_PHASE_STRIP = NO; 897 + GCC_DYNAMIC_NO_PIC = NO; 898 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 899 + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; 900 + GCC_OPTIMIZATION_LEVEL = 0; 901 + MACOSX_DEPLOYMENT_TARGET = 10.4; 902 + OTHER_CFLAGS = "-DDEBUG"; 903 + ZERO_LINK = NO; 904 + }; 905 + name = "Development-Tiger+"; 906 + }; 907 + 9171C2B207B0605F0067EEDA = { 908 + isa = PBXBuildStyle; 909 + buildSettings = { 910 + COPY_PHASE_STRIP = YES; 911 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 912 + LIBRARY_SEARCH_PATHS = ""; 913 + MACOSX_DEPLOYMENT_TARGET = 10.4; 914 + ZERO_LINK = NO; 915 + }; 916 + name = "Deployment-Tiger+"; 917 + }; 918 + B6B9FA2A05B38B09007FB890 = { 919 + isa = PBXBuildStyle; 920 + buildSettings = { 921 + COPY_PHASE_STRIP = NO; 922 + GCC_DYNAMIC_NO_PIC = NO; 923 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 924 + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; 925 + GCC_OPTIMIZATION_LEVEL = 0; 926 + OTHER_CFLAGS = "-DDEBUG"; 927 + ZERO_LINK = NO; 928 + }; 929 + name = "Development-Panther"; 930 + }; 931 + B6B9FA2B05B38B09007FB890 = { 932 + isa = PBXBuildStyle; 933 + buildSettings = { 934 + COPY_PHASE_STRIP = YES; 935 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 936 + LIBRARY_SEARCH_PATHS = ""; 937 + ZERO_LINK = NO; 938 + }; 939 + name = "Deployment-Panther"; 940 + }; 941 + /* End PBXBuildStyle section */ 942 + 943 + /* Begin PBXContainerItemProxy section */ 944 + 91004356066E8609005A1EC3 = { 945 + isa = PBXContainerItemProxy; 946 + containerPortal = B6B9FA2C05B38B09007FB890; 947 + proxyType = 1; 948 + remoteGlobalIDString = B6A359E40667D15B00A3A2BB; 949 + remoteInfo = afinfo; 950 + }; 951 + 915912E808F7230600A78EF3 = { 952 + isa = PBXContainerItemProxy; 953 + containerPortal = B6B9FA2C05B38B09007FB890; 954 + proxyType = 1; 955 + remoteGlobalIDString = A9F41D1B08F4B00200A2BC1C; 956 + remoteInfo = auprofile; 957 + }; 958 + 91C82E0505CFF8B30042A20D = { 959 + isa = PBXContainerItemProxy; 960 + containerPortal = B6B9FA2C05B38B09007FB890; 961 + proxyType = 1; 962 + remoteGlobalIDString = 91C82D5305CFF8B20042A20D; 963 + remoteInfo = "afconvert (Upgraded)"; 964 + }; 965 + 91C82E0705CFF8B30042A20D = { 966 + isa = PBXContainerItemProxy; 967 + containerPortal = B6B9FA2C05B38B09007FB890; 968 + proxyType = 1; 969 + remoteGlobalIDString = 91C82D7205CFF8B20042A20D; 970 + remoteInfo = "afinterleave (Upgraded)"; 971 + }; 972 + 91C82E0905CFF8B30042A20D = { 973 + isa = PBXContainerItemProxy; 974 + containerPortal = B6B9FA2C05B38B09007FB890; 975 + proxyType = 1; 976 + remoteGlobalIDString = 91C82D8A05CFF8B20042A20D; 977 + remoteInfo = "afplay (Upgraded)"; 978 + }; 979 + 91C82E0B05CFF8B30042A20D = { 980 + isa = PBXContainerItemProxy; 981 + containerPortal = B6B9FA2C05B38B09007FB890; 982 + proxyType = 1; 983 + remoteGlobalIDString = 91C82DB905CFF8B30042A20D; 984 + remoteInfo = "afrecord (Upgraded)"; 985 + }; 986 + A9E885A30874B31900B2DFE8 = { 987 + isa = PBXContainerItemProxy; 988 + containerPortal = B6B9FA2C05B38B09007FB890; 989 + proxyType = 1; 990 + remoteGlobalIDString = A929CDB6069E34840010B9C5; 991 + remoteInfo = auprocess; 992 + }; 993 + /* End PBXContainerItemProxy section */ 994 + 995 + /* Begin PBXFileReference section */ 996 + 9137C6000655A6EB00A1A3A2 = { 997 + isa = PBXFileReference; 998 + fileEncoding = 30; 999 + lastKnownFileType = sourcecode.cpp.cpp; 1000 + path = AUOutputBL.cpp; 1001 + sourceTree = "<group>"; 1002 + }; 1003 + 9137C6010655A6EB00A1A3A2 = { 1004 + isa = PBXFileReference; 1005 + fileEncoding = 30; 1006 + lastKnownFileType = sourcecode.c.h; 1007 + path = AUOutputBL.h; 1008 + sourceTree = "<group>"; 1009 + }; 1010 + 9137C6200655A76F00A1A3A2 = { 1011 + isa = PBXFileReference; 1012 + fileEncoding = 30; 1013 + lastKnownFileType = sourcecode.cpp.cpp; 1014 + path = CAAudioUnit.cpp; 1015 + sourceTree = "<group>"; 1016 + }; 1017 + 9137C6210655A76F00A1A3A2 = { 1018 + isa = PBXFileReference; 1019 + fileEncoding = 30; 1020 + lastKnownFileType = sourcecode.c.h; 1021 + path = CAAudioUnit.h; 1022 + sourceTree = "<group>"; 1023 + }; 1024 + 9138521007138D8100E6E381 = { 1025 + isa = PBXFileReference; 1026 + fileEncoding = 30; 1027 + lastKnownFileType = sourcecode.cpp.cpp; 1028 + path = CAAudioFile.cpp; 1029 + sourceTree = "<group>"; 1030 + }; 1031 + 9138521107138D8100E6E381 = { 1032 + isa = PBXFileReference; 1033 + fileEncoding = 30; 1034 + lastKnownFileType = sourcecode.c.h; 1035 + path = CAAudioFile.h; 1036 + sourceTree = "<group>"; 1037 + }; 1038 + 9143EB7006876B5500CA9919 = { 1039 + isa = PBXFileReference; 1040 + fileEncoding = 30; 1041 + lastKnownFileType = sourcecode.c.h; 1042 + path = CADebugMacros.h; 1043 + sourceTree = "<group>"; 1044 + }; 1045 + 9143EB7106876B5500CA9919 = { 1046 + isa = PBXFileReference; 1047 + fileEncoding = 30; 1048 + lastKnownFileType = sourcecode.c.h; 1049 + path = CAReferenceCounted.h; 1050 + sourceTree = "<group>"; 1051 + }; 1052 + 9143EEB406876B9300CA9919 = { 1053 + isa = PBXFileReference; 1054 + fileEncoding = 30; 1055 + lastKnownFileType = sourcecode.c.h; 1056 + path = CADebugPrintf.h; 1057 + sourceTree = "<group>"; 1058 + }; 1059 + 9143EEB506876B9300CA9919 = { 1060 + isa = PBXFileReference; 1061 + fileEncoding = 30; 1062 + lastKnownFileType = sourcecode.c.h; 1063 + path = CAMath.h; 1064 + sourceTree = "<group>"; 1065 + }; 1066 + 9143EEEB06876BAA00CA9919 = { 1067 + isa = PBXFileReference; 1068 + fileEncoding = 30; 1069 + lastKnownFileType = sourcecode.c.h; 1070 + path = CAConditionalMacros.h; 1071 + sourceTree = "<group>"; 1072 + }; 1073 + 9186C799072033F000D7CA7A = { 1074 + isa = PBXFileReference; 1075 + fileEncoding = 4; 1076 + lastKnownFileType = sourcecode.c.h; 1077 + path = CAFilePathUtils.h; 1078 + sourceTree = "<group>"; 1079 + }; 1080 + 9186C79A072033F000D7CA7A = { 1081 + isa = PBXFileReference; 1082 + fileEncoding = 4; 1083 + lastKnownFileType = sourcecode.cpp.cpp; 1084 + path = CAFilePathUtils.cpp; 1085 + sourceTree = "<group>"; 1086 + }; 1087 + 918B313006069285000691DF = { 1088 + isa = PBXFileReference; 1089 + fileEncoding = 30; 1090 + lastKnownFileType = sourcecode.cpp.cpp; 1091 + path = afinfo.cpp; 1092 + sourceTree = "<group>"; 1093 + }; 1094 + 91AFB5DF071C95CF004D7421 = { 1095 + isa = PBXFileReference; 1096 + fileEncoding = 4; 1097 + lastKnownFileType = sourcecode.c.h; 1098 + path = AFToolsCommon.h; 1099 + sourceTree = "<group>"; 1100 + }; 1101 + 91AFB5E0071C95CF004D7421 = { 1102 + isa = PBXFileReference; 1103 + fileEncoding = 4; 1104 + lastKnownFileType = sourcecode.cpp.cpp; 1105 + path = AFToolsCommon.cpp; 1106 + sourceTree = "<group>"; 1107 + }; 1108 + 91B0CA2406640DFD00B57457 = { 1109 + isa = PBXFileReference; 1110 + fileEncoding = 30; 1111 + lastKnownFileType = sourcecode.cpp.cpp; 1112 + path = CAAudioFileFormats.cpp; 1113 + sourceTree = "<group>"; 1114 + }; 1115 + 91B0CA2506640DFD00B57457 = { 1116 + isa = PBXFileReference; 1117 + fileEncoding = 30; 1118 + lastKnownFileType = sourcecode.c.h; 1119 + path = CAAudioFileFormats.h; 1120 + sourceTree = "<group>"; 1121 + }; 1122 + 91C82D7005CFF8B20042A20D = { 1123 + isa = PBXFileReference; 1124 + explicitFileType = "compiled.mach-o.executable"; 1125 + includeInIndex = 0; 1126 + path = afconvert; 1127 + sourceTree = BUILT_PRODUCTS_DIR; 1128 + }; 1129 + 91C82D8805CFF8B20042A20D = { 1130 + isa = PBXFileReference; 1131 + explicitFileType = "compiled.mach-o.executable"; 1132 + includeInIndex = 0; 1133 + path = afinterleave; 1134 + sourceTree = BUILT_PRODUCTS_DIR; 1135 + }; 1136 + 91C82DB705CFF8B30042A20D = { 1137 + isa = PBXFileReference; 1138 + explicitFileType = "compiled.mach-o.executable"; 1139 + includeInIndex = 0; 1140 + path = afplay; 1141 + sourceTree = BUILT_PRODUCTS_DIR; 1142 + }; 1143 + 91C82DDD05CFF8B30042A20D = { 1144 + isa = PBXFileReference; 1145 + explicitFileType = "compiled.mach-o.executable"; 1146 + includeInIndex = 0; 1147 + path = afrecord; 1148 + sourceTree = BUILT_PRODUCTS_DIR; 1149 + }; 1150 + 91C82DEA05CFF8B30042A20D = { 1151 + isa = PBXFileReference; 1152 + explicitFileType = "compiled.mach-o.executable"; 1153 + includeInIndex = 0; 1154 + path = audioformats; 1155 + sourceTree = BUILT_PRODUCTS_DIR; 1156 + }; 1157 + 91F7F37605C5DC6B00998F2F = { 1158 + isa = PBXFileReference; 1159 + fileEncoding = 30; 1160 + lastKnownFileType = sourcecode.cpp.cpp; 1161 + path = QTAACFile.cpp; 1162 + sourceTree = "<group>"; 1163 + }; 1164 + 91F7F37705C5DC6B00998F2F = { 1165 + isa = PBXFileReference; 1166 + fileEncoding = 30; 1167 + lastKnownFileType = sourcecode.c.h; 1168 + path = QTAACFile.h; 1169 + sourceTree = "<group>"; 1170 + }; 1171 + 91FF724D07306039008E851B = { 1172 + isa = PBXFileReference; 1173 + fileEncoding = 4; 1174 + lastKnownFileType = sourcecode.c.h; 1175 + path = afconvert.h; 1176 + sourceTree = "<group>"; 1177 + }; 1178 + 91FF724F0730614D008E851B = { 1179 + isa = PBXFileReference; 1180 + fileEncoding = 4; 1181 + lastKnownFileType = sourcecode.cpp.cpp; 1182 + path = afconvert_main.cpp; 1183 + sourceTree = "<group>"; 1184 + }; 1185 + A929CDD2069E34840010B9C5 = { 1186 + isa = PBXFileReference; 1187 + explicitFileType = "compiled.mach-o.executable"; 1188 + includeInIndex = 0; 1189 + path = auprocess; 1190 + sourceTree = BUILT_PRODUCTS_DIR; 1191 + }; 1192 + A929CDD4069E34990010B9C5 = { 1193 + isa = PBXFileReference; 1194 + fileEncoding = 30; 1195 + lastKnownFileType = sourcecode.cpp.cpp; 1196 + path = auprocess.cpp; 1197 + sourceTree = SOURCE_ROOT; 1198 + }; 1199 + A929CDF1069E358A0010B9C5 = { 1200 + isa = PBXFileReference; 1201 + fileEncoding = 30; 1202 + lastKnownFileType = sourcecode.cpp.cpp; 1203 + name = CAAUProcessor.cpp; 1204 + path = /Developer/Examples/CoreAudio/PublicUtility/CAAUProcessor.cpp; 1205 + sourceTree = "<absolute>"; 1206 + }; 1207 + A929CDF2069E358A0010B9C5 = { 1208 + isa = PBXFileReference; 1209 + fileEncoding = 30; 1210 + lastKnownFileType = sourcecode.c.h; 1211 + name = CAAUProcessor.h; 1212 + path = /Developer/Examples/CoreAudio/PublicUtility/CAAUProcessor.h; 1213 + sourceTree = "<absolute>"; 1214 + }; 1215 + A9E52CE008E1EB0C00A2A9EA = { 1216 + isa = PBXFileReference; 1217 + fileEncoding = 30; 1218 + lastKnownFileType = sourcecode.c.h; 1219 + path = CAAtomicStack.h; 1220 + sourceTree = "<group>"; 1221 + }; 1222 + A9F41D4508F4B00200A2BC1C = { 1223 + isa = PBXFileReference; 1224 + explicitFileType = "compiled.mach-o.executable"; 1225 + includeInIndex = 0; 1226 + path = auprofile; 1227 + sourceTree = BUILT_PRODUCTS_DIR; 1228 + }; 1229 + A9F41D4E08F4B0A100A2BC1C = { 1230 + isa = PBXFileReference; 1231 + fileEncoding = 30; 1232 + lastKnownFileType = sourcecode.cpp.cpp; 1233 + path = auprofile.cpp; 1234 + sourceTree = "<group>"; 1235 + }; 1236 + B6A359E50667D15B00A3A2BB = { 1237 + isa = PBXFileReference; 1238 + explicitFileType = "compiled.mach-o.executable"; 1239 + includeInIndex = 0; 1240 + path = afinfo; 1241 + sourceTree = BUILT_PRODUCTS_DIR; 1242 + }; 1243 + B6D5203705B38D750077A2BA = { 1244 + isa = PBXFileReference; 1245 + fileEncoding = 30; 1246 + lastKnownFileType = sourcecode.cpp.cpp; 1247 + path = afconvert.cpp; 1248 + sourceTree = "<group>"; 1249 + }; 1250 + B6D5203905B38D870077A2BA = { 1251 + isa = PBXFileReference; 1252 + fileEncoding = 30; 1253 + lastKnownFileType = sourcecode.cpp.cpp; 1254 + path = CAChannelLayouts.cpp; 1255 + sourceTree = "<group>"; 1256 + }; 1257 + B6D5203A05B38D870077A2BA = { 1258 + isa = PBXFileReference; 1259 + fileEncoding = 30; 1260 + lastKnownFileType = sourcecode.c.h; 1261 + path = CAChannelLayouts.h; 1262 + sourceTree = "<group>"; 1263 + }; 1264 + B6D5204A05B38E2F0077A2BA = { 1265 + isa = PBXFileReference; 1266 + fileEncoding = 30; 1267 + lastKnownFileType = sourcecode.cpp.cpp; 1268 + path = CAXException.cpp; 1269 + sourceTree = "<group>"; 1270 + }; 1271 + B6D5204B05B38E2F0077A2BA = { 1272 + isa = PBXFileReference; 1273 + fileEncoding = 30; 1274 + lastKnownFileType = sourcecode.c.h; 1275 + path = CAXException.h; 1276 + sourceTree = "<group>"; 1277 + }; 1278 + B6D5205405B38E750077A2BA = { 1279 + isa = PBXFileReference; 1280 + fileEncoding = 30; 1281 + lastKnownFileType = sourcecode.cpp.cpp; 1282 + path = CAAudioFileConverter.cpp; 1283 + sourceTree = "<group>"; 1284 + }; 1285 + B6D5205505B38E750077A2BA = { 1286 + isa = PBXFileReference; 1287 + fileEncoding = 30; 1288 + lastKnownFileType = sourcecode.c.h; 1289 + path = CAAudioFileConverter.h; 1290 + sourceTree = "<group>"; 1291 + }; 1292 + B6D5205D05B38EE80077A2BA = { 1293 + isa = PBXFileReference; 1294 + lastKnownFileType = wrapper.framework; 1295 + name = AudioToolbox.framework; 1296 + path = /System/Library/Frameworks/AudioToolbox.framework; 1297 + sourceTree = "<absolute>"; 1298 + }; 1299 + B6D5205E05B38EE80077A2BA = { 1300 + isa = PBXFileReference; 1301 + lastKnownFileType = wrapper.framework; 1302 + name = CoreFoundation.framework; 1303 + path = /System/Library/Frameworks/CoreFoundation.framework; 1304 + sourceTree = "<absolute>"; 1305 + }; 1306 + B6D5206105B38EFE0077A2BA = { 1307 + isa = PBXFileReference; 1308 + lastKnownFileType = wrapper.framework; 1309 + name = CoreServices.framework; 1310 + path = /System/Library/Frameworks/CoreServices.framework; 1311 + sourceTree = "<absolute>"; 1312 + }; 1313 + B6D5206305B38F100077A2BA = { 1314 + isa = PBXFileReference; 1315 + fileEncoding = 30; 1316 + lastKnownFileType = sourcecode.cpp.cpp; 1317 + path = CAHostTimeBase.cpp; 1318 + sourceTree = "<group>"; 1319 + }; 1320 + B6D5206405B38F100077A2BA = { 1321 + isa = PBXFileReference; 1322 + fileEncoding = 30; 1323 + lastKnownFileType = sourcecode.c.h; 1324 + path = CAHostTimeBase.h; 1325 + sourceTree = "<group>"; 1326 + }; 1327 + B6D5206705B38F280077A2BA = { 1328 + isa = PBXFileReference; 1329 + fileEncoding = 30; 1330 + lastKnownFileType = sourcecode.cpp.cpp; 1331 + path = CAStreamBasicDescription.cpp; 1332 + sourceTree = "<group>"; 1333 + }; 1334 + B6D5206805B38F280077A2BA = { 1335 + isa = PBXFileReference; 1336 + fileEncoding = 30; 1337 + lastKnownFileType = sourcecode.c.h; 1338 + path = CAStreamBasicDescription.h; 1339 + sourceTree = "<group>"; 1340 + }; 1341 + B6D5206B05B38F3A0077A2BA = { 1342 + isa = PBXFileReference; 1343 + fileEncoding = 30; 1344 + lastKnownFileType = sourcecode.cpp.cpp; 1345 + path = CAAudioChannelLayout.cpp; 1346 + sourceTree = "<group>"; 1347 + }; 1348 + B6D5206C05B38F3A0077A2BA = { 1349 + isa = PBXFileReference; 1350 + fileEncoding = 30; 1351 + lastKnownFileType = sourcecode.c.h; 1352 + path = CAAudioChannelLayout.h; 1353 + sourceTree = "<group>"; 1354 + }; 1355 + B6D5206D05B38F3A0077A2BA = { 1356 + isa = PBXFileReference; 1357 + fileEncoding = 30; 1358 + lastKnownFileType = sourcecode.cpp.cpp; 1359 + path = CAAudioChannelLayoutObject.cpp; 1360 + sourceTree = "<group>"; 1361 + }; 1362 + B6D5207205B38F4E0077A2BA = { 1363 + isa = PBXFileReference; 1364 + fileEncoding = 30; 1365 + lastKnownFileType = sourcecode.cpp.cpp; 1366 + path = CABufferList.cpp; 1367 + sourceTree = "<group>"; 1368 + }; 1369 + B6D5207305B38F4E0077A2BA = { 1370 + isa = PBXFileReference; 1371 + fileEncoding = 30; 1372 + lastKnownFileType = sourcecode.c.h; 1373 + path = CABufferList.h; 1374 + sourceTree = "<group>"; 1375 + }; 1376 + B6D5253505B38FEB0077A2BA = { 1377 + isa = PBXFileReference; 1378 + fileEncoding = 30; 1379 + lastKnownFileType = sourcecode.cpp.cpp; 1380 + path = afinterleave.cpp; 1381 + sourceTree = "<group>"; 1382 + }; 1383 + B6D5254D05B390A20077A2BA = { 1384 + isa = PBXFileReference; 1385 + fileEncoding = 30; 1386 + lastKnownFileType = sourcecode.cpp.cpp; 1387 + path = afplay.cpp; 1388 + sourceTree = "<group>"; 1389 + }; 1390 + B6D5255405B479680077A2BA = { 1391 + isa = PBXFileReference; 1392 + fileEncoding = 30; 1393 + lastKnownFileType = sourcecode.cpp.cpp; 1394 + path = CAAudioFilePlayer.cpp; 1395 + sourceTree = "<group>"; 1396 + }; 1397 + B6D5255505B479680077A2BA = { 1398 + isa = PBXFileReference; 1399 + fileEncoding = 30; 1400 + lastKnownFileType = sourcecode.c.h; 1401 + path = CAAudioFilePlayer.h; 1402 + sourceTree = "<group>"; 1403 + }; 1404 + B6D5255605B479680077A2BA = { 1405 + isa = PBXFileReference; 1406 + fileEncoding = 30; 1407 + lastKnownFileType = sourcecode.cpp.cpp; 1408 + path = CAAudioFileRecorder.cpp; 1409 + sourceTree = "<group>"; 1410 + }; 1411 + B6D5255705B479680077A2BA = { 1412 + isa = PBXFileReference; 1413 + fileEncoding = 30; 1414 + lastKnownFileType = sourcecode.c.h; 1415 + path = CAAudioFileRecorder.h; 1416 + sourceTree = "<group>"; 1417 + }; 1418 + B6D5255805B479680077A2BA = { 1419 + isa = PBXFileReference; 1420 + fileEncoding = 30; 1421 + lastKnownFileType = sourcecode.cpp.cpp; 1422 + path = CAAudioFileStreamer.cpp; 1423 + sourceTree = "<group>"; 1424 + }; 1425 + B6D5255905B479680077A2BA = { 1426 + isa = PBXFileReference; 1427 + fileEncoding = 30; 1428 + lastKnownFileType = sourcecode.c.h; 1429 + path = CAAudioFileStreamer.h; 1430 + sourceTree = "<group>"; 1431 + }; 1432 + B6D5255A05B479680077A2BA = { 1433 + isa = PBXFileReference; 1434 + fileEncoding = 30; 1435 + lastKnownFileType = sourcecode.cpp.cpp; 1436 + path = CAChannelMappingPlayer.cpp; 1437 + sourceTree = "<group>"; 1438 + }; 1439 + B6D5255B05B479680077A2BA = { 1440 + isa = PBXFileReference; 1441 + fileEncoding = 30; 1442 + lastKnownFileType = sourcecode.c.h; 1443 + path = CAChannelMappingPlayer.h; 1444 + sourceTree = "<group>"; 1445 + }; 1446 + B6D5256405B4799F0077A2BA = { 1447 + isa = PBXFileReference; 1448 + fileEncoding = 30; 1449 + lastKnownFileType = sourcecode.cpp.cpp; 1450 + path = CAMutex.cpp; 1451 + sourceTree = "<group>"; 1452 + }; 1453 + B6D5256505B4799F0077A2BA = { 1454 + isa = PBXFileReference; 1455 + fileEncoding = 30; 1456 + lastKnownFileType = sourcecode.c.h; 1457 + path = CAMutex.h; 1458 + sourceTree = "<group>"; 1459 + }; 1460 + B6D5256805B479C40077A2BA = { 1461 + isa = PBXFileReference; 1462 + fileEncoding = 30; 1463 + lastKnownFileType = sourcecode.cpp.cpp; 1464 + path = CAGuard.cpp; 1465 + sourceTree = "<group>"; 1466 + }; 1467 + B6D5256905B479C40077A2BA = { 1468 + isa = PBXFileReference; 1469 + fileEncoding = 30; 1470 + lastKnownFileType = sourcecode.c.h; 1471 + path = CAGuard.h; 1472 + sourceTree = "<group>"; 1473 + }; 1474 + B6D5256C05B479F50077A2BA = { 1475 + isa = PBXFileReference; 1476 + fileEncoding = 30; 1477 + lastKnownFileType = sourcecode.cpp.cpp; 1478 + path = CAChannelMapper.cpp; 1479 + sourceTree = "<group>"; 1480 + }; 1481 + B6D5256D05B479F50077A2BA = { 1482 + isa = PBXFileReference; 1483 + fileEncoding = 30; 1484 + lastKnownFileType = sourcecode.c.h; 1485 + path = CAChannelMapper.h; 1486 + sourceTree = "<group>"; 1487 + }; 1488 + B6D5257005B47A140077A2BA = { 1489 + isa = PBXFileReference; 1490 + lastKnownFileType = wrapper.framework; 1491 + name = AudioUnit.framework; 1492 + path = /System/Library/Frameworks/AudioUnit.framework; 1493 + sourceTree = "<absolute>"; 1494 + }; 1495 + B6D5257905B47A5C0077A2BA = { 1496 + isa = PBXFileReference; 1497 + fileEncoding = 30; 1498 + lastKnownFileType = sourcecode.cpp.cpp; 1499 + path = CABufferQueue.cpp; 1500 + sourceTree = "<group>"; 1501 + }; 1502 + B6D5257A05B47A5C0077A2BA = { 1503 + isa = PBXFileReference; 1504 + fileEncoding = 30; 1505 + lastKnownFileType = sourcecode.c.h; 1506 + path = CABufferQueue.h; 1507 + sourceTree = "<group>"; 1508 + }; 1509 + B6D5258605B47AB70077A2BA = { 1510 + isa = PBXFileReference; 1511 + fileEncoding = 30; 1512 + lastKnownFileType = sourcecode.cpp.cpp; 1513 + path = CAComponent.cpp; 1514 + sourceTree = "<group>"; 1515 + }; 1516 + B6D5258705B47AB70077A2BA = { 1517 + isa = PBXFileReference; 1518 + fileEncoding = 30; 1519 + lastKnownFileType = sourcecode.c.h; 1520 + path = CAComponent.h; 1521 + sourceTree = "<group>"; 1522 + }; 1523 + B6D5259005B47AEB0077A2BA = { 1524 + isa = PBXFileReference; 1525 + fileEncoding = 30; 1526 + lastKnownFileType = sourcecode.cpp.cpp; 1527 + path = CAPThread.cpp; 1528 + sourceTree = "<group>"; 1529 + }; 1530 + B6D5259105B47AEB0077A2BA = { 1531 + isa = PBXFileReference; 1532 + fileEncoding = 30; 1533 + lastKnownFileType = sourcecode.c.h; 1534 + path = CAPThread.h; 1535 + sourceTree = "<group>"; 1536 + }; 1537 + B6D5259405B47B050077A2BA = { 1538 + isa = PBXFileReference; 1539 + fileEncoding = 30; 1540 + lastKnownFileType = sourcecode.cpp.cpp; 1541 + path = CAComponentDescription.cpp; 1542 + sourceTree = "<group>"; 1543 + }; 1544 + B6D5259505B47B050077A2BA = { 1545 + isa = PBXFileReference; 1546 + fileEncoding = 30; 1547 + lastKnownFileType = sourcecode.c.h; 1548 + path = CAComponentDescription.h; 1549 + sourceTree = "<group>"; 1550 + }; 1551 + B6D5259F05B47B580077A2BA = { 1552 + isa = PBXFileReference; 1553 + fileEncoding = 30; 1554 + lastKnownFileType = sourcecode.cpp.cpp; 1555 + path = afrecord.cpp; 1556 + sourceTree = "<group>"; 1557 + }; 1558 + B6D52FED05B47C070077A2BA = { 1559 + isa = PBXFileReference; 1560 + lastKnownFileType = wrapper.framework; 1561 + name = CoreAudio.framework; 1562 + path = /System/Library/Frameworks/CoreAudio.framework; 1563 + sourceTree = "<absolute>"; 1564 + }; 1565 + B6D5300905B47DBE0077A2BA = { 1566 + isa = PBXFileReference; 1567 + lastKnownFileType = text.rtf; 1568 + path = ReadMe.rtf; 1569 + sourceTree = "<group>"; 1570 + }; 1571 + B6D5300A05B4817A0077A2BA = { 1572 + isa = PBXFileReference; 1573 + fileEncoding = 30; 1574 + lastKnownFileType = sourcecode.cpp.cpp; 1575 + path = audioformats.cpp; 1576 + sourceTree = "<group>"; 1577 + }; 1578 + B6D5301805B4822C0077A2BA = { 1579 + isa = PBXFileReference; 1580 + lastKnownFileType = text.rtf; 1581 + path = ReadMe.rtf; 1582 + sourceTree = "<group>"; 1583 + }; 1584 + /* End PBXFileReference section */ 1585 + 1586 + /* Begin PBXFrameworksBuildPhase section */ 1587 + 91C82D6A05CFF8B20042A20D = { 1588 + isa = PBXFrameworksBuildPhase; 1589 + buildActionMask = 2147483647; 1590 + files = ( 1591 + 91C82D6B05CFF8B20042A20D, 1592 + 91C82D6C05CFF8B20042A20D, 1593 + 91C82D6D05CFF8B20042A20D, 1594 + ); 1595 + runOnlyForDeploymentPostprocessing = 0; 1596 + }; 1597 + 91C82D8305CFF8B20042A20D = { 1598 + isa = PBXFrameworksBuildPhase; 1599 + buildActionMask = 2147483647; 1600 + files = ( 1601 + 91C82D8405CFF8B20042A20D, 1602 + 91C82D8505CFF8B20042A20D, 1603 + ); 1604 + runOnlyForDeploymentPostprocessing = 0; 1605 + }; 1606 + 91C82DB105CFF8B20042A20D = { 1607 + isa = PBXFrameworksBuildPhase; 1608 + buildActionMask = 2147483647; 1609 + files = ( 1610 + 91C82DB205CFF8B20042A20D, 1611 + 91C82DB305CFF8B20042A20D, 1612 + 91C82DB405CFF8B20042A20D, 1613 + ); 1614 + runOnlyForDeploymentPostprocessing = 0; 1615 + }; 1616 + 91C82DD605CFF8B30042A20D = { 1617 + isa = PBXFrameworksBuildPhase; 1618 + buildActionMask = 2147483647; 1619 + files = ( 1620 + 91C82DD705CFF8B30042A20D, 1621 + 91C82DD805CFF8B30042A20D, 1622 + 91C82DD905CFF8B30042A20D, 1623 + 91C82DDA05CFF8B30042A20D, 1624 + ); 1625 + runOnlyForDeploymentPostprocessing = 0; 1626 + }; 1627 + 91C82DE505CFF8B30042A20D = { 1628 + isa = PBXFrameworksBuildPhase; 1629 + buildActionMask = 2147483647; 1630 + files = ( 1631 + 91C82DE605CFF8B30042A20D, 1632 + 91C82DE705CFF8B30042A20D, 1633 + ); 1634 + runOnlyForDeploymentPostprocessing = 0; 1635 + }; 1636 + A929CDCD069E34840010B9C5 = { 1637 + isa = PBXFrameworksBuildPhase; 1638 + buildActionMask = 2147483647; 1639 + files = ( 1640 + A929CDCE069E34840010B9C5, 1641 + A929CDCF069E34840010B9C5, 1642 + A929CDD0069E34840010B9C5, 1643 + A929CDFB069E35CF0010B9C5, 1644 + ); 1645 + runOnlyForDeploymentPostprocessing = 0; 1646 + }; 1647 + A9F41D3908F4B00200A2BC1C = { 1648 + isa = PBXFrameworksBuildPhase; 1649 + buildActionMask = 2147483647; 1650 + files = ( 1651 + A9F41D3A08F4B00200A2BC1C, 1652 + A9F41D3B08F4B00200A2BC1C, 1653 + A9F41D3C08F4B00200A2BC1C, 1654 + A9F41D3D08F4B00200A2BC1C, 1655 + ); 1656 + runOnlyForDeploymentPostprocessing = 0; 1657 + }; 1658 + B6A359E30667D15B00A3A2BB = { 1659 + isa = PBXFrameworksBuildPhase; 1660 + buildActionMask = 2147483647; 1661 + files = ( 1662 + B6A359EB0667D1DB00A3A2BB, 1663 + B6A359EC0667D1DD00A3A2BB, 1664 + ); 1665 + runOnlyForDeploymentPostprocessing = 0; 1666 + }; 1667 + /* End PBXFrameworksBuildPhase section */ 1668 + 1669 + /* Begin PBXGroup section */ 1670 + B6B9FA2805B38B09007FB890 = { 1671 + isa = PBXGroup; 1672 + children = ( 1673 + B6D5203605B38D6C0077A2BA, 1674 + B6D5203805B38D870077A2BA, 1675 + B6D5204605B38DD60077A2BA, 1676 + B6D5205C05B38ECA0077A2BA, 1677 + B6D5204105B38D940077A2BA, 1678 + ); 1679 + sourceTree = "<group>"; 1680 + }; 1681 + B6D5203605B38D6C0077A2BA = { 1682 + isa = PBXGroup; 1683 + children = ( 1684 + B6D5301805B4822C0077A2BA, 1685 + 91FF724F0730614D008E851B, 1686 + B6D5203705B38D750077A2BA, 1687 + 91FF724D07306039008E851B, 1688 + 918B313006069285000691DF, 1689 + B6D5253505B38FEB0077A2BA, 1690 + B6D5254D05B390A20077A2BA, 1691 + B6D5259F05B47B580077A2BA, 1692 + B6D5300A05B4817A0077A2BA, 1693 + A929CDD4069E34990010B9C5, 1694 + A9F41D4E08F4B0A100A2BC1C, 1695 + ); 1696 + name = Source; 1697 + sourceTree = "<group>"; 1698 + }; 1699 + B6D5203805B38D870077A2BA = { 1700 + isa = PBXGroup; 1701 + children = ( 1702 + 9186C799072033F000D7CA7A, 1703 + 9186C79A072033F000D7CA7A, 1704 + 91AFB5DF071C95CF004D7421, 1705 + 91AFB5E0071C95CF004D7421, 1706 + B6D5205405B38E750077A2BA, 1707 + B6D5205505B38E750077A2BA, 1708 + B6D5203905B38D870077A2BA, 1709 + B6D5203A05B38D870077A2BA, 1710 + 91F7F37605C5DC6B00998F2F, 1711 + 91F7F37705C5DC6B00998F2F, 1712 + ); 1713 + path = Utility; 1714 + sourceTree = "<group>"; 1715 + }; 1716 + B6D5204105B38D940077A2BA = { 1717 + isa = PBXGroup; 1718 + children = ( 1719 + 91C82D7005CFF8B20042A20D, 1720 + 91C82D8805CFF8B20042A20D, 1721 + 91C82DB705CFF8B30042A20D, 1722 + 91C82DDD05CFF8B30042A20D, 1723 + 91C82DEA05CFF8B30042A20D, 1724 + B6A359E50667D15B00A3A2BB, 1725 + A929CDD2069E34840010B9C5, 1726 + A9F41D4508F4B00200A2BC1C, 1727 + ); 1728 + name = Products; 1729 + sourceTree = "<group>"; 1730 + }; 1731 + B6D5204605B38DD60077A2BA = { 1732 + isa = PBXGroup; 1733 + children = ( 1734 + A9E52CE008E1EB0C00A2A9EA, 1735 + 9143EEEB06876BAA00CA9919, 1736 + 9143EEB406876B9300CA9919, 1737 + 9143EEB506876B9300CA9919, 1738 + 9143EB7006876B5500CA9919, 1739 + 9143EB7106876B5500CA9919, 1740 + B6D5204705B38E2F0077A2BA, 1741 + 9137C6000655A6EB00A1A3A2, 1742 + 9137C6010655A6EB00A1A3A2, 1743 + A929CDF1069E358A0010B9C5, 1744 + A929CDF2069E358A0010B9C5, 1745 + 91B0CA2406640DFD00B57457, 1746 + 91B0CA2506640DFD00B57457, 1747 + 9137C6200655A76F00A1A3A2, 1748 + 9137C6210655A76F00A1A3A2, 1749 + B6D5206B05B38F3A0077A2BA, 1750 + B6D5206C05B38F3A0077A2BA, 1751 + B6D5206D05B38F3A0077A2BA, 1752 + B6D5207205B38F4E0077A2BA, 1753 + B6D5207305B38F4E0077A2BA, 1754 + B6D5258605B47AB70077A2BA, 1755 + B6D5258705B47AB70077A2BA, 1756 + B6D5259405B47B050077A2BA, 1757 + B6D5259505B47B050077A2BA, 1758 + B6D5256805B479C40077A2BA, 1759 + B6D5256905B479C40077A2BA, 1760 + B6D5206305B38F100077A2BA, 1761 + B6D5206405B38F100077A2BA, 1762 + B6D5256405B4799F0077A2BA, 1763 + B6D5256505B4799F0077A2BA, 1764 + B6D5259005B47AEB0077A2BA, 1765 + B6D5259105B47AEB0077A2BA, 1766 + B6D5206705B38F280077A2BA, 1767 + B6D5206805B38F280077A2BA, 1768 + B6D5204A05B38E2F0077A2BA, 1769 + B6D5204B05B38E2F0077A2BA, 1770 + ); 1771 + name = PublicUtility; 1772 + path = /Developer/Examples/CoreAudio/PublicUtility; 1773 + sourceTree = "<absolute>"; 1774 + }; 1775 + B6D5204705B38E2F0077A2BA = { 1776 + isa = PBXGroup; 1777 + children = ( 1778 + B6D5300905B47DBE0077A2BA, 1779 + 9138521007138D8100E6E381, 1780 + 9138521107138D8100E6E381, 1781 + B6D5255405B479680077A2BA, 1782 + B6D5255505B479680077A2BA, 1783 + B6D5255605B479680077A2BA, 1784 + B6D5255705B479680077A2BA, 1785 + B6D5255805B479680077A2BA, 1786 + B6D5255905B479680077A2BA, 1787 + B6D5257905B47A5C0077A2BA, 1788 + B6D5257A05B47A5C0077A2BA, 1789 + B6D5256C05B479F50077A2BA, 1790 + B6D5256D05B479F50077A2BA, 1791 + B6D5255A05B479680077A2BA, 1792 + B6D5255B05B479680077A2BA, 1793 + ); 1794 + path = "AudioFile-new"; 1795 + sourceTree = "<group>"; 1796 + }; 1797 + B6D5205C05B38ECA0077A2BA = { 1798 + isa = PBXGroup; 1799 + children = ( 1800 + B6D5205D05B38EE80077A2BA, 1801 + B6D5257005B47A140077A2BA, 1802 + B6D52FED05B47C070077A2BA, 1803 + B6D5205E05B38EE80077A2BA, 1804 + B6D5206105B38EFE0077A2BA, 1805 + ); 1806 + name = Frameworks; 1807 + sourceTree = "<group>"; 1808 + }; 1809 + /* End PBXGroup section */ 1810 + 1811 + /* Begin PBXHeadersBuildPhase section */ 1812 + 91C82D5405CFF8B20042A20D = { 1813 + isa = PBXHeadersBuildPhase; 1814 + buildActionMask = 2147483647; 1815 + files = ( 1816 + 91C82D5505CFF8B20042A20D, 1817 + 91C82D5705CFF8B20042A20D, 1818 + 91C82D5805CFF8B20042A20D, 1819 + 91C82D5A05CFF8B20042A20D, 1820 + 91C82D5B05CFF8B20042A20D, 1821 + 91C82D5C05CFF8B20042A20D, 1822 + 91C82D5D05CFF8B20042A20D, 1823 + 91B0CAC306641DEB00B57457, 1824 + 9143EEB606876B9300CA9919, 1825 + 9143EEB706876B9300CA9919, 1826 + 9143EEEC06876BAA00CA9919, 1827 + 9138521307138D8100E6E381, 1828 + 91AFB5E7071C988C004D7421, 1829 + 9186C79E0720343700D7CA7A, 1830 + 91FF724E07306039008E851B, 1831 + A9E52CE108E1EB0C00A2A9EA, 1832 + ); 1833 + runOnlyForDeploymentPostprocessing = 0; 1834 + }; 1835 + 91C82D7305CFF8B20042A20D = { 1836 + isa = PBXHeadersBuildPhase; 1837 + buildActionMask = 2147483647; 1838 + files = ( 1839 + 91C82D7505CFF8B20042A20D, 1840 + 91C82D7605CFF8B20042A20D, 1841 + 91C82D7705CFF8B20042A20D, 1842 + 91C82D7805CFF8B20042A20D, 1843 + 91C82D7905CFF8B20042A20D, 1844 + 9186C79B072033F000D7CA7A, 1845 + 9186C7B40720363700D7CA7A, 1846 + A9E52CE208E1EB0C00A2A9EA, 1847 + ); 1848 + runOnlyForDeploymentPostprocessing = 0; 1849 + }; 1850 + 91C82D8B05CFF8B20042A20D = { 1851 + isa = PBXHeadersBuildPhase; 1852 + buildActionMask = 2147483647; 1853 + files = ( 1854 + 91C82D8C05CFF8B20042A20D, 1855 + 91C82D8D05CFF8B20042A20D, 1856 + 91C82D8E05CFF8B20042A20D, 1857 + 91C82D8F05CFF8B20042A20D, 1858 + 91C82D9005CFF8B20042A20D, 1859 + 91C82D9105CFF8B20042A20D, 1860 + 91C82D9305CFF8B20042A20D, 1861 + 91C82D9405CFF8B20042A20D, 1862 + 91C82D9505CFF8B20042A20D, 1863 + 91C82D9705CFF8B20042A20D, 1864 + 91C82D9805CFF8B20042A20D, 1865 + 91C82D9905CFF8B20042A20D, 1866 + 91C82D9A05CFF8B20042A20D, 1867 + 91C82D9B05CFF8B20042A20D, 1868 + 91C82D9C05CFF8B20042A20D, 1869 + 9137C6030655A6EB00A1A3A2, 1870 + 9137C6230655A76F00A1A3A2, 1871 + 9186C7BA0720365A00D7CA7A, 1872 + A9E52CE308E1EB0C00A2A9EA, 1873 + ); 1874 + runOnlyForDeploymentPostprocessing = 0; 1875 + }; 1876 + 91C82DBA05CFF8B30042A20D = { 1877 + isa = PBXHeadersBuildPhase; 1878 + buildActionMask = 2147483647; 1879 + files = ( 1880 + 91C82DBC05CFF8B30042A20D, 1881 + 91C82DBD05CFF8B30042A20D, 1882 + 91C82DBE05CFF8B30042A20D, 1883 + 91C82DBF05CFF8B30042A20D, 1884 + 91C82DC005CFF8B30042A20D, 1885 + 91C82DC105CFF8B30042A20D, 1886 + 91C82DC205CFF8B30042A20D, 1887 + 91C82DC305CFF8B30042A20D, 1888 + 91C82DC405CFF8B30042A20D, 1889 + 91C82DC505CFF8B30042A20D, 1890 + 91C82DC605CFF8B30042A20D, 1891 + 91B0CA2706640DFD00B57457, 1892 + 91AFB5E9071C9893004D7421, 1893 + 9186C7A00720358500D7CA7A, 1894 + 9186C7BD0720368B00D7CA7A, 1895 + A9E52CE408E1EB0C00A2A9EA, 1896 + ); 1897 + runOnlyForDeploymentPostprocessing = 0; 1898 + }; 1899 + 91C82DE005CFF8B30042A20D = { 1900 + isa = PBXHeadersBuildPhase; 1901 + buildActionMask = 2147483647; 1902 + files = ( 1903 + 9137C6050655A75000A1A3A2, 1904 + 91B0CAC406641E2500B57457, 1905 + 91AFB730071CB5F0004D7421, 1906 + A9E52CE508E1EB0C00A2A9EA, 1907 + ); 1908 + runOnlyForDeploymentPostprocessing = 0; 1909 + }; 1910 + A929CDB7069E34840010B9C5 = { 1911 + isa = PBXHeadersBuildPhase; 1912 + buildActionMask = 2147483647; 1913 + files = ( 1914 + A929CDBA069E34840010B9C5, 1915 + A929CDBC069E34840010B9C5, 1916 + A929CDBD069E34840010B9C5, 1917 + A929CDBE069E34840010B9C5, 1918 + A929CDD7069E34B60010B9C5, 1919 + A929CDD8069E34C40010B9C5, 1920 + A929CDF4069E358A0010B9C5, 1921 + A929CE12069E35DD0010B9C5, 1922 + A929CE24069E35E10010B9C5, 1923 + A929CE30069E35E30010B9C5, 1924 + 9186C7C80720378800D7CA7A, 1925 + 9186C7CA0720378E00D7CA7A, 1926 + A9E52CE708E1EB0C00A2A9EA, 1927 + 910D345209057CCE00A0EDE6, 1928 + ); 1929 + runOnlyForDeploymentPostprocessing = 0; 1930 + }; 1931 + A9F41D1C08F4B00200A2BC1C = { 1932 + isa = PBXHeadersBuildPhase; 1933 + buildActionMask = 2147483647; 1934 + files = ( 1935 + A9F41D1D08F4B00200A2BC1C, 1936 + A9F41D1E08F4B00200A2BC1C, 1937 + A9F41D1F08F4B00200A2BC1C, 1938 + A9F41D2008F4B00200A2BC1C, 1939 + A9F41D2108F4B00200A2BC1C, 1940 + A9F41D2208F4B00200A2BC1C, 1941 + A9F41D2308F4B00200A2BC1C, 1942 + A9F41D2408F4B00200A2BC1C, 1943 + A9F41D2508F4B00200A2BC1C, 1944 + A9F41D2608F4B00200A2BC1C, 1945 + A9F41D2708F4B00200A2BC1C, 1946 + A9F41D2808F4B00200A2BC1C, 1947 + A9F41D2908F4B00200A2BC1C, 1948 + 910D345409057CD400A0EDE6, 1949 + ); 1950 + runOnlyForDeploymentPostprocessing = 0; 1951 + }; 1952 + B6A359E00667D15B00A3A2BB = { 1953 + isa = PBXHeadersBuildPhase; 1954 + buildActionMask = 2147483647; 1955 + files = ( 1956 + A9E52CE608E1EB0C00A2A9EA, 1957 + ); 1958 + runOnlyForDeploymentPostprocessing = 0; 1959 + }; 1960 + /* End PBXHeadersBuildPhase section */ 1961 + 1962 + /* Begin PBXNativeTarget section */ 1963 + 91C82D5305CFF8B20042A20D = { 1964 + isa = PBXNativeTarget; 1965 + buildConfigurationList = A9E883810874A59B00B2DFE8; 1966 + buildPhases = ( 1967 + 91C82D5405CFF8B20042A20D, 1968 + 91C82D5E05CFF8B20042A20D, 1969 + 91C82D6A05CFF8B20042A20D, 1970 + 91C82D6E05CFF8B20042A20D, 1971 + ); 1972 + buildRules = ( 1973 + ); 1974 + buildSettings = { 1975 + OTHER_CFLAGS = ""; 1976 + OTHER_LDFLAGS = ""; 1977 + OTHER_REZFLAGS = ""; 1978 + PRODUCT_NAME = afconvert; 1979 + REZ_EXECUTABLE = YES; 1980 + SECTORDER_FLAGS = ""; 1981 + WARNING_CFLAGS = ( 1982 + "-Wmost", 1983 + "-Wno-four-char-constants", 1984 + "-Wno-unknown-pragmas", 1985 + ); 1986 + }; 1987 + dependencies = ( 1988 + ); 1989 + name = afconvert; 1990 + productInstallPath = /usr/local/bin; 1991 + productName = Untitled; 1992 + productReference = 91C82D7005CFF8B20042A20D; 1993 + productType = "com.apple.product-type.tool"; 1994 + }; 1995 + 91C82D7205CFF8B20042A20D = { 1996 + isa = PBXNativeTarget; 1997 + buildConfigurationList = A9E883870874A59B00B2DFE8; 1998 + buildPhases = ( 1999 + 91C82D7305CFF8B20042A20D, 2000 + 91C82D7A05CFF8B20042A20D, 2001 + 91C82D8305CFF8B20042A20D, 2002 + 91C82D8605CFF8B20042A20D, 2003 + ); 2004 + buildRules = ( 2005 + ); 2006 + buildSettings = { 2007 + OTHER_CFLAGS = ""; 2008 + OTHER_LDFLAGS = ""; 2009 + OTHER_REZFLAGS = ""; 2010 + PRODUCT_NAME = afinterleave; 2011 + REZ_EXECUTABLE = YES; 2012 + SECTORDER_FLAGS = ""; 2013 + WARNING_CFLAGS = ( 2014 + "-Wmost", 2015 + "-Wno-four-char-constants", 2016 + "-Wno-unknown-pragmas", 2017 + ); 2018 + }; 2019 + dependencies = ( 2020 + ); 2021 + name = afinterleave; 2022 + productInstallPath = /usr/local/bin; 2023 + productName = afinterleave; 2024 + productReference = 91C82D8805CFF8B20042A20D; 2025 + productType = "com.apple.product-type.tool"; 2026 + }; 2027 + 91C82D8A05CFF8B20042A20D = { 2028 + isa = PBXNativeTarget; 2029 + buildConfigurationList = A9E8838D0874A59B00B2DFE8; 2030 + buildPhases = ( 2031 + 91C82D8B05CFF8B20042A20D, 2032 + 91C82D9D05CFF8B20042A20D, 2033 + 91C82DB105CFF8B20042A20D, 2034 + 91C82DB505CFF8B20042A20D, 2035 + ); 2036 + buildRules = ( 2037 + ); 2038 + buildSettings = { 2039 + LIBRARY_SEARCH_PATHS = ""; 2040 + OTHER_CFLAGS = ""; 2041 + OTHER_LDFLAGS = ""; 2042 + OTHER_REZFLAGS = ""; 2043 + PRODUCT_NAME = afplay; 2044 + REZ_EXECUTABLE = YES; 2045 + SECTORDER_FLAGS = ""; 2046 + WARNING_CFLAGS = ( 2047 + "-Wmost", 2048 + "-Wno-four-char-constants", 2049 + "-Wno-unknown-pragmas", 2050 + ); 2051 + }; 2052 + dependencies = ( 2053 + ); 2054 + name = afplay; 2055 + productInstallPath = /usr/local/bin; 2056 + productName = afplay; 2057 + productReference = 91C82DB705CFF8B30042A20D; 2058 + productType = "com.apple.product-type.tool"; 2059 + }; 2060 + 91C82DB905CFF8B30042A20D = { 2061 + isa = PBXNativeTarget; 2062 + buildConfigurationList = A9E883930874A59B00B2DFE8; 2063 + buildPhases = ( 2064 + 91C82DBA05CFF8B30042A20D, 2065 + 91C82DC705CFF8B30042A20D, 2066 + 91C82DD605CFF8B30042A20D, 2067 + 91C82DDB05CFF8B30042A20D, 2068 + ); 2069 + buildRules = ( 2070 + ); 2071 + buildSettings = { 2072 + OTHER_CFLAGS = ""; 2073 + OTHER_LDFLAGS = ""; 2074 + OTHER_REZFLAGS = ""; 2075 + PRODUCT_NAME = afrecord; 2076 + REZ_EXECUTABLE = YES; 2077 + SECTORDER_FLAGS = ""; 2078 + WARNING_CFLAGS = ( 2079 + "-Wmost", 2080 + "-Wno-four-char-constants", 2081 + "-Wno-unknown-pragmas", 2082 + ); 2083 + }; 2084 + dependencies = ( 2085 + ); 2086 + name = afrecord; 2087 + productInstallPath = /usr/local/bin; 2088 + productName = afrecord; 2089 + productReference = 91C82DDD05CFF8B30042A20D; 2090 + productType = "com.apple.product-type.tool"; 2091 + }; 2092 + 91C82DDF05CFF8B30042A20D = { 2093 + isa = PBXNativeTarget; 2094 + buildConfigurationList = A9E883990874A59B00B2DFE8; 2095 + buildPhases = ( 2096 + 91C82DE005CFF8B30042A20D, 2097 + 91C82DE205CFF8B30042A20D, 2098 + 91C82DE505CFF8B30042A20D, 2099 + 91C82DE805CFF8B30042A20D, 2100 + ); 2101 + buildRules = ( 2102 + ); 2103 + buildSettings = { 2104 + OTHER_CFLAGS = ""; 2105 + OTHER_LDFLAGS = ""; 2106 + OTHER_REZFLAGS = ""; 2107 + PRODUCT_NAME = audioformats; 2108 + REZ_EXECUTABLE = YES; 2109 + SECTORDER_FLAGS = ""; 2110 + WARNING_CFLAGS = ( 2111 + "-Wmost", 2112 + "-Wno-four-char-constants", 2113 + "-Wno-unknown-pragmas", 2114 + ); 2115 + }; 2116 + dependencies = ( 2117 + ); 2118 + name = audioformats; 2119 + productInstallPath = /usr/local/bin; 2120 + productName = audioformats; 2121 + productReference = 91C82DEA05CFF8B30042A20D; 2122 + productType = "com.apple.product-type.tool"; 2123 + }; 2124 + A929CDB6069E34840010B9C5 = { 2125 + isa = PBXNativeTarget; 2126 + buildConfigurationList = A9E883B10874A59B00B2DFE8; 2127 + buildPhases = ( 2128 + A929CDB7069E34840010B9C5, 2129 + A929CDC1069E34840010B9C5, 2130 + A929CDCD069E34840010B9C5, 2131 + A929CDD1069E34840010B9C5, 2132 + ); 2133 + buildRules = ( 2134 + ); 2135 + buildSettings = { 2136 + FRAMEWORK_SEARCH_PATHS = ""; 2137 + OTHER_CFLAGS = ""; 2138 + OTHER_LDFLAGS = ""; 2139 + OTHER_REZFLAGS = ""; 2140 + PRODUCT_NAME = auprocess; 2141 + REZ_EXECUTABLE = YES; 2142 + SECTORDER_FLAGS = ""; 2143 + WARNING_CFLAGS = ( 2144 + "-Wmost", 2145 + "-Wno-four-char-constants", 2146 + "-Wno-unknown-pragmas", 2147 + ); 2148 + }; 2149 + dependencies = ( 2150 + ); 2151 + name = auprocess; 2152 + productInstallPath = /usr/local/bin; 2153 + productName = Untitled; 2154 + productReference = A929CDD2069E34840010B9C5; 2155 + productType = "com.apple.product-type.tool"; 2156 + }; 2157 + A9F41D1B08F4B00200A2BC1C = { 2158 + isa = PBXNativeTarget; 2159 + buildConfigurationList = A9F41D3F08F4B00200A2BC1C; 2160 + buildPhases = ( 2161 + A9F41D1C08F4B00200A2BC1C, 2162 + A9F41D2A08F4B00200A2BC1C, 2163 + A9F41D3908F4B00200A2BC1C, 2164 + A9F41D3E08F4B00200A2BC1C, 2165 + ); 2166 + buildRules = ( 2167 + ); 2168 + buildSettings = { 2169 + FRAMEWORK_SEARCH_PATHS = ""; 2170 + OTHER_CFLAGS = ""; 2171 + OTHER_LDFLAGS = ""; 2172 + OTHER_REZFLAGS = ""; 2173 + PRODUCT_NAME = auprocess; 2174 + REZ_EXECUTABLE = YES; 2175 + SECTORDER_FLAGS = ""; 2176 + WARNING_CFLAGS = ( 2177 + "-Wmost", 2178 + "-Wno-four-char-constants", 2179 + "-Wno-unknown-pragmas", 2180 + ); 2181 + }; 2182 + dependencies = ( 2183 + ); 2184 + name = auprofile; 2185 + productInstallPath = /usr/local/bin; 2186 + productName = Untitled; 2187 + productReference = A9F41D4508F4B00200A2BC1C; 2188 + productType = "com.apple.product-type.tool"; 2189 + }; 2190 + B6A359E40667D15B00A3A2BB = { 2191 + isa = PBXNativeTarget; 2192 + buildConfigurationList = A9E883A50874A59B00B2DFE8; 2193 + buildPhases = ( 2194 + B6A359E00667D15B00A3A2BB, 2195 + B6A359E10667D15B00A3A2BB, 2196 + B6A359E20667D15B00A3A2BB, 2197 + B6A359E30667D15B00A3A2BB, 2198 + ); 2199 + buildRules = ( 2200 + ); 2201 + buildSettings = { 2202 + FRAMEWORK_SEARCH_PATHS = ""; 2203 + GCC_PRECOMPILE_PREFIX_HEADER = NO; 2204 + GCC_PREFIX_HEADER = ""; 2205 + GCC_WARN_FOUR_CHARACTER_CONSTANTS = NO; 2206 + GCC_WARN_UNKNOWN_PRAGMAS = NO; 2207 + INSTALL_PATH = /usr/local/bin; 2208 + OTHER_CFLAGS = ""; 2209 + OTHER_LDFLAGS = ""; 2210 + OTHER_REZFLAGS = ""; 2211 + PRODUCT_NAME = afinfo; 2212 + REZ_EXECUTABLE = YES; 2213 + SECTORDER_FLAGS = ""; 2214 + WARNING_CFLAGS = "-Wmost"; 2215 + }; 2216 + dependencies = ( 2217 + ); 2218 + name = afinfo; 2219 + productName = afinfo; 2220 + productReference = B6A359E50667D15B00A3A2BB; 2221 + productType = "com.apple.product-type.tool"; 2222 + }; 2223 + /* End PBXNativeTarget section */ 2224 + 2225 + /* Begin PBXProject section */ 2226 + B6B9FA2C05B38B09007FB890 = { 2227 + isa = PBXProject; 2228 + buildConfigurationList = A9E883B70874A59B00B2DFE8; 2229 + buildSettings = { 2230 + }; 2231 + buildStyles = ( 2232 + B6B9FA2A05B38B09007FB890, 2233 + 9171C2B107B060480067EEDA, 2234 + B6B9FA2B05B38B09007FB890, 2235 + 9171C2B207B0605F0067EEDA, 2236 + ); 2237 + hasScannedForEncodings = 1; 2238 + mainGroup = B6B9FA2805B38B09007FB890; 2239 + productRefGroup = B6D5204105B38D940077A2BA; 2240 + projectDirPath = ""; 2241 + targets = ( 2242 + 91C82D4C05CFF8B20042A20D, 2243 + 91C82D5305CFF8B20042A20D, 2244 + 91C82D7205CFF8B20042A20D, 2245 + 91C82D8A05CFF8B20042A20D, 2246 + 91C82DB905CFF8B30042A20D, 2247 + 91C82DDF05CFF8B30042A20D, 2248 + B6A359E40667D15B00A3A2BB, 2249 + A929CDB6069E34840010B9C5, 2250 + A9F41D1B08F4B00200A2BC1C, 2251 + ); 2252 + }; 2253 + /* End PBXProject section */ 2254 + 2255 + /* Begin PBXRezBuildPhase section */ 2256 + 91C82D6E05CFF8B20042A20D = { 2257 + isa = PBXRezBuildPhase; 2258 + buildActionMask = 2147483647; 2259 + files = ( 2260 + ); 2261 + runOnlyForDeploymentPostprocessing = 0; 2262 + }; 2263 + 91C82D8605CFF8B20042A20D = { 2264 + isa = PBXRezBuildPhase; 2265 + buildActionMask = 2147483647; 2266 + files = ( 2267 + ); 2268 + runOnlyForDeploymentPostprocessing = 0; 2269 + }; 2270 + 91C82DB505CFF8B20042A20D = { 2271 + isa = PBXRezBuildPhase; 2272 + buildActionMask = 2147483647; 2273 + files = ( 2274 + ); 2275 + runOnlyForDeploymentPostprocessing = 0; 2276 + }; 2277 + 91C82DDB05CFF8B30042A20D = { 2278 + isa = PBXRezBuildPhase; 2279 + buildActionMask = 2147483647; 2280 + files = ( 2281 + ); 2282 + runOnlyForDeploymentPostprocessing = 0; 2283 + }; 2284 + 91C82DE805CFF8B30042A20D = { 2285 + isa = PBXRezBuildPhase; 2286 + buildActionMask = 2147483647; 2287 + files = ( 2288 + ); 2289 + runOnlyForDeploymentPostprocessing = 0; 2290 + }; 2291 + A929CDD1069E34840010B9C5 = { 2292 + isa = PBXRezBuildPhase; 2293 + buildActionMask = 2147483647; 2294 + files = ( 2295 + ); 2296 + runOnlyForDeploymentPostprocessing = 0; 2297 + }; 2298 + A9F41D3E08F4B00200A2BC1C = { 2299 + isa = PBXRezBuildPhase; 2300 + buildActionMask = 2147483647; 2301 + files = ( 2302 + ); 2303 + runOnlyForDeploymentPostprocessing = 0; 2304 + }; 2305 + B6A359E20667D15B00A3A2BB = { 2306 + isa = PBXRezBuildPhase; 2307 + buildActionMask = 2147483647; 2308 + files = ( 2309 + ); 2310 + runOnlyForDeploymentPostprocessing = 0; 2311 + }; 2312 + /* End PBXRezBuildPhase section */ 2313 + 2314 + /* Begin PBXSourcesBuildPhase section */ 2315 + 91C82D5E05CFF8B20042A20D = { 2316 + isa = PBXSourcesBuildPhase; 2317 + buildActionMask = 2147483647; 2318 + files = ( 2319 + 91C82D5F05CFF8B20042A20D, 2320 + 91C82D6005CFF8B20042A20D, 2321 + 91C82D6205CFF8B20042A20D, 2322 + 91C82D6305CFF8B20042A20D, 2323 + 91C82D6505CFF8B20042A20D, 2324 + 91C82D6605CFF8B20042A20D, 2325 + 91C82D6705CFF8B20042A20D, 2326 + 91C82D6805CFF8B20042A20D, 2327 + 91C82D6905CFF8B20042A20D, 2328 + 91B0CAC206641DEB00B57457, 2329 + 9138521207138D8100E6E381, 2330 + 91AFB5E6071C988A004D7421, 2331 + 9186C79D0720343600D7CA7A, 2332 + 91FF72500730614D008E851B, 2333 + ); 2334 + runOnlyForDeploymentPostprocessing = 0; 2335 + }; 2336 + 91C82D7A05CFF8B20042A20D = { 2337 + isa = PBXSourcesBuildPhase; 2338 + buildActionMask = 2147483647; 2339 + files = ( 2340 + 91C82D7B05CFF8B20042A20D, 2341 + 91C82D7D05CFF8B20042A20D, 2342 + 91C82D7E05CFF8B20042A20D, 2343 + 91C82D7F05CFF8B20042A20D, 2344 + 91C82D8005CFF8B20042A20D, 2345 + 91C82D8105CFF8B20042A20D, 2346 + 91C82D8205CFF8B20042A20D, 2347 + 9186C79C072033F000D7CA7A, 2348 + 9186C7B30720363600D7CA7A, 2349 + ); 2350 + runOnlyForDeploymentPostprocessing = 0; 2351 + }; 2352 + 91C82D9D05CFF8B20042A20D = { 2353 + isa = PBXSourcesBuildPhase; 2354 + buildActionMask = 2147483647; 2355 + files = ( 2356 + 91C82D9E05CFF8B20042A20D, 2357 + 91C82D9F05CFF8B20042A20D, 2358 + 91C82DA005CFF8B20042A20D, 2359 + 91C82DA105CFF8B20042A20D, 2360 + 91C82DA205CFF8B20042A20D, 2361 + 91C82DA305CFF8B20042A20D, 2362 + 91C82DA405CFF8B20042A20D, 2363 + 91C82DA605CFF8B20042A20D, 2364 + 91C82DA705CFF8B20042A20D, 2365 + 91C82DA805CFF8B20042A20D, 2366 + 91C82DA905CFF8B20042A20D, 2367 + 91C82DAB05CFF8B20042A20D, 2368 + 91C82DAC05CFF8B20042A20D, 2369 + 91C82DAD05CFF8B20042A20D, 2370 + 91C82DAE05CFF8B20042A20D, 2371 + 91C82DAF05CFF8B20042A20D, 2372 + 91C82DB005CFF8B20042A20D, 2373 + 9137C6020655A6EB00A1A3A2, 2374 + 9137C6220655A76F00A1A3A2, 2375 + 9186C7B90720365900D7CA7A, 2376 + ); 2377 + runOnlyForDeploymentPostprocessing = 0; 2378 + }; 2379 + 91C82DC705CFF8B30042A20D = { 2380 + isa = PBXSourcesBuildPhase; 2381 + buildActionMask = 2147483647; 2382 + files = ( 2383 + 91C82DC805CFF8B30042A20D, 2384 + 91C82DCA05CFF8B30042A20D, 2385 + 91C82DCB05CFF8B30042A20D, 2386 + 91C82DCC05CFF8B30042A20D, 2387 + 91C82DCD05CFF8B30042A20D, 2388 + 91C82DCE05CFF8B30042A20D, 2389 + 91C82DCF05CFF8B30042A20D, 2390 + 91C82DD005CFF8B30042A20D, 2391 + 91C82DD105CFF8B30042A20D, 2392 + 91C82DD205CFF8B30042A20D, 2393 + 91C82DD305CFF8B30042A20D, 2394 + 91C82DD405CFF8B30042A20D, 2395 + 91C82DD505CFF8B30042A20D, 2396 + 91B0CA2606640DFD00B57457, 2397 + 91AFB5E8071C9892004D7421, 2398 + 9186C79F0720358400D7CA7A, 2399 + 9186C7BC0720368B00D7CA7A, 2400 + ); 2401 + runOnlyForDeploymentPostprocessing = 0; 2402 + }; 2403 + 91C82DE205CFF8B30042A20D = { 2404 + isa = PBXSourcesBuildPhase; 2405 + buildActionMask = 2147483647; 2406 + files = ( 2407 + 91C82DE305CFF8B30042A20D, 2408 + 9137C6040655A74F00A1A3A2, 2409 + 91E2D39806641E7800F19278, 2410 + 91AFB72F071CB5EF004D7421, 2411 + ); 2412 + runOnlyForDeploymentPostprocessing = 0; 2413 + }; 2414 + A929CDC1069E34840010B9C5 = { 2415 + isa = PBXSourcesBuildPhase; 2416 + buildActionMask = 2147483647; 2417 + files = ( 2418 + A929CDC5069E34840010B9C5, 2419 + A929CDC7069E34840010B9C5, 2420 + A929CDC8069E34840010B9C5, 2421 + A929CDC9069E34840010B9C5, 2422 + A929CDCA069E34840010B9C5, 2423 + A929CDD5069E34990010B9C5, 2424 + A929CDD6069E34B50010B9C5, 2425 + A929CDD9069E34C40010B9C5, 2426 + A929CDF3069E358A0010B9C5, 2427 + A929CE18069E35DD0010B9C5, 2428 + A929CE1E069E35E00010B9C5, 2429 + A929CE2A069E35E20010B9C5, 2430 + 9186C7C70720378800D7CA7A, 2431 + 9186C7C90720378D00D7CA7A, 2432 + 910D345109057CCE00A0EDE6, 2433 + ); 2434 + runOnlyForDeploymentPostprocessing = 0; 2435 + }; 2436 + A9F41D2A08F4B00200A2BC1C = { 2437 + isa = PBXSourcesBuildPhase; 2438 + buildActionMask = 2147483647; 2439 + files = ( 2440 + A9F41D2B08F4B00200A2BC1C, 2441 + A9F41D2C08F4B00200A2BC1C, 2442 + A9F41D2D08F4B00200A2BC1C, 2443 + A9F41D2E08F4B00200A2BC1C, 2444 + A9F41D2F08F4B00200A2BC1C, 2445 + A9F41D3108F4B00200A2BC1C, 2446 + A9F41D3208F4B00200A2BC1C, 2447 + A9F41D3308F4B00200A2BC1C, 2448 + A9F41D3408F4B00200A2BC1C, 2449 + A9F41D3508F4B00200A2BC1C, 2450 + A9F41D3608F4B00200A2BC1C, 2451 + A9F41D3708F4B00200A2BC1C, 2452 + A9F41D3808F4B00200A2BC1C, 2453 + A9F41D4F08F4B0A100A2BC1C, 2454 + 910D345309057CD300A0EDE6, 2455 + ); 2456 + runOnlyForDeploymentPostprocessing = 0; 2457 + }; 2458 + B6A359E10667D15B00A3A2BB = { 2459 + isa = PBXSourcesBuildPhase; 2460 + buildActionMask = 2147483647; 2461 + files = ( 2462 + B6A359E70667D1BE00A3A2BB, 2463 + B6A359EA0667D1D000A3A2BB, 2464 + ); 2465 + runOnlyForDeploymentPostprocessing = 0; 2466 + }; 2467 + /* End PBXSourcesBuildPhase section */ 2468 + 2469 + /* Begin PBXTargetDependency section */ 2470 + 91004357066E8609005A1EC3 = { 2471 + isa = PBXTargetDependency; 2472 + target = B6A359E40667D15B00A3A2BB; 2473 + targetProxy = 91004356066E8609005A1EC3; 2474 + }; 2475 + 915912E908F7230600A78EF3 = { 2476 + isa = PBXTargetDependency; 2477 + target = A9F41D1B08F4B00200A2BC1C; 2478 + targetProxy = 915912E808F7230600A78EF3; 2479 + }; 2480 + 91C82E0605CFF8B30042A20D = { 2481 + isa = PBXTargetDependency; 2482 + target = 91C82D5305CFF8B20042A20D; 2483 + targetProxy = 91C82E0505CFF8B30042A20D; 2484 + }; 2485 + 91C82E0805CFF8B30042A20D = { 2486 + isa = PBXTargetDependency; 2487 + target = 91C82D7205CFF8B20042A20D; 2488 + targetProxy = 91C82E0705CFF8B30042A20D; 2489 + }; 2490 + 91C82E0A05CFF8B30042A20D = { 2491 + isa = PBXTargetDependency; 2492 + target = 91C82D8A05CFF8B20042A20D; 2493 + targetProxy = 91C82E0905CFF8B30042A20D; 2494 + }; 2495 + 91C82E0C05CFF8B30042A20D = { 2496 + isa = PBXTargetDependency; 2497 + target = 91C82DB905CFF8B30042A20D; 2498 + targetProxy = 91C82E0B05CFF8B30042A20D; 2499 + }; 2500 + A9E885A40874B31900B2DFE8 = { 2501 + isa = PBXTargetDependency; 2502 + target = A929CDB6069E34840010B9C5; 2503 + targetProxy = A9E885A30874B31900B2DFE8; 2504 + }; 2505 + /* End PBXTargetDependency section */ 2506 + 2507 + /* Begin XCBuildConfiguration section */ 2508 + A9E883820874A59B00B2DFE8 = { 2509 + isa = XCBuildConfiguration; 2510 + buildSettings = { 2511 + COPY_PHASE_STRIP = NO; 2512 + GCC_DYNAMIC_NO_PIC = NO; 2513 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 2514 + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; 2515 + GCC_OPTIMIZATION_LEVEL = 0; 2516 + OTHER_CFLAGS = "-DDEBUG"; 2517 + OTHER_LDFLAGS = ""; 2518 + OTHER_REZFLAGS = ""; 2519 + PRODUCT_NAME = afconvert; 2520 + REZ_EXECUTABLE = YES; 2521 + SECTORDER_FLAGS = ""; 2522 + WARNING_CFLAGS = ( 2523 + "-Wmost", 2524 + "-Wno-four-char-constants", 2525 + "-Wno-unknown-pragmas", 2526 + ); 2527 + ZERO_LINK = NO; 2528 + }; 2529 + name = "Development-Panther"; 2530 + }; 2531 + A9E883830874A59B00B2DFE8 = { 2532 + isa = XCBuildConfiguration; 2533 + buildSettings = { 2534 + COPY_PHASE_STRIP = NO; 2535 + GCC_DYNAMIC_NO_PIC = NO; 2536 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 2537 + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; 2538 + GCC_OPTIMIZATION_LEVEL = 0; 2539 + GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = SUPPORT_CODEC_PROFILE; 2540 + MACOSX_DEPLOYMENT_TARGET = 10.4; 2541 + OTHER_CFLAGS = "-DDEBUG"; 2542 + OTHER_LDFLAGS = ""; 2543 + OTHER_REZFLAGS = ""; 2544 + PRODUCT_NAME = afconvert; 2545 + REZ_EXECUTABLE = YES; 2546 + SECTORDER_FLAGS = ""; 2547 + WARNING_CFLAGS = ( 2548 + "-Wmost", 2549 + "-Wno-four-char-constants", 2550 + "-Wno-unknown-pragmas", 2551 + ); 2552 + ZERO_LINK = NO; 2553 + }; 2554 + name = "Development-Tiger+"; 2555 + }; 2556 + A9E883840874A59B00B2DFE8 = { 2557 + isa = XCBuildConfiguration; 2558 + buildSettings = { 2559 + COPY_PHASE_STRIP = YES; 2560 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 2561 + LIBRARY_SEARCH_PATHS = ""; 2562 + OTHER_CFLAGS = ""; 2563 + OTHER_LDFLAGS = ""; 2564 + OTHER_REZFLAGS = ""; 2565 + PRODUCT_NAME = afconvert; 2566 + REZ_EXECUTABLE = YES; 2567 + SECTORDER_FLAGS = ""; 2568 + WARNING_CFLAGS = ( 2569 + "-Wmost", 2570 + "-Wno-four-char-constants", 2571 + "-Wno-unknown-pragmas", 2572 + ); 2573 + ZERO_LINK = NO; 2574 + }; 2575 + name = "Deployment-Panther"; 2576 + }; 2577 + A9E883850874A59B00B2DFE8 = { 2578 + isa = XCBuildConfiguration; 2579 + buildSettings = { 2580 + COPY_PHASE_STRIP = YES; 2581 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 2582 + LIBRARY_SEARCH_PATHS = ""; 2583 + MACOSX_DEPLOYMENT_TARGET = 10.4; 2584 + OTHER_CFLAGS = ""; 2585 + OTHER_LDFLAGS = ""; 2586 + OTHER_REZFLAGS = ""; 2587 + PRODUCT_NAME = afconvert; 2588 + REZ_EXECUTABLE = YES; 2589 + SECTORDER_FLAGS = ""; 2590 + WARNING_CFLAGS = ( 2591 + "-Wmost", 2592 + "-Wno-four-char-constants", 2593 + "-Wno-unknown-pragmas", 2594 + ); 2595 + ZERO_LINK = NO; 2596 + }; 2597 + name = "Deployment-Tiger+"; 2598 + }; 2599 + A9E883860874A59B00B2DFE8 = { 2600 + isa = XCBuildConfiguration; 2601 + buildSettings = { 2602 + OTHER_CFLAGS = ""; 2603 + OTHER_LDFLAGS = ""; 2604 + OTHER_REZFLAGS = ""; 2605 + PRODUCT_NAME = afconvert; 2606 + REZ_EXECUTABLE = YES; 2607 + SECTORDER_FLAGS = ""; 2608 + WARNING_CFLAGS = ( 2609 + "-Wmost", 2610 + "-Wno-four-char-constants", 2611 + "-Wno-unknown-pragmas", 2612 + ); 2613 + }; 2614 + name = Default; 2615 + }; 2616 + A9E883880874A59B00B2DFE8 = { 2617 + isa = XCBuildConfiguration; 2618 + buildSettings = { 2619 + COPY_PHASE_STRIP = NO; 2620 + GCC_DYNAMIC_NO_PIC = NO; 2621 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 2622 + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; 2623 + GCC_OPTIMIZATION_LEVEL = 0; 2624 + OTHER_CFLAGS = "-DDEBUG"; 2625 + OTHER_LDFLAGS = ""; 2626 + OTHER_REZFLAGS = ""; 2627 + PRODUCT_NAME = afinterleave; 2628 + REZ_EXECUTABLE = YES; 2629 + SECTORDER_FLAGS = ""; 2630 + WARNING_CFLAGS = ( 2631 + "-Wmost", 2632 + "-Wno-four-char-constants", 2633 + "-Wno-unknown-pragmas", 2634 + ); 2635 + ZERO_LINK = NO; 2636 + }; 2637 + name = "Development-Panther"; 2638 + }; 2639 + A9E883890874A59B00B2DFE8 = { 2640 + isa = XCBuildConfiguration; 2641 + buildSettings = { 2642 + COPY_PHASE_STRIP = NO; 2643 + GCC_DYNAMIC_NO_PIC = NO; 2644 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 2645 + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; 2646 + GCC_OPTIMIZATION_LEVEL = 0; 2647 + MACOSX_DEPLOYMENT_TARGET = 10.4; 2648 + OTHER_CFLAGS = "-DDEBUG"; 2649 + OTHER_LDFLAGS = ""; 2650 + OTHER_REZFLAGS = ""; 2651 + PRODUCT_NAME = afinterleave; 2652 + REZ_EXECUTABLE = YES; 2653 + SECTORDER_FLAGS = ""; 2654 + WARNING_CFLAGS = ( 2655 + "-Wmost", 2656 + "-Wno-four-char-constants", 2657 + "-Wno-unknown-pragmas", 2658 + ); 2659 + ZERO_LINK = NO; 2660 + }; 2661 + name = "Development-Tiger+"; 2662 + }; 2663 + A9E8838A0874A59B00B2DFE8 = { 2664 + isa = XCBuildConfiguration; 2665 + buildSettings = { 2666 + COPY_PHASE_STRIP = YES; 2667 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 2668 + LIBRARY_SEARCH_PATHS = ""; 2669 + OTHER_CFLAGS = ""; 2670 + OTHER_LDFLAGS = ""; 2671 + OTHER_REZFLAGS = ""; 2672 + PRODUCT_NAME = afinterleave; 2673 + REZ_EXECUTABLE = YES; 2674 + SECTORDER_FLAGS = ""; 2675 + WARNING_CFLAGS = ( 2676 + "-Wmost", 2677 + "-Wno-four-char-constants", 2678 + "-Wno-unknown-pragmas", 2679 + ); 2680 + ZERO_LINK = NO; 2681 + }; 2682 + name = "Deployment-Panther"; 2683 + }; 2684 + A9E8838B0874A59B00B2DFE8 = { 2685 + isa = XCBuildConfiguration; 2686 + buildSettings = { 2687 + COPY_PHASE_STRIP = YES; 2688 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 2689 + LIBRARY_SEARCH_PATHS = ""; 2690 + MACOSX_DEPLOYMENT_TARGET = 10.4; 2691 + OTHER_CFLAGS = ""; 2692 + OTHER_LDFLAGS = ""; 2693 + OTHER_REZFLAGS = ""; 2694 + PRODUCT_NAME = afinterleave; 2695 + REZ_EXECUTABLE = YES; 2696 + SECTORDER_FLAGS = ""; 2697 + WARNING_CFLAGS = ( 2698 + "-Wmost", 2699 + "-Wno-four-char-constants", 2700 + "-Wno-unknown-pragmas", 2701 + ); 2702 + ZERO_LINK = NO; 2703 + }; 2704 + name = "Deployment-Tiger+"; 2705 + }; 2706 + A9E8838C0874A59B00B2DFE8 = { 2707 + isa = XCBuildConfiguration; 2708 + buildSettings = { 2709 + OTHER_CFLAGS = ""; 2710 + OTHER_LDFLAGS = ""; 2711 + OTHER_REZFLAGS = ""; 2712 + PRODUCT_NAME = afinterleave; 2713 + REZ_EXECUTABLE = YES; 2714 + SECTORDER_FLAGS = ""; 2715 + WARNING_CFLAGS = ( 2716 + "-Wmost", 2717 + "-Wno-four-char-constants", 2718 + "-Wno-unknown-pragmas", 2719 + ); 2720 + }; 2721 + name = Default; 2722 + }; 2723 + A9E8838E0874A59B00B2DFE8 = { 2724 + isa = XCBuildConfiguration; 2725 + buildSettings = { 2726 + COPY_PHASE_STRIP = NO; 2727 + GCC_DYNAMIC_NO_PIC = NO; 2728 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 2729 + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; 2730 + GCC_OPTIMIZATION_LEVEL = 0; 2731 + LIBRARY_SEARCH_PATHS = ""; 2732 + OTHER_CFLAGS = "-DDEBUG"; 2733 + OTHER_LDFLAGS = ""; 2734 + OTHER_REZFLAGS = ""; 2735 + PRODUCT_NAME = afplay; 2736 + REZ_EXECUTABLE = YES; 2737 + SECTORDER_FLAGS = ""; 2738 + WARNING_CFLAGS = ( 2739 + "-Wmost", 2740 + "-Wno-four-char-constants", 2741 + "-Wno-unknown-pragmas", 2742 + ); 2743 + ZERO_LINK = NO; 2744 + }; 2745 + name = "Development-Panther"; 2746 + }; 2747 + A9E8838F0874A59B00B2DFE8 = { 2748 + isa = XCBuildConfiguration; 2749 + buildSettings = { 2750 + COPY_PHASE_STRIP = NO; 2751 + GCC_DYNAMIC_NO_PIC = NO; 2752 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 2753 + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; 2754 + GCC_OPTIMIZATION_LEVEL = 0; 2755 + LIBRARY_SEARCH_PATHS = ""; 2756 + MACOSX_DEPLOYMENT_TARGET = 10.4; 2757 + OTHER_CFLAGS = "-DDEBUG"; 2758 + OTHER_LDFLAGS = ""; 2759 + OTHER_REZFLAGS = ""; 2760 + PRODUCT_NAME = afplay; 2761 + REZ_EXECUTABLE = YES; 2762 + SECTORDER_FLAGS = ""; 2763 + WARNING_CFLAGS = ( 2764 + "-Wmost", 2765 + "-Wno-four-char-constants", 2766 + "-Wno-unknown-pragmas", 2767 + ); 2768 + ZERO_LINK = NO; 2769 + }; 2770 + name = "Development-Tiger+"; 2771 + }; 2772 + A9E883900874A59B00B2DFE8 = { 2773 + isa = XCBuildConfiguration; 2774 + buildSettings = { 2775 + COPY_PHASE_STRIP = YES; 2776 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 2777 + LIBRARY_SEARCH_PATHS = ""; 2778 + OTHER_CFLAGS = ""; 2779 + OTHER_LDFLAGS = ""; 2780 + OTHER_REZFLAGS = ""; 2781 + PRODUCT_NAME = afplay; 2782 + REZ_EXECUTABLE = YES; 2783 + SECTORDER_FLAGS = ""; 2784 + WARNING_CFLAGS = ( 2785 + "-Wmost", 2786 + "-Wno-four-char-constants", 2787 + "-Wno-unknown-pragmas", 2788 + ); 2789 + ZERO_LINK = NO; 2790 + }; 2791 + name = "Deployment-Panther"; 2792 + }; 2793 + A9E883910874A59B00B2DFE8 = { 2794 + isa = XCBuildConfiguration; 2795 + buildSettings = { 2796 + COPY_PHASE_STRIP = YES; 2797 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 2798 + LIBRARY_SEARCH_PATHS = ""; 2799 + MACOSX_DEPLOYMENT_TARGET = 10.4; 2800 + OTHER_CFLAGS = ""; 2801 + OTHER_LDFLAGS = ""; 2802 + OTHER_REZFLAGS = ""; 2803 + PRODUCT_NAME = afplay; 2804 + REZ_EXECUTABLE = YES; 2805 + SECTORDER_FLAGS = ""; 2806 + WARNING_CFLAGS = ( 2807 + "-Wmost", 2808 + "-Wno-four-char-constants", 2809 + "-Wno-unknown-pragmas", 2810 + ); 2811 + ZERO_LINK = NO; 2812 + }; 2813 + name = "Deployment-Tiger+"; 2814 + }; 2815 + A9E883920874A59B00B2DFE8 = { 2816 + isa = XCBuildConfiguration; 2817 + buildSettings = { 2818 + LIBRARY_SEARCH_PATHS = ""; 2819 + OTHER_CFLAGS = ""; 2820 + OTHER_LDFLAGS = ""; 2821 + OTHER_REZFLAGS = ""; 2822 + PRODUCT_NAME = afplay; 2823 + REZ_EXECUTABLE = YES; 2824 + SECTORDER_FLAGS = ""; 2825 + WARNING_CFLAGS = ( 2826 + "-Wmost", 2827 + "-Wno-four-char-constants", 2828 + "-Wno-unknown-pragmas", 2829 + ); 2830 + }; 2831 + name = Default; 2832 + }; 2833 + A9E883940874A59B00B2DFE8 = { 2834 + isa = XCBuildConfiguration; 2835 + buildSettings = { 2836 + COPY_PHASE_STRIP = NO; 2837 + GCC_DYNAMIC_NO_PIC = NO; 2838 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 2839 + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; 2840 + GCC_OPTIMIZATION_LEVEL = 0; 2841 + OTHER_CFLAGS = "-DDEBUG"; 2842 + OTHER_LDFLAGS = ""; 2843 + OTHER_REZFLAGS = ""; 2844 + PRODUCT_NAME = afrecord; 2845 + REZ_EXECUTABLE = YES; 2846 + SECTORDER_FLAGS = ""; 2847 + WARNING_CFLAGS = ( 2848 + "-Wmost", 2849 + "-Wno-four-char-constants", 2850 + "-Wno-unknown-pragmas", 2851 + ); 2852 + ZERO_LINK = NO; 2853 + }; 2854 + name = "Development-Panther"; 2855 + }; 2856 + A9E883950874A59B00B2DFE8 = { 2857 + isa = XCBuildConfiguration; 2858 + buildSettings = { 2859 + COPY_PHASE_STRIP = NO; 2860 + GCC_DYNAMIC_NO_PIC = NO; 2861 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 2862 + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; 2863 + GCC_OPTIMIZATION_LEVEL = 0; 2864 + MACOSX_DEPLOYMENT_TARGET = 10.4; 2865 + OTHER_CFLAGS = "-DDEBUG"; 2866 + OTHER_LDFLAGS = ""; 2867 + OTHER_REZFLAGS = ""; 2868 + PRODUCT_NAME = afrecord; 2869 + REZ_EXECUTABLE = YES; 2870 + SECTORDER_FLAGS = ""; 2871 + WARNING_CFLAGS = ( 2872 + "-Wmost", 2873 + "-Wno-four-char-constants", 2874 + "-Wno-unknown-pragmas", 2875 + ); 2876 + ZERO_LINK = NO; 2877 + }; 2878 + name = "Development-Tiger+"; 2879 + }; 2880 + A9E883960874A59B00B2DFE8 = { 2881 + isa = XCBuildConfiguration; 2882 + buildSettings = { 2883 + COPY_PHASE_STRIP = YES; 2884 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 2885 + LIBRARY_SEARCH_PATHS = ""; 2886 + OTHER_CFLAGS = ""; 2887 + OTHER_LDFLAGS = ""; 2888 + OTHER_REZFLAGS = ""; 2889 + PRODUCT_NAME = afrecord; 2890 + REZ_EXECUTABLE = YES; 2891 + SECTORDER_FLAGS = ""; 2892 + WARNING_CFLAGS = ( 2893 + "-Wmost", 2894 + "-Wno-four-char-constants", 2895 + "-Wno-unknown-pragmas", 2896 + ); 2897 + ZERO_LINK = NO; 2898 + }; 2899 + name = "Deployment-Panther"; 2900 + }; 2901 + A9E883970874A59B00B2DFE8 = { 2902 + isa = XCBuildConfiguration; 2903 + buildSettings = { 2904 + COPY_PHASE_STRIP = YES; 2905 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 2906 + LIBRARY_SEARCH_PATHS = ""; 2907 + MACOSX_DEPLOYMENT_TARGET = 10.4; 2908 + OTHER_CFLAGS = ""; 2909 + OTHER_LDFLAGS = ""; 2910 + OTHER_REZFLAGS = ""; 2911 + PRODUCT_NAME = afrecord; 2912 + REZ_EXECUTABLE = YES; 2913 + SECTORDER_FLAGS = ""; 2914 + WARNING_CFLAGS = ( 2915 + "-Wmost", 2916 + "-Wno-four-char-constants", 2917 + "-Wno-unknown-pragmas", 2918 + ); 2919 + ZERO_LINK = NO; 2920 + }; 2921 + name = "Deployment-Tiger+"; 2922 + }; 2923 + A9E883980874A59B00B2DFE8 = { 2924 + isa = XCBuildConfiguration; 2925 + buildSettings = { 2926 + OTHER_CFLAGS = ""; 2927 + OTHER_LDFLAGS = ""; 2928 + OTHER_REZFLAGS = ""; 2929 + PRODUCT_NAME = afrecord; 2930 + REZ_EXECUTABLE = YES; 2931 + SECTORDER_FLAGS = ""; 2932 + WARNING_CFLAGS = ( 2933 + "-Wmost", 2934 + "-Wno-four-char-constants", 2935 + "-Wno-unknown-pragmas", 2936 + ); 2937 + }; 2938 + name = Default; 2939 + }; 2940 + A9E8839A0874A59B00B2DFE8 = { 2941 + isa = XCBuildConfiguration; 2942 + buildSettings = { 2943 + COPY_PHASE_STRIP = NO; 2944 + GCC_DYNAMIC_NO_PIC = NO; 2945 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 2946 + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; 2947 + GCC_OPTIMIZATION_LEVEL = 0; 2948 + OTHER_CFLAGS = "-DDEBUG"; 2949 + OTHER_LDFLAGS = ""; 2950 + OTHER_REZFLAGS = ""; 2951 + PRODUCT_NAME = audioformats; 2952 + REZ_EXECUTABLE = YES; 2953 + SECTORDER_FLAGS = ""; 2954 + WARNING_CFLAGS = ( 2955 + "-Wmost", 2956 + "-Wno-four-char-constants", 2957 + "-Wno-unknown-pragmas", 2958 + ); 2959 + ZERO_LINK = NO; 2960 + }; 2961 + name = "Development-Panther"; 2962 + }; 2963 + A9E8839B0874A59B00B2DFE8 = { 2964 + isa = XCBuildConfiguration; 2965 + buildSettings = { 2966 + COPY_PHASE_STRIP = NO; 2967 + GCC_DYNAMIC_NO_PIC = NO; 2968 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 2969 + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; 2970 + GCC_OPTIMIZATION_LEVEL = 0; 2971 + MACOSX_DEPLOYMENT_TARGET = 10.4; 2972 + OTHER_CFLAGS = "-DDEBUG"; 2973 + OTHER_LDFLAGS = ""; 2974 + OTHER_REZFLAGS = ""; 2975 + PRODUCT_NAME = audioformats; 2976 + REZ_EXECUTABLE = YES; 2977 + SECTORDER_FLAGS = ""; 2978 + WARNING_CFLAGS = ( 2979 + "-Wmost", 2980 + "-Wno-four-char-constants", 2981 + "-Wno-unknown-pragmas", 2982 + ); 2983 + ZERO_LINK = NO; 2984 + }; 2985 + name = "Development-Tiger+"; 2986 + }; 2987 + A9E8839C0874A59B00B2DFE8 = { 2988 + isa = XCBuildConfiguration; 2989 + buildSettings = { 2990 + COPY_PHASE_STRIP = YES; 2991 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 2992 + LIBRARY_SEARCH_PATHS = ""; 2993 + OTHER_CFLAGS = ""; 2994 + OTHER_LDFLAGS = ""; 2995 + OTHER_REZFLAGS = ""; 2996 + PRODUCT_NAME = audioformats; 2997 + REZ_EXECUTABLE = YES; 2998 + SECTORDER_FLAGS = ""; 2999 + WARNING_CFLAGS = ( 3000 + "-Wmost", 3001 + "-Wno-four-char-constants", 3002 + "-Wno-unknown-pragmas", 3003 + ); 3004 + ZERO_LINK = NO; 3005 + }; 3006 + name = "Deployment-Panther"; 3007 + }; 3008 + A9E8839D0874A59B00B2DFE8 = { 3009 + isa = XCBuildConfiguration; 3010 + buildSettings = { 3011 + COPY_PHASE_STRIP = YES; 3012 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 3013 + LIBRARY_SEARCH_PATHS = ""; 3014 + MACOSX_DEPLOYMENT_TARGET = 10.4; 3015 + OTHER_CFLAGS = ""; 3016 + OTHER_LDFLAGS = ""; 3017 + OTHER_REZFLAGS = ""; 3018 + PRODUCT_NAME = audioformats; 3019 + REZ_EXECUTABLE = YES; 3020 + SECTORDER_FLAGS = ""; 3021 + WARNING_CFLAGS = ( 3022 + "-Wmost", 3023 + "-Wno-four-char-constants", 3024 + "-Wno-unknown-pragmas", 3025 + ); 3026 + ZERO_LINK = NO; 3027 + }; 3028 + name = "Deployment-Tiger+"; 3029 + }; 3030 + A9E8839E0874A59B00B2DFE8 = { 3031 + isa = XCBuildConfiguration; 3032 + buildSettings = { 3033 + OTHER_CFLAGS = ""; 3034 + OTHER_LDFLAGS = ""; 3035 + OTHER_REZFLAGS = ""; 3036 + PRODUCT_NAME = audioformats; 3037 + REZ_EXECUTABLE = YES; 3038 + SECTORDER_FLAGS = ""; 3039 + WARNING_CFLAGS = ( 3040 + "-Wmost", 3041 + "-Wno-four-char-constants", 3042 + "-Wno-unknown-pragmas", 3043 + ); 3044 + }; 3045 + name = Default; 3046 + }; 3047 + A9E883A60874A59B00B2DFE8 = { 3048 + isa = XCBuildConfiguration; 3049 + buildSettings = { 3050 + COPY_PHASE_STRIP = NO; 3051 + FRAMEWORK_SEARCH_PATHS = ""; 3052 + GCC_DYNAMIC_NO_PIC = NO; 3053 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 3054 + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; 3055 + GCC_OPTIMIZATION_LEVEL = 0; 3056 + GCC_PRECOMPILE_PREFIX_HEADER = NO; 3057 + GCC_PREFIX_HEADER = ""; 3058 + GCC_WARN_FOUR_CHARACTER_CONSTANTS = NO; 3059 + GCC_WARN_UNKNOWN_PRAGMAS = NO; 3060 + INSTALL_PATH = /usr/local/bin; 3061 + OTHER_CFLAGS = "-DDEBUG"; 3062 + OTHER_LDFLAGS = ""; 3063 + OTHER_REZFLAGS = ""; 3064 + PRODUCT_NAME = afinfo; 3065 + REZ_EXECUTABLE = YES; 3066 + SECTORDER_FLAGS = ""; 3067 + WARNING_CFLAGS = "-Wmost"; 3068 + ZERO_LINK = NO; 3069 + }; 3070 + name = "Development-Panther"; 3071 + }; 3072 + A9E883A70874A59B00B2DFE8 = { 3073 + isa = XCBuildConfiguration; 3074 + buildSettings = { 3075 + COPY_PHASE_STRIP = NO; 3076 + FRAMEWORK_SEARCH_PATHS = ""; 3077 + GCC_DYNAMIC_NO_PIC = NO; 3078 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 3079 + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; 3080 + GCC_OPTIMIZATION_LEVEL = 0; 3081 + GCC_PRECOMPILE_PREFIX_HEADER = NO; 3082 + GCC_PREFIX_HEADER = ""; 3083 + GCC_WARN_FOUR_CHARACTER_CONSTANTS = NO; 3084 + GCC_WARN_UNKNOWN_PRAGMAS = NO; 3085 + INSTALL_PATH = /usr/local/bin; 3086 + MACOSX_DEPLOYMENT_TARGET = 10.4; 3087 + OTHER_CFLAGS = "-DDEBUG"; 3088 + OTHER_LDFLAGS = ""; 3089 + OTHER_REZFLAGS = ""; 3090 + PRODUCT_NAME = afinfo; 3091 + REZ_EXECUTABLE = YES; 3092 + SECTORDER_FLAGS = ""; 3093 + WARNING_CFLAGS = "-Wmost"; 3094 + ZERO_LINK = NO; 3095 + }; 3096 + name = "Development-Tiger+"; 3097 + }; 3098 + A9E883A80874A59B00B2DFE8 = { 3099 + isa = XCBuildConfiguration; 3100 + buildSettings = { 3101 + COPY_PHASE_STRIP = YES; 3102 + FRAMEWORK_SEARCH_PATHS = ""; 3103 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 3104 + GCC_PRECOMPILE_PREFIX_HEADER = NO; 3105 + GCC_PREFIX_HEADER = ""; 3106 + GCC_WARN_FOUR_CHARACTER_CONSTANTS = NO; 3107 + GCC_WARN_UNKNOWN_PRAGMAS = NO; 3108 + INSTALL_PATH = /usr/local/bin; 3109 + LIBRARY_SEARCH_PATHS = ""; 3110 + OTHER_CFLAGS = ""; 3111 + OTHER_LDFLAGS = ""; 3112 + OTHER_REZFLAGS = ""; 3113 + PRODUCT_NAME = afinfo; 3114 + REZ_EXECUTABLE = YES; 3115 + SECTORDER_FLAGS = ""; 3116 + WARNING_CFLAGS = "-Wmost"; 3117 + ZERO_LINK = NO; 3118 + }; 3119 + name = "Deployment-Panther"; 3120 + }; 3121 + A9E883A90874A59B00B2DFE8 = { 3122 + isa = XCBuildConfiguration; 3123 + buildSettings = { 3124 + COPY_PHASE_STRIP = YES; 3125 + FRAMEWORK_SEARCH_PATHS = ""; 3126 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 3127 + GCC_PRECOMPILE_PREFIX_HEADER = NO; 3128 + GCC_PREFIX_HEADER = ""; 3129 + GCC_WARN_FOUR_CHARACTER_CONSTANTS = NO; 3130 + GCC_WARN_UNKNOWN_PRAGMAS = NO; 3131 + INSTALL_PATH = /usr/local/bin; 3132 + LIBRARY_SEARCH_PATHS = ""; 3133 + MACOSX_DEPLOYMENT_TARGET = 10.4; 3134 + OTHER_CFLAGS = ""; 3135 + OTHER_LDFLAGS = ""; 3136 + OTHER_REZFLAGS = ""; 3137 + PRODUCT_NAME = afinfo; 3138 + REZ_EXECUTABLE = YES; 3139 + SECTORDER_FLAGS = ""; 3140 + WARNING_CFLAGS = "-Wmost"; 3141 + ZERO_LINK = NO; 3142 + }; 3143 + name = "Deployment-Tiger+"; 3144 + }; 3145 + A9E883AA0874A59B00B2DFE8 = { 3146 + isa = XCBuildConfiguration; 3147 + buildSettings = { 3148 + FRAMEWORK_SEARCH_PATHS = ""; 3149 + GCC_PRECOMPILE_PREFIX_HEADER = NO; 3150 + GCC_PREFIX_HEADER = ""; 3151 + GCC_WARN_FOUR_CHARACTER_CONSTANTS = NO; 3152 + GCC_WARN_UNKNOWN_PRAGMAS = NO; 3153 + INSTALL_PATH = /usr/local/bin; 3154 + OTHER_CFLAGS = ""; 3155 + OTHER_LDFLAGS = ""; 3156 + OTHER_REZFLAGS = ""; 3157 + PRODUCT_NAME = afinfo; 3158 + REZ_EXECUTABLE = YES; 3159 + SECTORDER_FLAGS = ""; 3160 + WARNING_CFLAGS = "-Wmost"; 3161 + }; 3162 + name = Default; 3163 + }; 3164 + A9E883AC0874A59B00B2DFE8 = { 3165 + isa = XCBuildConfiguration; 3166 + buildSettings = { 3167 + COPY_PHASE_STRIP = NO; 3168 + GCC_DYNAMIC_NO_PIC = NO; 3169 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 3170 + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; 3171 + GCC_OPTIMIZATION_LEVEL = 0; 3172 + OTHER_CFLAGS = "-DDEBUG"; 3173 + OTHER_LDFLAGS = ""; 3174 + OTHER_REZFLAGS = ""; 3175 + PRODUCT_NAME = All; 3176 + SECTORDER_FLAGS = ""; 3177 + WARNING_CFLAGS = ( 3178 + "-Wmost", 3179 + "-Wno-four-char-constants", 3180 + "-Wno-unknown-pragmas", 3181 + ); 3182 + ZERO_LINK = NO; 3183 + }; 3184 + name = "Development-Panther"; 3185 + }; 3186 + A9E883AD0874A59B00B2DFE8 = { 3187 + isa = XCBuildConfiguration; 3188 + buildSettings = { 3189 + COPY_PHASE_STRIP = NO; 3190 + GCC_DYNAMIC_NO_PIC = NO; 3191 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 3192 + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; 3193 + GCC_OPTIMIZATION_LEVEL = 0; 3194 + MACOSX_DEPLOYMENT_TARGET = 10.4; 3195 + OTHER_CFLAGS = "-DDEBUG"; 3196 + OTHER_LDFLAGS = ""; 3197 + OTHER_REZFLAGS = ""; 3198 + PRODUCT_NAME = All; 3199 + SECTORDER_FLAGS = ""; 3200 + WARNING_CFLAGS = ( 3201 + "-Wmost", 3202 + "-Wno-four-char-constants", 3203 + "-Wno-unknown-pragmas", 3204 + ); 3205 + ZERO_LINK = NO; 3206 + }; 3207 + name = "Development-Tiger+"; 3208 + }; 3209 + A9E883AE0874A59B00B2DFE8 = { 3210 + isa = XCBuildConfiguration; 3211 + buildSettings = { 3212 + COPY_PHASE_STRIP = YES; 3213 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 3214 + LIBRARY_SEARCH_PATHS = ""; 3215 + OTHER_CFLAGS = ""; 3216 + OTHER_LDFLAGS = ""; 3217 + OTHER_REZFLAGS = ""; 3218 + PRODUCT_NAME = All; 3219 + SECTORDER_FLAGS = ""; 3220 + WARNING_CFLAGS = ( 3221 + "-Wmost", 3222 + "-Wno-four-char-constants", 3223 + "-Wno-unknown-pragmas", 3224 + ); 3225 + ZERO_LINK = NO; 3226 + }; 3227 + name = "Deployment-Panther"; 3228 + }; 3229 + A9E883AF0874A59B00B2DFE8 = { 3230 + isa = XCBuildConfiguration; 3231 + buildSettings = { 3232 + COPY_PHASE_STRIP = YES; 3233 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 3234 + LIBRARY_SEARCH_PATHS = ""; 3235 + MACOSX_DEPLOYMENT_TARGET = 10.4; 3236 + OTHER_CFLAGS = ""; 3237 + OTHER_LDFLAGS = ""; 3238 + OTHER_REZFLAGS = ""; 3239 + PRODUCT_NAME = All; 3240 + SECTORDER_FLAGS = ""; 3241 + WARNING_CFLAGS = ( 3242 + "-Wmost", 3243 + "-Wno-four-char-constants", 3244 + "-Wno-unknown-pragmas", 3245 + ); 3246 + ZERO_LINK = NO; 3247 + }; 3248 + name = "Deployment-Tiger+"; 3249 + }; 3250 + A9E883B00874A59B00B2DFE8 = { 3251 + isa = XCBuildConfiguration; 3252 + buildSettings = { 3253 + OTHER_CFLAGS = ""; 3254 + OTHER_LDFLAGS = ""; 3255 + OTHER_REZFLAGS = ""; 3256 + PRODUCT_NAME = All; 3257 + SECTORDER_FLAGS = ""; 3258 + WARNING_CFLAGS = ( 3259 + "-Wmost", 3260 + "-Wno-four-char-constants", 3261 + "-Wno-unknown-pragmas", 3262 + ); 3263 + }; 3264 + name = Default; 3265 + }; 3266 + A9E883B20874A59B00B2DFE8 = { 3267 + isa = XCBuildConfiguration; 3268 + buildSettings = { 3269 + COPY_PHASE_STRIP = NO; 3270 + FRAMEWORK_SEARCH_PATHS = ""; 3271 + GCC_DYNAMIC_NO_PIC = NO; 3272 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 3273 + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; 3274 + GCC_OPTIMIZATION_LEVEL = 0; 3275 + OTHER_CFLAGS = "-DDEBUG"; 3276 + OTHER_LDFLAGS = ""; 3277 + OTHER_REZFLAGS = ""; 3278 + PRODUCT_NAME = auprocess; 3279 + REZ_EXECUTABLE = YES; 3280 + SECTORDER_FLAGS = ""; 3281 + WARNING_CFLAGS = ( 3282 + "-Wmost", 3283 + "-Wno-four-char-constants", 3284 + "-Wno-unknown-pragmas", 3285 + ); 3286 + ZERO_LINK = NO; 3287 + }; 3288 + name = "Development-Panther"; 3289 + }; 3290 + A9E883B30874A59B00B2DFE8 = { 3291 + isa = XCBuildConfiguration; 3292 + buildSettings = { 3293 + COPY_PHASE_STRIP = NO; 3294 + FRAMEWORK_SEARCH_PATHS = ""; 3295 + GCC_DYNAMIC_NO_PIC = NO; 3296 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 3297 + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; 3298 + GCC_OPTIMIZATION_LEVEL = 0; 3299 + MACOSX_DEPLOYMENT_TARGET = 10.4; 3300 + OTHER_CFLAGS = "-DDEBUG"; 3301 + OTHER_LDFLAGS = ""; 3302 + OTHER_REZFLAGS = ""; 3303 + PRODUCT_NAME = auprocess; 3304 + REZ_EXECUTABLE = YES; 3305 + SECTORDER_FLAGS = ""; 3306 + WARNING_CFLAGS = ( 3307 + "-Wmost", 3308 + "-Wno-four-char-constants", 3309 + "-Wno-unknown-pragmas", 3310 + ); 3311 + ZERO_LINK = NO; 3312 + }; 3313 + name = "Development-Tiger+"; 3314 + }; 3315 + A9E883B40874A59B00B2DFE8 = { 3316 + isa = XCBuildConfiguration; 3317 + buildSettings = { 3318 + COPY_PHASE_STRIP = YES; 3319 + FRAMEWORK_SEARCH_PATHS = ""; 3320 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 3321 + LIBRARY_SEARCH_PATHS = ""; 3322 + OTHER_CFLAGS = ""; 3323 + OTHER_LDFLAGS = ""; 3324 + OTHER_REZFLAGS = ""; 3325 + PRODUCT_NAME = auprocess; 3326 + REZ_EXECUTABLE = YES; 3327 + SECTORDER_FLAGS = ""; 3328 + WARNING_CFLAGS = ( 3329 + "-Wmost", 3330 + "-Wno-four-char-constants", 3331 + "-Wno-unknown-pragmas", 3332 + ); 3333 + ZERO_LINK = NO; 3334 + }; 3335 + name = "Deployment-Panther"; 3336 + }; 3337 + A9E883B50874A59B00B2DFE8 = { 3338 + isa = XCBuildConfiguration; 3339 + buildSettings = { 3340 + COPY_PHASE_STRIP = YES; 3341 + FRAMEWORK_SEARCH_PATHS = ""; 3342 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 3343 + LIBRARY_SEARCH_PATHS = ""; 3344 + MACOSX_DEPLOYMENT_TARGET = 10.4; 3345 + OTHER_CFLAGS = ""; 3346 + OTHER_LDFLAGS = ""; 3347 + OTHER_REZFLAGS = ""; 3348 + PRODUCT_NAME = auprocess; 3349 + REZ_EXECUTABLE = YES; 3350 + SECTORDER_FLAGS = ""; 3351 + WARNING_CFLAGS = ( 3352 + "-Wmost", 3353 + "-Wno-four-char-constants", 3354 + "-Wno-unknown-pragmas", 3355 + ); 3356 + ZERO_LINK = NO; 3357 + }; 3358 + name = "Deployment-Tiger+"; 3359 + }; 3360 + A9E883B60874A59B00B2DFE8 = { 3361 + isa = XCBuildConfiguration; 3362 + buildSettings = { 3363 + FRAMEWORK_SEARCH_PATHS = ""; 3364 + OTHER_CFLAGS = ""; 3365 + OTHER_LDFLAGS = ""; 3366 + OTHER_REZFLAGS = ""; 3367 + PRODUCT_NAME = auprocess; 3368 + REZ_EXECUTABLE = YES; 3369 + SECTORDER_FLAGS = ""; 3370 + WARNING_CFLAGS = ( 3371 + "-Wmost", 3372 + "-Wno-four-char-constants", 3373 + "-Wno-unknown-pragmas", 3374 + ); 3375 + }; 3376 + name = Default; 3377 + }; 3378 + A9E883B80874A59B00B2DFE8 = { 3379 + isa = XCBuildConfiguration; 3380 + buildSettings = { 3381 + }; 3382 + name = "Development-Panther"; 3383 + }; 3384 + A9E883B90874A59B00B2DFE8 = { 3385 + isa = XCBuildConfiguration; 3386 + buildSettings = { 3387 + }; 3388 + name = "Development-Tiger+"; 3389 + }; 3390 + A9E883BA0874A59B00B2DFE8 = { 3391 + isa = XCBuildConfiguration; 3392 + buildSettings = { 3393 + }; 3394 + name = "Deployment-Panther"; 3395 + }; 3396 + A9E883BB0874A59B00B2DFE8 = { 3397 + isa = XCBuildConfiguration; 3398 + buildSettings = { 3399 + }; 3400 + name = "Deployment-Tiger+"; 3401 + }; 3402 + A9E883BC0874A59B00B2DFE8 = { 3403 + isa = XCBuildConfiguration; 3404 + buildSettings = { 3405 + }; 3406 + name = Default; 3407 + }; 3408 + A9F41D4008F4B00200A2BC1C = { 3409 + isa = XCBuildConfiguration; 3410 + buildSettings = { 3411 + COPY_PHASE_STRIP = NO; 3412 + GCC_DYNAMIC_NO_PIC = NO; 3413 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 3414 + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; 3415 + GCC_OPTIMIZATION_LEVEL = 0; 3416 + OTHER_CFLAGS = "-DDEBUG"; 3417 + OTHER_LDFLAGS = ""; 3418 + OTHER_REZFLAGS = ""; 3419 + PRODUCT_NAME = auprofile; 3420 + REZ_EXECUTABLE = YES; 3421 + SECTORDER_FLAGS = ""; 3422 + WARNING_CFLAGS = ( 3423 + "-Wmost", 3424 + "-Wno-four-char-constants", 3425 + "-Wno-unknown-pragmas", 3426 + ); 3427 + ZERO_LINK = NO; 3428 + }; 3429 + name = "Development-Panther"; 3430 + }; 3431 + A9F41D4108F4B00200A2BC1C = { 3432 + isa = XCBuildConfiguration; 3433 + buildSettings = { 3434 + COPY_PHASE_STRIP = NO; 3435 + GCC_DYNAMIC_NO_PIC = NO; 3436 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 3437 + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; 3438 + GCC_OPTIMIZATION_LEVEL = 0; 3439 + MACOSX_DEPLOYMENT_TARGET = 10.4; 3440 + OTHER_CFLAGS = "-DDEBUG"; 3441 + OTHER_LDFLAGS = ""; 3442 + OTHER_REZFLAGS = ""; 3443 + PRODUCT_NAME = auprofile; 3444 + REZ_EXECUTABLE = YES; 3445 + SECTORDER_FLAGS = ""; 3446 + WARNING_CFLAGS = ( 3447 + "-Wmost", 3448 + "-Wno-four-char-constants", 3449 + "-Wno-unknown-pragmas", 3450 + ); 3451 + ZERO_LINK = NO; 3452 + }; 3453 + name = "Development-Tiger+"; 3454 + }; 3455 + A9F41D4208F4B00200A2BC1C = { 3456 + isa = XCBuildConfiguration; 3457 + buildSettings = { 3458 + COPY_PHASE_STRIP = YES; 3459 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 3460 + OTHER_CFLAGS = ""; 3461 + OTHER_LDFLAGS = ""; 3462 + OTHER_REZFLAGS = ""; 3463 + PRODUCT_NAME = auprofile; 3464 + REZ_EXECUTABLE = YES; 3465 + SECTORDER_FLAGS = ""; 3466 + WARNING_CFLAGS = ( 3467 + "-Wmost", 3468 + "-Wno-four-char-constants", 3469 + "-Wno-unknown-pragmas", 3470 + ); 3471 + ZERO_LINK = NO; 3472 + }; 3473 + name = "Deployment-Panther"; 3474 + }; 3475 + A9F41D4308F4B00200A2BC1C = { 3476 + isa = XCBuildConfiguration; 3477 + buildSettings = { 3478 + COPY_PHASE_STRIP = YES; 3479 + GCC_ENABLE_FIX_AND_CONTINUE = NO; 3480 + MACOSX_DEPLOYMENT_TARGET = 10.4; 3481 + OTHER_CFLAGS = ""; 3482 + OTHER_LDFLAGS = ""; 3483 + OTHER_REZFLAGS = ""; 3484 + PRODUCT_NAME = auprofile; 3485 + REZ_EXECUTABLE = YES; 3486 + SECTORDER_FLAGS = ""; 3487 + WARNING_CFLAGS = ( 3488 + "-Wmost", 3489 + "-Wno-four-char-constants", 3490 + "-Wno-unknown-pragmas", 3491 + ); 3492 + ZERO_LINK = NO; 3493 + }; 3494 + name = "Deployment-Tiger+"; 3495 + }; 3496 + A9F41D4408F4B00200A2BC1C = { 3497 + isa = XCBuildConfiguration; 3498 + buildSettings = { 3499 + OTHER_CFLAGS = ""; 3500 + OTHER_LDFLAGS = ""; 3501 + OTHER_REZFLAGS = ""; 3502 + PRODUCT_NAME = auprofile; 3503 + REZ_EXECUTABLE = YES; 3504 + SECTORDER_FLAGS = ""; 3505 + WARNING_CFLAGS = ( 3506 + "-Wmost", 3507 + "-Wno-four-char-constants", 3508 + "-Wno-unknown-pragmas", 3509 + ); 3510 + ZERO_LINK = NO; 3511 + }; 3512 + name = Default; 3513 + }; 3514 + /* End XCBuildConfiguration section */ 3515 + 3516 + /* Begin XCConfigurationList section */ 3517 + A9E883810874A59B00B2DFE8 = { 3518 + isa = XCConfigurationList; 3519 + buildConfigurations = ( 3520 + A9E883820874A59B00B2DFE8, 3521 + A9E883830874A59B00B2DFE8, 3522 + A9E883840874A59B00B2DFE8, 3523 + A9E883850874A59B00B2DFE8, 3524 + A9E883860874A59B00B2DFE8, 3525 + ); 3526 + defaultConfigurationIsVisible = 0; 3527 + defaultConfigurationName = Default; 3528 + }; 3529 + A9E883870874A59B00B2DFE8 = { 3530 + isa = XCConfigurationList; 3531 + buildConfigurations = ( 3532 + A9E883880874A59B00B2DFE8, 3533 + A9E883890874A59B00B2DFE8, 3534 + A9E8838A0874A59B00B2DFE8, 3535 + A9E8838B0874A59B00B2DFE8, 3536 + A9E8838C0874A59B00B2DFE8, 3537 + ); 3538 + defaultConfigurationIsVisible = 0; 3539 + defaultConfigurationName = Default; 3540 + }; 3541 + A9E8838D0874A59B00B2DFE8 = { 3542 + isa = XCConfigurationList; 3543 + buildConfigurations = ( 3544 + A9E8838E0874A59B00B2DFE8, 3545 + A9E8838F0874A59B00B2DFE8, 3546 + A9E883900874A59B00B2DFE8, 3547 + A9E883910874A59B00B2DFE8, 3548 + A9E883920874A59B00B2DFE8, 3549 + ); 3550 + defaultConfigurationIsVisible = 0; 3551 + defaultConfigurationName = Default; 3552 + }; 3553 + A9E883930874A59B00B2DFE8 = { 3554 + isa = XCConfigurationList; 3555 + buildConfigurations = ( 3556 + A9E883940874A59B00B2DFE8, 3557 + A9E883950874A59B00B2DFE8, 3558 + A9E883960874A59B00B2DFE8, 3559 + A9E883970874A59B00B2DFE8, 3560 + A9E883980874A59B00B2DFE8, 3561 + ); 3562 + defaultConfigurationIsVisible = 0; 3563 + defaultConfigurationName = Default; 3564 + }; 3565 + A9E883990874A59B00B2DFE8 = { 3566 + isa = XCConfigurationList; 3567 + buildConfigurations = ( 3568 + A9E8839A0874A59B00B2DFE8, 3569 + A9E8839B0874A59B00B2DFE8, 3570 + A9E8839C0874A59B00B2DFE8, 3571 + A9E8839D0874A59B00B2DFE8, 3572 + A9E8839E0874A59B00B2DFE8, 3573 + ); 3574 + defaultConfigurationIsVisible = 0; 3575 + defaultConfigurationName = Default; 3576 + }; 3577 + A9E883A50874A59B00B2DFE8 = { 3578 + isa = XCConfigurationList; 3579 + buildConfigurations = ( 3580 + A9E883A60874A59B00B2DFE8, 3581 + A9E883A70874A59B00B2DFE8, 3582 + A9E883A80874A59B00B2DFE8, 3583 + A9E883A90874A59B00B2DFE8, 3584 + A9E883AA0874A59B00B2DFE8, 3585 + ); 3586 + defaultConfigurationIsVisible = 0; 3587 + defaultConfigurationName = Default; 3588 + }; 3589 + A9E883AB0874A59B00B2DFE8 = { 3590 + isa = XCConfigurationList; 3591 + buildConfigurations = ( 3592 + A9E883AC0874A59B00B2DFE8, 3593 + A9E883AD0874A59B00B2DFE8, 3594 + A9E883AE0874A59B00B2DFE8, 3595 + A9E883AF0874A59B00B2DFE8, 3596 + A9E883B00874A59B00B2DFE8, 3597 + ); 3598 + defaultConfigurationIsVisible = 0; 3599 + defaultConfigurationName = Default; 3600 + }; 3601 + A9E883B10874A59B00B2DFE8 = { 3602 + isa = XCConfigurationList; 3603 + buildConfigurations = ( 3604 + A9E883B20874A59B00B2DFE8, 3605 + A9E883B30874A59B00B2DFE8, 3606 + A9E883B40874A59B00B2DFE8, 3607 + A9E883B50874A59B00B2DFE8, 3608 + A9E883B60874A59B00B2DFE8, 3609 + ); 3610 + defaultConfigurationIsVisible = 0; 3611 + defaultConfigurationName = Default; 3612 + }; 3613 + A9E883B70874A59B00B2DFE8 = { 3614 + isa = XCConfigurationList; 3615 + buildConfigurations = ( 3616 + A9E883B80874A59B00B2DFE8, 3617 + A9E883B90874A59B00B2DFE8, 3618 + A9E883BA0874A59B00B2DFE8, 3619 + A9E883BB0874A59B00B2DFE8, 3620 + A9E883BC0874A59B00B2DFE8, 3621 + ); 3622 + defaultConfigurationIsVisible = 0; 3623 + defaultConfigurationName = Default; 3624 + }; 3625 + A9F41D3F08F4B00200A2BC1C = { 3626 + isa = XCConfigurationList; 3627 + buildConfigurations = ( 3628 + A9F41D4008F4B00200A2BC1C, 3629 + A9F41D4108F4B00200A2BC1C, 3630 + A9F41D4208F4B00200A2BC1C, 3631 + A9F41D4308F4B00200A2BC1C, 3632 + A9F41D4408F4B00200A2BC1C, 3633 + ); 3634 + defaultConfigurationIsVisible = 0; 3635 + defaultConfigurationName = Default; 3636 + }; 3637 + /* End XCConfigurationList section */ 3638 + }; 3639 + rootObject = B6B9FA2C05B38B09007FB890; 3640 + }
+55
src/CoreAudio/AudioFileTools/CMakeLists.txt
··· 1 + project(AudioFileTools) 2 + 3 + include_directories(BEFORE ${CMAKE_SOURCE_DIR}/src/external/libcxx/include ${CMAKE_CURRENT_BINARY_DIR}) 4 + 5 + include_directories( 6 + ${CMAKE_CURRENT_SOURCE_DIR}/PublicUtility 7 + ${CMAKE_CURRENT_SOURCE_DIR}/Utility 8 + ${CMAKE_CURRENT_SOURCE_DIR}/../CoreAudioUtilityClasses/CoreAudio/PublicUtility 9 + ) 10 + 11 + add_definitions(-U__DARWIN_UNIX03 -D__DARWIN_UNIX03=0) 12 + 13 + set(sources 14 + PublicUtility/CAChannelMapper.cpp 15 + PublicUtility/CAChannelMappingPlayer.cpp 16 + ${CMAKE_CURRENT_SOURCE_DIR}/../CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAAudioUnit.cpp 17 + ${CMAKE_CURRENT_SOURCE_DIR}/../CoreAudioUtilityClasses/CoreAudio/PublicUtility/CABufferList.cpp 18 + ${CMAKE_CURRENT_SOURCE_DIR}/../CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAComponent.cpp 19 + ${CMAKE_CURRENT_SOURCE_DIR}/../CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAComponentDescription.cpp 20 + ${CMAKE_CURRENT_SOURCE_DIR}/../CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAAudioChannelLayout.cpp 21 + ${CMAKE_CURRENT_SOURCE_DIR}/../CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAAudioChannelLayoutObject.cpp 22 + ${CMAKE_CURRENT_SOURCE_DIR}/../CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAStreamBasicDescription.cpp 23 + ${CMAKE_CURRENT_SOURCE_DIR}/../CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAMutex.cpp 24 + ${CMAKE_CURRENT_SOURCE_DIR}/../CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAHostTimeBase.cpp 25 + ${CMAKE_CURRENT_SOURCE_DIR}/../CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAAudioFileFormats.cpp 26 + ${CMAKE_CURRENT_SOURCE_DIR}/../CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAXException.cpp 27 + ${CMAKE_CURRENT_SOURCE_DIR}/../CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAAUProcessor.cpp 28 + ${CMAKE_CURRENT_SOURCE_DIR}/../CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAFilePathUtils.cpp 29 + ${CMAKE_CURRENT_SOURCE_DIR}/../CoreAudioUtilityClasses/CoreAudio/PublicUtility/AUOutputBL.cpp 30 + PublicUtility/CAAudioFileStreamer.cpp 31 + PublicUtility/CAAudioFilePlayer.cpp 32 + PublicUtility/CAAudioFileRecorder.cpp 33 + PublicUtility/CABufferQueue.cpp 34 + PublicUtility/CAGuard.cpp 35 + PublicUtility/CAPThread.cpp 36 + Utility/CAAudioFileConverter.cpp 37 + Utility/CAChannelLayouts.cpp 38 + Utility/AFToolsCommon.cpp 39 + ) 40 + 41 + add_library(AudioFileTools_util OBJECT ${sources}) 42 + 43 + add_darling_executable(afplay afplay.cpp) 44 + target_link_libraries(afplay AudioFileTools_util system AudioToolbox cxx CoreServices CoreAudio) 45 + 46 + add_darling_executable(afrecord afrecord.cpp) 47 + target_link_libraries(afrecord AudioFileTools_util system AudioToolbox cxx CoreServices CoreAudio) 48 + 49 + add_darling_executable(afinfo afinfo.cpp) 50 + target_link_libraries(afinfo AudioFileTools_util system AudioToolbox cxx CoreServices CoreAudio) 51 + 52 + add_darling_executable(afconvert afconvert.cpp afconvert_main.cpp) 53 + target_link_libraries(afconvert AudioFileTools_util system AudioToolbox cxx CoreServices CoreAudio) 54 + 55 + install(TARGETS afplay afrecord afinfo afconvert DESTINATION libexec/darling/usr/bin)
+1241
src/CoreAudio/AudioFileTools/PublicUtility/CAAudioFile.cpp
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + CAAudioFile.cpp 40 + 41 + =============================================================================*/ 42 + 43 + #include "CAAudioFile.h" 44 + 45 + #if !CAAF_USE_EXTAUDIOFILE 46 + 47 + #include "CAXException.h" 48 + #include <algorithm> 49 + #include "CAHostTimeBase.h" 50 + #include "CADebugMacros.h" 51 + 52 + #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 53 + #include <AudioToolbox/AudioToolbox.h> 54 + #else 55 + #include <AudioFormat.h> 56 + #endif 57 + 58 + #if DEBUG 59 + //#define VERBOSE_IO 1 60 + //#define VERBOSE_CONVERTER 1 61 + //#define VERBOSE_CHANNELMAP 1 62 + //#define LOG_FUNCTION_ENTRIES 1 63 + 64 + #if VERBOSE_CHANNELMAP 65 + #include "CAChannelLayouts.h" // this is in Source/Tests/AudioFileTools/Utility 66 + #endif 67 + #endif 68 + 69 + #if LOG_FUNCTION_ENTRIES 70 + class FunctionLogger { 71 + public: 72 + FunctionLogger(const char *name, const char *fmt=NULL, ...) : mName(name) { 73 + Indent(); 74 + printf("-> %s ", name); 75 + if (fmt) { 76 + va_list args; 77 + va_start(args, fmt); 78 + vprintf(fmt, args); 79 + va_end(args); 80 + } 81 + printf("\n"); 82 + ++sIndent; 83 + } 84 + ~FunctionLogger() { 85 + --sIndent; 86 + Indent(); 87 + printf("<- %s\n", mName); 88 + if (sIndent == 0) 89 + printf("\n"); 90 + } 91 + 92 + static void Indent() { 93 + for (int i = sIndent; --i >= 0; ) { 94 + putchar(' '); putchar(' '); 95 + } 96 + } 97 + 98 + const char *mName; 99 + static int sIndent; 100 + }; 101 + int FunctionLogger::sIndent = 0; 102 + 103 + #define LOG_FUNCTION(name, format, ...) FunctionLogger _flog(name, format, ## __VA_ARGS__); 104 + #else 105 + #define LOG_FUNCTION(name, format, foo) 106 + #endif 107 + 108 + static const UInt32 kDefaultIOBufferSizeBytes = 0x10000; 109 + 110 + #if CAAUDIOFILE_PROFILE 111 + #define StartTiming(af, starttime) UInt64 starttime = af->mProfiling ? CAHostTimeBase::GetTheCurrentTime() : 0 112 + #define ElapsedTime(af, starttime, counter) if (af->mProfiling) counter += (CAHostTimeBase::GetTheCurrentTime() - starttime) 113 + #else 114 + #define StartTiming(af, starttime) 115 + #define ElapsedTime(af, starttime, counter) 116 + #endif 117 + 118 + #define kNoMoreInputRightNow 'nein' 119 + 120 + // _______________________________________________________________________________________ 121 + // 122 + CAAudioFile::CAAudioFile() : 123 + mAudioFile(0), 124 + mUseCache(false), 125 + mFinishingEncoding(false), 126 + mMode(kClosed), 127 + mFileDataOffset(-1), 128 + mFramesToSkipFollowingSeek(0), 129 + 130 + mClientOwnsIOBuffer(false), 131 + mPacketDescs(NULL), 132 + mNumPacketDescs(0), 133 + mConverter(NULL), 134 + mMagicCookie(NULL), 135 + mWriteBufferList(NULL) 136 + #if CAAUDIOFILE_PROFILE 137 + , 138 + mProfiling(false), 139 + mTicksInConverter(0), 140 + mTicksInReadInConverter(0), 141 + mTicksInIO(0), 142 + mInConverter(false) 143 + #endif 144 + { 145 + mIOBufferList.mBuffers[0].mData = NULL; 146 + mIOBufferList.mBuffers[0].mDataByteSize = 0; 147 + mClientMaxPacketSize = 0; 148 + mIOBufferSizeBytes = kDefaultIOBufferSizeBytes; 149 + } 150 + 151 + // _______________________________________________________________________________________ 152 + // 153 + CAAudioFile::~CAAudioFile() 154 + { 155 + Close(); 156 + } 157 + 158 + // _______________________________________________________________________________________ 159 + // 160 + void CAAudioFile::Close() 161 + { 162 + LOG_FUNCTION("CAAudioFile::Close", NULL, NULL); 163 + if (mMode == kClosed) 164 + return; 165 + if (mMode == kWriting) 166 + FlushEncoder(); 167 + CloseConverter(); 168 + if (mAudioFile != 0 && mOwnOpenFile) { 169 + AudioFileClose(mAudioFile); 170 + mAudioFile = 0; 171 + } 172 + if (!mClientOwnsIOBuffer) { 173 + delete[] (Byte *)mIOBufferList.mBuffers[0].mData; 174 + mIOBufferList.mBuffers[0].mData = NULL; 175 + mIOBufferList.mBuffers[0].mDataByteSize = 0; 176 + } 177 + delete[] mPacketDescs; mPacketDescs = NULL; mNumPacketDescs = 0; 178 + delete[] mMagicCookie; mMagicCookie = NULL; 179 + delete mWriteBufferList; mWriteBufferList = NULL; 180 + mMode = kClosed; 181 + } 182 + 183 + // _______________________________________________________________________________________ 184 + // 185 + void CAAudioFile::CloseConverter() 186 + { 187 + if (mConverter) { 188 + #if VERBOSE_CONVERTER 189 + printf("CAAudioFile %p : CloseConverter\n", this); 190 + #endif 191 + AudioConverterDispose(mConverter); 192 + mConverter = NULL; 193 + } 194 + } 195 + 196 + // ======================================================================================= 197 + 198 + // _______________________________________________________________________________________ 199 + // 200 + void CAAudioFile::Open(const FSRef &fsref) 201 + { 202 + LOG_FUNCTION("CAAudioFile::Open", "%p", this); 203 + XThrowIf(mMode != kClosed, kExtAudioFileError_InvalidOperationOrder, "file already open"); 204 + mFSRef = fsref; 205 + XThrowIfError(AudioFileOpen(&mFSRef, fsRdPerm, 0, &mAudioFile), "open audio file"); 206 + mOwnOpenFile = true; 207 + mMode = kReading; 208 + GetExistingFileInfo(); 209 + } 210 + 211 + // _______________________________________________________________________________________ 212 + // 213 + void CAAudioFile::Wrap(AudioFileID fileID, bool forWriting) 214 + { 215 + LOG_FUNCTION("CAAudioFile::Wrap", "%p", this); 216 + XThrowIf(mMode != kClosed, kExtAudioFileError_InvalidOperationOrder, "file already open"); 217 + 218 + mAudioFile = fileID; 219 + mOwnOpenFile = false; 220 + mMode = forWriting ? kPreparingToWrite : kReading; 221 + GetExistingFileInfo(); 222 + if (forWriting) 223 + FileFormatChanged(); 224 + } 225 + 226 + // _______________________________________________________________________________________ 227 + // 228 + void CAAudioFile::CreateNew(const FSRef &parentDir, CFStringRef filename, AudioFileTypeID filetype, const AudioStreamBasicDescription &dataFormat, const AudioChannelLayout *layout) 229 + { 230 + LOG_FUNCTION("CAAudioFile::CreateNew", "%p", this); 231 + XThrowIf(mMode != kClosed, kExtAudioFileError_InvalidOperationOrder, "file already open"); 232 + 233 + mFileDataFormat = dataFormat; 234 + if (layout) { 235 + mFileChannelLayout = layout; 236 + #if VERBOSE_CHANNELMAP 237 + printf("PrepareNew passed channel layout: %s\n", CAChannelLayouts::ConstantToString(mFileChannelLayout.Tag())); 238 + #endif 239 + } 240 + mMode = kPreparingToCreate; 241 + FileFormatChanged(&parentDir, filename, filetype); 242 + } 243 + 244 + // _______________________________________________________________________________________ 245 + // 246 + // called to create the file -- or update its format/channel layout/properties based on an encoder 247 + // setting change 248 + void CAAudioFile::FileFormatChanged(const FSRef *parentDir, CFStringRef filename, AudioFileTypeID filetype) 249 + { 250 + LOG_FUNCTION("CAAudioFile::FileFormatChanged", "%p", this); 251 + XThrowIf(mMode != kPreparingToCreate && mMode != kPreparingToWrite, kExtAudioFileError_InvalidOperationOrder, "new file not prepared"); 252 + 253 + UInt32 propertySize; 254 + OSStatus err; 255 + AudioStreamBasicDescription saveFileDataFormat = mFileDataFormat; 256 + 257 + #if VERBOSE_CONVERTER 258 + mFileDataFormat.PrintFormat(stdout, "", "Specified file data format"); 259 + #endif 260 + 261 + // Find out the actual format the converter will produce. This is necessary in 262 + // case the bitrate has forced a lower sample rate, which needs to be set correctly 263 + // in the stream description passed to AudioFileCreate. 264 + if (mConverter != NULL) { 265 + propertySize = sizeof(AudioStreamBasicDescription); 266 + Float64 origSampleRate = mFileDataFormat.mSampleRate; 267 + XThrowIfError(AudioConverterGetProperty(mConverter, kAudioConverterCurrentOutputStreamDescription, &propertySize, &mFileDataFormat), "get audio converter's output stream description"); 268 + // do the same for the channel layout being output by the converter 269 + #if VERBOSE_CONVERTER 270 + mFileDataFormat.PrintFormat(stdout, "", "Converter output"); 271 + #endif 272 + if (fiszero(mFileDataFormat.mSampleRate)) 273 + mFileDataFormat.mSampleRate = origSampleRate; 274 + err = AudioConverterGetPropertyInfo(mConverter, kAudioConverterOutputChannelLayout, &propertySize, NULL); 275 + if (err == noErr && propertySize > 0) { 276 + AudioChannelLayout *layout = static_cast<AudioChannelLayout *>(malloc(propertySize)); 277 + err = AudioConverterGetProperty(mConverter, kAudioConverterOutputChannelLayout, &propertySize, layout); 278 + if (err) { 279 + free(layout); 280 + XThrow(err, "couldn't get audio converter's output channel layout"); 281 + } 282 + mFileChannelLayout = layout; 283 + #if VERBOSE_CHANNELMAP 284 + printf("got new file's channel layout from converter: %s\n", CAChannelLayouts::ConstantToString(mFileChannelLayout.Tag())); 285 + #endif 286 + free(layout); 287 + } 288 + } 289 + 290 + // create the output file 291 + if (mMode == kPreparingToCreate) { 292 + CAStreamBasicDescription newFileDataFormat = mFileDataFormat; 293 + if (fiszero(newFileDataFormat.mSampleRate)) 294 + newFileDataFormat.mSampleRate = 44100; // just make something up for now 295 + #if VERBOSE_CONVERTER 296 + newFileDataFormat.PrintFormat(stdout, "", "Applied to new file"); 297 + #endif 298 + XThrowIfError(AudioFileCreate(parentDir, filename, filetype, &newFileDataFormat, 0, &mFSRef, &mAudioFile), "create audio file"); 299 + mMode = kPreparingToWrite; 300 + mOwnOpenFile = true; 301 + } else if (saveFileDataFormat != mFileDataFormat || fnotequal(saveFileDataFormat.mSampleRate, mFileDataFormat.mSampleRate)) { 302 + // second check must be explicit since operator== on ASBD treats SR of zero as "don't care" 303 + if (fiszero(mFileDataFormat.mSampleRate)) 304 + mFileDataFormat.mSampleRate = mClientDataFormat.mSampleRate; 305 + #if VERBOSE_CONVERTER 306 + mFileDataFormat.PrintFormat(stdout, "", "Applied to new file"); 307 + #endif 308 + XThrowIf(fiszero(mFileDataFormat.mSampleRate), kExtAudioFileError_InvalidDataFormat, "file's sample rate is 0"); 309 + XThrowIfError(AudioFileSetProperty(mAudioFile, kAudioFilePropertyDataFormat, sizeof(AudioStreamBasicDescription), &mFileDataFormat), "couldn't update file's data format"); 310 + } 311 + 312 + UInt32 deferSizeUpdates = 1; 313 + err = AudioFileSetProperty(mAudioFile, kAudioFilePropertyDeferSizeUpdates, sizeof(UInt32), &deferSizeUpdates); 314 + 315 + if (mConverter != NULL) { 316 + // encoder 317 + // get the magic cookie, if any, from the converter 318 + delete[] mMagicCookie; mMagicCookie = NULL; 319 + mMagicCookieSize = 0; 320 + 321 + err = AudioConverterGetPropertyInfo(mConverter, kAudioConverterCompressionMagicCookie, &propertySize, NULL); 322 + 323 + // we can get a noErr result and also a propertySize == 0 324 + // -- if the file format does support magic cookies, but this file doesn't have one. 325 + if (err == noErr && propertySize > 0) { 326 + mMagicCookie = new Byte[propertySize]; 327 + XThrowIfError(AudioConverterGetProperty(mConverter, kAudioConverterCompressionMagicCookie, &propertySize, mMagicCookie), "get audio converter's magic cookie"); 328 + mMagicCookieSize = propertySize; // the converter lies and tell us the wrong size 329 + // now set the magic cookie on the output file 330 + UInt32 willEatTheCookie = false; 331 + // the converter wants to give us one; will the file take it? 332 + err = AudioFileGetPropertyInfo(mAudioFile, kAudioFilePropertyMagicCookieData, 333 + NULL, &willEatTheCookie); 334 + if (err == noErr && willEatTheCookie) { 335 + #if VERBOSE_CONVERTER 336 + printf("Setting cookie on encoded file\n"); 337 + #endif 338 + XThrowIfError(AudioFileSetProperty(mAudioFile, kAudioFilePropertyMagicCookieData, mMagicCookieSize, mMagicCookie), "set audio file's magic cookie"); 339 + } 340 + } 341 + 342 + // get maximum packet size 343 + propertySize = sizeof(UInt32); 344 + XThrowIfError(AudioConverterGetProperty(mConverter, kAudioConverterPropertyMaximumOutputPacketSize, &propertySize, &mFileMaxPacketSize), "get audio converter's maximum output packet size"); 345 + 346 + AllocateBuffers(true /* okToFail */); 347 + } else { 348 + InitFileMaxPacketSize(); 349 + } 350 + 351 + if (mFileChannelLayout.IsValid() && mFileChannelLayout.NumberChannels() > 2) { 352 + // don't bother tagging mono/stereo files 353 + UInt32 isWritable; 354 + err = AudioFileGetPropertyInfo(mAudioFile, kAudioFilePropertyChannelLayout, NULL, &isWritable); 355 + if (!err && isWritable) { 356 + #if VERBOSE_CHANNELMAP 357 + printf("writing file's channel layout: %s\n", CAChannelLayouts::ConstantToString(mFileChannelLayout.Tag())); 358 + #endif 359 + err = AudioFileSetProperty(mAudioFile, kAudioFilePropertyChannelLayout, 360 + mFileChannelLayout.Size(), &mFileChannelLayout.Layout()); 361 + if (err) 362 + CAXException::Warning("could not set the file's channel layout", err); 363 + } else { 364 + #if VERBOSE_CHANNELMAP 365 + printf("file won't accept a channel layout (write)\n"); 366 + #endif 367 + } 368 + } 369 + 370 + UpdateClientMaxPacketSize(); // also sets mFrame0Offset 371 + mPacketMark = 0; 372 + mFrameMark = 0; 373 + } 374 + 375 + // _______________________________________________________________________________________ 376 + // 377 + void CAAudioFile::InitFileMaxPacketSize() 378 + { 379 + LOG_FUNCTION("CAAudioFile::InitFileMaxPacketSize", "%p", this); 380 + UInt32 propertySize = sizeof(UInt32); 381 + OSStatus err = AudioFileGetProperty(mAudioFile, kAudioFilePropertyMaximumPacketSize, 382 + &propertySize, &mFileMaxPacketSize); 383 + if (err) { 384 + // workaround for 3361377: not all file formats' maximum packet sizes are supported 385 + if (!mFileDataFormat.IsPCM()) 386 + XThrowIfError(err, "get audio file's maximum packet size"); 387 + mFileMaxPacketSize = mFileDataFormat.mBytesPerFrame; 388 + } 389 + AllocateBuffers(true /* okToFail */); 390 + } 391 + 392 + 393 + // _______________________________________________________________________________________ 394 + // 395 + SInt64 CAAudioFile::FileDataOffset() 396 + { 397 + if (mFileDataOffset < 0) { 398 + UInt32 propertySize = sizeof(SInt64); 399 + XThrowIfError(AudioFileGetProperty(mAudioFile, kAudioFilePropertyDataOffset, &propertySize, &mFileDataOffset), "couldn't get file's data offset"); 400 + } 401 + return mFileDataOffset; 402 + } 403 + 404 + // _______________________________________________________________________________________ 405 + // 406 + SInt64 CAAudioFile::GetNumberFrames() const 407 + { 408 + AudioFilePacketTableInfo pti; 409 + UInt32 propertySize = sizeof(pti); 410 + OSStatus err = AudioFileGetProperty(mAudioFile, kAudioFilePropertyPacketTableInfo, &propertySize, &pti); 411 + if (err == noErr) 412 + return pti.mNumberValidFrames; 413 + return mFileDataFormat.mFramesPerPacket * GetNumberPackets() - mFrame0Offset; 414 + } 415 + 416 + // _______________________________________________________________________________________ 417 + // 418 + void CAAudioFile::SetNumberFrames(SInt64 nFrames) 419 + { 420 + XThrowIf(mFileDataFormat.mFramesPerPacket != 1, kExtAudioFileError_InvalidDataFormat, "SetNumberFrames only supported for PCM"); 421 + XThrowIfError(AudioFileSetProperty(mAudioFile, kAudioFilePropertyAudioDataPacketCount, sizeof(SInt64), &nFrames), "Couldn't set number of packets on audio file"); 422 + } 423 + 424 + // _______________________________________________________________________________________ 425 + // 426 + // call for existing file, NOT new one - from Open() or Wrap() 427 + void CAAudioFile::GetExistingFileInfo() 428 + { 429 + LOG_FUNCTION("CAAudioFile::GetExistingFileInfo", "%p", this); 430 + UInt32 propertySize; 431 + OSStatus err; 432 + 433 + // get mFileDataFormat 434 + propertySize = sizeof(AudioStreamBasicDescription); 435 + XThrowIfError(AudioFileGetProperty(mAudioFile, kAudioFilePropertyDataFormat, &propertySize, &mFileDataFormat), "get audio file's data format"); 436 + 437 + // get mFileChannelLayout 438 + err = AudioFileGetPropertyInfo(mAudioFile, kAudioFilePropertyChannelLayout, &propertySize, NULL); 439 + if (err == noErr && propertySize > 0) { 440 + AudioChannelLayout *layout = static_cast<AudioChannelLayout *>(malloc(propertySize)); 441 + err = AudioFileGetProperty(mAudioFile, kAudioFilePropertyChannelLayout, &propertySize, layout); 442 + if (err == noErr) { 443 + mFileChannelLayout = layout; 444 + #if VERBOSE_CHANNELMAP 445 + printf("existing file's channel layout: %s\n", CAChannelLayouts::ConstantToString(mFileChannelLayout.Tag())); 446 + #endif 447 + } 448 + free(layout); 449 + XThrowIfError(err, "get audio file's channel layout"); 450 + } 451 + if (mMode != kReading) 452 + return; 453 + 454 + #if 0 455 + // get mNumberPackets 456 + propertySize = sizeof(mNumberPackets); 457 + XThrowIfError(AudioFileGetProperty(mAudioFile, kAudioFilePropertyAudioDataPacketCount, &propertySize, &mNumberPackets), "get audio file's packet count"); 458 + #if VERBOSE_IO 459 + printf("CAAudioFile::GetExistingFileInfo: %qd packets\n", mNumberPackets); 460 + #endif 461 + #endif 462 + 463 + // get mMagicCookie 464 + err = AudioFileGetPropertyInfo(mAudioFile, kAudioFilePropertyMagicCookieData, &propertySize, NULL); 465 + if (err == noErr && propertySize > 0) { 466 + mMagicCookie = new Byte[propertySize]; 467 + mMagicCookieSize = propertySize; 468 + XThrowIfError(AudioFileGetProperty(mAudioFile, kAudioFilePropertyMagicCookieData, &propertySize, mMagicCookie), "get audio file's magic cookie"); 469 + } 470 + InitFileMaxPacketSize(); 471 + mPacketMark = 0; 472 + mFrameMark = 0; 473 + 474 + UpdateClientMaxPacketSize(); 475 + } 476 + 477 + // ======================================================================================= 478 + 479 + // _______________________________________________________________________________________ 480 + // 481 + void CAAudioFile::SetFileChannelLayout(const CAAudioChannelLayout &layout) 482 + { 483 + LOG_FUNCTION("CAAudioFile::SetFileChannelLayout", "%p", this); 484 + mFileChannelLayout = layout; 485 + #if VERBOSE_CHANNELMAP 486 + printf("file channel layout set explicitly (%s): %s\n", mMode == kReading ? "read" : "write", CAChannelLayouts::ConstantToString(mFileChannelLayout.Tag())); 487 + #endif 488 + if (mMode != kReading) 489 + FileFormatChanged(); 490 + } 491 + 492 + // _______________________________________________________________________________________ 493 + // 494 + void CAAudioFile::SetClientFormat(const CAStreamBasicDescription &dataFormat, const CAAudioChannelLayout *layout) 495 + { 496 + LOG_FUNCTION("CAAudioFile::SetClientFormat", "%p", this); 497 + XThrowIf(!dataFormat.IsPCM(), kExtAudioFileError_NonPCMClientFormat, "non-PCM client format on audio file"); 498 + 499 + bool dataFormatChanging = (mClientDataFormat.mFormatID == 0 || mClientDataFormat != dataFormat); 500 + 501 + if (dataFormatChanging) { 502 + CloseConverter(); 503 + if (mWriteBufferList) { 504 + delete mWriteBufferList; 505 + mWriteBufferList = NULL; 506 + } 507 + mClientDataFormat = dataFormat; 508 + } 509 + 510 + if (layout && layout->IsValid()) { 511 + XThrowIf(layout->NumberChannels() != mClientDataFormat.NumberChannels(), kExtAudioFileError_InvalidChannelMap, "inappropriate channel map"); 512 + mClientChannelLayout = *layout; 513 + } 514 + 515 + bool differentLayouts; 516 + if (mClientChannelLayout.IsValid()) { 517 + if (mFileChannelLayout.IsValid()) { 518 + differentLayouts = mClientChannelLayout.Tag() != mFileChannelLayout.Tag(); 519 + #if VERBOSE_CHANNELMAP 520 + printf("two valid layouts, %s\n", differentLayouts ? "different" : "same"); 521 + #endif 522 + } else { 523 + differentLayouts = false; 524 + #if VERBOSE_CHANNELMAP 525 + printf("valid client layout, unknown file layout\n"); 526 + #endif 527 + } 528 + } else { 529 + differentLayouts = false; 530 + #if VERBOSE_CHANNELMAP 531 + if (mFileChannelLayout.IsValid()) 532 + printf("valid file layout, unknown client layout\n"); 533 + else 534 + printf("two invalid layouts\n"); 535 + #endif 536 + } 537 + 538 + if (mClientDataFormat != mFileDataFormat || differentLayouts) { 539 + // We need an AudioConverter. 540 + if (mMode == kReading) { 541 + // file -> client (decode) 542 + //mFileDataFormat.PrintFormat( stdout, "", "File: "); 543 + //mClientDataFormat.PrintFormat(stdout, "", "Client: "); 544 + 545 + if (mConverter == NULL) 546 + XThrowIfError(AudioConverterNew(&mFileDataFormat, &mClientDataFormat, &mConverter), 547 + "create audio converter"); 548 + 549 + #if VERBOSE_CONVERTER 550 + printf("CAAudioFile %p -- created converter\n", this); 551 + CAShow(mConverter); 552 + #endif 553 + // set the magic cookie, if any (for decode) 554 + if (mMagicCookie) 555 + SetConverterProperty(kAudioConverterDecompressionMagicCookie, mMagicCookieSize, mMagicCookie, mFileDataFormat.IsPCM()); 556 + // we get cookies from some AIFF's but the converter barfs on them, 557 + // so we set canFail to true for PCM 558 + 559 + SetConverterChannelLayout(false, mFileChannelLayout); 560 + SetConverterChannelLayout(true, mClientChannelLayout); 561 + 562 + // propagate leading/trailing frame counts 563 + if (mFileDataFormat.mBitsPerChannel == 0) { 564 + UInt32 propertySize; 565 + OSStatus err; 566 + AudioFilePacketTableInfo pti; 567 + propertySize = sizeof(pti); 568 + err = AudioFileGetProperty(mAudioFile, kAudioFilePropertyPacketTableInfo, &propertySize, &pti); 569 + if (err == noErr && (pti.mPrimingFrames > 0 || pti.mRemainderFrames > 0)) { 570 + AudioConverterPrimeInfo primeInfo; 571 + primeInfo.leadingFrames = pti.mPrimingFrames; 572 + primeInfo.trailingFrames = pti.mRemainderFrames; 573 + /* ignore any error. better to play it at all than not. */ 574 + /*err = */AudioConverterSetProperty(mConverter, kAudioConverterPrimeInfo, sizeof(primeInfo), &primeInfo); 575 + //XThrowIfError(err, "couldn't set prime info on converter"); 576 + } 577 + } 578 + } else if (mMode == kPreparingToCreate || mMode == kPreparingToWrite) { 579 + // client -> file (encode) 580 + if (mConverter == NULL) 581 + XThrowIfError(AudioConverterNew(&mClientDataFormat, &mFileDataFormat, &mConverter), "create audio converter"); 582 + mWriteBufferList = CABufferList::New("", mClientDataFormat); 583 + SetConverterChannelLayout(false, mClientChannelLayout); 584 + SetConverterChannelLayout(true, mFileChannelLayout); 585 + if (mMode == kPreparingToWrite) 586 + FileFormatChanged(); 587 + } else 588 + XThrowIfError(kExtAudioFileError_InvalidOperationOrder, "audio file format not yet known"); 589 + } 590 + UpdateClientMaxPacketSize(); 591 + } 592 + 593 + // _______________________________________________________________________________________ 594 + // 595 + OSStatus CAAudioFile::SetConverterProperty( 596 + AudioConverterPropertyID inPropertyID, 597 + UInt32 inPropertyDataSize, 598 + const void* inPropertyData, 599 + bool inCanFail) 600 + { 601 + OSStatus err = noErr; 602 + //LOG_FUNCTION("ExtAudioFile::SetConverterProperty", "%p %-4.4s", this, (char *)&inPropertyID); 603 + if (inPropertyID == kAudioConverterPropertySettings && *(CFPropertyListRef *)inPropertyData == NULL) 604 + ; 605 + else { 606 + err = AudioConverterSetProperty(mConverter, inPropertyID, inPropertyDataSize, inPropertyData); 607 + if (!inCanFail) { 608 + XThrowIfError(err, "set audio converter property"); 609 + } 610 + } 611 + UpdateClientMaxPacketSize(); 612 + if (mMode == kPreparingToWrite) 613 + FileFormatChanged(); 614 + return err; 615 + } 616 + 617 + // _______________________________________________________________________________________ 618 + // 619 + void CAAudioFile::SetConverterChannelLayout(bool output, const CAAudioChannelLayout &layout) 620 + { 621 + LOG_FUNCTION("CAAudioFile::SetConverterChannelLayout", "%p", this); 622 + OSStatus err; 623 + 624 + if (layout.IsValid()) { 625 + #if VERBOSE_CHANNELMAP 626 + printf("Setting converter's %s channel layout: %s\n", output ? "output" : "input", 627 + CAChannelLayouts::ConstantToString(mFileChannelLayout.Tag())); 628 + #endif 629 + if (output) { 630 + err = AudioConverterSetProperty(mConverter, kAudioConverterOutputChannelLayout, 631 + layout.Size(), &layout.Layout()); 632 + XThrowIf(err && err != kAudioConverterErr_OperationNotSupported, err, "couldn't set converter's output channel layout"); 633 + } else { 634 + err = AudioConverterSetProperty(mConverter, kAudioConverterInputChannelLayout, 635 + layout.Size(), &layout.Layout()); 636 + XThrowIf(err && err != kAudioConverterErr_OperationNotSupported, err, "couldn't set converter's input channel layout"); 637 + } 638 + if (mMode == kPreparingToWrite) 639 + FileFormatChanged(); 640 + } 641 + } 642 + 643 + // _______________________________________________________________________________________ 644 + // 645 + CFArrayRef CAAudioFile::GetConverterConfig() 646 + { 647 + CFArrayRef plist; 648 + UInt32 propertySize = sizeof(plist); 649 + XThrowIfError(AudioConverterGetProperty(mConverter, kAudioConverterPropertySettings, &propertySize, &plist), "get converter property settings"); 650 + return plist; 651 + } 652 + 653 + // _______________________________________________________________________________________ 654 + // 655 + void CAAudioFile::UpdateClientMaxPacketSize() 656 + { 657 + LOG_FUNCTION("CAAudioFile::UpdateClientMaxPacketSize", "%p", this); 658 + mFrame0Offset = 0; 659 + if (mConverter != NULL) { 660 + AudioConverterPropertyID property = (mMode == kReading) ? 661 + kAudioConverterPropertyMaximumOutputPacketSize : 662 + kAudioConverterPropertyMaximumInputPacketSize; 663 + 664 + UInt32 propertySize = sizeof(UInt32); 665 + XThrowIfError(AudioConverterGetProperty(mConverter, property, &propertySize, &mClientMaxPacketSize), 666 + "get audio converter's maximum packet size"); 667 + 668 + if (mFileDataFormat.mBitsPerChannel == 0) { 669 + AudioConverterPrimeInfo primeInfo; 670 + propertySize = sizeof(primeInfo); 671 + OSStatus err = AudioConverterGetProperty(mConverter, kAudioConverterPrimeInfo, &propertySize, &primeInfo); 672 + if (err == noErr) 673 + mFrame0Offset = primeInfo.leadingFrames; 674 + #if VERBOSE_CONVERTER 675 + printf("kAudioConverterPrimeInfo: err = %ld, leadingFrames = %ld\n", err, mFrame0Offset); 676 + #endif 677 + } 678 + } else { 679 + mClientMaxPacketSize = mFileMaxPacketSize; 680 + } 681 + } 682 + 683 + // _______________________________________________________________________________________ 684 + // Allocates: mIOBufferList, mIOBufferSizePackets, mPacketDescs 685 + // Dependent on: mFileMaxPacketSize, mIOBufferSizeBytes 686 + void CAAudioFile::AllocateBuffers(bool okToFail) 687 + { 688 + LOG_FUNCTION("CAAudioFile::AllocateBuffers", "%p", this); 689 + if (mFileMaxPacketSize == 0) { 690 + if (okToFail) 691 + return; 692 + XThrowIf(true, kExtAudioFileError_MaxPacketSizeUnknown, "file's maximum packet size is 0"); 693 + } 694 + UInt32 bufferSizeBytes = mIOBufferSizeBytes = std::max(mIOBufferSizeBytes, mFileMaxPacketSize); 695 + // must be big enough for at least one maximum size packet 696 + 697 + if (mIOBufferList.mBuffers[0].mDataByteSize != bufferSizeBytes) { 698 + mIOBufferList.mNumberBuffers = 1; 699 + mIOBufferList.mBuffers[0].mNumberChannels = mFileDataFormat.mChannelsPerFrame; 700 + if (!mClientOwnsIOBuffer) { 701 + //printf("reallocating I/O buffer\n"); 702 + delete[] (Byte *)mIOBufferList.mBuffers[0].mData; 703 + mIOBufferList.mBuffers[0].mData = new Byte[bufferSizeBytes]; 704 + } 705 + mIOBufferList.mBuffers[0].mDataByteSize = bufferSizeBytes; 706 + mIOBufferSizePackets = bufferSizeBytes / mFileMaxPacketSize; 707 + } 708 + 709 + UInt32 propertySize = sizeof(UInt32); 710 + UInt32 externallyFramed; 711 + XThrowIfError(AudioFormatGetProperty(kAudioFormatProperty_FormatIsExternallyFramed, 712 + sizeof(AudioStreamBasicDescription), &mFileDataFormat, &propertySize, &externallyFramed), 713 + "is format externally framed"); 714 + if (mNumPacketDescs != (externallyFramed ? mIOBufferSizePackets : 0)) { 715 + delete[] mPacketDescs; 716 + mPacketDescs = NULL; 717 + mNumPacketDescs = 0; 718 + 719 + if (externallyFramed) { 720 + //printf("reallocating packet descs\n"); 721 + mPacketDescs = new AudioStreamPacketDescription[mIOBufferSizePackets]; 722 + mNumPacketDescs = mIOBufferSizePackets; 723 + } 724 + } 725 + } 726 + 727 + // _______________________________________________________________________________________ 728 + // 729 + void CAAudioFile::SetIOBuffer(void *buf) 730 + { 731 + if (!mClientOwnsIOBuffer) 732 + delete[] (Byte *)mIOBufferList.mBuffers[0].mData; 733 + mIOBufferList.mBuffers[0].mData = buf; 734 + 735 + if (buf == NULL) { 736 + mClientOwnsIOBuffer = false; 737 + SetIOBufferSizeBytes(mIOBufferSizeBytes); 738 + } else { 739 + mClientOwnsIOBuffer = true; 740 + AllocateBuffers(); 741 + } 742 + // printf("CAAudioFile::SetIOBuffer %p: %p, 0x%lx bytes, mClientOwns = %d\n", this, mIOBufferList.mBuffers[0].mData, mIOBufferSizeBytes, mClientOwnsIOBuffer); 743 + } 744 + 745 + // =============================================================================== 746 + 747 + /* 748 + For Tiger: 749 + added kAudioFilePropertyPacketToFrame and kAudioFilePropertyFrameToPacket. 750 + You pass in an AudioFramePacketTranslation struct, with the appropriate field filled in, to AudioFileGetProperty. 751 + 752 + kAudioFilePropertyPacketToFrame = 'pkfr', 753 + // pass a AudioFramePacketTranslation with mPacket filled out and get mFrame back. mFrameOffsetInPacket is ignored. 754 + kAudioFilePropertyFrameToPacket = 'frpk', 755 + // pass a AudioFramePacketTranslation with mFrame filled out and get mPacket and mFrameOffsetInPacket back. 756 + 757 + struct AudioFramePacketTranslation 758 + { 759 + SInt64 mFrame; 760 + SInt64 mPacket; 761 + UInt32 mFrameOffsetInPacket; 762 + }; 763 + */ 764 + 765 + SInt64 CAAudioFile::PacketToFrame(SInt64 packet) const 766 + { 767 + AudioFramePacketTranslation trans; 768 + UInt32 propertySize; 769 + 770 + switch (mFileDataFormat.mFramesPerPacket) { 771 + case 1: 772 + return packet; 773 + case 0: 774 + trans.mPacket = packet; 775 + propertySize = sizeof(trans); 776 + XThrowIfError(AudioFileGetProperty(mAudioFile, kAudioFilePropertyPacketToFrame, &propertySize, &trans), 777 + "packet <-> frame translation unimplemented for format with variable frames/packet"); 778 + return trans.mFrame; 779 + } 780 + return packet * mFileDataFormat.mFramesPerPacket; 781 + } 782 + 783 + SInt64 CAAudioFile::FrameToPacket(SInt64 inFrame) const 784 + { 785 + AudioFramePacketTranslation trans; 786 + UInt32 propertySize; 787 + 788 + switch (mFileDataFormat.mFramesPerPacket) { 789 + case 1: 790 + return inFrame; 791 + case 0: 792 + trans.mFrame = inFrame; 793 + propertySize = sizeof(trans); 794 + XThrowIfError(AudioFileGetProperty(mAudioFile, kAudioFilePropertyFrameToPacket, &propertySize, &trans), 795 + "packet <-> frame translation unimplemented for format with variable frames/packet"); 796 + return trans.mPacket; 797 + } 798 + return inFrame / mFileDataFormat.mFramesPerPacket; 799 + } 800 + 801 + // _______________________________________________________________________________________ 802 + // 803 + 804 + SInt64 CAAudioFile::Tell() const // frameNumber 805 + { 806 + return mFrameMark - mFrame0Offset; 807 + } 808 + 809 + void CAAudioFile::SeekToPacket(SInt64 packetNumber) 810 + { 811 + #if VERBOSE_IO 812 + printf("CAAudioFile::SeekToPacket: %qd\n", packetNumber); 813 + #endif 814 + XThrowIf(mMode != kReading || packetNumber < 0 /*|| packetNumber >= mNumberPackets*/ , kExtAudioFileError_InvalidSeek, "seek to packet in audio file"); 815 + if (mPacketMark == packetNumber) 816 + return; // already there! don't reset converter 817 + mPacketMark = packetNumber; 818 + 819 + mFrameMark = PacketToFrame(packetNumber) - mFrame0Offset; 820 + mFramesToSkipFollowingSeek = 0; 821 + if (mConverter) 822 + // must reset -- if we reached end of stream. converter will no longer work otherwise 823 + AudioConverterReset(mConverter); 824 + } 825 + 826 + /* 827 + Example: AAC, 1024 frames/packet, 2112 frame offset 828 + 829 + 2112 830 + | 831 + Absolute frames: 0 1024 2048 | 3072 832 + +---------+---------+--|------+---------+---------+ 833 + Packets: | 0 | 1 | | 2 | 3 | 4 | 834 + +---------+---------+--|------+---------+---------+ 835 + Client frames: -2112 -1088 -64 | 960 SeekToFrame, TellFrame 836 + | 837 + 0 838 + 839 + * Offset between absolute and client frames is mFrame0Offset. 840 + *** mFrameMark is in client frames *** 841 + 842 + Examples: 843 + clientFrame 0 960 1000 1024 844 + absoluteFrame 2112 3072 3112 3136 845 + packet 0 0 0 1 846 + tempFrameMark* -2112 -2112 -2112 -1088 847 + mFramesToSkipFollowingSeek 2112 3072 3112 2112 848 + */ 849 + void CAAudioFile::Seek(SInt64 clientFrame) 850 + { 851 + if (clientFrame == mFrameMark) 852 + return; // already there! don't reset converter 853 + 854 + //SInt64 absoluteFrame = clientFrame + mFrame0Offset; 855 + XThrowIf(mMode != kReading || clientFrame < 0 || !mClientDataFormat.IsPCM(), kExtAudioFileError_InvalidSeek, "seek to frame in audio file"); 856 + 857 + #if VERBOSE_IO 858 + SInt64 prevFrameMark = mFrameMark; 859 + #endif 860 + 861 + SInt64 packet; 862 + packet = FrameToPacket(clientFrame); 863 + if (packet < 0) 864 + packet = 0; 865 + SeekToPacket(packet); 866 + // this will have backed up mFrameMark to match the beginning of the packet 867 + mFramesToSkipFollowingSeek = std::max(UInt32(clientFrame - mFrameMark), UInt32(0)); 868 + mFrameMark = clientFrame; 869 + 870 + #if VERBOSE_IO 871 + printf("CAAudioFile::SeekToFrame: frame %qd (from %qd), packet %qd, skip %ld frames\n", mFrameMark, prevFrameMark, packet, mFramesToSkipFollowingSeek); 872 + #endif 873 + } 874 + 875 + // _______________________________________________________________________________________ 876 + // 877 + void CAAudioFile::Read(UInt32 &ioNumPackets, AudioBufferList *ioData) 878 + // May read fewer packets than requested if: 879 + // buffer is not big enough 880 + // file does not contain that many more packets 881 + // Note that eofErr is not fatal, just results in 0 packets returned 882 + // ioData's buffer sizes may be shortened 883 + { 884 + XThrowIf(mClientMaxPacketSize == 0, kExtAudioFileError_MaxPacketSizeUnknown, "client maximum packet size is 0"); 885 + if (mIOBufferList.mBuffers[0].mData == NULL) { 886 + #if DEBUG 887 + printf("warning: CAAudioFile::AllocateBuffers called from ReadPackets\n"); 888 + #endif 889 + AllocateBuffers(); 890 + } 891 + UInt32 bufferSizeBytes = ioData->mBuffers[0].mDataByteSize; 892 + UInt32 maxNumPackets = bufferSizeBytes / mClientMaxPacketSize; 893 + // older versions of AudioConverterFillComplexBuffer don't do this, so do our own sanity check 894 + UInt32 nPackets = std::min(ioNumPackets, maxNumPackets); 895 + 896 + mMaxPacketsToRead = ~0UL; 897 + 898 + if (mClientDataFormat.mFramesPerPacket == 1) { // PCM or equivalent 899 + while (mFramesToSkipFollowingSeek > 0) { 900 + UInt32 skipFrames = std::min(mFramesToSkipFollowingSeek, maxNumPackets); 901 + UInt32 framesPerPacket; 902 + if ((framesPerPacket=mFileDataFormat.mFramesPerPacket) > 0) 903 + mMaxPacketsToRead = (skipFrames + framesPerPacket - 1) / framesPerPacket; 904 + 905 + if (mConverter == NULL) { 906 + XThrowIfError(ReadInputProc(NULL, &skipFrames, ioData, NULL, this), "read audio file"); 907 + } else { 908 + #if CAAUDIOFILE_PROFILE 909 + mInConverter = true; 910 + #endif 911 + StartTiming(this, fill); 912 + XThrowIfError(AudioConverterFillComplexBuffer(mConverter, ReadInputProc, this, &skipFrames, ioData, NULL), "convert audio packets (pcm read)"); 913 + ElapsedTime(this, fill, mTicksInConverter); 914 + #if CAAUDIOFILE_PROFILE 915 + mInConverter = false; 916 + #endif 917 + } 918 + if (skipFrames == 0) { // hit EOF 919 + ioNumPackets = 0; 920 + return; 921 + } 922 + mFrameMark += skipFrames; 923 + #if VERBOSE_IO 924 + printf("CAAudioFile::ReadPackets: skipped %ld frames\n", skipFrames); 925 + #endif 926 + 927 + mFramesToSkipFollowingSeek -= skipFrames; 928 + 929 + // restore mDataByteSize 930 + for (int i = ioData->mNumberBuffers; --i >= 0 ; ) 931 + ioData->mBuffers[i].mDataByteSize = bufferSizeBytes; 932 + } 933 + } 934 + 935 + if (mFileDataFormat.mFramesPerPacket > 0) 936 + // don't read more packets than we are being asked to produce 937 + mMaxPacketsToRead = nPackets / mFileDataFormat.mFramesPerPacket + 1; 938 + if (mConverter == NULL) { 939 + XThrowIfError(ReadInputProc(NULL, &nPackets, ioData, NULL, this), "read audio file"); 940 + } else { 941 + #if CAAUDIOFILE_PROFILE 942 + mInConverter = true; 943 + #endif 944 + StartTiming(this, fill); 945 + XThrowIfError(AudioConverterFillComplexBuffer(mConverter, ReadInputProc, this, &nPackets, ioData, NULL), "convert audio packets (read)"); 946 + ElapsedTime(this, fill, mTicksInConverter); 947 + #if CAAUDIOFILE_PROFILE 948 + mInConverter = false; 949 + #endif 950 + } 951 + if (mClientDataFormat.mFramesPerPacket == 1) 952 + mFrameMark += nPackets; 953 + 954 + ioNumPackets = nPackets; 955 + } 956 + 957 + // _______________________________________________________________________________________ 958 + // 959 + OSStatus CAAudioFile::ReadInputProc( AudioConverterRef inAudioConverter, 960 + UInt32* ioNumberDataPackets, 961 + AudioBufferList* ioData, 962 + AudioStreamPacketDescription** outDataPacketDescription, 963 + void* inUserData) 964 + { 965 + CAAudioFile *This = static_cast<CAAudioFile *>(inUserData); 966 + 967 + #if 0 968 + SInt64 remainingPacketsInFile = This->mNumberPackets - This->mPacketMark; 969 + if (remainingPacketsInFile <= 0) { 970 + *ioNumberDataPackets = 0; 971 + ioData->mBuffers[0].mDataByteSize = 0; 972 + if (outDataPacketDescription) 973 + *outDataPacketDescription = This->mPacketDescs; 974 + #if VERBOSE_IO 975 + printf("CAAudioFile::ReadInputProc: EOF\n"); 976 + #endif 977 + return noErr; // not eofErr; EOF is signified by 0 packets/0 bytes 978 + } 979 + #endif 980 + 981 + // determine how much to read 982 + AudioBufferList *readBuffer; 983 + UInt32 readPackets; 984 + if (inAudioConverter != NULL) { 985 + // getting called from converter, need to use our I/O buffer 986 + readBuffer = &This->mIOBufferList; 987 + readPackets = This->mIOBufferSizePackets; 988 + } else { 989 + // getting called directly from ReadPackets, use supplied buffer 990 + if (This->mFileMaxPacketSize == 0) 991 + return kExtAudioFileError_MaxPacketSizeUnknown; 992 + readBuffer = ioData; 993 + readPackets = std::min(*ioNumberDataPackets, readBuffer->mBuffers[0].mDataByteSize / This->mFileMaxPacketSize); 994 + // don't attempt to read more packets than will fit in the buffer 995 + } 996 + // don't try to read past EOF 997 + // if (readPackets > remainingPacketsInFile) 998 + // readPackets = remainingPacketsInFile; 999 + // don't read more packets than necessary to produce the requested amount of converted data 1000 + if (readPackets > This->mMaxPacketsToRead) { 1001 + #if VERBOSE_IO 1002 + printf("CAAudioFile::ReadInputProc: limiting read to %ld packets (from %ld)\n", This->mMaxPacketsToRead, readPackets); 1003 + #endif 1004 + readPackets = This->mMaxPacketsToRead; 1005 + } 1006 + 1007 + // read 1008 + UInt32 bytesRead; 1009 + OSStatus err; 1010 + 1011 + StartTiming(This, read); 1012 + StartTiming(This, readinconv); 1013 + err = AudioFileReadPackets(This->mAudioFile, This->mUseCache, &bytesRead, This->mPacketDescs, This->mPacketMark, &readPackets, readBuffer->mBuffers[0].mData); 1014 + #if CAAUDIOFILE_PROFILE 1015 + if (This->mInConverter) ElapsedTime(This, readinconv, This->mTicksInReadInConverter); 1016 + #endif 1017 + ElapsedTime(This, read, This->mTicksInIO); 1018 + 1019 + if (err) { 1020 + DebugMessageN1("Error %ld from AudioFileReadPackets!!!\n", err); 1021 + return err; 1022 + } 1023 + 1024 + #if VERBOSE_IO 1025 + printf("CAAudioFile::ReadInputProc: read %ld packets (%qd-%qd), %ld bytes, err %ld\n", readPackets, This->mPacketMark, This->mPacketMark + readPackets, bytesRead, err); 1026 + #if VERBOSE_IO >= 2 1027 + if (This->mPacketDescs) { 1028 + for (UInt32 i = 0; i < readPackets; ++i) { 1029 + printf(" read packet %qd : offset %qd, length %ld\n", This->mPacketMark + i, This->mPacketDescs[i].mStartOffset, This->mPacketDescs[i].mDataByteSize); 1030 + } 1031 + } 1032 + printf(" read buffer:"); CAShowAudioBufferList(readBuffer, 0, 4); 1033 + #endif 1034 + #endif 1035 + if (readPackets == 0) { 1036 + *ioNumberDataPackets = 0; 1037 + ioData->mBuffers[0].mDataByteSize = 0; 1038 + return noErr; 1039 + } 1040 + 1041 + if (outDataPacketDescription) 1042 + *outDataPacketDescription = This->mPacketDescs; 1043 + ioData->mBuffers[0].mDataByteSize = bytesRead; 1044 + ioData->mBuffers[0].mData = readBuffer->mBuffers[0].mData; 1045 + 1046 + This->mPacketMark += readPackets; 1047 + if (This->mClientDataFormat.mFramesPerPacket != 1) { // for PCM client formats we update in Read 1048 + // but for non-PCM client format (weird case) we must update here/now 1049 + if (This->mFileDataFormat.mFramesPerPacket > 0) 1050 + This->mFrameMark += readPackets * This->mFileDataFormat.mFramesPerPacket; 1051 + else { 1052 + for (UInt32 i = 0; i < readPackets; ++i) 1053 + This->mFrameMark += This->mPacketDescs[i].mVariableFramesInPacket; 1054 + } 1055 + } 1056 + *ioNumberDataPackets = readPackets; 1057 + return noErr; 1058 + } 1059 + 1060 + // _______________________________________________________________________________________ 1061 + // 1062 + void CAAudioFile::Write(UInt32 numPackets, const AudioBufferList *data) 1063 + { 1064 + if (mIOBufferList.mBuffers[0].mData == NULL) { 1065 + #if DEBUG 1066 + printf("warning: CAAudioFile::AllocateBuffers called from WritePackets\n"); 1067 + #endif 1068 + AllocateBuffers(); 1069 + } 1070 + 1071 + if (mMode == kPreparingToWrite) 1072 + mMode = kWriting; 1073 + else 1074 + XThrowIf(mMode != kWriting, kExtAudioFileError_InvalidOperationOrder, "can't write to this file"); 1075 + if (mConverter != NULL) { 1076 + mWritePackets = numPackets; 1077 + mWriteBufferList->SetFrom(data); 1078 + WritePacketsFromCallback(WriteInputProc, this); 1079 + } else { 1080 + StartTiming(this, write); 1081 + XThrowIfError(AudioFileWritePackets(mAudioFile, mUseCache, data->mBuffers[0].mDataByteSize, 1082 + NULL, mPacketMark, &numPackets, data->mBuffers[0].mData), 1083 + "write audio file"); 1084 + ElapsedTime(this, write, mTicksInIO); 1085 + #if VERBOSE_IO 1086 + printf("CAAudioFile::WritePackets: wrote %ld packets at %qd, %ld bytes\n", numPackets, mPacketMark, data->mBuffers[0].mDataByteSize); 1087 + #endif 1088 + //mNumberPackets = 1089 + mPacketMark += numPackets; 1090 + if (mFileDataFormat.mFramesPerPacket > 0) 1091 + mFrameMark += numPackets * mFileDataFormat.mFramesPerPacket; 1092 + // else: shouldn't happen since we're only called when there's no converter 1093 + } 1094 + } 1095 + 1096 + // _______________________________________________________________________________________ 1097 + // 1098 + void CAAudioFile::FlushEncoder() 1099 + { 1100 + if (mConverter != NULL) { 1101 + mFinishingEncoding = true; 1102 + WritePacketsFromCallback(WriteInputProc, this); 1103 + mFinishingEncoding = false; 1104 + 1105 + // get priming info from converter, set it on the file 1106 + if (mFileDataFormat.mBitsPerChannel == 0) { 1107 + UInt32 propertySize; 1108 + OSStatus err; 1109 + AudioConverterPrimeInfo primeInfo; 1110 + propertySize = sizeof(primeInfo); 1111 + 1112 + err = AudioConverterGetProperty(mConverter, kAudioConverterPrimeInfo, &propertySize, &primeInfo); 1113 + if (err == noErr) { 1114 + AudioFilePacketTableInfo pti; 1115 + propertySize = sizeof(pti); 1116 + err = AudioFileGetProperty(mAudioFile, kAudioFilePropertyPacketTableInfo, &propertySize, &pti); 1117 + if (err == noErr) { 1118 + //printf("old packet table info: %qd valid, %ld priming, %ld remainder\n", pti.mNumberValidFrames, pti.mPrimingFrames, pti.mRemainderFrames); 1119 + UInt64 totalFrames = pti.mNumberValidFrames + pti.mPrimingFrames + pti.mRemainderFrames; 1120 + pti.mPrimingFrames = primeInfo.leadingFrames; 1121 + pti.mRemainderFrames = primeInfo.trailingFrames; 1122 + pti.mNumberValidFrames = totalFrames - pti.mPrimingFrames - pti.mRemainderFrames; 1123 + //printf("new packet table info: %qd valid, %ld priming, %ld remainder\n", pti.mNumberValidFrames, pti.mPrimingFrames, pti.mRemainderFrames); 1124 + XThrowIfError(AudioFileSetProperty(mAudioFile, kAudioFilePropertyPacketTableInfo, sizeof(pti), &pti), "couldn't set packet table info on audio file"); 1125 + } 1126 + } 1127 + } 1128 + } 1129 + } 1130 + 1131 + // _______________________________________________________________________________________ 1132 + // 1133 + OSStatus CAAudioFile::WriteInputProc( AudioConverterRef /*inAudioConverter*/, 1134 + UInt32 * ioNumberDataPackets, 1135 + AudioBufferList* ioData, 1136 + AudioStreamPacketDescription ** outDataPacketDescription, 1137 + void* inUserData) 1138 + { 1139 + CAAudioFile *This = static_cast<CAAudioFile *>(inUserData); 1140 + if (This->mFinishingEncoding) { 1141 + *ioNumberDataPackets = 0; 1142 + ioData->mBuffers[0].mDataByteSize = 0; 1143 + ioData->mBuffers[0].mData = NULL; 1144 + if (outDataPacketDescription) 1145 + *outDataPacketDescription = NULL; 1146 + return noErr; 1147 + } 1148 + UInt32 numPackets = This->mWritePackets; 1149 + if (numPackets == 0) { 1150 + return kNoMoreInputRightNow; 1151 + } 1152 + This->mWriteBufferList->ToAudioBufferList(ioData); 1153 + This->mWriteBufferList->BytesConsumed(numPackets * This->mClientDataFormat.mBytesPerFrame); 1154 + *ioNumberDataPackets = numPackets; 1155 + if (outDataPacketDescription) 1156 + *outDataPacketDescription = NULL; 1157 + This->mWritePackets -= numPackets; 1158 + return noErr; 1159 + } 1160 + 1161 + // _______________________________________________________________________________________ 1162 + // 1163 + #if VERBOSE_IO 1164 + static void hexdump(const void *addr, long len) 1165 + { 1166 + const Byte *p = (Byte *)addr; 1167 + UInt32 offset = 0; 1168 + 1169 + if (len > 0x400) len = 0x400; 1170 + 1171 + while (len > 0) { 1172 + int n = len > 16 ? 16 : len; 1173 + printf("%08lX: ", offset); 1174 + for (int i = 0; i < 16; ++i) 1175 + if (i < n) 1176 + printf("%02X ", p[i]); 1177 + else printf(" "); 1178 + for (int i = 0; i < 16; ++i) 1179 + if (i < n) 1180 + putchar(p[i] >= ' ' && p[i] < 127 ? p[i] : '.'); 1181 + else putchar(' '); 1182 + putchar('\n'); 1183 + p += 16; 1184 + len -= 16; 1185 + offset += 16; 1186 + } 1187 + } 1188 + #endif 1189 + 1190 + // _______________________________________________________________________________________ 1191 + // 1192 + void CAAudioFile::WritePacketsFromCallback( 1193 + AudioConverterComplexInputDataProc inInputDataProc, 1194 + void * inInputDataProcUserData) 1195 + { 1196 + while (true) { 1197 + // keep writing until we exhaust the input (temporary stop), or produce no output (EOF) 1198 + UInt32 numEncodedPackets = mIOBufferSizePackets; 1199 + mIOBufferList.mBuffers[0].mDataByteSize = mIOBufferSizeBytes; 1200 + #if CAAUDIOFILE_PROFILE 1201 + mInConverter = true; 1202 + #endif 1203 + StartTiming(this, fill); 1204 + OSStatus err = AudioConverterFillComplexBuffer(mConverter, inInputDataProc, inInputDataProcUserData, 1205 + &numEncodedPackets, &mIOBufferList, mPacketDescs); 1206 + ElapsedTime(this, fill, mTicksInConverter); 1207 + #if CAAUDIOFILE_PROFILE 1208 + mInConverter = false; 1209 + #endif 1210 + XThrowIf(err != 0 && err != kNoMoreInputRightNow, err, "convert audio packets (write)"); 1211 + if (numEncodedPackets == 0) 1212 + break; 1213 + Byte *buf = (Byte *)mIOBufferList.mBuffers[0].mData; 1214 + #if VERBOSE_IO 1215 + printf("CAAudioFile::WritePacketsFromCallback: wrote %ld packets, %ld bytes\n", numEncodedPackets, mIOBufferList.mBuffers[0].mDataByteSize); 1216 + if (mPacketDescs) { 1217 + for (UInt32 i = 0; i < numEncodedPackets; ++i) { 1218 + printf(" write packet %qd : offset %qd, length %ld\n", mPacketMark + i, mPacketDescs[i].mStartOffset, mPacketDescs[i].mDataByteSize); 1219 + #if VERBOSE_IO >= 2 1220 + hexdump(buf + mPacketDescs[i].mStartOffset, mPacketDescs[i].mDataByteSize); 1221 + #endif 1222 + } 1223 + } 1224 + #endif 1225 + StartTiming(this, write); 1226 + XThrowIfError(AudioFileWritePackets(mAudioFile, mUseCache, mIOBufferList.mBuffers[0].mDataByteSize, mPacketDescs, mPacketMark, &numEncodedPackets, buf), "write audio file"); 1227 + ElapsedTime(this, write, mTicksInIO); 1228 + mPacketMark += numEncodedPackets; 1229 + //mNumberPackets += numEncodedPackets; 1230 + if (mFileDataFormat.mFramesPerPacket > 0) 1231 + mFrameMark += numEncodedPackets * mFileDataFormat.mFramesPerPacket; 1232 + else { 1233 + for (UInt32 i = 0; i < numEncodedPackets; ++i) 1234 + mFrameMark += mPacketDescs[i].mVariableFramesInPacket; 1235 + } 1236 + if (err == kNoMoreInputRightNow) 1237 + break; 1238 + } 1239 + } 1240 + 1241 + #endif // !CAAF_USE_EXTAUDIOFILE
+439
src/CoreAudio/AudioFileTools/PublicUtility/CAAudioFile.h
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + CAAudioFile.h 40 + 41 + =============================================================================*/ 42 + 43 + #ifndef __CAAudioFile_h__ 44 + #define __CAAudioFile_h__ 45 + 46 + #include <AvailabilityMacros.h> 47 + 48 + #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 49 + #include <AudioToolbox/AudioToolbox.h> 50 + #else 51 + #include <AudioToolbox.h> 52 + #endif 53 + 54 + #include "CAStreamBasicDescription.h" 55 + #include "CABufferList.h" 56 + #include "CAAudioChannelLayout.h" 57 + #include "CAXException.h" 58 + #include "CAMath.h" 59 + 60 + #ifndef CAAF_USE_EXTAUDIOFILE 61 + // option: use AudioToolbox/ExtAudioFile.h? Only available on Tiger. 62 + #if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_3 63 + // we are building software that must be deployable on Panther or earlier 64 + #define CAAF_USE_EXTAUDIOFILE 0 65 + #else 66 + // else we require Tiger and can use the API 67 + #define CAAF_USE_EXTAUDIOFILE 1 68 + #endif 69 + #endif 70 + 71 + #ifndef MAC_OS_X_VERSION_10_4 72 + // we have pre-Tiger headers; add our own declarations 73 + typedef UInt32 AudioFileTypeID; 74 + enum { 75 + kExtAudioFileError_InvalidProperty = -66561, 76 + kExtAudioFileError_InvalidPropertySize = -66562, 77 + kExtAudioFileError_NonPCMClientFormat = -66563, 78 + kExtAudioFileError_InvalidChannelMap = -66564, // number of channels doesn't match format 79 + kExtAudioFileError_InvalidOperationOrder = -66565, 80 + kExtAudioFileError_InvalidDataFormat = -66566, 81 + kExtAudioFileError_MaxPacketSizeUnknown = -66567, 82 + kExtAudioFileError_InvalidSeek = -66568, // writing, or offset out of bounds 83 + kExtAudioFileError_AsyncWriteTooLarge = -66569, 84 + kExtAudioFileError_AsyncWriteBufferOverflow = -66570 // an async write could not be completed in time 85 + }; 86 + #else 87 + #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 88 + #include <AudioToolbox/ExtendedAudioFile.h> 89 + #else 90 + #include "ExtendedAudioFile.h" 91 + #endif 92 + #endif 93 + 94 + // _______________________________________________________________________________________ 95 + // Wrapper class for an AudioFile, supporting encode/decode to/from a PCM client format 96 + class CAAudioFile { 97 + public: 98 + // implementation-independent helpers 99 + void Open(const char *filePath) { 100 + FSRef fsref; 101 + XThrowIfError(FSPathMakeRef((UInt8 *)filePath, &fsref, NULL), "locate audio file"); 102 + Open(fsref); 103 + } 104 + 105 + bool HasConverter() const { return GetConverter() != NULL; } 106 + 107 + double GetDurationSeconds() { 108 + double sr = GetFileDataFormat().mSampleRate; 109 + return fnonzero(sr) ? GetNumberFrames() / sr : 0.; 110 + } 111 + // will be 0 if the file's frames/packet is 0 (variable) 112 + // or the file's sample rate is 0 (unknown) 113 + 114 + #if CAAF_USE_EXTAUDIOFILE 115 + public: 116 + CAAudioFile() : mExtAF(NULL) { } 117 + virtual ~CAAudioFile() { if (mExtAF) Close(); } 118 + 119 + void Open(const FSRef &fsref) { 120 + // open an existing file 121 + XThrowIfError(ExtAudioFileOpen(&fsref, &mExtAF), "ExtAudioFileOpen failed"); 122 + } 123 + 124 + void CreateNew(const FSRef &inParentDir, CFStringRef inFileName, AudioFileTypeID inFileType, const AudioStreamBasicDescription &inStreamDesc, const AudioChannelLayout *inChannelLayout=NULL) { 125 + XThrowIfError(ExtAudioFileCreateNew(&inParentDir, inFileName, inFileType, &inStreamDesc, inChannelLayout, &mExtAF), "ExtAudioFileCreateNew failed"); 126 + } 127 + 128 + void Wrap(AudioFileID fileID, bool forWriting) { 129 + // use this to wrap an AudioFileID opened externally 130 + XThrowIfError(ExtAudioFileWrapAudioFileID(fileID, forWriting, &mExtAF), "ExtAudioFileWrapAudioFileID failed"); 131 + } 132 + 133 + void Close() { 134 + XThrowIfError(ExtAudioFileDispose(mExtAF), "ExtAudioFileClose failed"); 135 + mExtAF = NULL; 136 + } 137 + 138 + const CAStreamBasicDescription &GetFileDataFormat() { 139 + UInt32 size = sizeof(mFileDataFormat); 140 + XThrowIfError(ExtAudioFileGetProperty(mExtAF, kExtAudioFileProperty_FileDataFormat, &size, &mFileDataFormat), "Couldn't get file's data format"); 141 + return mFileDataFormat; 142 + } 143 + 144 + const CAAudioChannelLayout & GetFileChannelLayout() { 145 + return FetchChannelLayout(mFileChannelLayout, kExtAudioFileProperty_FileChannelLayout); 146 + } 147 + 148 + void SetFileChannelLayout(const CAAudioChannelLayout &layout) { 149 + XThrowIfError(ExtAudioFileSetProperty(mExtAF, kExtAudioFileProperty_FileChannelLayout, layout.Size(), &layout.Layout()), "Couldn't set file's channel layout"); 150 + mFileChannelLayout = layout; 151 + } 152 + 153 + const CAStreamBasicDescription &GetClientDataFormat() { 154 + UInt32 size = sizeof(mClientDataFormat); 155 + XThrowIfError(ExtAudioFileGetProperty(mExtAF, kExtAudioFileProperty_ClientDataFormat, &size, &mClientDataFormat), "Couldn't get client data format"); 156 + return mClientDataFormat; 157 + } 158 + 159 + const CAAudioChannelLayout & GetClientChannelLayout() { 160 + return FetchChannelLayout(mClientChannelLayout, kExtAudioFileProperty_ClientChannelLayout); 161 + } 162 + 163 + void SetClientFormat(const CAStreamBasicDescription &dataFormat, const CAAudioChannelLayout *layout=NULL) { 164 + XThrowIfError(ExtAudioFileSetProperty(mExtAF, kExtAudioFileProperty_ClientDataFormat, sizeof(dataFormat), &dataFormat), "Couldn't set client format"); 165 + if (layout) 166 + SetClientChannelLayout(*layout); 167 + } 168 + 169 + void SetClientChannelLayout(const CAAudioChannelLayout &layout) { 170 + XThrowIfError(ExtAudioFileSetProperty(mExtAF, kExtAudioFileProperty_ClientChannelLayout, layout.Size(), &layout.Layout()), "Couldn't set client channel layout"); 171 + } 172 + 173 + AudioConverterRef GetConverter() const { 174 + UInt32 size = sizeof(AudioConverterRef); 175 + AudioConverterRef converter; 176 + XThrowIfError(ExtAudioFileGetProperty(mExtAF, kExtAudioFileProperty_AudioConverter, &size, &converter), "Couldn't get file's AudioConverter"); 177 + return converter; 178 + } 179 + 180 + OSStatus SetConverterProperty(AudioConverterPropertyID inPropertyID, UInt32 inPropertyDataSize, const void *inPropertyData, bool inCanFail=false) 181 + { 182 + OSStatus err = AudioConverterSetProperty(GetConverter(), inPropertyID, inPropertyDataSize, inPropertyData); 183 + if (!inCanFail) 184 + XThrowIfError(err, "Couldn't set audio converter property"); 185 + if (!err) { 186 + // must tell the file that we have changed the converter; a NULL converter config is sufficient 187 + CFPropertyListRef config = NULL; 188 + XThrowIfError(ExtAudioFileSetProperty(mExtAF, kExtAudioFileProperty_ConverterConfig, sizeof(CFPropertyListRef), &config), "couldn't signal the file that the converter has changed"); 189 + } 190 + return err; 191 + } 192 + 193 + SInt64 GetNumberFrames() { 194 + SInt64 length; 195 + UInt32 size = sizeof(SInt64); 196 + XThrowIfError(ExtAudioFileGetProperty(mExtAF, kExtAudioFileProperty_FileLengthFrames, &size, &length), "Couldn't get file's length"); 197 + return length; 198 + } 199 + 200 + void SetNumberFrames(SInt64 length) { 201 + XThrowIfError(ExtAudioFileSetProperty(mExtAF, kExtAudioFileProperty_FileLengthFrames, sizeof(SInt64), &length), "Couldn't set file's length"); 202 + } 203 + 204 + void Seek(SInt64 pos) { 205 + XThrowIfError(ExtAudioFileSeek(mExtAF, pos), "Couldn't seek in audio file"); 206 + } 207 + 208 + SInt64 Tell() { 209 + SInt64 pos; 210 + XThrowIfError(ExtAudioFileTell(mExtAF, &pos), "Couldn't get file's mark"); 211 + return pos; 212 + } 213 + 214 + void Read(UInt32 &ioFrames, AudioBufferList *ioData) { 215 + XThrowIfError(ExtAudioFileRead(mExtAF, &ioFrames, ioData), "Couldn't read audio file"); 216 + } 217 + 218 + void Write(UInt32 inFrames, const AudioBufferList *inData) { 219 + XThrowIfError(ExtAudioFileWrite(mExtAF, inFrames, inData), "Couldn't write audio file"); 220 + } 221 + 222 + void SetIOBufferSizeBytes(UInt32 bufferSizeBytes) { 223 + XThrowIfError(ExtAudioFileSetProperty(mExtAF, kExtAudioFileProperty_IOBufferSizeBytes, sizeof(UInt32), &bufferSizeBytes), "Couldn't set audio file's I/O buffer size"); 224 + } 225 + 226 + private: 227 + const CAAudioChannelLayout & FetchChannelLayout(CAAudioChannelLayout &layoutObj, ExtAudioFilePropertyID propID) { 228 + UInt32 size; 229 + XThrowIfError(ExtAudioFileGetPropertyInfo(mExtAF, propID, &size, NULL), "Couldn't get info about channel layout"); 230 + AudioChannelLayout *layout = (AudioChannelLayout *)malloc(size); 231 + OSStatus err = ExtAudioFileGetProperty(mExtAF, propID, &size, layout); 232 + if (err) { 233 + free(layout); 234 + XThrowIfError(err, "Couldn't get channel layout"); 235 + } 236 + layoutObj = layout; 237 + free(layout); 238 + return layoutObj; 239 + } 240 + 241 + 242 + private: 243 + ExtAudioFileRef mExtAF; 244 + 245 + CAStreamBasicDescription mFileDataFormat; 246 + CAAudioChannelLayout mFileChannelLayout; 247 + 248 + CAStreamBasicDescription mClientDataFormat; 249 + CAAudioChannelLayout mClientChannelLayout; 250 + #endif 251 + 252 + #if !CAAF_USE_EXTAUDIOFILE 253 + CAAudioFile(); 254 + virtual ~CAAudioFile(); 255 + 256 + // --- second-stage initializers --- 257 + // Use exactly one of the following: 258 + // - Open 259 + // - PrepareNew followed by Create 260 + // - Wrap 261 + 262 + void Open(const FSRef &fsref); 263 + // open an existing file 264 + 265 + void CreateNew(const FSRef &inParentDir, CFStringRef inFileName, AudioFileTypeID inFileType, const AudioStreamBasicDescription &inStreamDesc, const AudioChannelLayout *inChannelLayout=NULL); 266 + 267 + void Wrap(AudioFileID fileID, bool forWriting); 268 + // use this to wrap an AudioFileID opened externally 269 + 270 + // --- 271 + 272 + void Close(); 273 + // In case you want to close the file before the destructor executes 274 + 275 + // --- Data formats --- 276 + 277 + // Allow specifying the file's channel layout. Must be called before SetClientFormat. 278 + // When writing, the specified channel layout is written to the file (if the file format supports 279 + // the channel layout). When reading, the specified layout overrides the one read from the file, 280 + // if any. 281 + void SetFileChannelLayout(const CAAudioChannelLayout &layout); 282 + 283 + // This specifies the data format which the client will use for reading/writing the file, 284 + // which may be different from the file's format. An AudioConverter is created if necessary. 285 + // The client format must be linear PCM. 286 + void SetClientFormat(const CAStreamBasicDescription &dataFormat, const CAAudioChannelLayout *layout=NULL); 287 + void SetClientDataFormat(const CAStreamBasicDescription &dataFormat) { SetClientFormat(dataFormat, NULL); } 288 + void SetClientChannelLayout(const CAAudioChannelLayout &layout) { SetClientFormat(mClientDataFormat, &layout); } 289 + 290 + // Wrapping the underlying converter, if there is one 291 + OSStatus SetConverterProperty(AudioConverterPropertyID inPropertyID, 292 + UInt32 inPropertyDataSize, 293 + const void * inPropertyData, 294 + bool inCanFail = false); 295 + void SetConverterConfig(CFArrayRef config) { 296 + SetConverterProperty(kAudioConverterPropertySettings, sizeof(config), &config); } 297 + CFArrayRef GetConverterConfig(); 298 + 299 + // --- I/O --- 300 + // All I/O is sequential, but you can seek to an arbitrary position when reading. 301 + // SeekToPacket and TellPacket's packet numbers are in the file's data format, not the client's. 302 + // However, ReadPackets/WritePackets use packet counts in the client data format. 303 + 304 + void Read(UInt32 &ioNumFrames, AudioBufferList *ioData); 305 + void Write(UInt32 numFrames, const AudioBufferList *data); 306 + 307 + // These can fail for files without a constant mFramesPerPacket 308 + void Seek(SInt64 frameNumber); 309 + SInt64 Tell() const; // frameNumber 310 + 311 + // --- Accessors --- 312 + // note: client parameters only valid if SetClientFormat has been called 313 + AudioFileID GetAudioFileID() const { return mAudioFile; } 314 + const CAStreamBasicDescription &GetFileDataFormat() const { return mFileDataFormat; } 315 + const CAStreamBasicDescription &GetClientDataFormat() const { return mClientDataFormat; } 316 + const CAAudioChannelLayout & GetFileChannelLayout() const { return mFileChannelLayout; } 317 + const CAAudioChannelLayout & GetClientChannelLayout() const { return mClientChannelLayout; } 318 + AudioConverterRef GetConverter() const { return mConverter; } 319 + 320 + UInt32 GetFileMaxPacketSize() const { return mFileMaxPacketSize; } 321 + UInt32 GetClientMaxPacketSize() const { return mClientMaxPacketSize; } 322 + SInt64 GetNumberPackets() const { 323 + SInt64 npackets; 324 + UInt32 propertySize = sizeof(npackets); 325 + XThrowIfError(AudioFileGetProperty(mAudioFile, kAudioFilePropertyAudioDataPacketCount, &propertySize, &npackets), "get audio file's packet count"); 326 + return npackets; 327 + } 328 + SInt64 GetNumberFrames() const; 329 + // will be 0 if the file's frames/packet is 0 (variable) 330 + void SetNumberFrames(SInt64 length); // should only be set on a PCM file 331 + 332 + // --- Tunable performance parameters --- 333 + void SetUseCache(bool b) { mUseCache = b; } 334 + void SetIOBufferSizeBytes(UInt32 bufferSizeBytes) { mIOBufferSizeBytes = bufferSizeBytes; } 335 + UInt32 GetIOBufferSizeBytes() { return mIOBufferSizeBytes; } 336 + void * GetIOBuffer() { return mIOBufferList.mBuffers[0].mData; } 337 + void SetIOBuffer(void *buf); 338 + 339 + // -- Profiling --- 340 + #if CAAUDIOFILE_PROFILE 341 + void EnableProfiling(bool b) { mProfiling = b; } 342 + UInt64 TicksInConverter() const { return (mTicksInConverter > 0) ? (mTicksInConverter - mTicksInReadInConverter) : 0; } 343 + UInt64 TicksInIO() const { return mTicksInIO; } 344 + #endif 345 + 346 + // _______________________________________________________________________________________ 347 + private: 348 + SInt64 FileDataOffset(); 349 + void SeekToPacket(SInt64 packetNumber); 350 + SInt64 TellPacket() const { return mPacketMark; } // will be imprecise if SeekToFrame was called 351 + 352 + void SetConverterChannelLayout(bool output, const CAAudioChannelLayout &layout); 353 + void WritePacketsFromCallback( 354 + AudioConverterComplexInputDataProc inInputDataProc, 355 + void * inInputDataProcUserData); 356 + // will use I/O buffer size 357 + void InitFileMaxPacketSize(); 358 + void FileFormatChanged(const FSRef *parentDir=0, CFStringRef filename=0, AudioFileTypeID filetype=0); 359 + 360 + void GetExistingFileInfo(); 361 + void FlushEncoder(); 362 + void CloseConverter(); 363 + void UpdateClientMaxPacketSize(); 364 + void AllocateBuffers(bool okToFail=false); 365 + SInt64 PacketToFrame(SInt64 packet) const; 366 + SInt64 FrameToPacket(SInt64 inFrame) const; 367 + 368 + static OSStatus ReadInputProc( AudioConverterRef inAudioConverter, 369 + UInt32* ioNumberDataPackets, 370 + AudioBufferList* ioData, 371 + AudioStreamPacketDescription** outDataPacketDescription, 372 + void* inUserData); 373 + 374 + static OSStatus WriteInputProc( AudioConverterRef inAudioConverter, 375 + UInt32* ioNumberDataPackets, 376 + AudioBufferList* ioData, 377 + AudioStreamPacketDescription** outDataPacketDescription, 378 + void* inUserData); 379 + // _______________________________________________________________________________________ 380 + private: 381 + 382 + // the file 383 + FSRef mFSRef; 384 + AudioFileID mAudioFile; 385 + bool mOwnOpenFile; 386 + bool mUseCache; 387 + bool mFinishingEncoding; 388 + enum { kClosed, kReading, kPreparingToCreate, kPreparingToWrite, kWriting } mMode; 389 + 390 + // SInt64 mNumberPackets; // in file's format 391 + SInt64 mFileDataOffset; 392 + SInt64 mPacketMark; // in file's format 393 + SInt64 mFrameMark; // this may be offset from the start of the file 394 + // by the codec's latency; i.e. our frame 0 could 395 + // lie at frame 2112 of a decoded AAC file 396 + SInt32 mFrame0Offset; 397 + UInt32 mFramesToSkipFollowingSeek; 398 + 399 + // buffers 400 + UInt32 mIOBufferSizeBytes; 401 + UInt32 mIOBufferSizePackets; 402 + AudioBufferList mIOBufferList; // only one buffer -- USE ACCESSOR so it can be lazily initialized 403 + bool mClientOwnsIOBuffer; 404 + AudioStreamPacketDescription *mPacketDescs; 405 + UInt32 mNumPacketDescs; 406 + 407 + // formats/conversion 408 + AudioConverterRef mConverter; 409 + CAStreamBasicDescription mFileDataFormat; 410 + CAStreamBasicDescription mClientDataFormat; 411 + CAAudioChannelLayout mFileChannelLayout; 412 + CAAudioChannelLayout mClientChannelLayout; 413 + UInt32 mFileMaxPacketSize; 414 + UInt32 mClientMaxPacketSize; 415 + 416 + // cookie 417 + Byte * mMagicCookie; 418 + UInt32 mMagicCookieSize; 419 + 420 + // for ReadPackets 421 + UInt32 mMaxPacketsToRead; 422 + 423 + // for WritePackets 424 + UInt32 mWritePackets; 425 + CABufferList * mWriteBufferList; 426 + 427 + #if CAAUDIOFILE_PROFILE 428 + // performance 429 + bool mProfiling; 430 + UInt64 mTicksInConverter; 431 + UInt64 mTicksInReadInConverter; 432 + UInt64 mTicksInIO; 433 + bool mInConverter; 434 + #endif 435 + 436 + #endif // CAAF_USE_EXTAUDIOFILE 437 + }; 438 + 439 + #endif // __CAAudioFile_h__
+191
src/CoreAudio/AudioFileTools/PublicUtility/CAAudioFilePlayer.cpp
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + CAAudioFilePlayer.cpp 40 + 41 + =============================================================================*/ 42 + 43 + #include "CAAudioFilePlayer.h" 44 + #include "CAXException.h" 45 + 46 + CAAudioFilePlayer::CAAudioFilePlayer(int nBuffers, UInt32 bufferSizeFrames) : 47 + CAAudioFileReader(nBuffers, bufferSizeFrames), 48 + mOutputUnit(NULL) 49 + { 50 + // open output unit 51 + Component comp; 52 + ComponentDescription desc; 53 + 54 + desc.componentType = kAudioUnitType_Output; 55 + desc.componentSubType = kAudioUnitSubType_DefaultOutput; 56 + desc.componentManufacturer = kAudioUnitManufacturer_Apple; 57 + desc.componentFlags = 0; 58 + desc.componentFlagsMask = 0; 59 + comp = FindNextComponent(NULL, &desc); 60 + 61 + // if we can't find the default one, look explicitly for AUHAL 62 + if(comp == NULL) 63 + { 64 + desc.componentType = kAudioUnitType_Output; 65 + desc.componentSubType = kAudioUnitSubType_HALOutput; 66 + desc.componentManufacturer = kAudioUnitManufacturer_Apple; 67 + desc.componentFlags = 0; 68 + desc.componentFlagsMask = 0; 69 + comp = FindNextComponent(NULL, &desc); 70 + } 71 + 72 + XThrowIf(comp == NULL, -1, "find audio output unit"); 73 + XThrowIfError(OpenAComponent(comp, &mOutputUnit), "open audio output unit"); 74 + XThrowIfError(AudioUnitInitialize(mOutputUnit), "initialize audio output unit"); 75 + 76 + #if 0 77 + AudioStreamBasicDescription theFormat; 78 + UInt32 theSize = sizeof(AudioStreamBasicDescription); 79 + AudioUnitGetProperty(mOutputUnit, 'sfmt', kAudioUnitScope_Output, 0, &theFormat, &theSize); 80 + 81 + theFormat.mChannelsPerFrame = 6; 82 + theFormat.mBytesPerFrame = theFormat.mChannelsPerFrame * (theFormat.mBitsPerChannel / 8); 83 + theFormat.mBytesPerPacket = theFormat.mBytesPerFrame; 84 + AudioUnitSetProperty(mOutputUnit, 'sfmt', kAudioUnitScope_Output, 0, &theFormat, theSize); 85 + #endif 86 + } 87 + 88 + CAAudioFilePlayer::~CAAudioFilePlayer() 89 + { 90 + if (mOutputUnit) 91 + CloseComponent(mOutputUnit); 92 + } 93 + 94 + void CAAudioFilePlayer::SetFile(const FSRef &inFile) 95 + { 96 + Stop(); 97 + CAAudioFileReader::SetFile(inFile); 98 + SetupChannelMapping(); 99 + } 100 + 101 + void CAAudioFilePlayer::SetupChannelMapping() 102 + { 103 + // set render callback 104 + AURenderCallbackStruct input; 105 + input.inputProc = InputProc; 106 + input.inputProcRefCon = this; 107 + XThrowIfError(AudioUnitSetProperty( 108 + mOutputUnit, 109 + kAudioUnitProperty_SetRenderCallback, 110 + kAudioUnitScope_Global, 111 + 0, 112 + &input, 113 + sizeof(input)), "connect input proc to output unit"); 114 + 115 + const CAStreamBasicDescription &fmt = GetFile().GetClientDataFormat(); 116 + XThrowIfError(AudioUnitSetProperty( 117 + mOutputUnit, 118 + kAudioUnitProperty_StreamFormat, 119 + kAudioUnitScope_Input, 120 + 0, 121 + (void *)&fmt, 122 + sizeof(AudioStreamBasicDescription)), "set audio output format"); 123 + const CAAudioChannelLayout &layoutObj = GetFile().GetFileChannelLayout(); 124 + if (layoutObj.IsValid()) { 125 + const AudioChannelLayout *layout = layoutObj; 126 + /*OSStatus err =*/ AudioUnitSetProperty( 127 + mOutputUnit, 128 + kAudioUnitProperty_AudioChannelLayout, 129 + kAudioUnitScope_Input, 130 + 0, 131 + layout, 132 + layoutObj.Size()); 133 + // $$$ FIXME: why does this fail sometimes? 134 + } 135 + } 136 + 137 + void CAAudioFilePlayer::Start() 138 + { 139 + if (IsRunning()) 140 + Stop(); 141 + if (ReachedEndOfStream()) 142 + SetCurrentPosition(0.); 143 + CAAudioFileReader::Start(); 144 + XThrowIfError(AudioOutputUnitStart(mOutputUnit), "start audio output unit"); 145 + } 146 + 147 + void CAAudioFilePlayer::Stop() 148 + { 149 + if (IsRunning()) { 150 + XThrowIfError(AudioOutputUnitStop(mOutputUnit), "stop audio output unit"); 151 + CAAudioFileReader::Stop(); 152 + } 153 + } 154 + 155 + void CAAudioFilePlayer::SetVolume(double volume) 156 + { 157 + AudioUnitSetParameter(mOutputUnit, kHALOutputParam_Volume, 158 + kAudioUnitScope_Global, 0, volume, 0); 159 + } 160 + 161 + OSStatus CAAudioFilePlayer::GetPlayBuffer( 162 + UInt32 inNumberFrames, 163 + AudioBufferList * ioData) 164 + { 165 + UInt32 nFrames = inNumberFrames; 166 + PullBuffer(nFrames, ioData); 167 + // printf("read %ld frames\n", nFrames); 168 + if (nFrames < inNumberFrames) { 169 + AudioBuffer *buf = ioData->mBuffers; 170 + UInt32 bytesPerFrame = buf->mNumberChannels * sizeof(Float32); 171 + for (UInt32 i = 0; i < ioData->mNumberBuffers; ++i, ++buf) { 172 + memset((Byte *)buf->mData + nFrames * bytesPerFrame, 0, 173 + (inNumberFrames - nFrames) * bytesPerFrame); 174 + } 175 + } 176 + return noErr; 177 + } 178 + 179 + OSStatus CAAudioFilePlayer::InputProc( 180 + void * inRefCon, 181 + AudioUnitRenderActionFlags *ioActionFlags, 182 + const AudioTimeStamp * inTimeStamp, 183 + UInt32 inBusNumber, 184 + UInt32 inNumberFrames, 185 + AudioBufferList * ioData) 186 + { 187 + CAAudioFilePlayer *This = static_cast<CAAudioFilePlayer *>(inRefCon); 188 + return This->GetPlayBuffer(inNumberFrames, ioData); 189 + } 190 + 191 +
+89
src/CoreAudio/AudioFileTools/PublicUtility/CAAudioFilePlayer.h
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + CAAudioFilePlayer.h 40 + 41 + =============================================================================*/ 42 + 43 + #ifndef __CAAudioFilePlayer_h__ 44 + #define __CAAudioFilePlayer_h__ 45 + 46 + #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 47 + #include <AudioUnit/AudioUnit.h> 48 + #else 49 + #include <AudioUnit.h> 50 + #endif 51 + #include "CAAudioFileStreamer.h" 52 + 53 + // Simple player -- owns an output unit 54 + class CAAudioFilePlayer : public CAAudioFileReader { 55 + public: 56 + CAAudioFilePlayer(int nBuffers, UInt32 bufferSizeFrames); 57 + virtual ~CAAudioFilePlayer(); 58 + 59 + // $$$ to add: change device, HAL I/O buffer size 60 + 61 + virtual void Start(); 62 + virtual void Stop(); 63 + void SetVolume(double volume); // 0-1 64 + 65 + void SetFile(const FSRef &inFile); 66 + 67 + protected: 68 + // our virtual methods: 69 + virtual void SetupChannelMapping(); 70 + 71 + AudioUnit GetOutputUnit() { return mOutputUnit; } 72 + 73 + protected: 74 + static OSStatus InputProc( 75 + void * inRefCon, 76 + AudioUnitRenderActionFlags *ioActionFlags, 77 + const AudioTimeStamp * inTimeStamp, 78 + UInt32 inBusNumber, 79 + UInt32 inNumberFrames, 80 + AudioBufferList * ioData); 81 + 82 + OSStatus GetPlayBuffer( 83 + UInt32 inNumberFrames, 84 + AudioBufferList * ioData); 85 + 86 + AudioUnit mOutputUnit; 87 + }; 88 + 89 + #endif // __CAAudioFilePlayer_h__
+197
src/CoreAudio/AudioFileTools/PublicUtility/CAAudioFileRecorder.cpp
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + CAAudioFileRecorder.cpp 40 + 41 + =============================================================================*/ 42 + 43 + #include "CAAudioFileRecorder.h" 44 + #include "CAXException.h" 45 + 46 + CAAudioFileRecorder::CAAudioFileRecorder(int nBuffers, UInt32 bufferSizeFrames) : 47 + CAAudioFileWriter(nBuffers, bufferSizeFrames), 48 + mInputUnit(NULL), 49 + mAudioInputPtrs(NULL) 50 + { 51 + // open input unit 52 + Component comp; 53 + ComponentDescription desc; 54 + 55 + desc.componentType = kAudioUnitType_Output; 56 + desc.componentSubType = kAudioUnitSubType_HALOutput; 57 + desc.componentManufacturer = kAudioUnitManufacturer_Apple; 58 + desc.componentFlags = 0; 59 + desc.componentFlagsMask = 0; 60 + comp = FindNextComponent(NULL, &desc); 61 + XThrowIf(comp == NULL, -1, "find audio input unit"); 62 + XThrowIfError(OpenAComponent(comp, &mInputUnit), "open audio input unit"); 63 + 64 + UInt32 enableIO; 65 + UInt32 propSize; 66 + 67 + enableIO = 0; 68 + XThrowIfError(AudioUnitSetProperty(mInputUnit, 69 + kAudioOutputUnitProperty_EnableIO, 70 + kAudioUnitScope_Output, 71 + 0, 72 + &enableIO, 73 + sizeof(enableIO)), "failed to disable output"); 74 + 75 + enableIO = 1; 76 + XThrowIfError(AudioUnitSetProperty(mInputUnit, 77 + kAudioOutputUnitProperty_EnableIO, 78 + kAudioUnitScope_Input, 79 + 1, 80 + &enableIO, 81 + sizeof(enableIO)), "failed to enable input"); 82 + 83 + // select the default input device 84 + propSize = sizeof(AudioDeviceID); 85 + AudioDeviceID inputDevice; 86 + XThrowIfError( 87 + AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice, &propSize, &inputDevice), 88 + "failed to get default input device"); 89 + 90 + XThrowIfError( 91 + AudioUnitSetProperty(mInputUnit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, &inputDevice, sizeof(inputDevice)), 92 + "failed to select input device"); 93 + 94 + // set render callback 95 + AURenderCallbackStruct input; 96 + input.inputProc = InputProc; 97 + input.inputProcRefCon = this; 98 + XThrowIfError(AudioUnitSetProperty( 99 + mInputUnit, 100 + kAudioOutputUnitProperty_SetInputCallback, 101 + kAudioUnitScope_Global, 102 + 0, 103 + &input, 104 + sizeof(input)), "connect input proc to output unit"); 105 + 106 + XThrowIfError(AudioUnitInitialize(mInputUnit), "initialize audio input unit"); 107 + 108 + // get the hardware format 109 + propSize = sizeof(mInputDataFormat); 110 + XThrowIfError(AudioUnitGetProperty(mInputUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 1, &mInputDataFormat, &propSize), "couldn't get input unit's stream format"); 111 + } 112 + 113 + CAAudioFileRecorder::~CAAudioFileRecorder() 114 + { 115 + if (mInputUnit) 116 + CloseComponent(mInputUnit); 117 + delete mAudioInputPtrs; 118 + } 119 + 120 + void CAAudioFileRecorder::SetFile(const FSRef &parentFSRef, CFStringRef filename, AudioFileTypeID filetype, const CAStreamBasicDescription &dataFormat, const CAAudioChannelLayout *layout) 121 + { 122 + delete mAudioInputPtrs; mAudioInputPtrs = NULL; 123 + 124 + CAStreamBasicDescription fileDataFormat = dataFormat; 125 + if (fileDataFormat.mSampleRate == 0.) 126 + fileDataFormat.mSampleRate = mInputDataFormat.mSampleRate; 127 + 128 + CAAudioFileWriter::SetFile(parentFSRef, filename, filetype, fileDataFormat, layout); 129 + 130 + const CAStreamBasicDescription &fmt = GetFile().GetClientDataFormat(); 131 + XThrowIfError(AudioUnitSetProperty( 132 + mInputUnit, 133 + kAudioUnitProperty_StreamFormat, 134 + kAudioUnitScope_Output, 135 + 1, 136 + (void *)&fmt, 137 + sizeof(AudioStreamBasicDescription)), "set audio input format"); 138 + 139 + GetFile().SetIOBufferSizeBytes(GetBufferSizeFrames() * fmt.mBytesPerFrame); 140 + 141 + mAudioInputPtrs = CABufferList::New("audio input ptrs", fmt); 142 + } 143 + 144 + /* 145 + void CAAudioFileRecorder::SetFile(AudioFileID fileID) 146 + { 147 + delete mAudioInputPtrs; mAudioInputPtrs = NULL; 148 + 149 + CAAudioFileWriter::SetFile(fileID, mInputDataFormat.mSampleRate); 150 + 151 + const CAStreamBasicDescription &fmt = GetFile().GetClientDataFormat(); 152 + XThrowIfError(AudioUnitSetProperty( 153 + mInputUnit, 154 + kAudioUnitProperty_StreamFormat, 155 + kAudioUnitScope_Output, 156 + 1, 157 + (void *)&fmt, 158 + sizeof(AudioStreamBasicDescription)), "set audio input format"); 159 + 160 + GetFile().SetIOBufferSize(GetBufferSizeFrames() * fmt.mBytesPerFrame); 161 + 162 + mAudioInputPtrs = CABufferList::New("audio input ptrs", fmt); 163 + } 164 + */ 165 + 166 + void CAAudioFileRecorder::Start() 167 + { 168 + CAAudioFileWriter::Start(); 169 + XThrowIfError(AudioOutputUnitStart(mInputUnit), "start audio input unit"); 170 + } 171 + 172 + void CAAudioFileRecorder::Stop() 173 + { 174 + XThrowIfError(AudioOutputUnitStop(mInputUnit), "stop audio input unit"); 175 + CAAudioFileWriter::Stop(); 176 + } 177 + 178 + OSStatus CAAudioFileRecorder::InputProc( 179 + void * inRefCon, 180 + AudioUnitRenderActionFlags *ioActionFlags, 181 + const AudioTimeStamp * inTimeStamp, 182 + UInt32 inBusNumber, 183 + UInt32 inNumberFrames, 184 + AudioBufferList * ioData) 185 + { 186 + CAAudioFileRecorder *This = static_cast<CAAudioFileRecorder *>(inRefCon); 187 + AudioUnitRenderActionFlags flags = 0; 188 + AudioBufferList *abl = &This->mAudioInputPtrs->GetModifiableBufferList(); 189 + for (UInt32 i = 0; i < abl->mNumberBuffers; ++i) 190 + abl->mBuffers[i].mData = NULL; 191 + OSStatus err = AudioUnitRender(This->mInputUnit, &flags, inTimeStamp, 1, inNumberFrames, abl); 192 + if (err) 193 + return err; 194 + 195 + This->PushBuffer(inNumberFrames, abl); 196 + return noErr; 197 + }
+77
src/CoreAudio/AudioFileTools/PublicUtility/CAAudioFileRecorder.h
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + CAAudioFileRecorder.h 40 + 41 + =============================================================================*/ 42 + 43 + #ifndef __CAAudioFileRecorder_h__ 44 + #define __CAAudioFileRecorder_h__ 45 + 46 + #include "CAAudioFileStreamer.h" 47 + #include <AudioUnit/AudioUnit.h> 48 + 49 + // Simple file recorder using the HAL audio "output" unit as an input unit. 50 + class CAAudioFileRecorder : public CAAudioFileWriter { 51 + public: 52 + CAAudioFileRecorder(int nBuffers, UInt32 bufferSizeFrames); 53 + ~CAAudioFileRecorder(); 54 + 55 + void Start(); 56 + void Stop(); 57 + 58 + void SetFile(AudioFileID fileID); 59 + void SetFile(const FSRef &parentFSRef, CFStringRef filename, AudioFileTypeID filetype, const CAStreamBasicDescription &dataFormat, const CAAudioChannelLayout *layout); 60 + 61 + const CAStreamBasicDescription & IODataFormat() { return mInputDataFormat; } 62 + 63 + protected: 64 + static OSStatus InputProc( 65 + void * inRefCon, 66 + AudioUnitRenderActionFlags *ioActionFlags, 67 + const AudioTimeStamp * inTimeStamp, 68 + UInt32 inBusNumber, 69 + UInt32 inNumberFrames, 70 + AudioBufferList * ioData); 71 + 72 + AudioUnit mInputUnit; 73 + CABufferList * mAudioInputPtrs; 74 + CAStreamBasicDescription mInputDataFormat; 75 + }; 76 + 77 + #endif // __CAAudioFileRecorder_h__
+221
src/CoreAudio/AudioFileTools/PublicUtility/CAAudioFileStreamer.cpp
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + CAAudioFileStreamer.cpp 40 + 41 + =============================================================================*/ 42 + 43 + #include "CAAudioFileStreamer.h" 44 + 45 + // ____________________________________________________________________________ 46 + 47 + void CAAudioFileReader::FileReadBuffer::UpdateAfterRead(SInt64 curFrame, UInt32 nFrames) 48 + { 49 + //printf("read %ld PCM packets, file packets %qd-%qd\n", nPackets, b->mStartPacket, b->mEndPacket); 50 + mEndFrame = nFrames; 51 + mEndOfStream = (nFrames == 0); 52 + mBufferStartFileFrame = curFrame; 53 + } 54 + 55 + // ____________________________________________________________________________ 56 + 57 + void CAAudioFileReader::SetFile(const FSRef &inFile) 58 + { 59 + Stop(); 60 + CancelAndDisposeBuffers(); 61 + 62 + delete mFile; mFile = NULL; 63 + mFile = new CAAudioFile; 64 + mFile->Open(inFile); 65 + 66 + const CAStreamBasicDescription &fileFmt = mFile->GetFileDataFormat(); 67 + CAStreamBasicDescription iofmt; 68 + iofmt.SetCanonical(fileFmt.mChannelsPerFrame, false); // deinterleaved 69 + iofmt.mSampleRate = fileFmt.mSampleRate; 70 + mFile->SetClientFormat(iofmt, NULL); 71 + 72 + SetFormat(iofmt); 73 + } 74 + 75 + void CAAudioFileReader::Start() 76 + { 77 + mErrorCount = 0; 78 + mEndOfStream = false; 79 + Prime(); 80 + mRunning = true; 81 + } 82 + 83 + void CAAudioFileReader::Stop() 84 + { 85 + mRunning = false; 86 + } 87 + 88 + void CAAudioFileReader::ReadBuffer(FileReadBuffer *b) 89 + { 90 + b->SetEmpty(); 91 + CABufferList *ioMemory = b->GetBufferList(); 92 + CABufferList *fileBuffers = GetBufferList(); 93 + fileBuffers->SetFrom(ioMemory); 94 + UInt32 nFrames = GetBufferSizeFrames(); 95 + SInt64 curFrame = mFile->Tell(); 96 + mFile->Read(nFrames, &fileBuffers->GetModifiableBufferList()); 97 + b->UpdateAfterRead(curFrame, nFrames); 98 + } 99 + 100 + double CAAudioFileReader::GetCurrentPosition() const 101 + { 102 + return double(GetCurrentFrame()) / double(GetNumberFrames()); 103 + #if 0 104 + double nFrames = double(GetNumberFrames()); // +1 to account for leftovers from decoder 105 + if (!mRunning) 106 + return double(GetCurrentFrame()) / nFrames; 107 + 108 + if (mEndOfStream) { 109 + //printf("EOF\n"); 110 + return 1.0; 111 + } 112 + 113 + const FileReadBuffer *b = static_cast<const FileReadBuffer *>(GetCurrentBuffer()); 114 + // the buffer from which we're reading 115 + UInt32 startFrame, endFrame; 116 + b->GetLocation(startFrame, endFrame); 117 + //printf("%qd + %ld / %.f\n", b->mBufferStartFileFrame, startFrame, nFrames); 118 + return double(b->mBufferStartFileFrame + startFrame) / nFrames; 119 + //if (endFrame > 0) { 120 + //double frac = (double(startFrame) / double(endFrame)) * double(endPacket - startPacket); 121 + //packetIndex += frac; 122 + //printf("frames %ld-%ld, packets %qd-%qd, frac %.3f\n", 123 + // startFrame, endFrame, startPacket, endPacket, frac); 124 + //} 125 + //double pos = packetIndex / nPacketsPlus1; 126 + //printf("%.3f / %.0f = %.3f\n", packetIndex, nPacketsPlus1, pos); 127 + //return pos; 128 + 129 + //return double(GetCurrentFrame()) / nFrames; 130 + #endif 131 + } 132 + 133 + SInt64 CAAudioFileReader::GetCurrentFrame() const 134 + { 135 + if (!mRunning) 136 + return mFile->Tell(); 137 + if (mEndOfStream) 138 + return GetNumberFrames(); 139 + const FileReadBuffer *b = static_cast<const FileReadBuffer *>(GetCurrentBuffer()); 140 + // the buffer from which we're reading 141 + UInt32 startFrame, endFrame; 142 + b->GetLocation(startFrame, endFrame); 143 + //printf("%qd + %ld / %.f\n", b->mBufferStartFileFrame, startFrame, nFrames); 144 + return b->mBufferStartFileFrame + startFrame; 145 + } 146 + 147 + void CAAudioFileReader::SetCurrentPosition(double loc) 148 + { 149 + bool wasRunning = IsRunning(); 150 + if (wasRunning) 151 + Stop(); 152 + SInt64 frameNumber = SInt64(loc * GetFile().GetNumberFrames() + 0.5); 153 + try { 154 + GetFile().Seek(frameNumber); 155 + } 156 + catch (...) { 157 + 158 + } 159 + if (wasRunning) 160 + Start(); 161 + } 162 + 163 + // ____________________________________________________________________________ 164 + 165 + void CAAudioFileWriter::SetFile(AudioFileID fileID) 166 + { 167 + Stop(); 168 + CancelAndDisposeBuffers(); 169 + 170 + delete mFile; mFile = NULL; 171 + mFile = new CAAudioFile; 172 + mFile->Wrap(fileID, true); 173 + 174 + const CAStreamBasicDescription &fileFmt = mFile->GetFileDataFormat(); 175 + CAStreamBasicDescription iofmt; 176 + iofmt.SetCanonical(fileFmt.mChannelsPerFrame, false); // deinterleaved 177 + iofmt.mSampleRate = fileFmt.mSampleRate; 178 + mFile->SetClientFormat(iofmt, NULL); 179 + 180 + SetFormat(iofmt); 181 + } 182 + 183 + void CAAudioFileWriter::SetFile(const FSRef &parentDir, CFStringRef filename, AudioFileTypeID filetype, const CAStreamBasicDescription &dataFormat, const CAAudioChannelLayout *layout) 184 + { 185 + Stop(); 186 + CancelAndDisposeBuffers(); 187 + 188 + delete mFile; mFile = NULL; 189 + mFile = new CAAudioFile; 190 + mFile->CreateNew(parentDir, filename, filetype, dataFormat, layout ? &layout->Layout() : NULL); 191 + 192 + const CAStreamBasicDescription &fileFmt = mFile->GetFileDataFormat(); 193 + CAStreamBasicDescription iofmt; 194 + iofmt.SetCanonical(fileFmt.mChannelsPerFrame, false); // deinterleaved 195 + iofmt.mSampleRate = fileFmt.mSampleRate; 196 + mFile->SetClientFormat(iofmt, NULL); 197 + 198 + SetFormat(iofmt); 199 + } 200 + 201 + void CAAudioFileWriter::Start() 202 + { 203 + mErrorCount = 0; 204 + mRunning = true; 205 + } 206 + 207 + void CAAudioFileWriter::Stop() 208 + { 209 + Flush(); 210 + mRunning = false; 211 + } 212 + 213 + void CAAudioFileWriter::WriteBuffer(CABufferQueue::Buffer *b) 214 + { 215 + CABufferList *ioMemory = b->GetBufferList(); 216 + CABufferList *fileBuffers = GetBufferList(); 217 + UInt32 nFrames = b->FrameCount(); 218 + fileBuffers->SetFrom(ioMemory, GetBytesPerFrame() * nFrames); 219 + mFile->Write(nFrames, &fileBuffers->GetModifiableBufferList()); 220 + b->SetEmpty(); 221 + }
+128
src/CoreAudio/AudioFileTools/PublicUtility/CAAudioFileStreamer.h
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + CAAudioFileStreamer.h 40 + 41 + =============================================================================*/ 42 + 43 + #ifndef __CAAudioFileStreamer_h__ 44 + #define __CAAudioFileStreamer_h__ 45 + 46 + #include "CABufferQueue.h" 47 + #include "CAAudioFile.h" 48 + 49 + // ____________________________________________________________________________ 50 + // Base class for CAAudioFileReader and CAAudioFileWriter 51 + class CAAudioFileStreamer { 52 + public: 53 + CAAudioFileStreamer() : mRunning(false), mFile(NULL) { } 54 + virtual ~CAAudioFileStreamer() { delete mFile; } 55 + 56 + CAAudioFile & GetFile() { return *mFile; } 57 + const CAAudioFile & GetFile() const { return *mFile; } 58 + 59 + bool IsRunning() { return mRunning; } 60 + 61 + protected: 62 + bool mRunning; 63 + CAAudioFile * mFile; 64 + }; 65 + 66 + // ____________________________________________________________________________ 67 + 68 + class CAAudioFileReader : public CAPullBufferQueue, public CAAudioFileStreamer { 69 + public: 70 + CAAudioFileReader(int nBuffers, UInt32 bufferSizeFrames) : 71 + CAPullBufferQueue(nBuffers, bufferSizeFrames) { } 72 + 73 + void SetFile(const FSRef &inFile); 74 + virtual void Start(); 75 + virtual void Stop(); 76 + double GetCurrentPosition() const; // 0-1 77 + SInt64 GetCurrentFrame() const;// { return mFile->Tell(); } 78 + SInt64 GetNumberFrames() const { return mFile->GetNumberFrames(); } 79 + 80 + void SetCurrentPosition(double loc); // 0-1 81 + 82 + private: 83 + class FileReadBuffer : public CABufferQueue::Buffer { 84 + public: 85 + FileReadBuffer(CABufferQueue *queue, const CAStreamBasicDescription &fmt, UInt32 nBytes) : 86 + CABufferQueue::Buffer(queue, fmt, nBytes) 87 + { } 88 + 89 + void UpdateAfterRead(SInt64 curFrame, UInt32 nFramesRead); 90 + void GetLocation(UInt32 &frm0, UInt32 &frame1) const { 91 + frm0 = mStartFrame; frame1 = mEndFrame; 92 + } 93 + 94 + SInt64 mBufferStartFileFrame; 95 + }; 96 + 97 + virtual CABufferQueue::Buffer * CreateBuffer(const CAStreamBasicDescription &fmt, UInt32 nBytes) { 98 + return new FileReadBuffer(this, fmt, nBytes); 99 + } 100 + virtual void ProcessBuffer(CABufferQueue::Buffer *b) { 101 + ReadBuffer(static_cast<FileReadBuffer *>(b)); 102 + } 103 + void ReadBuffer(FileReadBuffer *b); 104 + }; 105 + 106 + // ____________________________________________________________________________ 107 + 108 + class CAAudioFileWriter : public CAPushBufferQueue, public CAAudioFileStreamer { 109 + public: 110 + CAAudioFileWriter(int nBuffers, UInt32 bufferSizeFrames) : 111 + CAPushBufferQueue(nBuffers, bufferSizeFrames) { } 112 + 113 + void SetFile(AudioFileID file); 114 + void SetFile(const FSRef &parentDir, CFStringRef filename, AudioFileTypeID filetype, const CAStreamBasicDescription &dataFormat, const CAAudioChannelLayout *layout); 115 + virtual void Start(); 116 + virtual void Stop(); 117 + 118 + private: 119 + virtual CABufferQueue::Buffer * CreateBuffer(const CAStreamBasicDescription &fmt, UInt32 nBytes) { 120 + return new CABufferQueue::Buffer(this, fmt, nBytes); 121 + } 122 + virtual void ProcessBuffer(CABufferQueue::Buffer *b) { 123 + WriteBuffer(b); 124 + } 125 + void WriteBuffer(CABufferQueue::Buffer *b); 126 + }; 127 + 128 + #endif // __CAAudioFileStreamer_h__
+309
src/CoreAudio/AudioFileTools/PublicUtility/CABufferQueue.cpp
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + CABufferQueue.cpp 40 + 41 + =============================================================================*/ 42 + 43 + #include "CABufferQueue.h" 44 + 45 + #if TARGET_OS_WIN32 46 + #include "CAWindows.h" 47 + #endif 48 + 49 + // ____________________________________________________________________________ 50 + 51 + CABufferQueue::WorkThread *CABufferQueue::sWorkThread = NULL; 52 + 53 + CABufferQueue::WorkThread::WorkThread() : 54 + CAPThread(ThreadEntry, this, CAPThread::kMaxThreadPriority, true), 55 + mStopped(false), 56 + mRunGuard("CABufferQueue::mRunGuard") 57 + { 58 + // prime the container to have some elements so we're not calling malloc dynamically 59 + Buffer *b = NULL; 60 + for (int i = 0; i < 64; ++i) 61 + mWorkQueue.push_back(b); 62 + mWorkQueue.clear(); 63 + Start(); 64 + } 65 + 66 + void CABufferQueue::WorkThread::Run() 67 + { 68 + while (!mStopped) { 69 + CAGuard::Locker lock(mRunGuard); 70 + mRunGuard.Wait(); 71 + 72 + while (!mStopped) { 73 + Buffer *b, *next; 74 + 75 + // add buffers from the other thread 76 + TAtomicStack<Buffer> reversed; 77 + 78 + b = mBuffersToAdd.pop_all(); // these are in reverse order 79 + while (b != NULL) { 80 + next = b->get_next(); 81 + reversed.push_NA(b); 82 + b = next; 83 + } 84 + while ((b = reversed.pop_NA()) != NULL) 85 + mWorkQueue.push_back(b); 86 + 87 + if (mWorkQueue.empty()) 88 + break; 89 + b = mWorkQueue.front(); 90 + mWorkQueue.pop_front(); 91 + 92 + b->Queue()->ProcessBuffer(b); 93 + b->SetInProgress(false); 94 + } 95 + } 96 + } 97 + 98 + void CABufferQueue::WorkThread::Stop() 99 + { 100 + mStopped = true; 101 + mRunGuard.Notify(); 102 + } 103 + 104 + void CABufferQueue::WorkThread::AddBuffer(Buffer *b) 105 + { 106 + b->SetInProgress(true); 107 + mBuffersToAdd.push_atomic(b); 108 + mRunGuard.Notify(); 109 + } 110 + 111 + void CABufferQueue::WorkThread::RemoveBuffers(CABufferQueue *owner) 112 + { 113 + CAGuard::Locker lock(mRunGuard); 114 + for (WorkQueue::iterator it = mWorkQueue.begin(); it != mWorkQueue.end(); ) { 115 + if ((*it)->Queue() == owner) { 116 + WorkQueue::iterator next = it; ++next; 117 + mWorkQueue.erase(it); 118 + it = next; 119 + } else 120 + ++it; 121 + } 122 + } 123 + 124 + // ____________________________________________________________________________ 125 + 126 + CABufferQueue::Buffer::Buffer(CABufferQueue *queue, const CAStreamBasicDescription &fmt, UInt32 nBytes) : 127 + mQueue(queue) 128 + { 129 + mMemory = CABufferList::New("", fmt); 130 + mMemory->AllocateBuffers(nBytes); 131 + mByteSize = nBytes; 132 + mInProgress = false; 133 + mStartFrame = mEndFrame = 0; 134 + mEndOfStream = false; 135 + } 136 + 137 + // return true if buffer emptied AND we're not at end-of-stream 138 + bool CABufferQueue::Buffer::CopyInto(AudioBufferList *destBufferList, int bytesPerFrame, UInt32 &framesProduced, UInt32 &framesRequired) 139 + { 140 + UInt32 framesInBuffer = mEndFrame - mStartFrame; 141 + UInt32 framesToCopy = std::min(framesInBuffer, framesRequired); 142 + if (framesToCopy > 0) { 143 + const CABufferList *bufMemory = mMemory; 144 + const AudioBufferList &srcBufferList = bufMemory->GetBufferList(); 145 + const AudioBuffer *srcbuf = srcBufferList.mBuffers; 146 + AudioBuffer *dstbuf = destBufferList->mBuffers; 147 + for (int i = destBufferList->mNumberBuffers; --i >= 0; ++srcbuf, ++dstbuf) { 148 + memcpy( 149 + (Byte *)dstbuf->mData + framesProduced * bytesPerFrame, 150 + (Byte *)srcbuf->mData + mStartFrame * bytesPerFrame, 151 + framesToCopy * bytesPerFrame); 152 + } 153 + framesProduced += framesToCopy; 154 + framesRequired -= framesToCopy; 155 + mStartFrame += framesToCopy; 156 + } 157 + return (framesToCopy == framesInBuffer) && !mEndOfStream; 158 + } 159 + 160 + // return true if buffer filled 161 + bool CABufferQueue::Buffer::CopyFrom(const AudioBufferList *srcBufferList, int bytesPerFrame, UInt32 &framesProduced, UInt32 &framesRequired) 162 + { 163 + UInt32 framesInBuffer = mEndFrame - mStartFrame; 164 + UInt32 freeFramesInBuffer = (mByteSize / bytesPerFrame) - framesInBuffer; 165 + UInt32 framesToCopy = std::min(freeFramesInBuffer, framesRequired); 166 + if (framesToCopy > 0) { 167 + const AudioBuffer *srcbuf = srcBufferList->mBuffers; 168 + const CABufferList *bufMemory = mMemory; 169 + const AudioBufferList &destBufferList = bufMemory->GetBufferList(); 170 + const AudioBuffer *dstbuf = destBufferList.mBuffers; 171 + for (int i = srcBufferList->mNumberBuffers; --i >= 0; ++srcbuf, ++dstbuf) { 172 + memcpy( 173 + (Byte *)dstbuf->mData + framesInBuffer * bytesPerFrame, 174 + (Byte *)srcbuf->mData + framesProduced * bytesPerFrame, 175 + framesToCopy * bytesPerFrame); 176 + } 177 + framesProduced += framesToCopy; 178 + framesRequired -= framesToCopy; 179 + mEndFrame += framesToCopy; 180 + } 181 + return (framesToCopy == freeFramesInBuffer); 182 + } 183 + 184 + // ____________________________________________________________________________ 185 + 186 + CABufferQueue::CABufferQueue(int nBuffers, UInt32 bufferSizeFrames) : 187 + mNumberBuffers(nBuffers), 188 + mBuffers(NULL), 189 + mBufferSizeFrames(bufferSizeFrames), 190 + mBufferList(NULL) 191 + { 192 + mCurrentBuffer = 0; 193 + mErrorCount = 0; 194 + 195 + if (sWorkThread == NULL) 196 + sWorkThread = new WorkThread(); 197 + mWorkThread = sWorkThread; // for now 198 + } 199 + 200 + CABufferQueue::~CABufferQueue() 201 + { 202 + CancelAndDisposeBuffers(); 203 + } 204 + 205 + void CABufferQueue::CancelBuffers() 206 + { 207 + mWorkThread->RemoveBuffers(this); 208 + } 209 + 210 + void CABufferQueue::CancelAndDisposeBuffers() 211 + { 212 + CancelBuffers(); 213 + if (mBuffers) { 214 + for (int i = 0; i < mNumberBuffers; ++i) 215 + delete mBuffers[i]; 216 + delete[] mBuffers; mBuffers = NULL; 217 + } 218 + delete mBufferList; mBufferList = NULL; 219 + } 220 + 221 + void CABufferQueue::SetFormat(const CAStreamBasicDescription &fmt) 222 + { 223 + CancelAndDisposeBuffers(); 224 + 225 + mBytesPerFrame = fmt.mBytesPerFrame; 226 + mBuffers = new Buffer*[mNumberBuffers]; 227 + for (int i = 0; i < mNumberBuffers; ++i) 228 + mBuffers[i] = CreateBuffer(fmt, mBufferSizeFrames * mBytesPerFrame); 229 + mBufferList = CABufferList::New("", fmt); 230 + } 231 + 232 + // ____________________________________________________________________________ 233 + 234 + void CAPushBufferQueue::PushBuffer(UInt32 inNumberFrames, const AudioBufferList *inBufferList) 235 + { 236 + UInt32 framesRequired = inNumberFrames; 237 + UInt32 framesProduced = 0; 238 + 239 + do { 240 + Buffer *b = mBuffers[mCurrentBuffer]; 241 + 242 + if (b->InProgress()) { 243 + ++mErrorCount; 244 + break; 245 + } 246 + 247 + if (b->CopyFrom(inBufferList, mBytesPerFrame, framesProduced, framesRequired)) { 248 + // buffer was filled, we're done with it 249 + sWorkThread->AddBuffer(b); 250 + if (++mCurrentBuffer == mNumberBuffers) 251 + mCurrentBuffer = 0; 252 + } 253 + } while (framesRequired > 0); 254 + } 255 + 256 + void CAPushBufferQueue::Flush() 257 + { 258 + if (mBuffers != NULL) { 259 + Buffer *b = mBuffers[mCurrentBuffer]; 260 + if (b->FrameCount() > 0 && !b->InProgress()) 261 + ProcessBuffer(b); 262 + } 263 + } 264 + 265 + // ____________________________________________________________________________ 266 + 267 + void CAPullBufferQueue::PullBuffer(UInt32 &ioFrames, AudioBufferList *outBufferList) 268 + { 269 + if (mEndOfStream) { 270 + ioFrames = 0; 271 + return; 272 + } 273 + UInt32 framesRequired = ioFrames; 274 + UInt32 framesProduced = 0; 275 + 276 + do { 277 + Buffer *b = mBuffers[mCurrentBuffer]; 278 + 279 + if (b->InProgress()) { 280 + ++mErrorCount; 281 + break; 282 + } 283 + 284 + if (b->CopyInto(outBufferList, mBytesPerFrame, framesProduced, framesRequired)) { 285 + // buffer emptied 286 + sWorkThread->AddBuffer(b); 287 + 288 + if (++mCurrentBuffer == mNumberBuffers) 289 + mCurrentBuffer = 0; 290 + } 291 + else if (b->ReachedEndOfStream()) { 292 + mEndOfStream = true; 293 + break; 294 + } 295 + } while (framesRequired > 0); 296 + ioFrames = framesProduced; 297 + } 298 + 299 + void CAPullBufferQueue::Prime() 300 + { 301 + mEndOfStream = false; 302 + for (int i = 0; i < mNumberBuffers; ++i) { 303 + Buffer *b = mBuffers[i]; 304 + ProcessBuffer(b); 305 + b->SetInProgress(false); 306 + } 307 + mCurrentBuffer = 0; 308 + } 309 +
+213
src/CoreAudio/AudioFileTools/PublicUtility/CABufferQueue.h
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + CABufferQueue.h 40 + 41 + =============================================================================*/ 42 + 43 + #ifndef __CABufferQueue_h__ 44 + #define __CABufferQueue_h__ 45 + 46 + #include "CAPThread.h" 47 + #include "CAGuard.h" 48 + #include "CAStreamBasicDescription.h" 49 + #include "CABufferList.h" 50 + #include <list> 51 + #include "CAAtomicStack.h" 52 + 53 + // ____________________________________________________________________________ 54 + 55 + // Abstraction for moving audio buffers between threads. 56 + // Has abstract subclasses for push and pull. 57 + class CABufferQueue { 58 + friend class CAPushBufferQueue; 59 + friend class CAPullBufferQueue; 60 + public: 61 + CABufferQueue(int nBuffers, UInt32 bufferSizeFrames); 62 + virtual ~CABufferQueue(); 63 + 64 + void SetFormat(const CAStreamBasicDescription &fmt); 65 + UInt32 GetBufferSizeFrames() const { return mBufferSizeFrames; } 66 + int ErrorCount() const { return mErrorCount; } 67 + 68 + // ----- 69 + class Buffer { 70 + public: 71 + Buffer(CABufferQueue *owner, const CAStreamBasicDescription &fmt, UInt32 nBytes); 72 + 73 + ~Buffer() { delete mMemory; } 74 + 75 + CABufferQueue * Queue() { return mQueue; } 76 + CABufferList * GetBufferList() { return mMemory; } 77 + UInt32 FrameCount() { return mEndFrame - mStartFrame; } 78 + void SetEmpty() { mStartFrame = mEndFrame = 0; } 79 + 80 + void SetInProgress(bool b) { mInProgress = b; } 81 + bool InProgress() const { return mInProgress; } 82 + bool ReachedEndOfStream() const { return mEndOfStream; } 83 + 84 + bool CopyInto(AudioBufferList *destBufferList, int bytesPerFrame, UInt32 &framesProduced, UInt32 &framesRequired); // return true if buffer emptied 85 + 86 + bool CopyFrom(const AudioBufferList *srcBufferList, int bytesPerFrame, UInt32 &framesProduced, UInt32 &framesRequired); // return true if buffer filled and not end-of-stream 87 + 88 + Buffer * get_next() { return mNext; } 89 + void set_next(Buffer *b) { mNext = b; } 90 + Buffer *& next() { return mNext; } 91 + 92 + #if DEBUG 93 + void print() { 94 + printf("Buffer %p:\n inProgress %d, endOfStream %d, frames %ld-%ld\n", this, mInProgress, mEndOfStream, mStartFrame, mEndFrame); 95 + } 96 + #endif 97 + 98 + protected: 99 + Buffer * mNext; 100 + CABufferQueue * mQueue; 101 + CABufferList * mMemory; 102 + UInt32 mByteSize; 103 + 104 + bool mInProgress; // true if in the work queue 105 + bool mEndOfStream; // true if the operation resulted in end-of-stream 106 + UInt32 mStartFrame, mEndFrame; // produce/consume pointers within the buffer 107 + }; 108 + 109 + #if DEBUG 110 + void print() { 111 + printf("BufferQueue %p\n mCurrentBuffer=%d\n", this, mCurrentBuffer); 112 + if (mBuffers) 113 + for (int i = 0; i < mNumberBuffers; ++i) { 114 + Buffer *b = mBuffers[i]; 115 + printf(" buffer[%d]: ", i); 116 + if (b) 117 + b->print(); 118 + else printf("NULL\n"); 119 + } 120 + } 121 + #endif 122 + 123 + protected: 124 + virtual Buffer * CreateBuffer(const CAStreamBasicDescription &fmt, UInt32 nBytes) = 0; 125 + virtual void ProcessBuffer(Buffer *b) = 0; 126 + void CancelBuffers(); 127 + void CancelAndDisposeBuffers(); 128 + 129 + CABufferList * GetBufferList() { return mBufferList; } 130 + const Buffer * GetCurrentBuffer() const { return mBuffers[mCurrentBuffer]; } 131 + UInt32 GetBytesPerFrame() const { return mBytesPerFrame; } 132 + 133 + private: 134 + 135 + // ----- 136 + class WorkThread : public CAPThread { 137 + public: 138 + WorkThread(); 139 + 140 + static void * ThreadEntry(void *param) 141 + { 142 + static_cast<WorkThread *>(param)->Run(); 143 + return NULL; 144 + } 145 + void Run(); 146 + void Stop(); 147 + 148 + void AddBuffer(Buffer *buffer); 149 + void RemoveBuffers(CABufferQueue *owner); 150 + 151 + private: 152 + typedef std::list<Buffer *> WorkQueue; 153 + 154 + bool mStopped; 155 + WorkQueue mWorkQueue; 156 + CAGuard mRunGuard; 157 + TAtomicStack<Buffer> mBuffersToAdd; 158 + }; 159 + 160 + static WorkThread * sWorkThread; 161 + 162 + // ----- 163 + private: 164 + WorkThread * mWorkThread; 165 + 166 + int mCurrentBuffer; 167 + int mNumberBuffers; 168 + Buffer ** mBuffers; // array of pointers 169 + UInt32 mBufferSizeFrames; 170 + UInt32 mBytesPerFrame; // function of client format 171 + CABufferList * mBufferList; // maintained in SetFormat 172 + protected: 173 + int mErrorCount; 174 + }; 175 + 176 + // ____________________________________________________________________________ 177 + 178 + // Abstract class. 179 + // The client pushes buffers in; they are consumed (via ProcessBuffer) on the work thread. 180 + // (ex: file recorder) 181 + class CAPushBufferQueue : public CABufferQueue { 182 + public: 183 + CAPushBufferQueue(int nBuffers, UInt32 bufferSizeFrames) : 184 + CABufferQueue(nBuffers, bufferSizeFrames) { } 185 + 186 + void PushBuffer(UInt32 inNumberFrames, const AudioBufferList *inBufferList); 187 + // push a buffer in 188 + void Flush(); 189 + // emit a possibly incomplete final buffer 190 + }; 191 + 192 + // ____________________________________________________________________________ 193 + 194 + // Abstract class. 195 + // The client pulls buffers out; they are produced (via ProcessBuffer) on the work thread. 196 + // (ex: file player) 197 + class CAPullBufferQueue : public CABufferQueue { 198 + public: 199 + CAPullBufferQueue(int nBuffers, UInt32 bufferSizeFrames) : 200 + CABufferQueue(nBuffers, bufferSizeFrames), 201 + mEndOfStream(false) { } 202 + 203 + void Prime(); 204 + // produce initial buffers 205 + void PullBuffer(UInt32 &ioFrames, AudioBufferList *outBufferList); 206 + // pull a buffer out 207 + bool ReachedEndOfStream() const { return mEndOfStream; } 208 + 209 + protected: 210 + bool mEndOfStream; 211 + }; 212 + 213 + #endif // __CABufferQueue_h__
+206
src/CoreAudio/AudioFileTools/PublicUtility/CAChannelMapper.cpp
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + CAChannelMapper.cpp 40 + 41 + =============================================================================*/ 42 + 43 + #include "CAChannelMapper.h" 44 + #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 45 + #include <AudioToolbox/AudioToolbox.h> 46 + #else 47 + #include <AudioToolbox.h> 48 + #endif 49 + 50 + static void DefaultChannelLayout(CAAudioChannelLayout &layout, UInt32 nchannels) 51 + { 52 + // we really can't do a sensible downmix without valid source/destination channel layouts 53 + if (nchannels == 1) 54 + layout = CAAudioChannelLayout(kAudioChannelLayoutTag_Mono); 55 + else if (nchannels == 2) 56 + layout = CAAudioChannelLayout(kAudioChannelLayoutTag_Stereo); 57 + } 58 + 59 + CAChannelMapper::CAChannelMapper( const CAStreamBasicDescription &srcFormat, 60 + const CAStreamBasicDescription &destFormat, 61 + const CAAudioChannelLayout * inSrcLayout, 62 + const CAAudioChannelLayout * inDestLayout) : 63 + mSrcNChannels(srcFormat.mChannelsPerFrame), 64 + mDestNChannels(destFormat.mChannelsPerFrame) 65 + { 66 + if (inSrcLayout && inSrcLayout->IsValid()) 67 + mSrcLayout = *inSrcLayout; 68 + else 69 + DefaultChannelLayout(mSrcLayout, srcFormat.mChannelsPerFrame); 70 + 71 + if (inDestLayout && inDestLayout->IsValid()) 72 + mDestLayout = *inDestLayout; 73 + else 74 + DefaultChannelLayout(mDestLayout, destFormat.mChannelsPerFrame); 75 + } 76 + 77 + CAChannelMapper::~CAChannelMapper() 78 + { 79 + if (mMatrixMixer) 80 + CloseComponent(mMatrixMixer); 81 + } 82 + 83 + OSStatus CAChannelMapper::OpenMixer(double sampleRate) 84 + { 85 + CAComponent comp(kAudioUnitType_Mixer, kAudioUnitSubType_MatrixMixer, kAudioUnitManufacturer_Apple); 86 + OSStatus err; 87 + 88 + err = CAAudioUnit::Open(comp, mMatrixMixer); 89 + if (err) return err; 90 + 91 + CAStreamBasicDescription fmt; 92 + fmt.mSampleRate = sampleRate; 93 + UInt32 nbuses = 1; 94 + 95 + err = mMatrixMixer.SetProperty(kAudioUnitProperty_BusCount, kAudioUnitScope_Input, 0, &nbuses, sizeof(UInt32)); 96 + if (err) return err; 97 + err = mMatrixMixer.SetProperty(kAudioUnitProperty_BusCount, kAudioUnitScope_Output, 0, &nbuses, sizeof(UInt32)); 98 + if (err) return err; 99 + 100 + fmt.SetCanonical(mSrcNChannels, false); 101 + err = mMatrixMixer.SetFormat(kAudioUnitScope_Input, 0, fmt); 102 + if (err) return err; 103 + 104 + fmt.SetCanonical(mDestNChannels, false); 105 + err = mMatrixMixer.SetFormat(kAudioUnitScope_Output, 0, fmt); 106 + if (err) return err; 107 + 108 + // set render callback 109 + AURenderCallbackStruct input; 110 + input.inputProc = MixerInputProc; 111 + input.inputProcRefCon = this; 112 + err = mMatrixMixer.SetProperty( 113 + kAudioUnitProperty_SetRenderCallback, 114 + kAudioUnitScope_Global, 115 + 0, 116 + &input, 117 + sizeof(input)); 118 + 119 + err = mMatrixMixer.Initialize(); 120 + if (err) return err; 121 + 122 + return ResetMixer(); 123 + } 124 + 125 + OSStatus CAChannelMapper::ResetMixer() 126 + { 127 + int nin = mSrcNChannels, nout = mDestNChannels; 128 + int i, j; 129 + 130 + // set global, input and output volumes 131 + mMatrixMixer.SetParameter(kMatrixMixerParam_Volume, kAudioUnitScope_Global, 0xFFFFFFFF, 1.); 132 + for (i = 0; i < nout; ++i) { 133 + mMatrixMixer.SetParameter(kMatrixMixerParam_Volume, kAudioUnitScope_Global, 0xFFFF0000 | i, 1.); 134 + } 135 + for (i = 0; i < nin; ++i) { 136 + mMatrixMixer.SetParameter(kMatrixMixerParam_Volume, kAudioUnitScope_Global, (i<<16) | 0xFFFF, 1.); 137 + } 138 + // set crosspoint volumes 139 + for (i = 0; i < nin; ++i) { 140 + for (j = 0; j < nout; ++j) { 141 + mMatrixMixer.SetParameter(kMatrixMixerParam_Volume, kAudioUnitScope_Global, (i<<16) | j, 0.); 142 + } 143 + } 144 + return noErr; 145 + } 146 + 147 + OSStatus CAChannelMapper::ConfigureDownmix() 148 + { 149 + OSStatus err = ResetMixer(); 150 + if (err) 151 + return err; 152 + 153 + const AudioChannelLayout *layouts[] = { &mSrcLayout.Layout(), &mDestLayout.Layout() }; 154 + UInt32 propSize; 155 + err = AudioFormatGetPropertyInfo(kAudioFormatProperty_MatrixMixMap, sizeof(layouts), layouts, &propSize); 156 + if (err) 157 + return err; 158 + 159 + void *mixmap = malloc(propSize); 160 + err = AudioFormatGetProperty(kAudioFormatProperty_MatrixMixMap, sizeof(layouts), layouts, &propSize, mixmap); 161 + if (!err) { 162 + mMatrixMixer.SetParameter(kMatrixMixerParam_Volume, kAudioUnitScope_Global, 0xFFFFFFFF, 1.); 163 + int nin = mSrcNChannels, nout = mDestNChannels; 164 + int i, j; 165 + // set the crosspoint volumes 166 + Float32 *val = (Float32 *)mixmap; 167 + for (i = 0; i < nin; ++i) { 168 + for (j = 0; j < nout; ++j) { 169 + mMatrixMixer.SetParameter(kMatrixMixerParam_Volume, kAudioUnitScope_Global, (i<<16) | j, *val++); 170 + } 171 + } 172 + } 173 + free(mixmap); 174 + return noErr; 175 + } 176 + 177 + OSStatus CAChannelMapper::ConnectChannelToChannel(UInt32 inChannel, UInt32 outChannel) 178 + { 179 + return mMatrixMixer.SetParameter(kMatrixMixerParam_Volume, kAudioUnitScope_Global, 180 + (inChannel << 16) | outChannel, 1.); 181 + } 182 + 183 + OSStatus CAChannelMapper::Mix(const AudioBufferList *src, AudioBufferList *dest, UInt32 nFrames) 184 + { 185 + mMixInputBufferList = src; 186 + AudioUnitRenderActionFlags flags = 0; 187 + AudioTimeStamp ts; 188 + ts.mFlags = 0; 189 + return AudioUnitRender(mMatrixMixer.AU(), &flags, &ts, 0, nFrames, dest); 190 + } 191 + 192 + OSStatus CAChannelMapper::MixerInputProc( 193 + void * inRefCon, 194 + AudioUnitRenderActionFlags *ioActionFlags, 195 + const AudioTimeStamp * inTimeStamp, 196 + UInt32 inBusNumber, 197 + UInt32 inNumberFrames, 198 + AudioBufferList * ioData) 199 + { 200 + CAChannelMapper *This = static_cast<CAChannelMapper *>(inRefCon); 201 + const AudioBufferList *mixInputBufferList = This->mMixInputBufferList; 202 + UInt32 copySize = sizeof(UInt32) + (mixInputBufferList->mNumberBuffers * sizeof(AudioBuffer)); 203 + memcpy(ioData, mixInputBufferList, copySize); 204 + 205 + return noErr; 206 + }
+93
src/CoreAudio/AudioFileTools/PublicUtility/CAChannelMapper.h
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + CAChannelMapper.h 40 + 41 + =============================================================================*/ 42 + 43 + #ifndef __CAChannelMapper_h__ 44 + #define __CAChannelMapper_h__ 45 + 46 + #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 47 + #include <AudioUnit/AudioUnit.h> 48 + #else 49 + #include <AudioUnit.h> 50 + #endif 51 + #include "CAAudioChannelLayout.h" 52 + #include "CAStreamBasicDescription.h" 53 + #include "CAAudioUnit.h" 54 + #include "MatrixMixerVolumes.h" 55 + 56 + class CAChannelMapper { 57 + public: 58 + CAChannelMapper(const CAStreamBasicDescription &srcFormat, 59 + const CAStreamBasicDescription &destFormat, 60 + const CAAudioChannelLayout * srcLayout = NULL, 61 + const CAAudioChannelLayout * destLayout = NULL); 62 + ~CAChannelMapper(); 63 + 64 + UInt32 NumSourceChannels() { return mSrcNChannels; } 65 + UInt32 NumDestChannels() { return mDestNChannels; } 66 + const CAAudioChannelLayout &SourceLayout() { return mSrcLayout; } 67 + const CAAudioChannelLayout &DestLayout() { return mDestLayout; } 68 + AudioUnit GetMixer() { return mMatrixMixer.AU(); } 69 + 70 + bool CanDownmix() { return mSrcLayout.IsValid() && mDestLayout.IsValid(); } 71 + OSStatus OpenMixer(double sampleRate); 72 + OSStatus ResetMixer(); // enables all ins/outs, zeroes all crosspoints 73 + OSStatus ConfigureDownmix(); 74 + OSStatus ConnectChannelToChannel(UInt32 inChannel, UInt32 outChannel); 75 + OSStatus Mix(const AudioBufferList *src, AudioBufferList *dest, UInt32 nFrames); 76 + void PrintMatrixMixerVolumes(FILE *f) { ::PrintMatrixMixerVolumes(f, mMatrixMixer.AU()); } 77 + 78 + private: 79 + static OSStatus MixerInputProc( 80 + void * inRefCon, 81 + AudioUnitRenderActionFlags *ioActionFlags, 82 + const AudioTimeStamp * inTimeStamp, 83 + UInt32 inBusNumber, 84 + UInt32 inNumberFrames, 85 + AudioBufferList * ioData); 86 + 87 + UInt32 mSrcNChannels, mDestNChannels; 88 + CAAudioChannelLayout mSrcLayout, mDestLayout; 89 + CAAudioUnit mMatrixMixer; 90 + const AudioBufferList * mMixInputBufferList; 91 + }; 92 + 93 + #endif // __CAChannelMapper_h__
+165
src/CoreAudio/AudioFileTools/PublicUtility/CAChannelMappingPlayer.cpp
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + CAChannelMappingPlayer.cpp 40 + 41 + =============================================================================*/ 42 + 43 + #include "CAChannelMappingPlayer.h" 44 + #include "CAXException.h" 45 + 46 + #if DEBUG 47 + #define VERBOSE 1 48 + #endif 49 + 50 + CAChannelMappingPlayer::CAChannelMappingPlayer(int nBuffers, UInt32 bufferSizeFrames) : 51 + CAAudioFilePlayer(nBuffers, bufferSizeFrames), 52 + mMapper(NULL) 53 + { 54 + } 55 + 56 + CAChannelMappingPlayer::~CAChannelMappingPlayer() 57 + { 58 + delete mMapper; 59 + } 60 + 61 + void CAChannelMappingPlayer::SetupChannelMapping() 62 + { 63 + delete mMapper; 64 + mMapper = NULL; 65 + 66 + const CAStreamBasicDescription &fileFormat = GetFile().GetClientDataFormat(); 67 + CAStreamBasicDescription deviceFormat; 68 + UInt32 propertySize = sizeof(AudioStreamBasicDescription); 69 + 70 + XThrowIfError(AudioUnitGetProperty( 71 + GetOutputUnit(), 72 + kAudioUnitProperty_StreamFormat, 73 + kAudioUnitScope_Output, 74 + 0, 75 + (void *)&deviceFormat, 76 + &propertySize), "get output device's format"); 77 + 78 + #if VERBOSE 79 + printf("CAChannelMappingPlayer::SetupChannelMapping: %ld-ch file, %ld-ch device\n", 80 + fileFormat.mChannelsPerFrame, deviceFormat.mChannelsPerFrame); 81 + #endif 82 + 83 + if (fileFormat.mChannelsPerFrame <= deviceFormat.mChannelsPerFrame) { 84 + // no mapping needed, use output unit's default behavior 85 + // (default stereo pair and speaker config from AMS) 86 + #if VERBOSE 87 + printf(" using output unit's channel mapping\n"); 88 + #endif 89 + CAAudioFilePlayer::SetupChannelMapping(); 90 + } else { 91 + // fewer device than file channels, mapping needed 92 + CAAudioChannelLayout fileLayout, deviceLayout; 93 + 94 + #if VERBOSE 95 + printf(" using our own channel mapping\n"); 96 + #endif 97 + deviceFormat.mSampleRate = fileFormat.mSampleRate; 98 + deviceFormat.SetCanonical(deviceFormat.mChannelsPerFrame, false); // force deinterleaved 99 + 100 + fileLayout = GetFile().GetFileChannelLayout(); 101 + 102 + UInt32 layoutSize; 103 + Boolean writable; 104 + OSStatus err = AudioUnitGetPropertyInfo( 105 + GetOutputUnit(), 106 + kAudioUnitProperty_AudioChannelLayout, 107 + kAudioUnitScope_Input, 108 + 0, 109 + &layoutSize, 110 + &writable); 111 + if (!err) { 112 + char *buf = (char *)malloc(layoutSize); 113 + err = AudioUnitGetProperty( 114 + GetOutputUnit(), 115 + kAudioUnitProperty_AudioChannelLayout, 116 + kAudioUnitScope_Input, 117 + 0, 118 + buf, 119 + &layoutSize); 120 + deviceLayout = CAAudioChannelLayout(reinterpret_cast<AudioChannelLayout *>(buf)); 121 + free(buf); 122 + } 123 + mMapper = new CAChannelMapper(fileFormat, deviceFormat, &fileLayout, &deviceLayout); 124 + 125 + // give the output unit the same number of channels as in the device, 126 + // since we'll be doing the mapping ourselves 127 + XThrowIfError(AudioUnitSetProperty( 128 + GetOutputUnit(), 129 + kAudioUnitProperty_StreamFormat, 130 + kAudioUnitScope_Input, 131 + 0, 132 + (void *)&deviceFormat, 133 + sizeof(AudioStreamBasicDescription)), "set audio output format"); 134 + 135 + XThrowIfError(mMapper->OpenMixer(fileFormat.mSampleRate), "open mixer"); 136 + XThrowIfError(mMapper->ConfigureDownmix(), "configure downmix"); 137 + 138 + AudioUnitConnection conn; 139 + conn.sourceAudioUnit = mMapper->GetMixer(); 140 + conn.sourceOutputNumber = 0; 141 + conn.destInputNumber = 0; 142 + 143 + XThrowIfError(AudioUnitSetProperty( 144 + GetOutputUnit(), 145 + kAudioUnitProperty_MakeConnection, 146 + kAudioUnitScope_Global, 147 + 0, 148 + (void *)&conn, 149 + sizeof(AudioUnitConnection)), "connect mixer to output unit"); 150 + 151 + AURenderCallbackStruct input; 152 + input.inputProc = InputProc; 153 + input.inputProcRefCon = this; 154 + XThrowIfError(AudioUnitSetProperty( 155 + conn.sourceAudioUnit, 156 + kAudioUnitProperty_SetRenderCallback, 157 + kAudioUnitScope_Global, 158 + 0, 159 + &input, 160 + sizeof(input)), "connect input proc to mixer"); 161 + // provide NO channel layout 162 + // mReadBuf = CABufferList::New("", fileFormat); 163 + // mReadBuf->AllocateBuffers( 164 + } 165 + }
+65
src/CoreAudio/AudioFileTools/PublicUtility/CAChannelMappingPlayer.h
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + CAChannelMappingPlayer.h 40 + 41 + =============================================================================*/ 42 + 43 + #ifndef __CAChannelMappingPlayer_h__ 44 + #define __CAChannelMappingPlayer_h__ 45 + 46 + #include "CAAudioFilePlayer.h" 47 + #include "CAChannelMapper.h" 48 + 49 + // Specialization of CAAudioFilePlayer to perform channel remapping or downmixing. 50 + class CAChannelMappingPlayer : public CAAudioFilePlayer { 51 + public: 52 + CAChannelMappingPlayer(int nBuffers, UInt32 bufferSizeFrames); 53 + ~CAChannelMappingPlayer(); 54 + 55 + // CAAudioFilePlayer overrides: 56 + virtual void SetupChannelMapping(); 57 + 58 + CAChannelMapper * GetMapper() { return mMapper; } 59 + 60 + private: 61 + CAChannelMapper * mMapper; 62 + }; 63 + 64 + 65 + #endif // __CAChannelMappingPlayer_h__
+334
src/CoreAudio/AudioFileTools/PublicUtility/CAGuard.cpp
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*================================================================================================== 39 + CAGuard.cpp 40 + 41 + ==================================================================================================*/ 42 + 43 + //================================================================================================== 44 + // Includes 45 + //================================================================================================== 46 + 47 + // Self Include 48 + #include "CAGuard.h" 49 + 50 + #if TARGET_OS_MAC 51 + #include <errno.h> 52 + #endif 53 + 54 + // PublicUtility Inludes 55 + #include "CADebugMacros.h" 56 + #include "CAException.h" 57 + #include "CAHostTimeBase.h" 58 + 59 + //================================================================================================== 60 + // Logging 61 + //================================================================================================== 62 + 63 + #if CoreAudio_Debug 64 + // #define Log_Ownership 1 65 + // #define Log_WaitOwnership 1 66 + // #define Log_TimedWaits 1 67 + // #define Log_Latency 1 68 + // #define Log_Errors 1 69 + #endif 70 + 71 + //#warning Need a try-based Locker too 72 + //================================================================================================== 73 + // CAGuard 74 + //================================================================================================== 75 + 76 + CAGuard::CAGuard(const char* inName) 77 + : 78 + CAMutex(inName) 79 + #if Log_Average_Latency 80 + ,mAverageLatencyAccumulator(0.0), 81 + mAverageLatencyCount(0) 82 + #endif 83 + { 84 + #if TARGET_OS_MAC 85 + OSStatus theError = pthread_cond_init(&mCondVar, NULL); 86 + ThrowIf(theError != 0, CAException(theError), "CAGuard::CAGuard: Could not init the cond var"); 87 + #elif TARGET_OS_WIN32 88 + mEvent = CreateEvent(NULL, true, false, NULL); 89 + ThrowIfNULL(mEvent, CAException(GetLastError()), "CAGuard::CAGuard: Could not create the event"); 90 + #endif 91 + } 92 + 93 + CAGuard::~CAGuard() 94 + { 95 + #if TARGET_OS_MAC 96 + pthread_cond_destroy(&mCondVar); 97 + #elif TARGET_OS_WIN32 98 + if(mEvent != NULL) 99 + { 100 + CloseHandle(mEvent); 101 + } 102 + #endif 103 + } 104 + 105 + void CAGuard::Wait() 106 + { 107 + #if TARGET_OS_MAC 108 + ThrowIf(!pthread_equal(pthread_self(), mOwner), CAException(1), "CAGuard::Wait: A thread has to have locked a guard before it can wait"); 109 + 110 + mOwner = 0; 111 + 112 + #if Log_WaitOwnership 113 + DebugPrintfRtn(DebugPrintfFile, "%p %.4f: CAGuard::Wait: thread %p is waiting on %s, owner: %p\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), pthread_self(), mName, mOwner); 114 + #endif 115 + 116 + OSStatus theError = pthread_cond_wait(&mCondVar, &mMutex); 117 + ThrowIf(theError != 0, CAException(theError), "CAGuard::Wait: Could not wait for a signal"); 118 + mOwner = pthread_self(); 119 + 120 + #if Log_WaitOwnership 121 + DebugPrintfRtn(DebugPrintfFile, "%p %.4f: CAGuard::Wait: thread %p waited on %s, owner: %p\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), pthread_self(), mName, mOwner); 122 + #endif 123 + #elif TARGET_OS_WIN32 124 + ThrowIf(GetCurrentThreadId() != mOwner, CAException(1), "CAGuard::Wait: A thread has to have locked a guard before it can wait"); 125 + 126 + mOwner = 0; 127 + 128 + #if Log_WaitOwnership 129 + DebugPrintfRtn(DebugPrintfFile, "%lu %.4f: CAGuard::Wait: thread %lu is waiting on %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), GetCurrentThreadId(), mName, mOwner); 130 + #endif 131 + 132 + ReleaseMutex(mMutex); 133 + HANDLE theHandles[] = { mMutex, mEvent }; 134 + OSStatus theError = WaitForMultipleObjects(2, theHandles, true, INFINITE); 135 + ThrowIfError(theError, CAException(GetLastError()), "CAGuard::Wait: Could not wait for the signal"); 136 + mOwner = GetCurrentThreadId(); 137 + ResetEvent(mEvent); 138 + 139 + #if Log_WaitOwnership 140 + DebugPrintfRtn(DebugPrintfFile, "%lu %.4f: CAGuard::Wait: thread %lu waited on %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), GetCurrentThreadId(), mName, mOwner); 141 + #endif 142 + #endif 143 + } 144 + 145 + bool CAGuard::WaitFor(UInt64 inNanos) 146 + { 147 + bool theAnswer = false; 148 + 149 + #if TARGET_OS_MAC 150 + ThrowIf(!pthread_equal(pthread_self(), mOwner), CAException(1), "CAGuard::WaitFor: A thread has to have locked a guard be for it can wait"); 151 + 152 + #if Log_TimedWaits 153 + DebugMessageN1("CAGuard::WaitFor: waiting %.0f", (Float64)inNanos); 154 + #endif 155 + 156 + struct timespec theTimeSpec; 157 + static const UInt64 kNanosPerSecond = 1000000000ULL; 158 + if(inNanos > kNanosPerSecond) 159 + { 160 + theTimeSpec.tv_sec = inNanos / kNanosPerSecond; 161 + theTimeSpec.tv_nsec = inNanos % kNanosPerSecond; 162 + } 163 + else 164 + { 165 + theTimeSpec.tv_sec = 0; 166 + theTimeSpec.tv_nsec = inNanos; 167 + } 168 + 169 + #if Log_TimedWaits || Log_Latency || Log_Average_Latency 170 + UInt64 theStartNanos = CAHostTimeBase::GetCurrentTimeInNanos(); 171 + #endif 172 + 173 + mOwner = 0; 174 + 175 + #if Log_WaitOwnership 176 + DebugPrintfRtn(DebugPrintfFile, "%p %.4f: CAGuard::WaitFor: thread %p is waiting on %s, owner: %p\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), pthread_self(), mName, mOwner); 177 + #endif 178 + 179 + OSStatus theError = pthread_cond_timedwait_relative_np(&mCondVar, &mMutex, &theTimeSpec); 180 + ThrowIf((theError != 0) && (theError != ETIMEDOUT), CAException(theError), "CAGuard::WaitFor: Wait got an error"); 181 + mOwner = pthread_self(); 182 + 183 + #if Log_TimedWaits || Log_Latency || Log_Average_Latency 184 + UInt64 theEndNanos = CAHostTimeBase::GetCurrentTimeInNanos(); 185 + #endif 186 + 187 + #if Log_TimedWaits 188 + DebugMessageN1("CAGuard::WaitFor: waited %.0f", (Float64)(theEndNanos - theStartNanos)); 189 + #endif 190 + 191 + #if Log_Latency 192 + DebugMessageN1("CAGuard::WaitFor: latency %.0f", (Float64)((theEndNanos - theStartNanos) - inNanos)); 193 + #endif 194 + 195 + #if Log_Average_Latency 196 + ++mAverageLatencyCount; 197 + mAverageLatencyAccumulator += (theEndNanos - theStartNanos) - inNanos; 198 + if(mAverageLatencyCount >= 50) 199 + { 200 + DebugMessageN2("CAGuard::WaitFor: average latency %.3f ns over %ld waits", mAverageLatencyAccumulator / mAverageLatencyCount, mAverageLatencyCount); 201 + mAverageLatencyCount = 0; 202 + mAverageLatencyAccumulator = 0.0; 203 + } 204 + #endif 205 + 206 + #if Log_WaitOwnership 207 + DebugPrintfRtn(DebugPrintfFile, "%p %.4f: CAGuard::WaitFor: thread %p waited on %s, owner: %p\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), pthread_self(), mName, mOwner); 208 + #endif 209 + 210 + theAnswer = theError == ETIMEDOUT; 211 + #elif TARGET_OS_WIN32 212 + ThrowIf(GetCurrentThreadId() != mOwner, CAException(1), "CAGuard::WaitFor: A thread has to have locked a guard be for it can wait"); 213 + 214 + #if Log_TimedWaits 215 + DebugMessageN1("CAGuard::WaitFor: waiting %.0f", (Float64)inNanos); 216 + #endif 217 + 218 + // the time out is specified in milliseconds(!) 219 + UInt32 theWaitTime = static_cast<UInt32>(inNanos / 1000000ULL); 220 + 221 + #if Log_TimedWaits || Log_Latency || Log_Average_Latency 222 + UInt64 theStartNanos = CAHostTimeBase::GetCurrentTimeInNanos(); 223 + #endif 224 + 225 + mOwner = 0; 226 + 227 + #if Log_WaitOwnership 228 + DebugPrintfRtn(DebugPrintfFile, "%lu %.4f: CAGuard::WaitFor: thread %lu is waiting on %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), GetCurrentThreadId(), mName, mOwner); 229 + #endif 230 + 231 + ReleaseMutex(mMutex); 232 + HANDLE theHandles[] = { mMutex, mEvent }; 233 + OSStatus theError = WaitForMultipleObjects(2, theHandles, true, theWaitTime); 234 + ThrowIf((theError != WAIT_OBJECT_0) && (theError != WAIT_TIMEOUT), CAException(GetLastError()), "CAGuard::WaitFor: Wait got an error"); 235 + mOwner = GetCurrentThreadId(); 236 + ResetEvent(mEvent); 237 + 238 + #if Log_TimedWaits || Log_Latency || Log_Average_Latency 239 + UInt64 theEndNanos = CAHostTimeBase::GetCurrentTimeInNanos(); 240 + #endif 241 + 242 + #if Log_TimedWaits 243 + DebugMessageN1("CAGuard::WaitFor: waited %.0f", (Float64)(theEndNanos - theStartNanos)); 244 + #endif 245 + 246 + #if Log_Latency 247 + DebugMessageN1("CAGuard::WaitFor: latency %.0f", (Float64)((theEndNanos - theStartNanos) - inNanos)); 248 + #endif 249 + 250 + #if Log_Average_Latency 251 + ++mAverageLatencyCount; 252 + mAverageLatencyAccumulator += (theEndNanos - theStartNanos) - inNanos; 253 + if(mAverageLatencyCount >= 50) 254 + { 255 + DebugMessageN2("CAGuard::WaitFor: average latency %.3f ns over %ld waits", mAverageLatencyAccumulator / mAverageLatencyCount, mAverageLatencyCount); 256 + mAverageLatencyCount = 0; 257 + mAverageLatencyAccumulator = 0.0; 258 + } 259 + #endif 260 + 261 + #if Log_WaitOwnership 262 + DebugPrintfRtn(DebugPrintfFile, "%lu %.4f: CAGuard::WaitFor: thread %lu waited on %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), GetCurrentThreadId(), mName, mOwner); 263 + #endif 264 + 265 + theAnswer = theError == WAIT_TIMEOUT; 266 + #endif 267 + 268 + return theAnswer; 269 + } 270 + 271 + bool CAGuard::WaitUntil(UInt64 inNanos) 272 + { 273 + bool theAnswer = false; 274 + UInt64 theCurrentNanos = CAHostTimeBase::GetCurrentTimeInNanos(); 275 + 276 + #if Log_TimedWaits 277 + DebugMessageN2("CAGuard::WaitUntil: now: %.0f, requested: %.0f", (double)theCurrentNanos, (double)inNanos); 278 + #endif 279 + 280 + if(inNanos > theCurrentNanos) 281 + { 282 + #if Log_Errors 283 + if((inNanos - theCurrentNanos) > 1000000000ULL) 284 + { 285 + DebugMessage("CAGuard::WaitUntil: about to wait for more than a second"); 286 + } 287 + #endif 288 + theAnswer = WaitFor(inNanos - theCurrentNanos); 289 + } 290 + #if Log_Errors 291 + else 292 + { 293 + DebugMessageN2("CAGuard::WaitUntil: Time has expired before waiting, now: %.0f, requested: %.0f", (double)theCurrentNanos, (double)inNanos); 294 + } 295 + #endif 296 + 297 + return theAnswer; 298 + } 299 + 300 + void CAGuard::Notify() 301 + { 302 + #if TARGET_OS_MAC 303 + #if Log_WaitOwnership 304 + DebugPrintfRtn(DebugPrintfFile, "%p %.4f: CAGuard::Notify: thread %p is notifying %s, owner: %p\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), pthread_self(), mName, mOwner); 305 + #endif 306 + 307 + OSStatus theError = pthread_cond_signal(&mCondVar); 308 + ThrowIf(theError != 0, CAException(theError), "CAGuard::Notify: failed"); 309 + #elif TARGET_OS_WIN32 310 + #if Log_WaitOwnership 311 + DebugPrintfRtn(DebugPrintfFile, "%lu %.4f: CAGuard::Notify: thread %lu is notifying %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), GetCurrentThreadId(), mName, mOwner); 312 + #endif 313 + 314 + SetEvent(mEvent); 315 + #endif 316 + } 317 + 318 + void CAGuard::NotifyAll() 319 + { 320 + #if TARGET_OS_MAC 321 + #if Log_WaitOwnership 322 + DebugPrintfRtn(DebugPrintfFile, "%p %.4f: CAGuard::NotifyAll: thread %p is notifying %s, owner: %p\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), pthread_self(), mName, mOwner); 323 + #endif 324 + 325 + OSStatus theError = pthread_cond_broadcast(&mCondVar); 326 + ThrowIf(theError != 0, CAException(theError), "CAGuard::NotifyAll: failed"); 327 + #elif TARGET_OS_WIN32 328 + #if Log_WaitOwnership 329 + DebugPrintfRtn(DebugPrintfFile, "%lu %.4f: CAGuard::NotifyAll: thread %lu is notifying %s, owner: %lu\n", GetCurrentThreadId(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), GetCurrentThreadId(), mName, mOwner); 330 + #endif 331 + 332 + SetEvent(mEvent); 333 + #endif 334 + }
+128
src/CoreAudio/AudioFileTools/PublicUtility/CAGuard.h
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*================================================================================================== 39 + CAGuard.h 40 + 41 + ==================================================================================================*/ 42 + #if !defined(__CAGuard_h__) 43 + #define __CAGuard_h__ 44 + 45 + //================================================================================================== 46 + // Includes 47 + //============================================================================= 48 + 49 + // Super Class Includes 50 + #include "CAMutex.h" 51 + 52 + #if CoreAudio_Debug 53 + // #define Log_Average_Latency 1 54 + #endif 55 + 56 + //================================================================================================== 57 + // CAGuard 58 + // 59 + // This is your typical mutex with signalling implemented via pthreads. 60 + // Lock() will return true if and only if the guard is locked on that call. 61 + // A thread that already has the guard will receive 'false' if it locks it 62 + // again. Use of the stack-based CAGuard::Locker class is highly recommended 63 + // to properly manage the recursive nesting. The Wait calls with timeouts 64 + // will return true if and only if the timeout period expired. They will 65 + // return false if they receive notification any other way. 66 + //================================================================================================== 67 + 68 + class CAGuard : public CAMutex 69 + { 70 + 71 + // Construction/Destruction 72 + public: 73 + CAGuard(const char* inName); 74 + virtual ~CAGuard(); 75 + 76 + // Actions 77 + public: 78 + virtual void Wait(); 79 + virtual bool WaitFor(UInt64 inNanos); 80 + virtual bool WaitUntil(UInt64 inNanos); 81 + 82 + virtual void Notify(); 83 + virtual void NotifyAll(); 84 + 85 + // Implementation 86 + protected: 87 + #if TARGET_OS_MAC 88 + pthread_cond_t mCondVar; 89 + #else 90 + HANDLE mEvent; 91 + #endif 92 + #if Log_Average_Latency 93 + Float64 mAverageLatencyAccumulator; 94 + UInt32 mAverageLatencyCount; 95 + #endif 96 + 97 + // Helper class to manage taking and releasing recursively 98 + public: 99 + class Locker 100 + { 101 + 102 + // Construction/Destruction 103 + public: 104 + Locker(CAGuard& inGuard) : mGuard(inGuard), mNeedsRelease(false) { mNeedsRelease = mGuard.Lock(); } 105 + ~Locker() { if(mNeedsRelease) { mGuard.Unlock(); } } 106 + 107 + private: 108 + Locker(const Locker&); 109 + Locker& operator=(const Locker&); 110 + 111 + // Actions 112 + public: 113 + void Wait() { mGuard.Wait(); } 114 + bool WaitFor(UInt64 inNanos) { return mGuard.WaitFor(inNanos); } 115 + bool WaitUntil(UInt64 inNanos) { return mGuard.WaitUntil(inNanos); } 116 + 117 + void Notify() { mGuard.Notify(); } 118 + void NotifyAll() { mGuard.NotifyAll(); } 119 + 120 + // Implementation 121 + private: 122 + CAGuard& mGuard; 123 + bool mNeedsRelease; 124 + }; 125 + 126 + }; 127 + 128 + #endif
+335
src/CoreAudio/AudioFileTools/PublicUtility/CAPThread.cpp
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + CAPThread.cp 40 + 41 + =============================================================================*/ 42 + 43 + //============================================================================= 44 + // Includes 45 + //============================================================================= 46 + 47 + // Self Include 48 + #include "CAPThread.h" 49 + 50 + // PublicUtility Includes 51 + #include "CADebugMacros.h" 52 + #include "CAException.h" 53 + 54 + // System Includes 55 + #if TARGET_OS_MAC 56 + #include <mach/mach.h> 57 + #endif 58 + 59 + // Standard Library Includes 60 + #include <stdio.h> 61 + 62 + //================================================================================================== 63 + // CAPThread 64 + //================================================================================================== 65 + 66 + // returns the thread's priority as it was last set by the API 67 + #define CAPTHREAD_SET_PRIORITY 0 68 + // returns the thread's priority as it was last scheduled by the Kernel 69 + #define CAPTHREAD_SCHEDULED_PRIORITY 1 70 + 71 + CAPThread::CAPThread(ThreadRoutine inThreadRoutine, void* inParameter, UInt32 inPriority, bool inFixedPriority) 72 + : 73 + #if TARGET_OS_MAC 74 + mPThread(0), 75 + mSpawningThreadPriority(getScheduledPriority(pthread_self(), CAPTHREAD_SET_PRIORITY)), 76 + #elif TARGET_OS_WIN32 77 + mThreadHandle(NULL), 78 + mThreadID(0), 79 + #endif 80 + mThreadRoutine(inThreadRoutine), 81 + mThreadParameter(inParameter), 82 + mPriority(inPriority), 83 + mPeriod(0), 84 + mComputation(0), 85 + mConstraint(0), 86 + mIsPreemptible(true), 87 + mTimeConstraintSet(false), 88 + mFixedPriority(inFixedPriority) 89 + { 90 + } 91 + 92 + CAPThread::CAPThread(ThreadRoutine inThreadRoutine, void* inParameter, UInt32 inPeriod, UInt32 inComputation, UInt32 inConstraint, bool inIsPreemptible) 93 + : 94 + #if TARGET_OS_MAC 95 + mPThread(0), 96 + mSpawningThreadPriority(getScheduledPriority(pthread_self(), CAPTHREAD_SET_PRIORITY)), 97 + #elif TARGET_OS_WIN32 98 + mThreadHandle(NULL), 99 + mThreadID(0), 100 + #endif 101 + mThreadRoutine(inThreadRoutine), 102 + mThreadParameter(inParameter), 103 + mPriority(kDefaultThreadPriority), 104 + mPeriod(inPeriod), 105 + mComputation(inComputation), 106 + mConstraint(inConstraint), 107 + mIsPreemptible(inIsPreemptible), 108 + mTimeConstraintSet(true), 109 + mFixedPriority(false) 110 + { 111 + } 112 + 113 + CAPThread::~CAPThread() 114 + { 115 + } 116 + 117 + UInt32 CAPThread::GetScheduledPriority() 118 + { 119 + #if TARGET_OS_MAC 120 + return CAPThread::getScheduledPriority( mPThread, CAPTHREAD_SCHEDULED_PRIORITY ); 121 + #elif TARGET_OS_WIN32 122 + UInt32 theAnswer = 0; 123 + if(mThreadHandle != NULL) 124 + { 125 + theAnswer = GetThreadPriority(mThreadHandle); 126 + } 127 + return theAnswer; 128 + #endif 129 + } 130 + 131 + void CAPThread::SetPriority(UInt32 inPriority, bool inFixedPriority) 132 + { 133 + mPriority = inPriority; 134 + mTimeConstraintSet = false; 135 + mFixedPriority = inFixedPriority; 136 + #if TARGET_OS_MAC 137 + if(mPThread != 0) 138 + { 139 + 140 + if (mFixedPriority) 141 + { 142 + thread_extended_policy_data_t theFixedPolicy; 143 + theFixedPolicy.timeshare = false; // set to true for a non-fixed thread 144 + AssertNoError(thread_policy_set(pthread_mach_thread_np(mPThread), THREAD_EXTENDED_POLICY, (thread_policy_t)&theFixedPolicy, THREAD_EXTENDED_POLICY_COUNT), "CAPThread::SetPriority: failed to set the fixed-priority policy"); 145 + } 146 + // We keep a reference to the spawning thread's priority around (initialized in the constructor), 147 + // and set the importance of the child thread relative to the spawning thread's priority. 148 + thread_precedence_policy_data_t thePrecedencePolicy; 149 + 150 + thePrecedencePolicy.importance = mPriority - mSpawningThreadPriority; 151 + AssertNoError(thread_policy_set(pthread_mach_thread_np(mPThread), THREAD_PRECEDENCE_POLICY, (thread_policy_t)&thePrecedencePolicy, THREAD_PRECEDENCE_POLICY_COUNT), "CAPThread::SetPriority: failed to set the precedence policy"); 152 + } 153 + #elif TARGET_OS_WIN32 154 + if(mThreadHandle != NULL) 155 + { 156 + SetThreadPriority(mThreadHandle, mPriority); 157 + } 158 + #endif 159 + } 160 + 161 + void CAPThread::SetTimeConstraints(UInt32 inPeriod, UInt32 inComputation, UInt32 inConstraint, bool inIsPreemptible) 162 + { 163 + mPeriod = inPeriod; 164 + mComputation = inComputation; 165 + mConstraint = inConstraint; 166 + mIsPreemptible = inIsPreemptible; 167 + mTimeConstraintSet = true; 168 + #if TARGET_OS_MAC 169 + if(mPThread != 0) 170 + { 171 + thread_time_constraint_policy_data_t thePolicy; 172 + thePolicy.period = mPeriod; 173 + thePolicy.computation = mComputation; 174 + thePolicy.constraint = mConstraint; 175 + thePolicy.preemptible = mIsPreemptible; 176 + AssertNoError(thread_policy_set(pthread_mach_thread_np(mPThread), THREAD_TIME_CONSTRAINT_POLICY, (thread_policy_t)&thePolicy, THREAD_TIME_CONSTRAINT_POLICY_COUNT), "CAPThread::SetTimeConstraints: thread_policy_set failed"); 177 + } 178 + #elif TARGET_OS_WIN32 179 + if(mThreadHandle != NULL) 180 + { 181 + SetThreadPriority(mThreadHandle, THREAD_PRIORITY_TIME_CRITICAL); 182 + } 183 + #endif 184 + } 185 + 186 + void CAPThread::Start() 187 + { 188 + #if TARGET_OS_MAC 189 + if(mPThread == 0) 190 + { 191 + OSStatus theResult; 192 + pthread_attr_t theThreadAttributes; 193 + 194 + theResult = pthread_attr_init(&theThreadAttributes); 195 + ThrowIf(theResult != 0, CAException(theResult), "CAPThread::Start: Thread attributes could not be created."); 196 + 197 + theResult = pthread_attr_setdetachstate(&theThreadAttributes, PTHREAD_CREATE_DETACHED); 198 + ThrowIf(theResult != 0, CAException(theResult), "CAPThread::Start: A thread could not be created in the detached state."); 199 + 200 + theResult = pthread_create(&mPThread, &theThreadAttributes, (ThreadRoutine)CAPThread::Entry, this); 201 + ThrowIf(theResult != 0 || !mPThread, CAException(theResult), "CAPThread::Start: Could not create a thread."); 202 + 203 + pthread_attr_destroy(&theThreadAttributes); 204 + 205 + } 206 + #elif TARGET_OS_WIN32 207 + if(mThreadID == 0) 208 + { 209 + // clean up the existing thread handle 210 + if(mThreadHandle != NULL) 211 + { 212 + CloseHandle(mThreadHandle); 213 + mThreadHandle = NULL; 214 + } 215 + 216 + // create a new thread 217 + mThreadHandle = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Entry, this, 0, &mThreadID); 218 + ThrowIf(mThreadHandle == NULL, CAException(GetLastError()), "CAPThread::Start: Could not create a thread."); 219 + } 220 + #endif 221 + } 222 + 223 + #if TARGET_OS_MAC 224 + 225 + void* CAPThread::Entry(CAPThread* inCAPThread) 226 + { 227 + void* theAnswer = NULL; 228 + 229 + try 230 + { 231 + if(inCAPThread->mTimeConstraintSet) 232 + { 233 + inCAPThread->SetTimeConstraints(inCAPThread->mPeriod, inCAPThread->mComputation, inCAPThread->mConstraint, inCAPThread->mIsPreemptible); 234 + } 235 + else 236 + { 237 + inCAPThread->SetPriority(inCAPThread->mPriority, inCAPThread->mFixedPriority); 238 + } 239 + 240 + if(inCAPThread->mThreadRoutine != NULL) 241 + { 242 + theAnswer = inCAPThread->mThreadRoutine(inCAPThread->mThreadParameter); 243 + } 244 + } 245 + catch (...) 246 + { 247 + // what should be done here? 248 + } 249 + inCAPThread->mPThread = 0; 250 + return theAnswer; 251 + } 252 + 253 + UInt32 CAPThread::getScheduledPriority(pthread_t inThread, int inPriorityKind) 254 + { 255 + thread_basic_info_data_t threadInfo; 256 + policy_info_data_t thePolicyInfo; 257 + unsigned int count; 258 + 259 + if (inThread == NULL) 260 + return 0; 261 + 262 + // get basic info 263 + count = THREAD_BASIC_INFO_COUNT; 264 + thread_info (pthread_mach_thread_np (inThread), THREAD_BASIC_INFO, (thread_info_t)&threadInfo, &count); 265 + 266 + switch (threadInfo.policy) { 267 + case POLICY_TIMESHARE: 268 + count = POLICY_TIMESHARE_INFO_COUNT; 269 + thread_info(pthread_mach_thread_np (inThread), THREAD_SCHED_TIMESHARE_INFO, (thread_info_t)&(thePolicyInfo.ts), &count); 270 + if (inPriorityKind == CAPTHREAD_SCHEDULED_PRIORITY) { 271 + return thePolicyInfo.ts.cur_priority; 272 + } 273 + return thePolicyInfo.ts.base_priority; 274 + break; 275 + 276 + case POLICY_FIFO: 277 + count = POLICY_FIFO_INFO_COUNT; 278 + thread_info(pthread_mach_thread_np (inThread), THREAD_SCHED_FIFO_INFO, (thread_info_t)&(thePolicyInfo.fifo), &count); 279 + if ( (thePolicyInfo.fifo.depressed) && (inPriorityKind == CAPTHREAD_SCHEDULED_PRIORITY) ) { 280 + return thePolicyInfo.fifo.depress_priority; 281 + } 282 + return thePolicyInfo.fifo.base_priority; 283 + break; 284 + 285 + case POLICY_RR: 286 + count = POLICY_RR_INFO_COUNT; 287 + thread_info(pthread_mach_thread_np (inThread), THREAD_SCHED_RR_INFO, (thread_info_t)&(thePolicyInfo.rr), &count); 288 + if ( (thePolicyInfo.rr.depressed) && (inPriorityKind == CAPTHREAD_SCHEDULED_PRIORITY) ) { 289 + return thePolicyInfo.rr.depress_priority; 290 + } 291 + return thePolicyInfo.rr.base_priority; 292 + break; 293 + } 294 + 295 + return 0; 296 + } 297 + 298 + #elif TARGET_OS_WIN32 299 + 300 + UInt32 WINAPI CAPThread::Entry(CAPThread* inCAPThread) 301 + { 302 + UInt32 theAnswer = 0; 303 + 304 + try 305 + { 306 + if(inCAPThread->mTimeConstraintSet) 307 + { 308 + inCAPThread->SetTimeConstraints(inCAPThread->mPeriod, inCAPThread->mComputation, inCAPThread->mConstraint, inCAPThread->mIsPreemptible); 309 + } 310 + else 311 + { 312 + inCAPThread->SetPriority(inCAPThread->mPriority, inCAPThread->mFixedPriority); 313 + } 314 + 315 + if(inCAPThread->mThreadRoutine != NULL) 316 + { 317 + theAnswer = reinterpret_cast<UInt32>(inCAPThread->mThreadRoutine(inCAPThread->mThreadParameter)); 318 + } 319 + inCAPThread->mThreadID = 0; 320 + } 321 + catch (...) 322 + { 323 + // what should be done here? 324 + } 325 + return theAnswer; 326 + } 327 + 328 + // a definition of this function here for now 329 + extern "C" 330 + Boolean CompareAndSwap(UInt32 inOldValue, UInt32 inNewValue, UInt32* inOldValuePtr) 331 + { 332 + return InterlockedCompareExchange((volatile LONG*)inOldValuePtr, inNewValue, inOldValue) == inOldValue; 333 + } 334 + 335 + #endif
+155
src/CoreAudio/AudioFileTools/PublicUtility/CAPThread.h
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*================================================================================================== 39 + CAPThread.h 40 + 41 + ==================================================================================================*/ 42 + #if !defined(__CAPThread_h__) 43 + #define __CAPThread_h__ 44 + 45 + //================================================================================================== 46 + // Includes 47 + //================================================================================================== 48 + 49 + // System Includes 50 + #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 51 + #include <CoreAudio/CoreAudioTypes.h> 52 + #else 53 + #include <CoreAudioTypes.h> 54 + #endif 55 + 56 + #if TARGET_OS_MAC 57 + #include <pthread.h> 58 + #include <unistd.h> 59 + #elif TARGET_OS_WIN32 60 + #include <windows.h> 61 + #else 62 + #error Unsupported operating system 63 + #endif 64 + 65 + //================================================================================================== 66 + // CAPThread 67 + // 68 + // This class wraps a pthread and a Win32 thread. 69 + // caution: long-running fixed priority threads can make the system unresponsive 70 + //================================================================================================== 71 + 72 + class CAPThread 73 + { 74 + 75 + // Types 76 + public: 77 + typedef void* (*ThreadRoutine)(void* inParameter); 78 + 79 + // Constants 80 + public: 81 + enum 82 + { 83 + #if TARGET_OS_MAC 84 + kMinThreadPriority = 1, 85 + kMaxThreadPriority = 63, 86 + kDefaultThreadPriority = 31 87 + #elif TARGET_OS_WIN32 88 + kMinThreadPriority = 1, 89 + kMaxThreadPriority = 31, 90 + kDefaultThreadPriority = THREAD_PRIORITY_NORMAL 91 + #endif 92 + }; 93 + 94 + // Construction/Destruction 95 + public: 96 + CAPThread(ThreadRoutine inThreadRoutine, void* inParameter, UInt32 inPriority = kDefaultThreadPriority, bool inFixedPriority=false); 97 + CAPThread(ThreadRoutine inThreadRoutine, void* inParameter, UInt32 inPeriod, UInt32 inComputation, UInt32 inConstraint, bool inIsPreemptible); 98 + virtual ~CAPThread(); 99 + 100 + // Properties 101 + public: 102 + #if TARGET_OS_MAC 103 + pthread_t GetPThread() const { return mPThread; } 104 + bool IsCurrentThread() const { return (0 != mPThread) && (pthread_self() == mPThread); } 105 + bool IsRunning() const { return 0 != mPThread; } 106 + #elif TARGET_OS_WIN32 107 + HANDLE GetThreadHandle() const { return mThreadHandle; } 108 + UInt32 GetThreadID() const { return mThreadID; } 109 + bool IsCurrentThread() const { return (0 != mThreadID) && (GetCurrentThreadId() == mThreadID); } 110 + bool IsRunning() const { return 0 != mThreadID; } 111 + #endif 112 + 113 + bool IsTimeShareThread() const { return !mTimeConstraintSet; } 114 + bool IsTimeConstraintThread() const { return mTimeConstraintSet; } 115 + 116 + UInt32 GetPriority() const { return mPriority; } 117 + UInt32 GetScheduledPriority(); 118 + void SetPriority(UInt32 inPriority, bool inFixedPriority=false); 119 + 120 + void GetTimeConstraints(UInt32& outPeriod, UInt32& outComputation, UInt32& outConstraint, bool& outIsPreemptible) const { outPeriod = mPeriod; outComputation = mComputation; outConstraint = mConstraint; outIsPreemptible = mIsPreemptible; } 121 + void SetTimeConstraints(UInt32 inPeriod, UInt32 inComputation, UInt32 inConstraint, bool inIsPreemptible); 122 + void ClearTimeConstraints() { SetPriority(mPriority); } 123 + 124 + // Actions 125 + public: 126 + virtual void Start(); 127 + 128 + // Implementation 129 + protected: 130 + #if TARGET_OS_MAC 131 + static void* Entry(CAPThread* inCAPThread); 132 + static UInt32 getScheduledPriority(pthread_t inThread, int inPriorityKind); 133 + #elif TARGET_OS_WIN32 134 + static UInt32 WINAPI Entry(CAPThread* inCAPThread); 135 + #endif 136 + 137 + #if TARGET_OS_MAC 138 + pthread_t mPThread; 139 + UInt32 mSpawningThreadPriority; 140 + #elif TARGET_OS_WIN32 141 + HANDLE mThreadHandle; 142 + UInt32 mThreadID; 143 + #endif 144 + ThreadRoutine mThreadRoutine; 145 + void* mThreadParameter; 146 + SInt32 mPriority; 147 + UInt32 mPeriod; 148 + UInt32 mComputation; 149 + UInt32 mConstraint; 150 + bool mIsPreemptible; 151 + bool mTimeConstraintSet; 152 + bool mFixedPriority; 153 + }; 154 + 155 + #endif
+26
src/CoreAudio/AudioFileTools/PublicUtility/ReadMe.rtf
··· 1 + {\rtf1\mac\ansicpg10000\cocoartf102 2 + {\fonttbl\f0\fswiss\fcharset77 Helvetica;\f1\fnil\fcharset77 Monaco;} 3 + {\colortbl;\red255\green255\blue255;\red104\green56\blue33;} 4 + \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural 5 + 6 + \f0\fs36 \cf0 AudioFile-new\ 7 + \ 8 + 9 + \fs24 This folder contains new classes for working with audio files, using the AudioToolbox AudioFile and AudioConverter API's. It is currently a work in progress. Some command-line tools using these classes are in the AudioFileTools sample project.\ 10 + \ 11 + CAAudioFile has been reworked to optionally use the new ExtendedAudioFile API in Tiger. The functionality is essentially the same but a number of method names have been changed. To use the provided Panther-compatible implementation instead of requiring ExtendedAudioFile, define 12 + \f1\fs18 \cf2 \CocoaLigature0 CAAF_USE_EXTAUDIOFILE 13 + \f0\fs24 \cf0 \CocoaLigature1 to 1.\ 14 + \ 15 + The main classes are:\ 16 + \ 17 + CAAudioFile - wraps an AudioFile in an AudioConverter. The client specifies a PCM format to be used when reading/writing from the file, and the class performs any necessary decoding/encoding transparently. Be aware that most methods of this class may throw exceptions.\ 18 + \ 19 + CAAudioFileStreamer / CAAudioFileReader / CAAudioFileWriter - perfom asynchronous streaming of CAAudioFiles on a separate work thread for file I/O and decoding.These classes don't actually connect to the audio hardware.\ 20 + \ 21 + CAAudioFilePlayer / CAAudioFileRecorder - Subclasses of CAAudioFileReader / CAAudioFileWriter which use audio "output" (now I/O) units to actually play and recorder the audio.\ 22 + \ 23 + CAChannelMapper - uses the matrix mixer audio unit for converting (downmixing if necessary) between audio channel layouts.\ 24 + \ 25 + The other classes are support classes for the above.\ 26 + }
+45
src/CoreAudio/AudioFileTools/ReadMe.rtf
··· 1 + {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf100 2 + {\fonttbl\f0\fswiss\fcharset77 Helvetica;\f1\fmodern\fcharset77 Courier;\f2\fswiss\fcharset77 Helvetica-Bold; 3 + } 4 + {\colortbl;\red255\green255\blue255;} 5 + \vieww12420\viewh14680\viewkind0 6 + \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural 7 + 8 + \f0\fs36 \cf0 AudioFileTools\ 9 + 10 + \fs24 \ 11 + This project contains a collection of sample command-line tools that demonstrate use of the AudioFile, AudioConverter, AudioFormat, and AudioUnit APIs. Most make heavy use of the CAAudioFile class (in PublicUtility/AudioFile-new).\ 12 + \ 13 + Note that CAAudioFile.h is conditionalized with 14 + \f1 \CocoaLigature0 CAAF_USE_EXTAUDIOFILE 15 + \f0 \CocoaLigature1 . If this symbol is defined and non-zero, the CAAudioFile implementation uses the ExtendedAudioFile API set introduced in Tiger. Otherwise, CAAudioFile carries its own similar implementation, which is deployable on Panther systems. If your build environment does not define this symbol, the header automatically defines it based on the Mac OS deployment build settings. The "-Tiger+" build styles in this project define the Mac OS deployment target to 10.4 and will thus use ExtendedAudioFile. The "-Panther" build styles do not define a Mac OS deployment target and thus do not use ExtendedAudioFile.\ 16 + \ 17 + The tools include:\ 18 + \ 19 + 20 + \f2\b afconvert 21 + \f0\b0 - reads one audio file, writes it to another format. Good example of the power of CAAudioFile and use of the AudioConverter for codecs.\ 22 + \ 23 + 24 + \f2\b afinterleave 25 + \f0\b0 - creates an interleaved file from 2 or more input files\ 26 + \ 27 + 28 + \f2\b afplay 29 + \f0\b0 - plays an audio file (can be encoded)\ 30 + \ 31 + 32 + \f2\b afrecord 33 + \f0\b0 - records an audio file (record format is hardcoded)\ 34 + \ 35 + 36 + \f2\b audioformats 37 + \f0\b0 - demonstrates some uses of the AudioFormat and AudioFile APIs.\ 38 + \ 39 + 40 + \f2\b qtaacdecode 41 + \f0\b0 - this has been removed. Please see the QT SDK's examples for using their AudioExtraction API\ 42 + \ 43 + 44 + \f2\b auprocess 45 + \f0\b0 - processes an audio file with an Audio Unit and generates a new file. Illustrates the usage of the CAAUProcessor class, which presents a wrapper class around using any AU in either a real-time or offline context}
+283
src/CoreAudio/AudioFileTools/Utility/AFToolsCommon.cpp
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + AFToolsCommon.cpp 40 + 41 + =============================================================================*/ 42 + 43 + #include "AFToolsCommon.h" 44 + #include "CAAudioFileFormats.h" 45 + #include <ctype.h> 46 + #include <CoreServices/Endian.h> 47 + 48 + 49 + /* 50 + struct AudioStreamBasicDescription 51 + { 52 + Float64 mSampleRate; // the native sample rate of the audio stream 53 + UInt32 mFormatID; // the specific encoding type of audio stream 54 + UInt32 mFormatFlags; // flags specific to each format 55 + UInt32 mBytesPerPacket; // the number of bytes in a packet 56 + UInt32 mFramesPerPacket; // the number of frames in each packet 57 + UInt32 mBytesPerFrame; // the number of bytes in a frame 58 + UInt32 mChannelsPerFrame; // the number of channels in each frame 59 + UInt32 mBitsPerChannel; // the number of bits in each channel 60 + UInt32 mReserved; // reserved, pads the structure out to force 8 byte alignment 61 + }; 62 + */ 63 + bool ParseStreamDescription(const char *inTextDesc, CAStreamBasicDescription &fmt) 64 + { 65 + const char *p = inTextDesc; 66 + int bitdepth = 0; 67 + CAAudioFileFormats *theFileFormats = CAAudioFileFormats::Instance(); 68 + 69 + memset(&fmt, 0, sizeof(fmt)); 70 + OSType formatID; 71 + int x; 72 + if (strchr("-@/#", p[3])) { 73 + // special-case for 3-char format ID's ending with a space 74 + char fmtstr[4]; 75 + memcpy(fmtstr, p, 3); 76 + fmtstr[3] = ' '; 77 + formatID = EndianU32_BtoN(*(UInt32 *)fmtstr); 78 + x = 3; 79 + } else { 80 + x = StrToOSType(p, formatID); 81 + } 82 + if (theFileFormats->IsKnownDataFormat(formatID)) { 83 + p += x; 84 + fmt.mFormatID = formatID; 85 + if (*p == '-') { 86 + ++p; 87 + bitdepth = 0; 88 + while (isdigit(*p)) 89 + bitdepth = 10 * bitdepth + *p++ - '0'; 90 + fmt.mBitsPerChannel = bitdepth; 91 + } 92 + } 93 + 94 + if (fmt.mFormatID == 0) { 95 + // unknown format, assume LPCM 96 + if (p[0] == '-') // previously we required a leading dash on PCM formats 97 + // pcm 98 + ++p; 99 + fmt.mFormatID = kAudioFormatLinearPCM; 100 + fmt.mFormatFlags = kAudioFormatFlagIsPacked; 101 + fmt.mFramesPerPacket = 1; 102 + fmt.mChannelsPerFrame = 1; 103 + bool isUnsigned = false; 104 + 105 + if (p[0] == 'B' && p[1] == 'E') { 106 + fmt.mFormatFlags |= kLinearPCMFormatFlagIsBigEndian; 107 + p += 2; 108 + } else if (p[0] == 'L' && p[1] == 'E') { 109 + p += 2; 110 + } else { 111 + // default is native-endian 112 + #if TARGET_RT_BIG_ENDIAN 113 + fmt.mFormatFlags |= kLinearPCMFormatFlagIsBigEndian; 114 + #endif 115 + } 116 + if (p[0] == 'F') { 117 + fmt.mFormatFlags |= kAudioFormatFlagIsFloat; 118 + ++p; 119 + } else { 120 + if (p[0] == 'U') { 121 + isUnsigned = true; 122 + ++p; 123 + } 124 + if (p[0] == 'I') 125 + ++p; 126 + else { 127 + fprintf(stderr, "The format '%s' is unknown or an unparseable PCM format specifier\n", inTextDesc); 128 + goto Bail; 129 + } 130 + } 131 + 132 + while (isdigit(*p)) 133 + bitdepth = 10 * bitdepth + *p++ - '0'; 134 + if (fmt.mFormatFlags & kAudioFormatFlagIsFloat) { 135 + if (bitdepth != 32 && bitdepth != 64) { 136 + fprintf(stderr, "Valid float bitdepths are 32 and 64\n"); 137 + goto Bail; 138 + } 139 + } else { 140 + if (bitdepth != 8 && bitdepth != 16 && bitdepth != 24 && bitdepth != 32) { 141 + fprintf(stderr, "Valid integer bitdepths are 8, 16, 24, and 32\n"); 142 + goto Bail; 143 + } 144 + if (!isUnsigned) 145 + fmt.mFormatFlags |= kAudioFormatFlagIsSignedInteger; 146 + } 147 + fmt.mBitsPerChannel = bitdepth; 148 + fmt.mBytesPerPacket = fmt.mBytesPerFrame = bitdepth / 8; 149 + } 150 + if (*p == '@') { 151 + ++p; 152 + while (isdigit(*p)) 153 + fmt.mSampleRate = 10 * fmt.mSampleRate + (*p++ - '0'); 154 + } 155 + if (*p == '/') { 156 + UInt32 flags = 0; 157 + while (true) { 158 + char c = *++p; 159 + if (c >= '0' && c <= '9') 160 + flags = (flags << 4) | (c - '0'); 161 + else if (c >= 'A' && c <= 'F') 162 + flags = (flags << 4) | (c - 'A' + 10); 163 + else if (c >= 'a' && c <= 'f') 164 + flags = (flags << 4) | (c - 'a' + 10); 165 + else break; 166 + } 167 + fmt.mFormatFlags = flags; 168 + } 169 + if (*p == '#') { 170 + ++p; 171 + while (isdigit(*p)) 172 + fmt.mFramesPerPacket = 10 * fmt.mFramesPerPacket + (*p++ - '0'); 173 + } 174 + if (*p != '\0') 175 + goto Bail; 176 + return true; 177 + 178 + Bail: 179 + fprintf(stderr, "Invalid format string: %s\n", inTextDesc); 180 + fprintf(stderr, "Syntax of format strings is: [-][BE|LE]{F|I|UI}{8|16|24|32|64}[@sample_rate_hz][/format_flags]\n"); 181 + return false; 182 + } 183 + 184 + void PrintAudioFileTypesAndFormats(FILE *outfile) 185 + { 186 + CAAudioFileFormats *theFileFormats = CAAudioFileFormats::Instance(); 187 + 188 + for (int i = 0; i < theFileFormats->mNumFileFormats; ++i) { 189 + CAAudioFileFormats::FileFormatInfo *ffi = &theFileFormats->mFileFormats[i]; 190 + 191 + int j; 192 + char buf[20]; 193 + char fmtName[256] = { 0 }; 194 + if (ffi->mFileTypeName) 195 + CFStringGetCString(ffi->mFileTypeName, fmtName, sizeof(fmtName), kCFStringEncodingUTF8); 196 + fprintf(outfile, " '%s' = %s", OSTypeToStr(buf, sizeof(buf), ffi->mFileTypeID), fmtName); 197 + 198 + int next = ffi->NumberOfExtensions(); 199 + if (next > 0) { 200 + fprintf(outfile, " ("); 201 + for (j = 0; j < next; ++j) { 202 + if (j > 0) fprintf(outfile, ", "); 203 + fprintf(outfile, ".%s", ffi->GetExtension(j, buf, sizeof(buf))); 204 + } 205 + fprintf(outfile, ")"); 206 + } 207 + 208 + fprintf(outfile, "\n data_formats: "); 209 + int count = 0; 210 + for (j = 0; j < ffi->mNumDataFormats; ++j) { 211 + CAAudioFileFormats::DataFormatInfo *dfi = &ffi->mDataFormats[j]; 212 + if (dfi->mFormatID == kAudioFormatLinearPCM) { 213 + for (int k = 0; k < dfi->mNumVariants; ++k) { 214 + if (++count == 6) { 215 + fprintf(outfile, "\n "); 216 + count = 0; 217 + } 218 + AudioStreamBasicDescription *asbd = &dfi->mVariants[k]; 219 + if (asbd->mFormatFlags & ~(kAudioFormatFlagIsPacked | kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsBigEndian | kAudioFormatFlagIsFloat)) 220 + fprintf(outfile, "(%08lx/%ld) ", asbd->mFormatFlags, asbd->mBitsPerChannel); 221 + else { 222 + fprintf(outfile, "%s", 223 + (asbd->mFormatFlags & kAudioFormatFlagIsBigEndian) ? "BE" : "LE"); 224 + if (asbd->mFormatFlags & kAudioFormatFlagIsFloat) 225 + fprintf(outfile, "F"); 226 + else 227 + fprintf(outfile, "%sI", 228 + (asbd->mFormatFlags & kAudioFormatFlagIsSignedInteger) ? "" : "U"); 229 + fprintf(outfile, "%ld ", asbd->mBitsPerChannel); 230 + } 231 + } 232 + } else { 233 + if (++count == 6) { 234 + fprintf(outfile, "\n "); 235 + count = 0; 236 + } 237 + fprintf(outfile, "'%s' ", OSTypeToStr(buf, sizeof(buf), dfi->mFormatID)); 238 + } 239 + } 240 + fprintf(outfile, "\n"); 241 + } 242 + } 243 + 244 + #if 0 245 + char *OSTypeToStr(char *buf, OSType t) 246 + { 247 + char *p = buf; 248 + char str[4], *q = str; 249 + *(UInt32 *)str = EndianU32_NtoB(t); 250 + for (int i = 0; i < 4; ++i) { 251 + if (isprint(*q) && *q != '\\') 252 + *p++ = *q++; 253 + else { 254 + sprintf(p, "\\x%02x", *q++); 255 + p += 4; 256 + } 257 + } 258 + *p = '\0'; 259 + return buf; 260 + } 261 + 262 + int StrToOSType(const char *str, OSType &t) 263 + { 264 + char buf[4]; 265 + const char *p = str; 266 + int x; 267 + for (int i = 0; i < 4; ++i) { 268 + if (*p != '\\') { 269 + if ((buf[i] = *p++) == '\0') 270 + goto fail; 271 + } else { 272 + if (*++p != 'x') goto fail; 273 + if (sscanf(++p, "%02X", &x) != 1) goto fail; 274 + buf[i] = x; 275 + p += 2; 276 + } 277 + } 278 + t = EndianU32_BtoN(*(UInt32 *)buf); 279 + return p - str; 280 + fail: 281 + return 0; 282 + } 283 + #endif
+59
src/CoreAudio/AudioFileTools/Utility/AFToolsCommon.h
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + AFToolsCommon.h 40 + 41 + =============================================================================*/ 42 + 43 + #ifndef __AFToolsCommon_h__ 44 + #define __AFToolsCommon_h__ 45 + 46 + // Various utility functions appropriate for reuse in Core Audio command-line tools 47 + 48 + #include <stdio.h> 49 + #include "CAStreamBasicDescription.h" 50 + 51 + bool ParseStreamDescription(const char *inTextDesc, CAStreamBasicDescription &fmt); 52 + // parse a textual representation of an AudioStreamBasicDescription 53 + void PrintAudioFileTypesAndFormats(FILE *outfile); 54 + 55 + // utilities to convert OSType's to and from printable strings 56 + // buffer should be at least 17 bytes 57 + 58 + 59 + #endif // __AFToolsCommon_h__
+592
src/CoreAudio/AudioFileTools/Utility/CAAudioFileConverter.cpp
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + CAAudioFileConverter.cpp 40 + 41 + =============================================================================*/ 42 + 43 + #include "CAAudioFileConverter.h" 44 + #include "CAChannelLayouts.h" 45 + #include <sys/stat.h> 46 + #include <algorithm> 47 + #include "CAXException.h" 48 + #include "CAFilePathUtils.h" 49 + #if !TARGET_OS_MAC 50 + #include <AudioCodec.h> 51 + #endif 52 + 53 + char* dirname(const char* str) 54 + { 55 + static char buffer[4096]; 56 + strcpy(buffer, str); 57 + return dirname(buffer); 58 + } 59 + char* basename(const char* str) 60 + { 61 + static char buffer[4096]; 62 + strcpy(buffer, str); 63 + return basename(buffer); 64 + } 65 + 66 + CAAudioFileConverter::ConversionParameters::ConversionParameters() : 67 + flags(0) 68 + { 69 + memset(&input, 0, sizeof(input)); 70 + memset(&output, 0, sizeof(output)); 71 + output.channels = -1; 72 + output.bitRate = -1; 73 + output.codecQuality = -1; 74 + output.srcQuality = -1; 75 + output.strategy = -1; 76 + output.primeMethod = -1; 77 + } 78 + 79 + CAAudioFileConverter::CAAudioFileConverter() : 80 + mReadBuffer(NULL), 81 + mReadPtrs(NULL) 82 + { 83 + mOutName[0] = '\0'; 84 + } 85 + 86 + CAAudioFileConverter::~CAAudioFileConverter() 87 + { 88 + } 89 + 90 + void CAAudioFileConverter::GenerateOutputFileName(const char *inputFilePath, 91 + const CAStreamBasicDescription &inputFormat, 92 + const CAStreamBasicDescription &outputFormat, OSType outputFileType, 93 + char *outName) 94 + { 95 + struct stat sb; 96 + char inputDir[256]; 97 + char inputBasename[256]; 98 + 99 + strcpy(inputDir, dirname(inputFilePath)); 100 + const char *infname = basename(inputFilePath); 101 + const char *inext = strrchr(infname, '.'); 102 + if (inext == NULL) strcpy(inputBasename, infname); 103 + else { 104 + int n; 105 + memcpy(inputBasename, infname, n = inext - infname); 106 + inputBasename[n] = '\0'; 107 + } 108 + 109 + CFArrayRef exts; 110 + UInt32 propSize = sizeof(exts); 111 + XThrowIfError(AudioFileGetGlobalInfo(kAudioFileGlobalInfo_ExtensionsForType, 112 + sizeof(OSType), &outputFileType, &propSize, &exts), "generate output file name"); 113 + char outputExt[32]; 114 + CFStringRef cfext = (CFStringRef)CFArrayGetValueAtIndex(exts, 0); 115 + CFStringGetCString(cfext, outputExt, sizeof(outputExt), kCFStringEncodingUTF8); 116 + CFRelease(exts); 117 + 118 + // 1. olddir + oldname + newext 119 + sprintf(outName, "%s/%s.%s", inputDir, inputBasename, outputExt); 120 + #if TARGET_OS_MAC 121 + if (lstat(outName, &sb)) return; 122 + #else 123 + if (stat(outName, &sb)) return; 124 + #endif 125 + 126 + if (outputFormat.IsPCM()) { 127 + // If sample rate changed: 128 + // 2. olddir + oldname + "-SR" + newext 129 + if (inputFormat.mSampleRate != outputFormat.mSampleRate && outputFormat.mSampleRate != 0.) { 130 + sprintf(outName, "%s/%s-%.0fk.%s", inputDir, inputBasename, outputFormat.mSampleRate/1000., outputExt); 131 + #if TARGET_OS_MAC 132 + if (lstat(outName, &sb)) return; 133 + #else 134 + if (stat(outName, &sb)) return; 135 + #endif 136 + } 137 + // If bit depth changed: 138 + // 3. olddir + oldname + "-bit" + newext 139 + if (inputFormat.mBitsPerChannel != outputFormat.mBitsPerChannel) { 140 + sprintf(outName, "%s/%s-%ldbit.%s", inputDir, inputBasename, outputFormat.mBitsPerChannel, outputExt); 141 + #if TARGET_OS_MAC 142 + if (lstat(outName, &sb)) return; 143 + #else 144 + if (stat(outName, &sb)) return; 145 + #endif 146 + } 147 + } 148 + 149 + // maybe more with channels/layouts? $$$ 150 + 151 + // now just append digits 152 + for (int i = 1; ; ++i) { 153 + sprintf(outName, "%s/%s-%d.%s", inputDir, inputBasename, i, outputExt); 154 + #if TARGET_OS_MAC 155 + if (lstat(outName, &sb)) return; 156 + #else 157 + if (stat(outName, &sb)) return; 158 + #endif 159 + } 160 + } 161 + 162 + void CAAudioFileConverter::PrintFormats(const CAAudioChannelLayout *origSrcFileLayout) 163 + { 164 + const CAAudioChannelLayout &srcFileLayout = mSrcFile.GetFileChannelLayout(); 165 + const CAAudioChannelLayout &destFileLayout = mDestFile.GetFileChannelLayout(); 166 + 167 + // see where we've gotten 168 + if (mParams.flags & kOpt_Verbose) { 169 + printf("Formats:\n"); 170 + mSrcFile.GetFileDataFormat().PrintFormat(stdout, " ", "Input file "); 171 + if (srcFileLayout.IsValid()) { 172 + printf(" %s", 173 + CAChannelLayouts::ConstantToString(srcFileLayout.Tag())); 174 + if (srcFileLayout.IsValid() && origSrcFileLayout != NULL && 175 + srcFileLayout != *origSrcFileLayout) 176 + printf(" -- overriding layout %s in file", 177 + CAChannelLayouts::ConstantToString(origSrcFileLayout->Tag())); 178 + printf("\n"); 179 + } 180 + mDestFile.GetFileDataFormat().PrintFormat(stdout, " ", "Output file "); 181 + if (destFileLayout.IsValid()) 182 + printf(" %s\n", 183 + CAChannelLayouts::ConstantToString(destFileLayout.Tag())); 184 + if (mSrcFile.HasConverter()) { 185 + mSrcFile.GetClientDataFormat().PrintFormat(stdout, " ", "Input client "); 186 + CAShow(mSrcFile.GetConverter()); 187 + } 188 + if (mDestFile.HasConverter()) { 189 + mDestFile.GetClientDataFormat().PrintFormat(stdout, " ", "Output client"); 190 + CAShow(mDestFile.GetConverter()); 191 + } 192 + } 193 + } 194 + 195 + void CAAudioFileConverter::OpenInputFile() 196 + { 197 + if (mParams.input.audioFileID) 198 + mSrcFile.Wrap(mParams.input.audioFileID, false); 199 + else 200 + mSrcFile.Open(mParams.input.filePath); 201 + } 202 + 203 + void CAAudioFileConverter::OpenOutputFile(const CAStreamBasicDescription &srcFormat, const CAStreamBasicDescription &destFormat, FSRef &destFSRef, CAAudioChannelLayout &destFileLayout) 204 + { 205 + const ConversionParameters &params = mParams; 206 + 207 + // output file 208 + if (params.output.filePath == NULL) { 209 + GenerateOutputFileName(params.input.filePath, srcFormat, 210 + destFormat, params.output.fileType, mOutName); 211 + } else 212 + strcpy(mOutName, params.output.filePath); 213 + 214 + // deal with pre-existing output file 215 + if (FSPathMakeRef((UInt8 *)mOutName, &destFSRef, NULL) == noErr) { 216 + XThrowIf(!(params.flags & kOpt_OverwriteOutputFile), 1, "overwrite output file"); 217 + // not allowed to overwrite 218 + // output file exists - delete it 219 + XThrowIfError(FSDeleteObject(&destFSRef), "delete output file"); 220 + } 221 + // get FSRef/CFStringRef for output file 222 + FSRef outFolderFSRef; 223 + CFStringRef outFileName; 224 + XThrowIfError(PosixPathToParentFSRefAndName(mOutName, outFolderFSRef, outFileName), "locate output audio file"); 225 + 226 + // create the output file 227 + mDestFile.CreateNew(outFolderFSRef, outFileName, params.output.fileType, destFormat, &destFileLayout.Layout()); 228 + CFRelease(outFileName); 229 + } 230 + 231 + 232 + void CAAudioFileConverter::ConvertFile(const ConversionParameters &_params) 233 + { 234 + FSRef destFSRef; 235 + UInt32 propertySize; 236 + CAStreamBasicDescription destFormat; 237 + CAAudioChannelLayout origSrcFileLayout, srcFileLayout, destFileLayout; 238 + bool openedSourceFile = false, createdOutputFile = false; 239 + 240 + mParams = _params; 241 + mReadBuffer = NULL; 242 + mReadPtrs = NULL; 243 + CABufferList *writeBuffer = NULL; 244 + CABufferList *writePtrs = NULL; 245 + 246 + PrepareConversion(); 247 + 248 + try { 249 + if (TaggedDecodingFromCAF()) 250 + ReadCAFInfo(); 251 + OpenInputFile(); 252 + openedSourceFile = true; 253 + 254 + // get input file's format 255 + const CAStreamBasicDescription &srcFormat = mSrcFile.GetFileDataFormat(); 256 + if (mParams.flags & kOpt_Verbose) { 257 + printf("Input file: %s, %qd frames\n", mParams.input.filePath ? basename(mParams.input.filePath) : "?", 258 + mSrcFile.GetNumberFrames()); 259 + } 260 + mSrcFormat = srcFormat; 261 + 262 + // prepare output file's format 263 + destFormat = mParams.output.dataFormat; 264 + 265 + bool encoding = !destFormat.IsPCM(); 266 + bool decoding = !srcFormat.IsPCM(); 267 + 268 + if (!encoding && destFormat.mSampleRate == 0.) 269 + // on encode, it's OK to have a 0 sample rate; ExtAudioFile will get the SR from the converter and set it on the file. 270 + // on decode or PCM->PCM, a sample rate of 0 is interpreted as using the source sample rate 271 + destFormat.mSampleRate = srcFormat.mSampleRate; 272 + 273 + // source channel layout 274 + srcFileLayout = mSrcFile.GetFileChannelLayout(); 275 + origSrcFileLayout = srcFileLayout; 276 + if (mParams.input.channelLayoutTag != 0) { 277 + XThrowIf(AudioChannelLayoutTag_GetNumberOfChannels(mParams.input.channelLayoutTag) 278 + != srcFormat.mChannelsPerFrame, -1, "input channel layout has wrong number of channels for file"); 279 + srcFileLayout = CAAudioChannelLayout(mParams.input.channelLayoutTag); 280 + mSrcFile.SetFileChannelLayout(srcFileLayout); 281 + } 282 + 283 + // destination channel layout 284 + int outChannels = mParams.output.channels; 285 + if (mParams.output.channelLayoutTag != 0) { 286 + // use the one specified by caller, if any 287 + destFileLayout = CAAudioChannelLayout(mParams.output.channelLayoutTag); 288 + } else if (srcFileLayout.IsValid()) { 289 + // otherwise, assume the same as the source, if any 290 + destFileLayout = srcFileLayout; 291 + } 292 + if (destFileLayout.IsValid()) { 293 + // the output channel layout specifies the number of output channels 294 + if (outChannels != -1) 295 + XThrowIf((unsigned)outChannels != destFileLayout.NumberChannels(), -1, 296 + "output channel layout has wrong number of channels"); 297 + else 298 + outChannels = destFileLayout.NumberChannels(); 299 + } 300 + 301 + if (!(mParams.flags & kOpt_NoSanitizeOutputFormat)) { 302 + // adjust the output format's channels; output.channels overrides the channels 303 + if (outChannels == -1) 304 + outChannels = srcFormat.mChannelsPerFrame; 305 + if (outChannels > 0) { 306 + destFormat.mChannelsPerFrame = outChannels; 307 + destFormat.mBytesPerPacket *= outChannels; 308 + destFormat.mBytesPerFrame *= outChannels; 309 + } 310 + 311 + // use AudioFormat API to clean up the output format 312 + propertySize = sizeof(AudioStreamBasicDescription); 313 + XThrowIfError(AudioFormatGetProperty(kAudioFormatProperty_FormatInfo, 0, NULL, &propertySize, &destFormat), 314 + "get destination format info"); 315 + } 316 + OpenOutputFile(srcFormat, destFormat, destFSRef, destFileLayout); 317 + createdOutputFile = true; 318 + mDestFormat = destFormat; 319 + 320 + // set up client formats 321 + CAStreamBasicDescription srcClientFormat, destClientFormat; 322 + { 323 + CAAudioChannelLayout srcClientLayout, destClientLayout; 324 + 325 + if (encoding) { 326 + if (decoding) { 327 + // transcoding 328 + // XThrowIf(encoding && decoding, -1, "transcoding not currently supported"); 329 + 330 + if (srcFormat.mChannelsPerFrame > 2 || destFormat.mChannelsPerFrame > 2) 331 + CAXException::Warning("Transcoding multichannel audio may not handle channel layouts correctly", 0); 332 + srcClientFormat.SetCanonical(std::min(srcFormat.mChannelsPerFrame, destFormat.mChannelsPerFrame), true); 333 + srcClientFormat.mSampleRate = std::max(srcFormat.mSampleRate, destFormat.mSampleRate); 334 + mSrcFile.SetClientFormat(srcClientFormat, NULL); 335 + 336 + destClientFormat = srcClientFormat; 337 + } else { 338 + // encoding 339 + srcClientFormat = srcFormat; 340 + destClientFormat = srcFormat; 341 + } 342 + // by here, destClientFormat will have a valid sample rate 343 + destClientLayout = srcFileLayout.IsValid() ? srcFileLayout : destFileLayout; 344 + 345 + mDestFile.SetClientFormat(destClientFormat, &destClientLayout); 346 + } else { 347 + // decoding or PCM->PCM 348 + if (destFormat.mSampleRate == 0.) 349 + destFormat.mSampleRate = srcFormat.mSampleRate; 350 + 351 + destClientFormat = destFormat; 352 + srcClientFormat = destFormat; 353 + srcClientLayout = destFileLayout; 354 + 355 + mSrcFile.SetClientFormat(srcClientFormat, &srcClientLayout); 356 + } 357 + } 358 + 359 + XThrowIf(srcClientFormat.mBytesPerPacket == 0, -1, "source client format not PCM"); 360 + XThrowIf(destClientFormat.mBytesPerPacket == 0, -1, "dest client format not PCM"); 361 + if (encoding) { 362 + // set the bitrate 363 + if (mParams.output.bitRate != -1) { 364 + if (mParams.flags & kOpt_Verbose) 365 + printf("bitrate = %ld\n", mParams.output.bitRate); 366 + mDestFile.SetConverterProperty(kAudioConverterEncodeBitRate, sizeof(UInt32), &mParams.output.bitRate); 367 + } 368 + 369 + // set the codec quality 370 + if (mParams.output.codecQuality != -1) { 371 + if (mParams.flags & kOpt_Verbose) 372 + printf("codec quality = %ld\n", mParams.output.codecQuality); 373 + mDestFile.SetConverterProperty(kAudioConverterCodecQuality, sizeof(UInt32), &mParams.output.codecQuality); 374 + } 375 + 376 + // set the bitrate strategy -- called bitrate format in the codecs since it had already shipped 377 + if (mParams.output.strategy != -1) { 378 + if (mParams.flags & kOpt_Verbose) 379 + printf("strategy = %ld\n", mParams.output.strategy); 380 + mDestFile.SetConverterProperty(kAudioCodecBitRateFormat, sizeof(UInt32), &mParams.output.strategy); 381 + } 382 + } 383 + // set the SRC quality 384 + if (mParams.output.srcQuality != -1) { 385 + if (srcFormat.mSampleRate != 0. && destFormat.mSampleRate != 0. && srcFormat.mSampleRate != destFormat.mSampleRate) { 386 + if (mParams.flags & kOpt_Verbose) 387 + printf("SRC quality = %ld\n", mParams.output.srcQuality); 388 + if (encoding) 389 + mDestFile.SetConverterProperty(kAudioConverterSampleRateConverterQuality, sizeof(UInt32), &mParams.output.srcQuality); 390 + else 391 + mSrcFile.SetConverterProperty(kAudioConverterSampleRateConverterQuality, sizeof(UInt32), &mParams.output.srcQuality); 392 + } 393 + } 394 + if (decoding) { 395 + if (mParams.output.primeMethod != -1) 396 + mSrcFile.SetConverterProperty(kAudioConverterPrimeMethod, sizeof(UInt32), &mParams.output.primeMethod); 397 + } 398 + 399 + PrintFormats(&origSrcFileLayout); 400 + 401 + // prepare I/O buffers 402 + UInt32 bytesToRead = 0x10000; 403 + UInt32 framesToRead = bytesToRead; // OK, ReadPackets will limit as appropriate 404 + ComputeReadSize(srcFormat, destFormat, bytesToRead, framesToRead); 405 + 406 + // const SInt64 totalFrames = mSrcFile.GetNumberFrames(); 407 + //#warning "GetNumberFrames() can be prohibitively slow for some formats" 408 + 409 + mReadBuffer = CABufferList::New("readbuf", srcClientFormat); 410 + mReadBuffer->AllocateBuffers(bytesToRead); 411 + mReadPtrs = CABufferList::New("readptrs", srcClientFormat); 412 + 413 + BeginConversion(); 414 + 415 + while (true) { 416 + //XThrowIf(Progress(mSrcFile.Tell(), totalFrames), userCanceledErr, "user stopped"); 417 + // this was commented out for awhile -- performance? make it optional? 418 + UInt32 nFrames = framesToRead; 419 + mReadPtrs->SetFrom(mReadBuffer); 420 + AudioBufferList *readbuf = &mReadPtrs->GetModifiableBufferList(); 421 + 422 + mSrcFile.Read(nFrames, readbuf); 423 + //printf("read %ld of %ld frames\n", nFrames, framesToRead); 424 + if (nFrames == 0) 425 + break; 426 + 427 + mDestFile.Write(nFrames, readbuf); 428 + if (ShouldTerminateConversion()) 429 + break; 430 + } 431 + 432 + if (decoding) { 433 + // fix up the destination file's length if necessary and possible 434 + SInt64 nframes = mSrcFile.GetNumberFrames(); 435 + if (nframes != 0) { 436 + // only shorten, don't try to lengthen 437 + nframes = SInt64(ceil(nframes * destFormat.mSampleRate / srcFormat.mSampleRate)); 438 + if (nframes < mDestFile.GetNumberFrames()) { 439 + mDestFile.SetNumberFrames(nframes); 440 + } 441 + } 442 + } 443 + EndConversion(); 444 + } 445 + catch (...) { 446 + delete mReadBuffer; 447 + delete mReadPtrs; 448 + delete writeBuffer; 449 + delete writePtrs; 450 + try { mSrcFile.Close(); } catch (...) { } 451 + try { mDestFile.Close(); } catch (...) { } 452 + if (createdOutputFile) 453 + unlink(mOutName); 454 + throw; 455 + } 456 + delete mReadBuffer; 457 + delete mReadPtrs; 458 + delete writeBuffer; 459 + delete writePtrs; 460 + mSrcFile.Close(); 461 + mDestFile.Close(); 462 + if (TaggedEncodingToCAF()) 463 + WriteCAFInfo(); 464 + 465 + if (mParams.flags & kOpt_Verbose) { 466 + // must close to flush encoder; GetNumberFrames() not necessarily valid until afterwards but then 467 + // the file is closed 468 + CAAudioFile temp; 469 + FSRef destFSRef; 470 + if (FSPathMakeRef((UInt8 *)mOutName, &destFSRef, NULL) == noErr) { 471 + temp.Open(destFSRef); 472 + printf("Output file: %s, %qd frames\n", basename(mOutName), temp.GetNumberFrames()); 473 + } 474 + } 475 + } 476 + 477 + #define kMaxFilename 64 478 + struct CAFSourceInfo { 479 + // our private user data chunk -- careful about compiler laying this out! 480 + // big endian 481 + char asbd[40]; 482 + UInt32 filetype; 483 + char filename[kMaxFilename]; 484 + }; 485 + 486 + static void ASBD_NtoB(const AudioStreamBasicDescription *infmt, AudioStreamBasicDescription *outfmt) 487 + { 488 + *(UInt64 *)&outfmt->mSampleRate = EndianU64_NtoB(*(UInt64 *)&infmt->mSampleRate); 489 + outfmt->mFormatID = EndianU32_NtoB(infmt->mFormatID); 490 + outfmt->mFormatFlags = EndianU32_NtoB(infmt->mFormatFlags); 491 + outfmt->mBytesPerPacket = EndianU32_NtoB(infmt->mBytesPerPacket); 492 + outfmt->mFramesPerPacket = EndianU32_NtoB(infmt->mFramesPerPacket); 493 + outfmt->mBytesPerFrame = EndianU32_NtoB(infmt->mBytesPerFrame); 494 + outfmt->mChannelsPerFrame = EndianU32_NtoB(infmt->mChannelsPerFrame); 495 + outfmt->mBitsPerChannel = EndianU32_NtoB(infmt->mBitsPerChannel); 496 + } 497 + 498 + static void ASBD_BtoN(const AudioStreamBasicDescription *infmt, AudioStreamBasicDescription *outfmt) 499 + { 500 + *(UInt64 *)&outfmt->mSampleRate = EndianU64_BtoN(*(UInt64 *)&infmt->mSampleRate); 501 + outfmt->mFormatID = EndianU32_BtoN(infmt->mFormatID); 502 + outfmt->mFormatFlags = EndianU32_BtoN(infmt->mFormatFlags); 503 + outfmt->mBytesPerPacket = EndianU32_BtoN(infmt->mBytesPerPacket); 504 + outfmt->mFramesPerPacket = EndianU32_BtoN(infmt->mFramesPerPacket); 505 + outfmt->mBytesPerFrame = EndianU32_BtoN(infmt->mBytesPerFrame); 506 + outfmt->mChannelsPerFrame = EndianU32_BtoN(infmt->mChannelsPerFrame); 507 + outfmt->mBitsPerChannel = EndianU32_BtoN(infmt->mBitsPerChannel); 508 + } 509 + 510 + void CAAudioFileConverter::WriteCAFInfo() 511 + { 512 + FSRef fsref; 513 + AudioFileID afid = 0; 514 + CAFSourceInfo info; 515 + UInt32 size; 516 + 517 + try { 518 + XThrowIfError(FSPathMakeRef((UInt8 *)mParams.input.filePath, &fsref, NULL), "couldn't locate input file"); 519 + XThrowIfError(AudioFileOpen(&fsref, fsRdPerm, 0, &afid), "couldn't open input file"); 520 + size = sizeof(AudioFileTypeID); 521 + XThrowIfError(AudioFileGetProperty(afid, kAudioFilePropertyFileFormat, &size, &info.filetype), "couldn't get input file's format"); 522 + AudioFileClose(afid); 523 + afid = 0; 524 + 525 + XThrowIfError(FSPathMakeRef((UInt8 *)mOutName, &fsref, NULL), "couldn't locate output file"); 526 + XThrowIfError(AudioFileOpen(&fsref, fsRdWrPerm, 0, &afid), "couldn't open output file"); 527 + const char *srcFilename = strrchr(mParams.input.filePath, '/'); 528 + if (srcFilename++ == NULL) srcFilename = mParams.input.filePath; 529 + ASBD_NtoB(&mSrcFormat, (AudioStreamBasicDescription *)info.asbd); 530 + int namelen = std::min(kMaxFilename-1, (int)strlen(srcFilename)); 531 + memcpy(info.filename, srcFilename, namelen); 532 + info.filename[namelen++] = 0; 533 + info.filetype = EndianU32_NtoB(info.filetype); 534 + 535 + XThrowIfError(AudioFileSetUserData(afid, 'srcI', 0, offsetof(CAFSourceInfo, filename) + namelen, &info), "couldn't set CAF file's source info chunk"); 536 + AudioFileClose(afid); 537 + } 538 + catch (...) { 539 + if (afid) 540 + AudioFileClose(afid); 541 + throw; 542 + } 543 + } 544 + 545 + void CAAudioFileConverter::ReadCAFInfo() 546 + { 547 + FSRef fsref; 548 + AudioFileID afid = 0; 549 + CAFSourceInfo info; 550 + UInt32 size; 551 + OSStatus err; 552 + 553 + try { 554 + XThrowIfError(FSPathMakeRef((UInt8 *)mParams.input.filePath, &fsref, NULL), "couldn't locate input file"); 555 + XThrowIfError(AudioFileOpen(&fsref, fsRdPerm, 0, &afid), "couldn't open input file"); 556 + size = sizeof(AudioFileTypeID); 557 + XThrowIfError(AudioFileGetProperty(afid, kAudioFilePropertyFileFormat, &size, &info.filetype), "couldn't get input file's format"); 558 + if (info.filetype == kAudioFileCAFType) { 559 + size = sizeof(info); 560 + err = AudioFileGetUserData(afid, 'srcI', 0, &size, &info); 561 + if (!err) { 562 + // restore the following from the original file info: 563 + // filetype 564 + // data format 565 + // filename 566 + AudioStreamBasicDescription destfmt; 567 + ASBD_BtoN((AudioStreamBasicDescription *)info.asbd, &destfmt); 568 + mParams.output.dataFormat = destfmt; 569 + mParams.output.fileType = EndianU32_BtoN(info.filetype); 570 + if (mParams.output.filePath == NULL) { 571 + int len = strlen(mParams.input.filePath) + strlen(info.filename) + 2; 572 + char *newname = (char *)malloc(len); // $$$ leaked 573 + 574 + const char *dir = dirname(mParams.input.filePath); 575 + if (dir && (dir[0] !='.' && dir[1] != '/')) 576 + sprintf(newname, "%s/%s", dir, info.filename); 577 + else 578 + strcpy(newname, info.filename); 579 + mParams.output.filePath = newname; 580 + mParams.flags = (mParams.flags & ~kOpt_OverwriteOutputFile) | kOpt_NoSanitizeOutputFormat; 581 + } 582 + } 583 + } 584 + AudioFileClose(afid); 585 + } 586 + catch (...) { 587 + if (afid) 588 + AudioFileClose(afid); 589 + throw; 590 + } 591 + } 592 +
+155
src/CoreAudio/AudioFileTools/Utility/CAAudioFileConverter.h
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + CAAudioFileConverter.h 40 + 41 + =============================================================================*/ 42 + 43 + #ifndef __CAAudioFileConverter_h__ 44 + #define __CAAudioFileConverter_h__ 45 + 46 + /* 47 + Compile options: 48 + CAAUDIOFILE_PROFILE 49 + */ 50 + 51 + #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 52 + #include <AudioToolbox/AudioToolbox.h> 53 + #else 54 + #include <AudioToolbox.h> 55 + #endif 56 + #include "CAStreamBasicDescription.h" 57 + #include "CABufferList.h" 58 + #include "CAHostTimeBase.h" 59 + #include "CAAudioChannelLayout.h" 60 + #include "CAAudioFile.h" 61 + 62 + class CAAudioFileConverter { 63 + public: 64 + // options for ConversionParameters.flags 65 + enum { 66 + kOpt_OverwriteOutputFile = 1, 67 + kOpt_Verbose = 2, 68 + kOpt_CAFTag = 4, // tags encoded CAF files with info about the source file 69 + // or restores based on it when decoding 70 + kOpt_NoSanitizeOutputFormat = 8 // used internally 71 + }; 72 + 73 + struct ConversionParameters { 74 + ConversionParameters(); 75 + 76 + UInt32 flags; 77 + 78 + struct { 79 + const char * filePath; // POSIX path, UTF-8 80 + AudioFileID audioFileID; // or set this to non-zero 81 + AudioChannelLayoutTag channelLayoutTag; // 0 to use the one in the file, or default 82 + } input; 83 + 84 + struct { 85 + const char * filePath; // POSIX path; if null, file is written to same 86 + // directory as input file, name generated from 87 + // its name with the appropriate filename extension 88 + // (fails if file already exists) 89 + AudioFileTypeID fileType; 90 + CAStreamBasicDescription dataFormat; 91 + int channels; // -1 for same number of channels as input 92 + SInt32 bitRate; // -1 for default 93 + SInt32 codecQuality; // 0-127, -1 for default 94 + SInt32 srcQuality; // 0-127, -1 for default 95 + SInt32 strategy; // 0-2, -1 for default 96 + SInt32 primeMethod; // 0-2, -1 for default 97 + AudioChannelLayoutTag channelLayoutTag; // 0 for default 98 + } output; 99 + 100 + //UInt32 bufferSize; // [UNIMPLEMENTED] 101 + }; 102 + 103 + CAAudioFileConverter(); 104 + 105 + virtual ~CAAudioFileConverter(); 106 + 107 + void ConvertFile(const ConversionParameters &params); 108 + virtual bool Progress(SInt64 packetsConverted, SInt64 packetsTotal) { return false; } 109 + virtual void GenerateOutputFileName(const char *inputFilePath, 110 + const CAStreamBasicDescription &inputFormat, 111 + const CAStreamBasicDescription &outputFormat, 112 + OSType outputFileType, char *outName); 113 + 114 + const char * GetOutputFileName() { return mOutName; } 115 + const CAAudioFile & InputFile() { return mSrcFile; } 116 + const CAAudioFile & OutputFile() { return mDestFile; } 117 + 118 + // customization 119 + virtual void PrepareConversion() { } 120 + virtual void OpenInputFile(); 121 + virtual void OpenOutputFile(const CAStreamBasicDescription &srcFormat, const CAStreamBasicDescription &destFormat, FSRef &destFSRef, CAAudioChannelLayout &destFileLayout); 122 + virtual void ComputeReadSize(const CAStreamBasicDescription &srcFormat, const CAStreamBasicDescription &destFormat, UInt32 &bytesToRead, UInt32 &framesToRead) { } 123 + virtual void BeginConversion() { } 124 + virtual void EndConversion() { } 125 + virtual bool ShouldTerminateConversion() { return false; } 126 + 127 + bool TaggedEncodingToCAF() const { 128 + return (mParams.flags & kOpt_CAFTag) && mDestFormat.mFormatID != kAudioFormatLinearPCM && mParams.output.fileType == kAudioFileCAFType; 129 + } 130 + bool TaggedDecodingFromCAF() const { 131 + return (mParams.flags & kOpt_CAFTag) && mSrcFormat.mFormatID != kAudioFormatLinearPCM; 132 + // don't know for sure that the source file is CAF... 133 + } 134 + 135 + void WriteCAFInfo(); 136 + void ReadCAFInfo(); 137 + 138 + protected: 139 + void PrintFormats(const CAAudioChannelLayout *origSrcFileLayout); 140 + 141 + ConversionParameters mParams; 142 + CAAudioFile mSrcFile; 143 + CAAudioFile mDestFile; 144 + CAStreamBasicDescription mSrcFormat; // valid after OpenInputFile 145 + CAStreamBasicDescription mDestFormat; // valid after OpenOutputFile 146 + 147 + private: 148 + CABufferList * mReadBuffer; 149 + CABufferList * mReadPtrs; 150 + 151 + protected: 152 + char mOutName[PATH_MAX]; 153 + }; 154 + 155 + #endif // __CAAudioFileConverter_h__
+165
src/CoreAudio/AudioFileTools/Utility/CAChannelLayouts.cpp
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + CAChannelLayouts.cpp 40 + 41 + =============================================================================*/ 42 + 43 + #include "CAChannelLayouts.h" 44 + #include <string.h> 45 + #include <stdio.h> 46 + 47 + struct LayoutTag { 48 + UInt32 constant; 49 + const char *name; 50 + }; 51 + 52 + #define TAG(x) { x, #x }, 53 + 54 + static LayoutTag gLayoutTags[] = { 55 + TAG(kAudioChannelLayoutTag_Mono) 56 + TAG(kAudioChannelLayoutTag_Stereo) 57 + TAG(kAudioChannelLayoutTag_StereoHeadphones) 58 + TAG(kAudioChannelLayoutTag_MatrixStereo) 59 + TAG(kAudioChannelLayoutTag_MidSide) 60 + TAG(kAudioChannelLayoutTag_XY) 61 + TAG(kAudioChannelLayoutTag_Binaural) 62 + TAG(kAudioChannelLayoutTag_Ambisonic_B_Format) 63 + TAG(kAudioChannelLayoutTag_Quadraphonic) 64 + TAG(kAudioChannelLayoutTag_Pentagonal) 65 + TAG(kAudioChannelLayoutTag_Hexagonal) 66 + TAG(kAudioChannelLayoutTag_Octagonal) 67 + TAG(kAudioChannelLayoutTag_Cube) 68 + TAG(kAudioChannelLayoutTag_MPEG_1_0) 69 + TAG(kAudioChannelLayoutTag_MPEG_2_0) 70 + TAG(kAudioChannelLayoutTag_MPEG_3_0_A) 71 + TAG(kAudioChannelLayoutTag_MPEG_3_0_B) 72 + TAG(kAudioChannelLayoutTag_MPEG_4_0_A) 73 + TAG(kAudioChannelLayoutTag_MPEG_4_0_B) 74 + TAG(kAudioChannelLayoutTag_MPEG_5_0_A) 75 + TAG(kAudioChannelLayoutTag_MPEG_5_0_B) 76 + TAG(kAudioChannelLayoutTag_MPEG_5_0_C) 77 + TAG(kAudioChannelLayoutTag_MPEG_5_0_D) 78 + TAG(kAudioChannelLayoutTag_MPEG_5_1_A) 79 + TAG(kAudioChannelLayoutTag_MPEG_5_1_B) 80 + TAG(kAudioChannelLayoutTag_MPEG_5_1_C) 81 + TAG(kAudioChannelLayoutTag_MPEG_5_1_D) 82 + TAG(kAudioChannelLayoutTag_MPEG_6_1_A) 83 + TAG(kAudioChannelLayoutTag_MPEG_7_1_A) 84 + TAG(kAudioChannelLayoutTag_MPEG_7_1_B) 85 + TAG(kAudioChannelLayoutTag_MPEG_7_1_C) 86 + TAG(kAudioChannelLayoutTag_Emagic_Default_7_1) 87 + TAG(kAudioChannelLayoutTag_SMPTE_DTV) 88 + TAG(kAudioChannelLayoutTag_ITU_1_0) 89 + TAG(kAudioChannelLayoutTag_ITU_2_0) 90 + TAG(kAudioChannelLayoutTag_ITU_2_1) 91 + TAG(kAudioChannelLayoutTag_ITU_2_2) 92 + TAG(kAudioChannelLayoutTag_ITU_3_0) 93 + TAG(kAudioChannelLayoutTag_ITU_3_1) 94 + TAG(kAudioChannelLayoutTag_ITU_3_2) 95 + TAG(kAudioChannelLayoutTag_ITU_3_2_1) 96 + TAG(kAudioChannelLayoutTag_ITU_3_4_1) 97 + TAG(kAudioChannelLayoutTag_DVD_0) 98 + TAG(kAudioChannelLayoutTag_DVD_1) 99 + TAG(kAudioChannelLayoutTag_DVD_2) 100 + TAG(kAudioChannelLayoutTag_DVD_3) 101 + TAG(kAudioChannelLayoutTag_DVD_4) 102 + TAG(kAudioChannelLayoutTag_DVD_5) 103 + TAG(kAudioChannelLayoutTag_DVD_6) 104 + TAG(kAudioChannelLayoutTag_DVD_7) 105 + TAG(kAudioChannelLayoutTag_DVD_8) 106 + TAG(kAudioChannelLayoutTag_DVD_9) 107 + TAG(kAudioChannelLayoutTag_DVD_10) 108 + TAG(kAudioChannelLayoutTag_DVD_11) 109 + TAG(kAudioChannelLayoutTag_DVD_12) 110 + TAG(kAudioChannelLayoutTag_DVD_13) 111 + TAG(kAudioChannelLayoutTag_DVD_14) 112 + TAG(kAudioChannelLayoutTag_DVD_15) 113 + TAG(kAudioChannelLayoutTag_DVD_16) 114 + TAG(kAudioChannelLayoutTag_DVD_17) 115 + TAG(kAudioChannelLayoutTag_DVD_18) 116 + TAG(kAudioChannelLayoutTag_DVD_19) 117 + TAG(kAudioChannelLayoutTag_DVD_20) 118 + TAG(kAudioChannelLayoutTag_AudioUnit_4) 119 + TAG(kAudioChannelLayoutTag_AudioUnit_5) 120 + TAG(kAudioChannelLayoutTag_AudioUnit_6) 121 + TAG(kAudioChannelLayoutTag_AudioUnit_8) 122 + TAG(kAudioChannelLayoutTag_AudioUnit_5_0) 123 + TAG(kAudioChannelLayoutTag_AudioUnit_6_0) 124 + TAG(kAudioChannelLayoutTag_AudioUnit_7_0) 125 + TAG(kAudioChannelLayoutTag_AudioUnit_5_1) 126 + TAG(kAudioChannelLayoutTag_AudioUnit_6_1) 127 + TAG(kAudioChannelLayoutTag_AudioUnit_7_1) 128 + TAG(kAudioChannelLayoutTag_AAC_Quadraphonic) 129 + TAG(kAudioChannelLayoutTag_AAC_4_0) 130 + TAG(kAudioChannelLayoutTag_AAC_5_0) 131 + TAG(kAudioChannelLayoutTag_AAC_5_1) 132 + TAG(kAudioChannelLayoutTag_AAC_6_0) 133 + TAG(kAudioChannelLayoutTag_AAC_6_1) 134 + TAG(kAudioChannelLayoutTag_AAC_7_0) 135 + TAG(kAudioChannelLayoutTag_AAC_7_1) 136 + TAG(kAudioChannelLayoutTag_AAC_Octagonal) 137 + 138 + TAG(kAudioChannelLayoutTag_TMH_10_2_std) 139 + TAG(kAudioChannelLayoutTag_TMH_10_2_full) 140 + { 0, NULL } // sentinel 141 + }; 142 + 143 + static const char *prefix = "kAudioChannelLayoutTag_"; 144 + 145 + UInt32 CAChannelLayouts::StringToConstant(const char *s) 146 + { 147 + int prefixlen = strlen(prefix); 148 + for (LayoutTag *t = gLayoutTags; t->name != NULL; ++t) { 149 + if (!strcmp(t->name, s) || !strcmp(t->name + prefixlen, s)) 150 + return t->constant; 151 + } 152 + return kInvalidTag; 153 + } 154 + 155 + const char * CAChannelLayouts::ConstantToString(UInt32 layoutTag) 156 + { 157 + static char buffer[256]; 158 + for (LayoutTag *t = gLayoutTags; t->name != NULL; ++t) { 159 + if (layoutTag == t->constant) 160 + return t->name + strlen(prefix); 161 + } 162 + sprintf(buffer, "unknown (0x%lx)", layoutTag); 163 + return buffer; 164 + } 165 +
+62
src/CoreAudio/AudioFileTools/Utility/CAChannelLayouts.h
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + CAChannelLayouts.h 40 + 41 + =============================================================================*/ 42 + 43 + #ifndef __CAChannelLayouts_h__ 44 + #define __CAChannelLayouts_h__ 45 + 46 + #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 47 + #include <CoreAudio/CoreAudioTypes.h> 48 + #else 49 + #include <CoreAudioTypes.h> 50 + #endif 51 + 52 + // convert between channel layout tag constant and its name 53 + class CAChannelLayouts { 54 + public: 55 + static const AudioChannelLayoutTag kInvalidTag = 0xFFFF0000; 56 + 57 + static AudioChannelLayoutTag StringToConstant(const char *s); 58 + static const char * ConstantToString(AudioChannelLayoutTag layoutTag); 59 + }; 60 + 61 + 62 + #endif // __CAChannelLayouts_h__
+174
src/CoreAudio/AudioFileTools/Utility/CAFilePathUtils.cpp
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + CAFilePathUtils.cpp 40 + 41 + =============================================================================*/ 42 + 43 + #include "CAFilePathUtils.h" 44 + #include <string.h> 45 + 46 + OSStatus PosixPathToParentFSRefAndName(const char *path, FSRef &outParentDir, CFStringRef &outFileName) 47 + { 48 + // convert C string to CFString 49 + #if !TARGET_OS_WIN32 50 + CFStringRef cfFullPath = CFStringCreateWithCString(NULL, path, kCFStringEncodingUTF8); 51 + #else 52 + CFStringRef cfFullPath = CFStringCreateWithCString(NULL, path, kCFStringEncodingWindowsLatin1); 53 + #endif 54 + // convert CF string to URL 55 + CFURLRef fullurl = CFURLCreateWithFileSystemPath(NULL, cfFullPath, TARGET_OS_WIN32 ? kCFURLWindowsPathStyle : kCFURLPOSIXPathStyle, false); 56 + CFRelease(cfFullPath); 57 + // get the directory portion of the URL 58 + CFURLRef dirurl = CFURLCreateCopyDeletingLastPathComponent(NULL, fullurl); 59 + // get the directory's FSSpec 60 + OSStatus err = CFURLGetFSRef(dirurl, &outParentDir) ? OSStatus(noErr) : OSStatus(fnfErr); 61 + CFRelease(dirurl); 62 + 63 + CFStringRef lastPathComponent = CFURLCopyLastPathComponent(fullurl); 64 + CFRelease(fullurl); 65 + CFMutableStringRef filename = CFStringCreateMutableCopy(NULL, 0, lastPathComponent); 66 + CFRelease(lastPathComponent); 67 + // convert colons (legal in POSIX paths, illegal in File Manager) to slashes 68 + CFStringFindAndReplace(filename, CFSTR(":"), CFSTR("/"), CFRangeMake(0, CFStringGetLength(filename)), 0); 69 + 70 + outFileName = filename; 71 + 72 + return err; 73 + } 74 + 75 + 76 + #if TARGET_OS_WIN32 77 + 78 + char* dirname(const char* inPath) 79 + { 80 + static char sAnswer[1024]; 81 + 82 + char* theAnswer = NULL; 83 + SInt32 thePathLength = strlen(inPath); 84 + if(thePathLength < 1023) 85 + { 86 + // make a working copy 87 + strcpy(sAnswer, inPath); 88 + 89 + // start at the end of the string 90 + SInt32 theIndex = thePathLength - 1; 91 + 92 + // walk back over the '\' characters 93 + while((theIndex > 0) && (sAnswer[theIndex] == '\\')) 94 + { 95 + --theIndex; 96 + } 97 + 98 + // now keep walking back until we get to a '\' 99 + while((theIndex > 0) && (sAnswer[theIndex] != '\\')) 100 + { 101 + --theIndex; 102 + } 103 + 104 + // where we are now is either the first character of the path or the '\' that marks the end of the directory name 105 + if(theIndex > 0) 106 + { 107 + // we have a name so put a '\0' in place of the '\' 108 + sAnswer[theIndex] = 0; 109 + } 110 + else 111 + { 112 + // no name, so the answer is "." 113 + sAnswer[0] = '.'; 114 + sAnswer[1] = 0; 115 + } 116 + 117 + // set the return value 118 + theAnswer = sAnswer; 119 + } 120 + 121 + return theAnswer; 122 + } 123 + 124 + char* basename(const char* inPath) 125 + { 126 + static char sAnswer[1024]; 127 + 128 + char* theAnswer = NULL; 129 + SInt32 thePathLength = strlen(inPath); 130 + if(thePathLength < 1023) 131 + { 132 + // make a working copy 133 + strcpy(sAnswer, inPath); 134 + 135 + // start at the end of the string 136 + SInt32 theLastIndex = thePathLength - 1; 137 + 138 + // walk back over the '\' characters 139 + while((theLastIndex > 0) && (sAnswer[theLastIndex] == '\\')) 140 + { 141 + --theLastIndex; 142 + } 143 + 144 + // check to see if we're at the beginning now 145 + if(theLastIndex > 0) 146 + { 147 + // there's a name in there now, so start where we are and go back to the next '\' 148 + UInt32 theFirstIndex = theLastIndex; 149 + while((theFirstIndex > 0) && (sAnswer[theFirstIndex] != '\\')) 150 + { 151 + --theFirstIndex; 152 + } 153 + 154 + // we now have a string, so put a '\0' after the last character 155 + sAnswer[theLastIndex + 1] = 0; 156 + 157 + // and set the return value 158 + theAnswer = &sAnswer[theFirstIndex]; 159 + } 160 + else 161 + { 162 + // the path was entirely '\' characters, so the return value is "\" 163 + sAnswer[0] = '\\'; 164 + sAnswer[1] = 0; 165 + 166 + // set the return value 167 + theAnswer = sAnswer; 168 + } 169 + } 170 + 171 + return theAnswer; 172 + } 173 + 174 + #endif
+63
src/CoreAudio/AudioFileTools/Utility/CAFilePathUtils.h
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + CAFilePathUtils.h 40 + 41 + =============================================================================*/ 42 + 43 + #ifndef __CAFilePathUtils_h__ 44 + #define __CAFilePathUtils_h__ 45 + 46 + #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 47 + #include <CoreServices/CoreServices.h> 48 + #include <CoreFoundation/CoreFoundation.h> 49 + #else 50 + #include <TargetConditionals.h> 51 + #include <CoreServices.h> 52 + #include <CoreFoundation.h> 53 + #endif 54 + 55 + OSStatus PosixPathToParentFSRefAndName(const char *path, FSRef &outParentDir, CFStringRef &outFileName); 56 + #if !TARGET_OS_WIN32 57 + #include <libgen.h> 58 + #else 59 + char* dirname(const char* inPath); 60 + char* basename(const char* inPath); 61 + #endif 62 + 63 + #endif // __CAFilePathUtils_h__
+363
src/CoreAudio/AudioFileTools/Utility/QTAACFile.cpp
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + QTAACFile.cpp 40 + 41 + =============================================================================*/ 42 + 43 + #include "QTAACFile.h" 44 + #include "CAXException.h" 45 + #include "CAStreamBasicDescription.h" 46 + 47 + 48 + // _______________________________________________________________________________________ 49 + // 50 + QTAACFile::QTAACFile() : 51 + mMovieResFile(-1), 52 + mMovie(NULL), 53 + mPacketHandle(NULL), 54 + mMagicCookie(NULL), 55 + mConverter(NULL), 56 + mFileMaxPacketSize(0) 57 + { 58 + } 59 + 60 + // _______________________________________________________________________________________ 61 + // 62 + QTAACFile::~QTAACFile() 63 + { 64 + Close(); 65 + CloseConverter(); 66 + if (mPacketHandle) 67 + DisposeHandle(mPacketHandle); 68 + } 69 + 70 + // _______________________________________________________________________________________ 71 + // 72 + void QTAACFile::Close() 73 + { 74 + if (mMovieResFile != -1) { 75 + CloseMovieFile(mMovieResFile); 76 + mMovieResFile = -1; 77 + } 78 + if (mMovie) { 79 + DisposeMovie(mMovie); 80 + mMovie = NULL; 81 + } 82 + if (mMagicCookie) { 83 + free(mMagicCookie); 84 + mMagicCookie = NULL; 85 + } 86 + } 87 + 88 + // _______________________________________________________________________________________ 89 + // 90 + void QTAACFile::CloseConverter() 91 + { 92 + if (mConverter) { 93 + AudioConverterDispose(mConverter); 94 + mConverter = NULL; 95 + } 96 + } 97 + 98 + // _______________________________________________________________________________________ 99 + /* 100 + GetMP4DecoderConfig 101 + 102 + NOTE: This is designed to work only for a very specific case -- an MPEG-4/QuickTime movie 103 + containing AAC-encoded audio. It is adapted from the "SoundPlayer"QuickTime sample code, 104 + but with much generality removed. 105 + 106 + If the audio is not MPEG-4, then we'll fail immediately with an exception. 107 + 108 + If the audio is MPEG-4, but not AAC-encoded, then we will fail somewhere beyond this function, when passing the magic cookie (ESDS) to the AudioConverter. 109 + */ 110 + static void GetMP4DecoderConfig(Media inMedia, AudioStreamBasicDescription &outStreamFormat, char **outEsds, UInt32 *outEsdsSize) 111 + { 112 + OSStatus err = noErr; 113 + Size size; 114 + Handle extension = NULL; 115 + SoundDescriptionHandle hSoundDescription = (SoundDescriptionHandle)NewHandle(0); 116 + struct MyMP4AudioAtom { 117 + UInt32 size; 118 + OSType atomType; 119 + UInt32 version; 120 + }; 121 + 122 + try { 123 + // get the description of the sample data 124 + GetMediaSampleDescription(inMedia, 1, (SampleDescriptionHandle)hSoundDescription); 125 + XThrowIfError(GetMoviesError(), "couldn't get media sample description"); 126 + 127 + // other formats: exercise for the reader! 128 + OSType fmt = (*hSoundDescription)->dataFormat; 129 + XThrowIf(fmt != 'mp4a', -1, "can only decode MPEG-4/AAC"); 130 + 131 + extension = NewHandle(0); 132 + 133 + // get the "magic" decompression atom 134 + // This extension to the SoundDescription information stores data specific to a given audio decompressor. 135 + // Some audio decompression algorithms require a set of out-of-stream values to configure the decompressor 136 + // which are stored in a siDecompressionParams atom. The contents of the siDecompressionParams atom are dependent 137 + // on the audio decompressor. 138 + 139 + err = GetSoundDescriptionExtension(hSoundDescription, &extension, siDecompressionParams); 140 + 141 + // if it doesn't have an atom, that's ok for some formats, but not for AAC 142 + XThrowIfError(err, "couldn't get sound description extension"); 143 + 144 + size = GetHandleSize(extension); 145 + HLock(extension); 146 + UserDataAtom *atom = (UserDataAtom *)*extension; 147 + bool moreAtoms = true; 148 + do { 149 + long atomSize = EndianS32_BtoN(atom->size); 150 + 151 + XThrowIf(atomSize < 8, -1, "invalid sound description atom"); 152 + switch (EndianU32_BtoN(atom->atomType)) { 153 + case 'esds': 154 + *outEsdsSize = atomSize - sizeof(MyMP4AudioAtom); 155 + *outEsds = (char *)malloc(*outEsdsSize); 156 + memcpy(*outEsds, (char *)atom + sizeof(MyMP4AudioAtom), *outEsdsSize); 157 + break; 158 + case kAudioTerminatorAtomType: 159 + moreAtoms = false; 160 + break; 161 + } 162 + atom = (UserDataAtom *)((char *)atom + atomSize); 163 + } while (moreAtoms); 164 + 165 + HUnlock(extension); 166 + 167 + // set up our stream description 168 + memset(&outStreamFormat, 0, sizeof(AudioStreamBasicDescription)); 169 + outStreamFormat.mFormatID = kAudioFormatMPEG4AAC; 170 + } 171 + catch (...) { 172 + if (extension) DisposeHandle(extension); 173 + if (hSoundDescription) DisposeHandle((Handle)hSoundDescription); 174 + throw; 175 + } 176 + if (extension) DisposeHandle(extension); 177 + if (hSoundDescription) DisposeHandle((Handle)hSoundDescription); 178 + } 179 + 180 + // _______________________________________________________________________________________ 181 + // 182 + void QTAACFile::Open(const char *filename) 183 + { 184 + FSRef theFSRef; 185 + Track theAudioTrack; 186 + FSSpec theFSSpec; 187 + 188 + // convert from POSIX full path to FSSpec 189 + XThrowIfError(FSPathMakeRef((UInt8 *)filename, &theFSRef, NULL), "locate file"); 190 + XThrowIfError(FSGetCatalogInfo(&theFSRef, 0, NULL, NULL, &theFSSpec, NULL), "get FSSpec"); 191 + 192 + // make a QuickTime movie (will open MP4 transparently) 193 + XThrowIfError(OpenMovieFile(&theFSSpec, &mMovieResFile, fsRdPerm), "OpenMovieFile failed"); 194 + SInt16 nResID = 0; 195 + Str255 strName; 196 + Boolean bWasChanged; 197 + XThrowIfError(NewMovieFromFile(&mMovie, mMovieResFile, &nResID, strName, newMovieActive, &bWasChanged), "NewMovieFromFile failed"); 198 + 199 + // NOTE: we're assuming the data we want is in the movie's first enabled audio track 200 + theAudioTrack = GetMovieIndTrackType(mMovie, 1, SoundMediaType, movieTrackMediaType | movieTrackEnabledOnly); 201 + XThrowIf(theAudioTrack == NULL, -1, "movie contains no audio track"); 202 + 203 + // find the track's media, and interrogate it for the audio format and magic cookie (decoder config) 204 + mMedia = GetTrackMedia(theAudioTrack); 205 + XThrowIf(mMedia == NULL, -1, "track contains no media"); 206 + GetMP4DecoderConfig(mMedia, mFileDataFormat, &mMagicCookie, &mMagicCookieSize); 207 + 208 + // Fill out the remaining fields of the ASBD by evaluating the magic cookie 209 + UInt32 size = sizeof(mFileDataFormat); 210 + XThrowIfError(AudioFormatGetProperty(kAudioFormatProperty_ASBDFromESDS, mMagicCookieSize, mMagicCookie, &size, &mFileDataFormat), 211 + "couldn't get ASBD from the Magic Cookie"); 212 + 213 + // build a vector of times at which packets begin 214 + // so later we can randomly access the file by packet number 215 + TimeValue currentTime = 0; 216 + static const Fixed oneFixed = 0x10000; 217 + while (true) { 218 + TimeValue interestingTime, interestingDuration; 219 + GetMediaNextInterestingTime(mMedia, nextTimeMediaSample | nextTimeEdgeOK, currentTime, oneFixed, &interestingTime, &interestingDuration); 220 + if (interestingTime < 0) 221 + break; 222 + mPacketTimes.push_back(interestingTime); 223 + currentTime = interestingTime + 1; 224 + } 225 + mNumberPackets = mPacketTimes.size(); 226 + mPacketMark = 0; 227 + mPacketHandle = NewHandle(1024); // memory into which packets will be read 228 + } 229 + 230 + // _______________________________________________________________________________________ 231 + // 232 + void QTAACFile::SetClientFormat(const CAStreamBasicDescription &dataFormat) 233 + { 234 + CloseConverter(); 235 + 236 + XThrowIf(!dataFormat.IsPCM(), -1, "non-PCM client format on audio file"); 237 + mClientDataFormat = dataFormat; 238 + 239 + if (mClientDataFormat != mFileDataFormat) { 240 + // We need an AudioConverter. 241 + // file -> client 242 + XThrowIfError(AudioConverterNew(&mFileDataFormat, &mClientDataFormat, &mConverter), 243 + "create audio converter"); 244 + 245 + // set the magic cookie, if any (for decode) 246 + if (mMagicCookie) 247 + SetConverterProperty(kAudioConverterDecompressionMagicCookie, 248 + mMagicCookieSize, mMagicCookie, true); 249 + } 250 + UpdateClientMaxPacketSize(); 251 + } 252 + 253 + // _______________________________________________________________________________________ 254 + // 255 + OSStatus QTAACFile::SetConverterProperty(AudioConverterPropertyID inPropertyID, 256 + UInt32 inPropertyDataSize, 257 + const void* inPropertyData, 258 + bool inCanFail) 259 + { 260 + OSStatus err = AudioConverterSetProperty(mConverter, inPropertyID, inPropertyDataSize, inPropertyData); 261 + if (!inCanFail) { 262 + XThrowIfError(err, "set audio converter property"); 263 + } 264 + UpdateClientMaxPacketSize(); 265 + return err; 266 + } 267 + 268 + // _______________________________________________________________________________________ 269 + // 270 + void QTAACFile::UpdateClientMaxPacketSize() 271 + { 272 + if (mConverter != NULL) { 273 + AudioConverterPropertyID property = 274 + kAudioConverterPropertyMaximumOutputPacketSize; 275 + 276 + UInt32 propertySize = sizeof(UInt32); 277 + XThrowIfError(AudioConverterGetProperty(mConverter, property, &propertySize, &mClientMaxPacketSize), 278 + "get audio converter's maximum packet size"); 279 + } else 280 + mClientMaxPacketSize = mFileMaxPacketSize; 281 + XThrowIf(mClientMaxPacketSize == 0, -1, "client maximum packet size is 0"); 282 + } 283 + 284 + // _______________________________________________________________________________________ 285 + // 286 + // This function reads the next packet from the movie. It always reads only 1 packet, 287 + // regardless of how many were asked for -- whether it's called either as a callback from 288 + // AudioConverterFillComplexBuffer, or directly from ReadPackets (below), the caller 289 + // will just call again if it wants more. 290 + OSStatus QTAACFile::ReadInputProc( AudioConverterRef inAudioConverter, 291 + UInt32* ioNumberDataPackets, 292 + AudioBufferList* ioData, 293 + AudioStreamPacketDescription** outDataPacketDescription, 294 + void* inUserData) 295 + { 296 + QTAACFile *This = static_cast<QTAACFile *>(inUserData); 297 + 298 + UInt32 remainingPacketsInFile = This->mNumberPackets - This->mPacketMark; 299 + if (remainingPacketsInFile == 0) { 300 + // end of file 301 + *ioNumberDataPackets = 0; 302 + ioData->mBuffers[0].mDataByteSize = 0; 303 + return noErr; // EOF is signified by 0 packets/0 bytes/noErr 304 + } 305 + 306 + UInt32 ioPackets = 1; 307 + 308 + // don't try to read past EOF 309 + if (ioPackets > remainingPacketsInFile) 310 + ioPackets = remainingPacketsInFile; 311 + 312 + long bytesRead; 313 + OSStatus err; 314 + 315 + HUnlock(This->mPacketHandle); 316 + err = GetMediaSample(This->mMedia, // specifies the media for this operation 317 + This->mPacketHandle, // function returns the sample data into this handle 318 + 0, // maximum number of bytes of sample data to be returned 319 + &bytesRead, // the number of bytes of sample data returned 320 + This->mPacketTimes[This->mPacketMark], 321 + // starting time of the sample to be retrieved (must be in Media's TimeScale) 322 + NULL, // indicates the actual time of the returned sample data 323 + NULL, // duration of each sample in the media 324 + NULL, // sample description corresponding to the returned sample data (NULL to ignore) 325 + NULL, // index value to the sample description that corresponds to the returned sample data (NULL to ignore) 326 + 0, // maximum number of samples to be returned (0 to use a value that is appropriate for the media) 327 + NULL, // number of samples it actually returned 328 + NULL); // flags that describe the sample (NULL to ignore) 329 + 330 + if (err) 331 + return err; 332 + 333 + if (outDataPacketDescription) { 334 + This->mPacketDescription.mStartOffset = 0; 335 + This->mPacketDescription.mVariableFramesInPacket = 0; 336 + This->mPacketDescription.mDataByteSize = bytesRead; 337 + *outDataPacketDescription = &This->mPacketDescription; 338 + } 339 + 340 + HLock(This->mPacketHandle); 341 + ioData->mBuffers[0].mDataByteSize = bytesRead; 342 + ioData->mBuffers[0].mData = *This->mPacketHandle; 343 + This->mPacketMark += ioPackets; 344 + *ioNumberDataPackets = ioPackets; 345 + return noErr; 346 + } 347 + 348 + // _______________________________________________________________________________________ 349 + // 350 + void QTAACFile::ReadPackets(UInt32 &ioNumPackets, AudioBufferList *ioData) 351 + { 352 + // older versions of AudioConverterFillComplexBuffer don't do this, so do our own sanity check 353 + UInt32 maxNumPackets = ioData->mBuffers[0].mDataByteSize / mClientMaxPacketSize; 354 + if (ioNumPackets > maxNumPackets) 355 + ioNumPackets = maxNumPackets; 356 + 357 + if (mConverter == NULL) 358 + XThrowIfError(ReadInputProc(NULL, &ioNumPackets, ioData, NULL, this), "read audio file"); 359 + else { 360 + XThrowIfError(AudioConverterFillComplexBuffer(mConverter, ReadInputProc, this, &ioNumPackets, ioData, NULL), 361 + "qt convert audio packets"); 362 + } 363 + }
+109
src/CoreAudio/AudioFileTools/Utility/QTAACFile.h
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + QTAACFile.h 40 + 41 + =============================================================================*/ 42 + 43 + #ifndef __QTAACFile_h__ 44 + #define __QTAACFile_h__ 45 + 46 + #include <QuickTime/QuickTime.h> 47 + #include <AudioToolbox/AudioConverter.h> 48 + #include <AudioToolbox/AudioFormat.h> 49 + #include <vector> 50 + #include "CAStreamBasicDescription.h" 51 + #include "CAAudioChannelLayout.h" 52 + 53 + /* 54 + This class is a stripped-down analogue to CAAudioFile, designed solely for reading AAC audio 55 + tracks from QuickTime/MP4 files. 56 + 57 + Throws CAXException's on errors. 58 + */ 59 + class QTAACFile { 60 + public: 61 + QTAACFile(); 62 + ~QTAACFile(); 63 + 64 + void Open(const char *filePath); 65 + void Close(); 66 + 67 + void SetClientFormat(const CAStreamBasicDescription &dataFormat); 68 + // set the PCM format to which the movie's audio will be decoded 69 + 70 + OSStatus SetConverterProperty( AudioConverterPropertyID inPropertyID, 71 + UInt32 inPropertyDataSize, 72 + const void* inPropertyData, 73 + bool inCanFail); 74 + 75 + void ReadPackets(UInt32 &ioNumPackets, AudioBufferList *ioData); 76 + // read packets from the audio file in the client format 77 + 78 + private: 79 + void CloseConverter(); 80 + void UpdateClientMaxPacketSize(); 81 + 82 + static OSStatus ReadInputProc( AudioConverterRef inAudioConverter, 83 + UInt32* ioNumberDataPackets, 84 + AudioBufferList* ioData, 85 + AudioStreamPacketDescription** outDataPacketDescription, 86 + void* inUserData); 87 + 88 + private: 89 + typedef std::vector<TimeValue> TimeValueList; 90 + 91 + SInt16 mMovieResFile; 92 + Movie mMovie; 93 + Media mMedia; 94 + Handle mPacketHandle; 95 + UInt32 mMagicCookieSize; 96 + char * mMagicCookie; 97 + TimeValueList mPacketTimes; 98 + UInt32 mNumberPackets; // in file's format 99 + UInt32 mPacketMark; // location in file, in file's format 100 + 101 + CAStreamBasicDescription mFileDataFormat; 102 + CAStreamBasicDescription mClientDataFormat; 103 + AudioConverterRef mConverter; 104 + UInt32 mFileMaxPacketSize; 105 + UInt32 mClientMaxPacketSize; 106 + AudioStreamPacketDescription mPacketDescription; 107 + }; 108 + 109 + #endif // __QTAACFile_h__
+251
src/CoreAudio/AudioFileTools/afconvert.cpp
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + afconvert.cpp 40 + 41 + =============================================================================*/ 42 + 43 + /* 44 + afconvert 45 + 46 + command-line tool to convert an audio file to another format 47 + */ 48 + 49 + #include "afconvert.h" 50 + #include <stdio.h> 51 + #include <vector> 52 + #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 53 + #include <CoreServices/CoreServices.h> 54 + #include <AudioToolbox/AudioToolbox.h> 55 + #else 56 + #include <CoreServices.h> 57 + #include <AudioToolbox.h> 58 + #endif 59 + #include "CAChannelLayouts.h" 60 + 61 + #include "CAAudioFileConverter.h" 62 + #include "CAXException.h" 63 + #include "CAAudioFileFormats.h" 64 + #include "AFToolsCommon.h" 65 + #if !TARGET_OS_MAC 66 + #include <QTML.h> 67 + #include "CAWindows.h" 68 + #endif 69 + 70 + 71 + void AFConvertTool::usage() 72 + { 73 + fprintf(stderr, 74 + "Usage:\n" 75 + "%s [option...] input_file [output_file]\n\n" 76 + "Options: (may appear before or after arguments)\n" 77 + " { -f | --file } file_format:\n", 78 + #if !TARGET_OS_WIN32 79 + getprogname()); 80 + #else 81 + "afconvert"); 82 + #endif 83 + PrintAudioFileTypesAndFormats(stderr); 84 + fprintf(stderr, 85 + " { -d | --data } data_format[@sample_rate_hz][/format_flags][#frames_per_packet] :\n" 86 + " [-][BE|LE]{F|[U]I}{8|16|24|32|64} (PCM)\n" 87 + " e.g. BEI16 F32@44100\n" 88 + " or a data format appropriate to file format, as above\n" 89 + " format_flags: hex digits, e.g. '80'\n" 90 + " bitdepth on non-PCM formats can be specified, e.g.: alac-24\n" 91 + " Frames per packet can be specified for some encoders, e.g.: samr#12\n" 92 + " { -c | --channels } number_of_channels\n" 93 + " add/remove channels without regard to order\n" 94 + " { -l | --channellayout } layout_tag\n" 95 + " layout_tag: name of a constant from CoreAudioTypes.h\n" 96 + " (prefix \"kAudioChannelLayoutTag_\" may be omitted)\n" 97 + " if specified once, applies to output file; if twice, the first\n" 98 + " applies to the input file, the second to the output file\n" 99 + " { -b | --bitrate } bit_rate_bps\n" 100 + " e.g. 128000\n" 101 + " { -q | --quality } codec_quality\n" 102 + " codec_quality: 0-127\n" 103 + " { -r | --src-quality } src_quality\n" 104 + " src_quality (sample rate converter quality): 0-127\n" 105 + " { -v | --verbose }\n" 106 + " print progress verbosely\n" 107 + " { -s | --strategy } strategy\n" 108 + " bitrate strategy for encoded file\n" 109 + " 0 for CBR, 1 for ABR, 2 for VBR\n" 110 + " { -t | --tag }\n" 111 + " If encoding to CAF, store the source file's format and name in a user chunk.\n" 112 + " If decoding from CAF, use the destination format and filename found in a user chunk.\n" 113 + " --prime-method method\n" 114 + " decode priming method (see AudioConverter.h)\n" 115 + ); 116 + ExtraUsageOptions(); 117 + exit(1); 118 + } 119 + 120 + void Warning(const char *s, OSStatus error) 121 + { 122 + char buf[256]; 123 + fprintf(stderr, "*** warning: %s (%s)\n", s, CAXException::FormatError(buf, sizeof(buf), error)); 124 + } 125 + 126 + OSType AFConvertTool::Parse4CharCode(const char *arg, const char *name) 127 + { 128 + OSType t; 129 + StrToOSType(arg, t); 130 + if (t == 0) { 131 + fprintf(stderr, "invalid 4-char-code argument for %s: '%s'\n\n", name, arg); 132 + usage(); 133 + } 134 + return t; 135 + } 136 + 137 + 138 + int AFConvertTool::main(int argc, const char * argv[]) 139 + { 140 + Init(); 141 + 142 + CAAudioFileConverter::ConversionParameters &params = *mParams; 143 + bool gotOutDataFormat = false; 144 + 145 + CAXException::SetWarningHandler(Warning); 146 + 147 + if (argc < 2) 148 + usage(); 149 + 150 + params.flags = CAAudioFileConverter::kOpt_OverwriteOutputFile; 151 + 152 + for (int i = 1; i < argc; ++i) { 153 + const char *arg = argv[i]; 154 + if (arg[0] != '-') { 155 + if (params.input.filePath == NULL) params.input.filePath = arg; 156 + else if (params.output.filePath == NULL) params.output.filePath = arg; 157 + else usage(); 158 + } else { 159 + arg += 1; 160 + if (arg[0] == 'f' || !strcmp(arg, "-file")) { 161 + if (++i == argc) MissingArgument(); 162 + params.output.fileType = Parse4CharCode(argv[i], "-f | --file"); 163 + } else if (arg[0] == 'd' || !strcmp(arg, "-data")) { 164 + if (++i == argc) MissingArgument(); 165 + if (!ParseStreamDescription(argv[i], params.output.dataFormat)) 166 + usage(); 167 + gotOutDataFormat = true; 168 + } else if (arg[0] == 'b' || !strcmp(arg, "-bitrate")) { 169 + if (++i == argc) MissingArgument(); 170 + params.output.bitRate = ParseInt(argv[i], "-b | --bitrate"); 171 + } else if (arg[0] == 'q' || !strcmp(arg, "-quality")) { 172 + if (++i == argc) MissingArgument(); 173 + params.output.codecQuality = ParseInt(argv[i], "-q | --quality"); 174 + } else if (arg[0] == 'r' || !strcmp(arg, "-src-quality")) { 175 + if (++i == argc) MissingArgument(); 176 + params.output.srcQuality = ParseInt(argv[i], "-r | --src-quality"); 177 + } else if (arg[0] == 'l' || !strcmp(arg, "-channellayout")) { 178 + if (++i == argc) MissingArgument(); 179 + UInt32 tag = CAChannelLayouts::StringToConstant(argv[i]); 180 + if (tag == CAChannelLayouts::kInvalidTag) { 181 + fprintf(stderr, "unknown channel layout tag: %s\n\n", argv[i]); 182 + usage(); 183 + } 184 + if (params.output.channelLayoutTag == 0) 185 + params.output.channelLayoutTag = tag; 186 + else if (params.input.channelLayoutTag == 0) { 187 + params.input.channelLayoutTag = params.output.channelLayoutTag; 188 + params.output.channelLayoutTag = tag; 189 + } else { 190 + fprintf(stderr, "too many channel layout tags!\n\n"); 191 + usage(); 192 + } 193 + } else if (arg[0] == 'c' || !strcmp(arg, "-channels")) { 194 + if (++i == argc) MissingArgument(); 195 + params.output.channels = ParseInt(argv[i], "-c | --channels"); 196 + } else if (arg[0] == 'v' || !strcmp(arg, "-verbose")) { 197 + params.flags |= CAAudioFileConverter::kOpt_Verbose; 198 + } else if (arg[0] == 's' || !strcmp(arg, "-strategy")) { 199 + if (++i == argc) MissingArgument(); 200 + params.output.strategy = ParseInt(argv[i], "-s | --strategy"); 201 + } else if (arg[0] == 't' || !strcmp(arg, "-tag")) { 202 + params.flags |= CAAudioFileConverter::kOpt_CAFTag; 203 + } else if (!strcmp(arg, "-prime-method")) { 204 + if (++i == argc) MissingArgument(); 205 + params.output.primeMethod = ParseInt(argv[i], "-p | --prime-method"); 206 + } else if (!ParseOtherOption(argv, i)) { 207 + fprintf(stderr, "unknown argument: %s\n\n", arg - 1); 208 + usage(); 209 + } 210 + } 211 + } 212 + if (params.input.filePath == NULL) { 213 + fprintf(stderr, "no input file specified\n\n"); 214 + usage(); 215 + } 216 + 217 + if (!(params.flags & CAAudioFileConverter::kOpt_CAFTag)) { 218 + if (!gotOutDataFormat) { 219 + if (params.output.fileType == 0) { 220 + fprintf(stderr, "no output file or data format specified\n\n"); 221 + usage(); 222 + } 223 + if (!CAAudioFileFormats::Instance()->InferDataFormatFromFileFormat(params.output.fileType, params.output.dataFormat)) { 224 + fprintf(stderr, "Couldn't infer data format from file format\n\n"); 225 + usage(); 226 + } 227 + } else if (params.output.fileType == 0) { 228 + CAAudioFileFormats *formats = CAAudioFileFormats::Instance(); 229 + if (!formats->InferFileFormatFromFilename(params.output.filePath, params.output.fileType) && !formats->InferFileFormatFromDataFormat(params.output.dataFormat, params.output.fileType)) { 230 + params.output.dataFormat.PrintFormat(stderr, "", "Couldn't infer file format from data format"); 231 + usage(); 232 + } 233 + } 234 + } 235 + 236 + try { 237 + mAFConverter->ConvertFile(params); 238 + Success(); 239 + } 240 + catch (CAXException &e) { 241 + char buf[256]; 242 + fprintf(stderr, "Error: %s (%s)\n", e.mOperation, e.FormatError(buf, sizeof(buf))); 243 + return 1; 244 + } 245 + catch (...) { 246 + fprintf(stderr, "An unknown error occurred\n"); 247 + return 1; 248 + } 249 + 250 + return 0; 251 + }
+94
src/CoreAudio/AudioFileTools/afconvert.h
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + afconvert.h 40 + 41 + =============================================================================*/ 42 + 43 + #ifndef __afconvert_h__ 44 + #define __afconvert_h__ 45 + 46 + #include "CAAudioFileConverter.h" 47 + 48 + class AFConvertTool { 49 + public: 50 + AFConvertTool() : 51 + mAFConverter(NULL), 52 + mParams(NULL) 53 + { } 54 + 55 + virtual ~AFConvertTool() { 56 + delete mAFConverter; 57 + delete mParams; 58 + } 59 + 60 + 61 + int main(int argc, const char *argv[]); 62 + virtual void Init() { // called on entry to main 63 + mParams = new CAAudioFileConverter::ConversionParameters; 64 + mAFConverter = new CAAudioFileConverter; 65 + } 66 + 67 + virtual bool ParseOtherOption(const char *argv[], int &argIndex) { return false; } 68 + virtual void Success() { } // called after successful conversion 69 + 70 + void usage(); 71 + virtual void ExtraUsageOptions() { } 72 + void MissingArgument() { 73 + fprintf(stderr, "missing argument\n\n"); 74 + usage(); 75 + } 76 + OSType Parse4CharCode(const char *arg, const char *name); 77 + 78 + int ParseInt(const char *arg, const char *name) 79 + { 80 + int x; 81 + if (sscanf(arg, "%d", &x) != 1) { 82 + fprintf(stderr, "invalid integer argument for %s: '%s'\n\n", name, arg); 83 + usage(); 84 + } 85 + return x; 86 + } 87 + 88 + 89 + 90 + CAAudioFileConverter * mAFConverter; 91 + CAAudioFileConverter::ConversionParameters *mParams; 92 + }; 93 + 94 + #endif // __afconvert_h__
+56
src/CoreAudio/AudioFileTools/afconvert_main.cpp
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + afconvert_main.cpp 40 + 41 + =============================================================================*/ 42 + 43 + #include "afconvert.h" 44 + #if !TARGET_OS_MAC 45 + #include <QTML.h> 46 + #endif 47 + 48 + int main(int argc, const char * argv[]) 49 + { 50 + AFConvertTool t; 51 + 52 + int theAnswer = t.main(argc, argv); 53 + 54 + return theAnswer; 55 + } 56 +
+217
src/CoreAudio/AudioFileTools/afinfo.cpp
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + afinfo.cpp 40 + 41 + =============================================================================*/ 42 + 43 + #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 44 + #include <AudioToolbox/AudioToolbox.h> 45 + #else 46 + #include <AudioToolbox.h> 47 + #endif 48 + 49 + #if TARGET_OS_WIN32 50 + #include <QTML.h> 51 + #endif 52 + 53 + #include <stdio.h> 54 + #include "CAStreamBasicDescription.h" 55 + #include <stdlib.h> 56 + #include <CoreServices/Endian.h> 57 + 58 + //using namespace std; 59 + 60 + int main (int argc, const char * argv[]) 61 + { 62 + #if TARGET_OS_WIN32 63 + InitializeQTML(0L); 64 + #endif 65 + int enc = kCFStringEncodingUTF8; 66 + 67 + for (int i=1; i<argc; ++i) 68 + { 69 + OSStatus err; 70 + CAStreamBasicDescription asbd; 71 + AudioChannelLayout *acl = 0; 72 + UInt32 propertySize; 73 + UInt32 specifierSize; 74 + AudioFileID afid; 75 + Boolean res; 76 + FSRef fsRef; 77 + AudioFileTypeID filetype; 78 + CFStringRef filename = CFStringCreateWithCString(NULL, argv[i], enc); 79 + if (!filename) continue; 80 + 81 + CFURLRef url = CFURLCreateWithFileSystemPath(NULL, filename, kCFURLPOSIXPathStyle, true); 82 + if (!url) { 83 + fprintf(stderr, "Can't create CFURL for '%s'\n", argv[i]); 84 + goto Bail3; 85 + } 86 + 87 + res = CFURLGetFSRef(url, &fsRef); 88 + if (!res) { 89 + fprintf(stderr, "Can't get FSRef for '%s'\n", argv[i]); 90 + goto Bail2; 91 + } 92 + 93 + err = AudioFileOpen(&fsRef, fsRdPerm, 0, &afid); 94 + if (err) { 95 + fprintf(stderr, "AudioFileOpen failed for '%s'\n", argv[i]); 96 + goto Bail2; 97 + } 98 + 99 + propertySize = sizeof(AudioFileTypeID); 100 + err = AudioFileGetProperty(afid, kAudioFilePropertyFileFormat, &propertySize, &filetype); 101 + if (err) { 102 + fprintf(stderr, "AudioFileGetProperty kAudioFilePropertyFileFormat failed for '%s'\n", argv[i]); 103 + goto Bail1; 104 + } 105 + filetype = EndianU32_NtoB(filetype); // for display purposes 106 + 107 + propertySize = sizeof(asbd); 108 + err = AudioFileGetProperty(afid, kAudioFilePropertyDataFormat, &propertySize, &asbd); 109 + if (err) { 110 + fprintf(stderr, "AudioFileGetProperty kAudioFilePropertyDataFormat failed for '%s'\n", argv[i]); 111 + goto Bail1; 112 + } 113 + 114 + printf("File: %s\n", argv[i]); 115 + printf("File type ID: %-4.4s\n", (char *)&filetype); 116 + asbd.PrintFormat(stdout, "", "Data format: "); 117 + 118 + UInt32 writable; 119 + err = AudioFileGetPropertyInfo(afid, kAudioFilePropertyChannelLayout, &propertySize, &writable); 120 + if (err) { 121 + //fprintf(stderr, "AudioFileGetPropertyInfo kAudioFilePropertyChannelLayout failed for '%s'\n", argv[i]); 122 + printf(" no channel layout.\n"); 123 + } else { 124 + 125 + acl = (AudioChannelLayout*)calloc(1, propertySize); 126 + err = AudioFileGetProperty(afid, kAudioFilePropertyChannelLayout, &propertySize, acl); 127 + if (err) { 128 + fprintf(stderr, "AudioFileGetProperty kAudioFilePropertyChannelLayout failed for '%s'\n", argv[i]); 129 + goto Bail1; 130 + } 131 + 132 + CFStringRef aclname; 133 + char aclstr[512]; 134 + specifierSize = propertySize; 135 + propertySize = sizeof(aclname); 136 + AudioFormatGetProperty(kAudioFormatProperty_ChannelLayoutName, specifierSize, acl, &propertySize, &aclname); 137 + if (err) { 138 + fprintf(stderr, "AudioFileGetProperty kAudioFilePropertyChannelLayout failed for '%s'\n", argv[i]); 139 + goto Bail1; 140 + } 141 + CFStringGetCString(aclname, aclstr, 512, kCFStringEncodingUTF8); 142 + 143 + printf("Channel layout: %s\n", aclstr); 144 + } 145 + 146 + UInt64 dataByteCount; 147 + propertySize = sizeof(dataByteCount); 148 + err = AudioFileGetProperty(afid, kAudioFilePropertyAudioDataByteCount, &propertySize, &dataByteCount); 149 + if (err) { 150 + fprintf(stderr, "AudioFileGetProperty kAudioFilePropertyAudioDataByteCount failed for '%s'\n", argv[i]); 151 + } else { 152 + printf("audio bytes: %llu\n", dataByteCount); 153 + } 154 + 155 + UInt64 dataPacketCount; 156 + UInt64 totalFrames; 157 + totalFrames = 0; 158 + propertySize = sizeof(dataPacketCount); 159 + err = AudioFileGetProperty(afid, kAudioFilePropertyAudioDataPacketCount, &propertySize, &dataPacketCount); 160 + if (err) { 161 + fprintf(stderr, "AudioFileGetProperty kAudioFilePropertyAudioDataPacketCount failed for '%s'\n", argv[i]); 162 + } else { 163 + printf("audio packets: %llu\n", dataPacketCount); 164 + if (asbd.mFramesPerPacket) 165 + totalFrames = asbd.mFramesPerPacket * dataPacketCount; 166 + } 167 + 168 + AudioFilePacketTableInfo pti; 169 + propertySize = sizeof(pti); 170 + err = AudioFileGetProperty(afid, kAudioFilePropertyPacketTableInfo, &propertySize, &pti); 171 + if (err == noErr) { 172 + totalFrames = pti.mNumberValidFrames; 173 + printf("audio %qd valid frames + %ld priming + %ld remainder = %qd\n", pti.mNumberValidFrames, pti.mPrimingFrames, pti.mRemainderFrames, pti.mNumberValidFrames + pti.mPrimingFrames + pti.mRemainderFrames); 174 + } 175 + 176 + if (totalFrames != 0) 177 + printf("duration: %.4f seconds\n", (double)totalFrames / (double)asbd.mSampleRate ); 178 + 179 + UInt32 maxPacketSize; 180 + propertySize = sizeof(maxPacketSize); 181 + err = AudioFileGetProperty(afid, kAudioFilePropertyMaximumPacketSize, &propertySize, &maxPacketSize); 182 + if (err) { 183 + fprintf(stderr, "AudioFileGetProperty kAudioFilePropertyMaximumPacketSize failed for '%s'\n", argv[i]); 184 + } else { 185 + printf("maximum packet size: %lu\n", maxPacketSize); 186 + } 187 + 188 + UInt64 dataOffset; 189 + propertySize = sizeof(dataOffset); 190 + err = AudioFileGetProperty(afid, kAudioFilePropertyDataOffset, &propertySize, &dataOffset); 191 + if (err) { 192 + fprintf(stderr, "AudioFileGetProperty kAudioFilePropertyDataOffset failed for '%s'\n", argv[i]); 193 + } else { 194 + printf("audio data file offset: %llu\n", dataOffset); 195 + } 196 + 197 + UInt32 isOptimized; 198 + propertySize = sizeof(isOptimized); 199 + err = AudioFileGetProperty(afid, kAudioFilePropertyIsOptimized, &propertySize, &isOptimized); 200 + if (err) { 201 + fprintf(stderr, "AudioFileGetProperty kAudioFilePropertyIsOptimized failed for '%s'\n", argv[i]); 202 + } else { 203 + printf(isOptimized ? "optimized\n" : "not optimized\n"); 204 + } 205 + 206 + Bail1: 207 + AudioFileClose(afid); 208 + Bail2: 209 + CFRelease(url); 210 + Bail3: 211 + CFRelease(filename); 212 + free(acl); 213 + 214 + printf("----\n"); 215 + } 216 + return 0; 217 + }
+252
src/CoreAudio/AudioFileTools/afinterleave.cpp
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + Interleaver.cpp 40 + 41 + =============================================================================*/ 42 + 43 + #include "CAAudioFile.h" 44 + #include "CAXException.h" 45 + #include <unistd.h> 46 + #include "CAChannelLayouts.h" 47 + #include "CAFilePathUtils.h" 48 + 49 + static void usage() 50 + { 51 + fprintf(stderr, 52 + "Usage:\n" 53 + "%s [option...] input_file... -o output_file\n\n" 54 + "Options: (may appear before or after arguments)\n" 55 + " { -l | --channellayout } layout_tag\n" 56 + " layout_tag: name of a constant from CoreAudioTypes.h\n" 57 + " (prefix \"kAudioChannelLayoutTag_\" may be omitted)\n", 58 + getprogname() 59 + ); 60 + exit(1); 61 + } 62 + 63 + 64 + void Interleave(int nInputs, const char *infilenames[], const char *outfilename, const CAAudioChannelLayout *layout) 65 + { 66 + const UInt32 kBufferSizeFrames = 0x8000; 67 + const UInt32 kBufferSizeBytes = kBufferSizeFrames * sizeof(Float32); 68 + class FileAndBuffer : public CAAudioFile { 69 + public: 70 + FileAndBuffer() : mBuf(NULL), mPtrs(NULL) { } 71 + ~FileAndBuffer() { delete mBuf; delete mPtrs; } 72 + 73 + CABufferList * mBuf; 74 + CABufferList * mPtrs; 75 + }; 76 + FileAndBuffer *infiles = new FileAndBuffer[nInputs], *file; 77 + FileAndBuffer outfile; 78 + int i; 79 + UInt32 outputChannels = 0; 80 + double sampleRate = 0.; 81 + UInt32 maxBitDepth = 0; 82 + CAStreamBasicDescription clientFormat; 83 + bool outFileCreated = false; 84 + 85 + try { 86 + // set up input files 87 + for (i = 0; i < nInputs; ++i) { 88 + file = &infiles[i]; 89 + file->Open(infilenames[i]); 90 + const CAStreamBasicDescription &fmt = file->GetFileDataFormat(); 91 + //fmt.PrintFormat(stdout, "", "input file"); 92 + XThrowIf(fmt.mFormatID != kAudioFormatLinearPCM, -1, "input files must be PCM"); 93 + outputChannels += fmt.mChannelsPerFrame; 94 + if (sampleRate == 0.) 95 + sampleRate = fmt.mSampleRate; 96 + else 97 + XThrowIf(fmt.mSampleRate != sampleRate, -1, "input files must have the same sample rate"); 98 + if (fmt.mBitsPerChannel > maxBitDepth) 99 + maxBitDepth = fmt.mBitsPerChannel; 100 + clientFormat.mSampleRate = sampleRate; 101 + clientFormat.SetCanonical(fmt.mChannelsPerFrame, false); // deinterleaved 102 + file->SetClientFormat(clientFormat, NULL); 103 + file->mBuf = CABufferList::New("readbuf", clientFormat); 104 + file->mBuf->AllocateBuffers(kBufferSizeBytes); 105 + file->mPtrs = CABufferList::New("readptrs", clientFormat); 106 + //clientFormat.PrintFormat(stdout, "", "input client"); 107 + } 108 + 109 + if (layout != NULL) { 110 + if (AudioChannelLayoutTag_GetNumberOfChannels(layout->Tag()) != outputChannels) { 111 + fprintf(stderr, "Channel layout tag '%s' is inappropriate for %lu channels of audio -- aborting\n", 112 + CAChannelLayouts::ConstantToString(layout->Tag()), outputChannels); 113 + exit(2); 114 + } 115 + } 116 + 117 + // prepare output file format 118 + CAStreamBasicDescription outfmt; 119 + outfmt.mSampleRate = sampleRate; 120 + outfmt.mFormatID = kAudioFormatLinearPCM; 121 + outfmt.mFormatFlags = kLinearPCMFormatFlagIsBigEndian | kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked; 122 + outfmt.mBitsPerChannel = maxBitDepth; 123 + outfmt.mChannelsPerFrame = outputChannels; 124 + outfmt.mBytesPerPacket = outfmt.mBytesPerFrame = outputChannels * (maxBitDepth >> 3); 125 + outfmt.mFramesPerPacket = 1; 126 + //outfmt.PrintFormat(stdout, "", "output file"); 127 + 128 + unlink(outfilename); 129 + FSRef parentDir; 130 + CFStringRef outName; 131 + XThrowIfError(PosixPathToParentFSRefAndName(outfilename, parentDir, outName), "Couldn't locate output directory"); 132 + outfile.CreateNew(parentDir, outName, kAudioFileAIFFType, outfmt, layout ? &layout->Layout() : NULL); 133 + outFileCreated = true; 134 + 135 + // create the output file and buffers 136 + clientFormat.mSampleRate = sampleRate; 137 + clientFormat.SetCanonical(outputChannels, false); 138 + outfile.SetClientFormat(clientFormat, NULL); 139 + //clientFormat.PrintFormat(stdout, "", "output client"); 140 + 141 + outfile.mPtrs = CABufferList::New("writeptrs", clientFormat); 142 + 143 + AudioBufferList &writebufs = outfile.mPtrs->GetModifiableBufferList(); 144 + int outbuf = 0; 145 + for (i = 0; i < nInputs; ++i) { 146 + file = &infiles[i]; 147 + const CABufferList *bl = file->mBuf; 148 + const AudioBufferList &readbufs = bl->GetBufferList(); 149 + memcpy(&writebufs.mBuffers[outbuf], &readbufs.mBuffers[0], 150 + readbufs.mNumberBuffers * sizeof(AudioBuffer)); 151 + outbuf += readbufs.mNumberBuffers; 152 + } 153 + 154 + while (true) { 155 + UInt32 maxFramesRead = 0; 156 + UInt32 nframes; 157 + for (i = 0; i < nInputs; ++i) { 158 + file = &infiles[i]; 159 + file->mPtrs->SetFrom(file->mBuf); 160 + nframes = kBufferSizeFrames; 161 + AudioBufferList &readbufs = file->mPtrs->GetModifiableBufferList(); 162 + file->Read(nframes, &readbufs); 163 + //CAShowAudioBufferList(&readbufs, 8, 0); 164 + if (nframes > maxFramesRead) 165 + maxFramesRead = nframes; 166 + if (nframes < kBufferSizeFrames) 167 + file->mPtrs->PadWithZeroes(kBufferSizeBytes); 168 + } 169 + if (maxFramesRead == 0) 170 + break; 171 + 172 + if (maxFramesRead < kBufferSizeFrames) 173 + outfile.mPtrs->SetNumBytes(maxFramesRead * sizeof(Float32)); 174 + //CAShowAudioBufferList(&writebufs, 8, 0); 175 + outfile.Write(maxFramesRead, &writebufs); 176 + if (maxFramesRead < kBufferSizeFrames) 177 + break; 178 + } 179 + } 180 + catch (...) { 181 + if (outFileCreated) 182 + unlink(outfilename); 183 + delete[] infiles; 184 + throw; 185 + } 186 + outfile.Close(); 187 + // input files are closed from destructors 188 + delete[] infiles; 189 + } 190 + 191 + static void MissingArgument() 192 + { 193 + fprintf(stderr, "missing argument\n\n"); 194 + usage(); 195 + } 196 + 197 + int main(int argc, const char *argv[]) 198 + { 199 + int nins = 0; 200 + static const int MAX_INPUT_FILES = 32; 201 + const char *infiles[MAX_INPUT_FILES]; 202 + const char *outfile = NULL; 203 + UInt32 layoutTag = 0; 204 + 205 + for (int i = 1; i < argc; ++i) { 206 + const char *arg = argv[i]; 207 + if (arg[0] != '-') { 208 + if (nins >= MAX_INPUT_FILES) { 209 + fprintf(stderr, "too many input files\n\n"); 210 + usage(); 211 + } 212 + infiles[nins++] = arg; 213 + } else { 214 + arg += 1; 215 + if (arg[0] == 'o') { 216 + if (++i == argc) MissingArgument(); 217 + outfile = argv[i]; 218 + } else if (arg[0] == 'l' || !strcmp(arg, "-channellayout")) { 219 + if (++i == argc) MissingArgument(); 220 + layoutTag = CAChannelLayouts::StringToConstant(argv[i]); 221 + if (layoutTag == CAChannelLayouts::kInvalidTag) { 222 + fprintf(stderr, "unknown channel layout tag: %s\n\n", argv[i]); 223 + usage(); 224 + } 225 + } else { 226 + fprintf(stderr, "unknown argument: %s\n\n", arg - 1); 227 + usage(); 228 + } 229 + } 230 + } 231 + 232 + if (nins < 2 || outfile == NULL) 233 + usage(); 234 + 235 + try { 236 + if (layoutTag != 0) { 237 + CAAudioChannelLayout layout = CAAudioChannelLayout(layoutTag); 238 + Interleave(nins, infiles, outfile, &layout); 239 + } else 240 + Interleave(nins, infiles, outfile, NULL); 241 + } 242 + catch (CAXException &e) { 243 + char buf[256]; 244 + fprintf(stderr, "Error: %s (%s)\n", e.mOperation, CAXException::FormatError(buf, e.mError)); 245 + return 1; 246 + } 247 + catch (...) { 248 + fprintf(stderr, "An unknown error occurred\n"); 249 + return 1; 250 + } 251 + return 0; 252 + }
+193
src/CoreAudio/AudioFileTools/afplay.cpp
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + playaudiofile.cpp 40 + 41 + =============================================================================*/ 42 + 43 + #include "CAChannelMappingPlayer.h" 44 + #include "CAXException.h" 45 + 46 + #if TARGET_OS_MAC 47 + #include <unistd.h> 48 + #else 49 + #include <QTML.h> 50 + #include "CAWindows.h" 51 + #endif 52 + 53 + static void usage() 54 + { 55 + fprintf(stderr, 56 + "Usage:\n" 57 + "%s [option...] audio_file\n\n" 58 + "Options: (may appear before or after arguments)\n" 59 + " {-a --all}\n" 60 + " for files with >2 channels, play each pair of channels in succession\n" 61 + " {-f --frame} FRAME\n" 62 + " starting sample frame number\n" 63 + " {-s --seconds} START_SECONDS END_SECONDS\n" 64 + " segment of file to play, in seconds\n" 65 + #if !TARGET_OS_WIN32 66 + , getprogname()); 67 + #else 68 + , "afplay"); 69 + #endif 70 + exit(1); 71 + } 72 + 73 + static void Play(CAChannelMappingPlayer &player, SInt64 startFrame, SInt64 endFrame) 74 + { 75 + CAAudioFile &file = player.GetFile(); 76 + if (startFrame < 0) { 77 + startFrame = 0; 78 + } 79 + if (endFrame <= 0) { 80 + SInt64 numFrames = SInt64(file.GetNumberFrames() * file.GetClientDataFormat().mSampleRate / file.GetFileDataFormat().mSampleRate); 81 + endFrame = numFrames; 82 + } 83 + player.Start(); 84 + while (true) { 85 + SInt64 pos = player.GetCurrentFrame(); 86 + //file.Tell(); 87 + if (pos >= endFrame) 88 + break; 89 + usleep(250000); // 250 ms 90 + } 91 + player.Stop(); 92 + } 93 + 94 + void MissingArgument() 95 + { 96 + fprintf(stderr, "Missing argument\n"); 97 + usage(); 98 + } 99 + 100 + int main(int argc, const char *argv[]) 101 + { 102 + const char *fileToPlay = NULL; 103 + bool playallpairs = false; 104 + double startSeconds = -1, endSeconds = -1; 105 + SInt64 startFrame = 0, endFrame = 0; 106 + 107 + #if TARGET_OS_WIN32 108 + InitializeQTML(0L); 109 + #endif 110 + 111 + for (int i = 1; i < argc; ++i) { 112 + const char *arg = argv[i]; 113 + if (arg[0] != '-') { 114 + if (fileToPlay != NULL) { 115 + fprintf(stderr, "may only specify one file to play\n"); 116 + usage(); 117 + } 118 + fileToPlay = arg; 119 + } else { 120 + arg += 1; 121 + if (arg[0] == 'a' || !strcmp(arg, "-all")) 122 + playallpairs = true; 123 + else if (arg[0] == 'f' || !strcmp(arg, "-frame")) { 124 + if (++i == argc) 125 + MissingArgument(); 126 + arg = argv[i]; 127 + sscanf(arg, "%qd", &startFrame); 128 + } else if (arg[0] == 's' || !strcmp(arg, "-seconds")) { 129 + if (++i == argc) 130 + MissingArgument(); 131 + arg = argv[i]; 132 + sscanf(arg, "%lf", &startSeconds); 133 + if (i + 1 < argc && argv[i+1][0] != '-') { 134 + arg = argv[++i]; 135 + sscanf(arg, "%lf", &endSeconds); 136 + } 137 + } else { 138 + fprintf(stderr, "unknown argument: %s\n\n", arg - 1); 139 + usage(); 140 + } 141 + } 142 + } 143 + 144 + if (fileToPlay == NULL) 145 + usage(); 146 + 147 + try { 148 + const int kNumberBuffers = 3; 149 + const unsigned kBufferSize = 0x1000; 150 + FSRef playFSRef; 151 + XThrowIfError(FSPathMakeRef((UInt8 *)fileToPlay, &playFSRef, NULL), "Input file not found"); 152 + CAChannelMappingPlayer player(kNumberBuffers, kBufferSize); 153 + player.SetFile(playFSRef); 154 + CAAudioFile &file = player.GetFile(); 155 + CAChannelMapper *mapper = player.GetMapper(); 156 + if (playallpairs && mapper == NULL) 157 + playallpairs = false; 158 + 159 + if (startSeconds >= 0) { 160 + Float64 sr = file.GetClientDataFormat().mSampleRate; 161 + startFrame = SInt64(startSeconds * sr); 162 + if (endSeconds > startSeconds) 163 + endFrame = SInt64(endSeconds * sr); 164 + printf("secs: %.1f-%.1f frames: %qd-%qd\n", startSeconds, endSeconds, startFrame, endFrame); 165 + } 166 + 167 + if (playallpairs) { 168 + int nChannelsInFile = file.GetFileDataFormat().NumberChannels(); 169 + for (int channel = 0; channel < nChannelsInFile && playallpairs; channel += 2) { 170 + printf("channels %d-%d of %d\n", channel, channel+1, nChannelsInFile); 171 + mapper->ResetMixer(); 172 + mapper->ConnectChannelToChannel(channel, 0); 173 + mapper->ConnectChannelToChannel(channel+1, 1); 174 + player.SetCurrentPosition(0.); 175 + Play(player, startFrame, endFrame); 176 + } 177 + } else { 178 + file.Seek(startFrame); 179 + Play(player, startFrame, endFrame); 180 + } 181 + } 182 + catch (CAXException &e) { 183 + char buf[256]; 184 + fprintf(stderr, "Error: %s (%s)\n", e.mOperation, CAXException::FormatError(buf, sizeof(buf), e.mError)); 185 + return 1; 186 + } 187 + catch (...) { 188 + fprintf(stderr, "An unknown error occurred\n"); 189 + return 1; 190 + } 191 + return 0; 192 + } 193 +
+225
src/CoreAudio/AudioFileTools/afrecord.cpp
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + afrecord.cpp 40 + 41 + =============================================================================*/ 42 + 43 + #include "CAAudioFileRecorder.h" 44 + #include "CAXException.h" 45 + #include <unistd.h> 46 + #include "AFToolsCommon.h" 47 + #include "CAFilePathUtils.h" 48 + #include "CAAudioFileFormats.h" 49 + 50 + static void usage() 51 + { 52 + fprintf(stderr, 53 + "Usage:\n" 54 + "%s [option...] audio_file\n\n" 55 + "Options: (may appear before or after arguments)\n" 56 + " { -f | --file } file_format:\n" 57 + , getprogname()); 58 + PrintAudioFileTypesAndFormats(stderr); 59 + fprintf(stderr, 60 + " { -d | --data } data_format[@sample_rate_hz]:\n" 61 + " [-][BE|LE]{F|[U]I}{8|16|24|32|64} (PCM)\n" 62 + " e.g. -BEI16 -F32@44100\n" 63 + " or a data format appropriate to file format, as above\n" 64 + " { -c | --channels } number_of_channels\n" 65 + " add/remove channels without regard to order\n" 66 + " { -l | --channellayout } layout_tag\n" 67 + " layout_tag: name of a constant from CoreAudioTypes.h\n" 68 + " (prefix \"kAudioChannelLayoutTag_\" may be omitted)\n" 69 + " if specified once, applies to output file; if twice, the first\n" 70 + " applies to the input file, the second to the output file\n" 71 + " { -b | --bitrate } bit_rate_bps\n" 72 + " e.g. 128000\n" 73 + " { -q | --quality } quality\n" 74 + " quality: 0-127\n" 75 + " { -v | --verbose }\n" 76 + " print progress verbosely\n" 77 + " { -p | --profile }\n" 78 + " collect and print performance profile\n" 79 + ); 80 + exit(1); 81 + } 82 + 83 + static void MissingArgument() 84 + { 85 + fprintf(stderr, "missing argument\n\n"); 86 + usage(); 87 + } 88 + 89 + static OSType Parse4CharCode(const char *arg, const char *name) 90 + { 91 + OSType t; 92 + StrToOSType(arg, t); 93 + if (t == 0) { 94 + fprintf(stderr, "invalid 4-char-code argument for %s: '%s'\n\n", name, arg); 95 + usage(); 96 + } 97 + return t; 98 + } 99 + 100 + static int ParseInt(const char *arg, const char *name) 101 + { 102 + int x; 103 + if (sscanf(arg, "%d", &x) != 1) { 104 + fprintf(stderr, "invalid integer argument for %s: '%s'\n\n", name, arg); 105 + usage(); 106 + } 107 + return x; 108 + } 109 + 110 + static void Record(CAAudioFileRecorder &recorder) 111 + { 112 + recorder.Start(); 113 + printf("Recording, press any key to stop:"); 114 + fflush(stdout); 115 + getchar(); 116 + //sleep(10); 117 + recorder.Stop(); 118 + } 119 + 120 + int main(int argc, const char *argv[]) 121 + { 122 + const char *recordFileName = NULL; 123 + 124 + // set up defaults 125 + AudioFileTypeID filetype = kAudioFileAIFFType; 126 + 127 + bool gotOutDataFormat = false; 128 + CAStreamBasicDescription dataFormat; 129 + dataFormat.mSampleRate = 44100.; // later get this from the hardware 130 + dataFormat.mFormatID = kAudioFormatLinearPCM; 131 + dataFormat.mFormatFlags = kAudioFormatFlagIsBigEndian | kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked; 132 + dataFormat.mFramesPerPacket = 1; 133 + dataFormat.mChannelsPerFrame = 2; 134 + dataFormat.mBitsPerChannel = 16; 135 + dataFormat.mBytesPerPacket = dataFormat.mBytesPerFrame = 4; 136 + 137 + SInt32 bitrate = -1, quality = -1; 138 + 139 + // parse arguments 140 + for (int i = 1; i < argc; ++i) { 141 + const char *arg = argv[i]; 142 + if (arg[0] != '-') { 143 + if (recordFileName != NULL) { 144 + fprintf(stderr, "may only specify one record file\n"); 145 + usage(); 146 + } 147 + recordFileName = arg; 148 + } else { 149 + arg += 1; 150 + if (arg[0] == 'f' || !strcmp(arg, "-file")) { 151 + if (++i == argc) MissingArgument(); 152 + filetype = Parse4CharCode(argv[i], "-f | --file"); 153 + } else if (arg[0] == 'd' || !strcmp(arg, "-data")) { 154 + if (++i == argc) MissingArgument(); 155 + if (!ParseStreamDescription(argv[i], dataFormat)) 156 + usage(); 157 + gotOutDataFormat = true; 158 + } else if (arg[0] == 'b' || !strcmp(arg, "-bitrate")) { 159 + if (++i == argc) MissingArgument(); 160 + bitrate = ParseInt(argv[i], "-b | --bitrate"); 161 + } else if (arg[0] == 'q' || !strcmp(arg, "-quality")) { 162 + if (++i == argc) MissingArgument(); 163 + quality = ParseInt(argv[i], "-q | --quality"); 164 + } else { 165 + fprintf(stderr, "unknown argument: %s\n\n", arg - 1); 166 + usage(); 167 + } 168 + } 169 + } 170 + 171 + if (recordFileName == NULL) 172 + usage(); 173 + 174 + if (!gotOutDataFormat) { 175 + if (filetype == 0) { 176 + fprintf(stderr, "no output file or data format specified\n\n"); 177 + usage(); 178 + } 179 + if (!CAAudioFileFormats::Instance()->InferDataFormatFromFileFormat(filetype, dataFormat)) { 180 + fprintf(stderr, "Couldn't infer data format from file format\n\n"); 181 + usage(); 182 + } 183 + } else if (filetype == 0) { 184 + if (!CAAudioFileFormats::Instance()->InferFileFormatFromDataFormat(dataFormat, filetype)) { 185 + dataFormat.PrintFormat(stderr, "", "Couldn't infer file format from data format"); 186 + usage(); 187 + } 188 + } 189 + 190 + unlink(recordFileName); 191 + 192 + if (dataFormat.IsPCM()) 193 + dataFormat.ChangeNumberChannels(2, true); 194 + else 195 + dataFormat.mChannelsPerFrame = 2; 196 + 197 + try { 198 + const int kNumberBuffers = 3; 199 + const unsigned kBufferSize = 0x8000; 200 + CAAudioFileRecorder recorder(kNumberBuffers, kBufferSize); 201 + FSRef parentDir; 202 + CFStringRef filename; 203 + XThrowIfError(PosixPathToParentFSRefAndName(recordFileName, parentDir, filename), "couldn't find output directory"); 204 + recorder.SetFile(parentDir, filename, filetype, dataFormat, NULL); 205 + 206 + CAAudioFile &recfile = recorder.GetFile(); 207 + if (bitrate >= 0) 208 + recfile.SetConverterProperty(kAudioConverterEncodeBitRate, sizeof(UInt32), &bitrate); 209 + if (quality >= 0) 210 + recfile.SetConverterProperty(kAudioConverterCodecQuality, sizeof(UInt32), &quality); 211 + 212 + Record(recorder); 213 + } 214 + catch (CAXException &e) { 215 + char buf[256]; 216 + fprintf(stderr, "Error: %s (%s)\n", e.mOperation, CAXException::FormatError(buf, sizeof(buf), e.mError)); 217 + return 1; 218 + } 219 + catch (...) { 220 + fprintf(stderr, "An unknown error occurred\n"); 221 + return 1; 222 + } 223 + return 0; 224 + } 225 +
+154
src/CoreAudio/AudioFileTools/audioformats.cpp
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + audioformats.cpp 40 + 41 + =============================================================================*/ 42 + 43 + #include "CAAudioFileFormats.h" 44 + #include <stdlib.h> 45 + #include "AFToolsCommon.h" 46 + 47 + #if TARGET_OS_WIN32 48 + #include <QTML.h> 49 + #endif 50 + 51 + // This program interrogates the AudioFile and AudioFormat API's for information 52 + // useful in constructing test scripts. It might also be useful as an example 53 + // of how to use these API's. 54 + 55 + void PrintFileFormats() 56 + { 57 + CAAudioFileFormats *fileFormats = CAAudioFileFormats::Instance(); 58 + 59 + for (int i = 0; i < fileFormats->mNumFileFormats; ++i) { 60 + CAAudioFileFormats::FileFormatInfo *ffi = &fileFormats->mFileFormats[i]; 61 + char buf[20], extbuf[32]; 62 + printf("('%s', '%s'", OSTypeToStr(buf, ffi->mFileTypeID), ffi->GetExtension(0, extbuf, sizeof(extbuf))); 63 + 64 + for (int j = 0; j < ffi->mNumDataFormats; ++j) { 65 + CAAudioFileFormats::DataFormatInfo *dfi = &ffi->mDataFormats[j]; 66 + if (dfi->mFormatID == kAudioFormatLinearPCM) { 67 + for (int k = 0; k < dfi->mNumVariants; ++k) { 68 + AudioStreamBasicDescription *asbd = &dfi->mVariants[k]; 69 + if (asbd->mFormatFlags & ~(kAudioFormatFlagIsPacked | kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsBigEndian | kAudioFormatFlagIsFloat)) 70 + printf("(%08lx/%ld) ", asbd->mFormatFlags, asbd->mBitsPerChannel); 71 + else { 72 + printf(", '%s", 73 + (asbd->mFormatFlags & kAudioFormatFlagIsBigEndian) ? "BE" : "LE"); 74 + if (asbd->mFormatFlags & kAudioFormatFlagIsFloat) 75 + printf("F"); 76 + else 77 + printf("%sI", 78 + (asbd->mFormatFlags & kAudioFormatFlagIsSignedInteger) ? "" : "U"); 79 + printf("%ld'", asbd->mBitsPerChannel); 80 + } 81 + } 82 + } else { 83 + printf(", '%s'", OSTypeToStr(buf, dfi->mFormatID)); 84 + } 85 + } 86 + printf("),\n"); 87 + } 88 + } 89 + 90 + struct LayoutTag { 91 + UInt32 constant; 92 + const char *name; 93 + }; 94 + 95 + #define TAG(x) { x, #x }, 96 + 97 + static LayoutTag gLayoutTags[] = { 98 + TAG(kAudioChannelLayoutTag_Stereo) 99 + TAG(kAudioChannelLayoutTag_AAC_Quadraphonic) 100 + TAG(kAudioChannelLayoutTag_AAC_4_0) 101 + TAG(kAudioChannelLayoutTag_AAC_5_0) 102 + TAG(kAudioChannelLayoutTag_AAC_5_1) 103 + TAG(kAudioChannelLayoutTag_AAC_6_0) 104 + TAG(kAudioChannelLayoutTag_AAC_6_1) 105 + TAG(kAudioChannelLayoutTag_AAC_7_0) 106 + TAG(kAudioChannelLayoutTag_AAC_7_1) 107 + TAG(kAudioChannelLayoutTag_AAC_Octagonal) 108 + TAG(kAudioChannelLayoutTag_MPEG_5_0_A) 109 + TAG(kAudioChannelLayoutTag_MPEG_5_0_B) 110 + TAG(kAudioChannelLayoutTag_MPEG_5_1_A) 111 + TAG(kAudioChannelLayoutTag_MPEG_5_1_B) 112 + { 0, NULL } // sentinel 113 + }; 114 + 115 + static const char *prefix = "kAudioChannelLayoutTag_"; 116 + 117 + void PrintCompatibleChannelLayouts() 118 + { 119 + int plen = strlen(prefix); 120 + for (LayoutTag *tag1 = gLayoutTags; tag1->name != NULL; ++tag1) { 121 + AudioChannelLayout layout1 = { tag1->constant, 0, 0 }; 122 + printf("\t'%s' : (", tag1->name + plen); 123 + int printed = 0; 124 + for (LayoutTag *tag2 = gLayoutTags; tag2->name != NULL; ++tag2) { 125 + AudioChannelLayout layout2 = { tag2->constant, 0, 0 }; 126 + AudioChannelLayout *layouts[] = { &layout1, &layout2 }; 127 + 128 + UInt32 propertySize; 129 + OSStatus err = AudioFormatGetPropertyInfo(kAudioFormatProperty_ChannelMap, sizeof(layouts), layouts, &propertySize); 130 + if (err == noErr) { 131 + SInt32 *map = (SInt32 *)malloc(propertySize); 132 + err = AudioFormatGetProperty(kAudioFormatProperty_ChannelMap, sizeof(layouts), layouts, &propertySize, map); 133 + if (err == noErr) { 134 + if (printed++) printf(", "); 135 + printf("'%s'", tag2->name + plen); 136 + } 137 + } 138 + } 139 + printf("),\n"); 140 + } 141 + } 142 + 143 + int main(int argc, const char *argv[]) 144 + { 145 + #if TARGET_OS_WIN32 146 + InitializeQTML(0L); 147 + #endif 148 + 149 + PrintFileFormats(); 150 + printf("#######################\n"); 151 + PrintCompatibleChannelLayouts(); 152 + 153 + return 0; 154 + }
+678
src/CoreAudio/AudioFileTools/auprocess.cpp
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + main.cpp 40 + 41 + =============================================================================*/ 42 + 43 + /* 44 + auprocess 45 + - takes a source audio file, an AU and generates a processed file 46 + */ 47 + 48 + #include "CAAUProcessor.h" 49 + #include "CAAudioFile.h" 50 + #include "CAXException.h" 51 + #include "CAHostTimeBase.h" 52 + #include "CAFilePathUtils.h" 53 + #include "CAAudioFileFormats.h" 54 + 55 + #if TARGET_OS_MAC 56 + #include <pthread.h> 57 + #include <mach/mach.h> 58 + #endif 59 + 60 + #define require_noerr ca_require_noerr 61 + 62 + #define CA_AU_PROFILE_TIME 1 63 + 64 + #if CA_AU_PROFILE_TIME 65 + UInt64 sReadTime = 0; 66 + UInt64 sRenderTime = 0; 67 + #endif 68 + 69 + #pragma mark __print helpers 70 + 71 + void PRINT_MARKS () 72 + { 73 + printf ("| "); 74 + for (int i = 0; i < 48; ++i) 75 + printf (" "); 76 + printf ("|\n"); 77 + } 78 + 79 + void PerfResult(const char *toolname, int group, const char *testname, double value, const char *units, const char *fmt="%.3f") 80 + { 81 + printf("<result tool='%s' group='%d' test='%s' value='", toolname, group, testname); 82 + printf(fmt, value); 83 + printf("' units='%s' />\n", units); 84 + } 85 + 86 + static int lastProgressPrintDone = -1; 87 + void PRINT_PROGRESS (Float32 inPercent) 88 + { 89 + int current = int(inPercent / 4.0); 90 + for (int i = lastProgressPrintDone; i < current; ++i) 91 + printf ("* "); 92 + lastProgressPrintDone = current; 93 + } 94 + 95 + #pragma mark __Inpput Callback Definitions 96 + 97 + static AURenderCallbackStruct sInputCallback; // we set one of these two callbacks based on AU type 98 + 99 + static OSStatus InputCallback (void *inRefCon, 100 + AudioUnitRenderActionFlags *ioActionFlags, 101 + const AudioTimeStamp *inTimeStamp, 102 + UInt32 inBusNumber, 103 + UInt32 inNumberFrames, 104 + AudioBufferList *ioData) 105 + { 106 + #if CA_AU_PROFILE_TIME 107 + UInt64 now = CAHostTimeBase::GetTheCurrentTime(); 108 + #endif 109 + 110 + CAAudioFile &readFile = *(static_cast<CAAudioFile*>(inRefCon)); 111 + 112 + #if !CAAF_USE_EXTAUDIOFILE 113 + if (SInt64(inTimeStamp->mSampleTime) > readFile.GetNumberPackets()) { 114 + #else 115 + if (SInt64(inTimeStamp->mSampleTime) > readFile.GetNumberFrames()) { 116 + #endif 117 + #if DEBUG 118 + printf ("reading past end of input\n"); 119 + #endif 120 + return -1; 121 + } 122 + 123 + readFile.Seek (SInt64(inTimeStamp->mSampleTime)); 124 + readFile.Read (inNumberFrames, ioData); 125 + 126 + #if CA_AU_PROFILE_TIME 127 + sReadTime += (CAHostTimeBase::GetTheCurrentTime() - now); 128 + #endif 129 + 130 + return noErr; 131 + } 132 + 133 + static OSStatus FConvInputCallback (void *inRefCon, 134 + AudioUnitRenderActionFlags *ioActionFlags, 135 + const AudioTimeStamp *inTimeStamp, 136 + UInt32 inBusNumber, 137 + UInt32 inNumberFrames, 138 + AudioBufferList *ioData) 139 + { 140 + #if CA_AU_PROFILE_TIME 141 + UInt64 now = CAHostTimeBase::GetTheCurrentTime(); 142 + #endif 143 + 144 + CAAudioFile &readFile = *(static_cast<CAAudioFile*>(inRefCon)); 145 + 146 + // this test is ONLY needed in case of processing with a Format Converter type of AU 147 + // in all other cases, the CAAUProcessor class will NEVER call you for input 148 + // beyond the end of the file.... 149 + 150 + #if !CAAF_USE_EXTAUDIOFILE 151 + if (SInt64(inTimeStamp->mSampleTime) >= readFile.GetNumberPackets()) { 152 + #else 153 + if (SInt64(inTimeStamp->mSampleTime) >= readFile.GetNumberFrames()) { 154 + #endif 155 + return -1; 156 + } 157 + 158 + readFile.Seek (SInt64(inTimeStamp->mSampleTime)); 159 + UInt32 readPackets = inNumberFrames; 160 + 161 + // also, have to do this for a format converter AU - otherwise we'd just read what we're told 162 + #if !CAAF_USE_EXTAUDIOFILE 163 + if (SInt64(inTimeStamp->mSampleTime + inNumberFrames) > readFile.GetNumberPackets()) { 164 + #else 165 + if (SInt64(inTimeStamp->mSampleTime + inNumberFrames) > readFile.GetNumberFrames()) { 166 + #endif 167 + // first set this to zero as we're only going to read a partial number of frames 168 + AudioBuffer *buf = ioData->mBuffers; 169 + for (UInt32 i = ioData->mNumberBuffers; i--; ++buf) 170 + memset((Byte *)buf->mData, 0, buf->mDataByteSize); 171 + #if !CAAF_USE_EXTAUDIOFILE 172 + readPackets = UInt32 (readFile.GetNumberPackets() - SInt64(inTimeStamp->mSampleTime)); 173 + #else 174 + readPackets = UInt32 (readFile.GetNumberFrames() - SInt64(inTimeStamp->mSampleTime)); 175 + #endif 176 + } 177 + 178 + readFile.Read (readPackets, ioData); 179 + 180 + #if CA_AU_PROFILE_TIME 181 + sReadTime += (CAHostTimeBase::GetTheCurrentTime() - now); 182 + #endif 183 + 184 + return noErr; 185 + } 186 + 187 + struct ReadBuffer { 188 + AUOutputBL *readData; 189 + UInt32 readFrames; 190 + }; 191 + 192 + static OSStatus MemoryInputCallback (void *inRefCon, 193 + AudioUnitRenderActionFlags *ioActionFlags, 194 + const AudioTimeStamp *inTimeStamp, 195 + UInt32 inBusNumber, 196 + UInt32 inNumberFrames, 197 + AudioBufferList *ioData) 198 + { 199 + #if CA_AU_PROFILE_TIME 200 + UInt64 now = CAHostTimeBase::GetTheCurrentTime(); 201 + #endif 202 + 203 + ReadBuffer *readBuffer = (ReadBuffer*)inRefCon; 204 + 205 + if (((readBuffer->readFrames + inNumberFrames) * sizeof(Float32)) > (readBuffer->readData->ABL()->mBuffers[0].mDataByteSize)) 206 + { 207 + // going past read size 208 + AudioBuffer *buf = ioData->mBuffers; 209 + for (UInt32 i = ioData->mNumberBuffers; i--; ++buf) 210 + memset((Byte *)buf->mData, 0, buf->mDataByteSize); 211 + } 212 + else 213 + { 214 + AudioBuffer *buf = ioData->mBuffers; 215 + AudioBuffer *rBuf = readBuffer->readData->ABL()->mBuffers; 216 + for (UInt32 i = ioData->mNumberBuffers; i--; ++buf, ++rBuf) { 217 + AudioBuffer readB = *rBuf; 218 + readB.mData = static_cast<Float32*>(rBuf->mData) + readBuffer->readFrames; 219 + memcpy (buf->mData, readB.mData, buf->mDataByteSize); 220 + } 221 + readBuffer->readFrames += inNumberFrames; 222 + } 223 + 224 + #if CA_AU_PROFILE_TIME 225 + sReadTime += (CAHostTimeBase::GetTheCurrentTime() - now); 226 + #endif 227 + 228 + return noErr; 229 + } 230 + 231 + #pragma mark __Utility Helpers 232 + 233 + CFPropertyListRef ReadPresetFromPresetFile (char* filePath) 234 + { 235 + if (!filePath) 236 + return NULL; 237 + 238 + FSRef ref; 239 + if (FSPathMakeRef((UInt8 *)filePath, &ref, NULL)) 240 + return NULL; 241 + 242 + CFDataRef resourceData = NULL; 243 + CFPropertyListRef theData = NULL; 244 + CFStringRef errString = NULL; 245 + CFURLRef fileURL = CFURLCreateFromFSRef (kCFAllocatorDefault, &ref); 246 + if (fileURL == NULL) { 247 + goto home; 248 + } 249 + 250 + SInt32 result; 251 + 252 + // Read the XML file. 253 + Boolean status; status = CFURLCreateDataAndPropertiesFromResource (kCFAllocatorDefault, fileURL, 254 + &resourceData, // place to put file data 255 + NULL, NULL, &result); 256 + if (status == false || result) { 257 + goto home; 258 + } 259 + 260 + theData = CFPropertyListCreateFromXMLData (kCFAllocatorDefault, resourceData, 261 + kCFPropertyListImmutable, &errString); 262 + if (theData == NULL || errString) { 263 + if (theData) 264 + CFRelease (theData); 265 + theData = NULL; 266 + goto home; 267 + } 268 + 269 + home: 270 + if (fileURL) 271 + CFRelease (fileURL); 272 + if (resourceData) 273 + CFRelease (resourceData); 274 + if (errString) 275 + CFRelease (errString); 276 + 277 + return theData; 278 + } 279 + 280 + #pragma mark __the setup code 281 + 282 + #define OFFLINE_AU_CMD "[-au TYPE SUBTYPE MANU] The Audio Unit component description\n\t" 283 + #define INPUT_FILE "[-i /Path/To/File] The file that is to be processed.\n\t" 284 + #define OUTPUT_FILE "[-o /Path/To/File/To/Create] This will be in the same format as the input file\n\t" 285 + #define AU_PRESET_CMD "[-p /Path/To/AUPreset/File] Specify an AU Preset File to establish the state of the AU\n\t" 286 + #define SHORT_MEM_CMD "[-m] Just reads and processes the first half second of the input file\n\t" 287 + #define USE_MAX_FRAMES "[-f max_frames] default is 32768 (512 for aufc units)" 288 + 289 + static char* usageStr = "Usage: auprocess\n\t" 290 + OFFLINE_AU_CMD 291 + INPUT_FILE 292 + OUTPUT_FILE 293 + AU_PRESET_CMD 294 + SHORT_MEM_CMD 295 + USE_MAX_FRAMES; 296 + 297 + int main(int argc, const char * argv[]) 298 + { 299 + setbuf (stdout, NULL); 300 + 301 + 302 + #if TARGET_OS_MAC 303 + { 304 + thread_extended_policy_data_t theFixedPolicy; 305 + theFixedPolicy.timeshare = false; // set to true for a non-fixed thread 306 + thread_policy_set(pthread_mach_thread_np(pthread_self()), 307 + THREAD_EXTENDED_POLICY, 308 + (thread_policy_t)&theFixedPolicy, 309 + THREAD_EXTENDED_POLICY_COUNT); 310 + 311 + // We keep a reference to the spawning thread's priority around (initialized in the constructor), 312 + // and set the importance of the child thread relative to the spawning thread's priority. 313 + thread_precedence_policy_data_t thePrecedencePolicy; 314 + 315 + thePrecedencePolicy.importance = 63 - 36; 316 + thread_policy_set(pthread_mach_thread_np(pthread_self()), 317 + THREAD_PRECEDENCE_POLICY, 318 + (thread_policy_t)&thePrecedencePolicy, 319 + THREAD_PRECEDENCE_POLICY_COUNT); 320 + } 321 + #endif 322 + 323 + 324 + // These are the variables that are set up from the input parsing 325 + char* srcFilePath = NULL; 326 + char* destFilePath = NULL; 327 + char* auPresetFile = NULL; 328 + bool shortMemoryProfile = false; 329 + OSType manu, subType, type = 0; 330 + int userSetFrames = -1; 331 + 332 + for (int i = 1; i < argc; ++i) 333 + { 334 + if (strcmp (argv[i], "-au") == 0) { 335 + if ( (i + 3) < argc ) { 336 + StrToOSType (argv[i + 1], type); 337 + StrToOSType (argv[i + 2], subType); 338 + StrToOSType (argv[i + 3], manu); 339 + i += 3; 340 + } else { 341 + printf ("Which Audio Unit:\n%s", usageStr); 342 + exit(1); 343 + } 344 + } 345 + else if (strcmp (argv[i], "-i") == 0) { 346 + srcFilePath = const_cast<char*>(argv[++i]); 347 + } 348 + else if (strcmp (argv[i], "-o") == 0) { 349 + destFilePath = const_cast<char*>(argv[++i]); 350 + } 351 + else if (strcmp (argv[i], "-p") == 0) { 352 + auPresetFile = const_cast<char*>(argv[++i]); 353 + } 354 + else if (strcmp (argv[i], "-m") == 0) { 355 + shortMemoryProfile = true; 356 + } 357 + else if (strcmp (argv[i], "-f") == 0) { 358 + sscanf(argv[++i], "%d", &userSetFrames); 359 + } 360 + else { 361 + printf ("%s\n", usageStr); 362 + exit(1); 363 + } 364 + } 365 + 366 + if (!type || !srcFilePath) { 367 + printf ("%s\n", usageStr); 368 + exit(1); 369 + } 370 + if (!destFilePath) { 371 + if (!shortMemoryProfile) { 372 + printf ("%s\n", usageStr); 373 + exit(1); 374 + } 375 + } 376 + // delete pre-existing output file 377 + if (!shortMemoryProfile) { 378 + FSRef destFSRef; 379 + if (FSPathMakeRef((UInt8 *)destFilePath, &destFSRef, NULL) == noErr) { 380 + // output file exists - delete it 381 + if (FSDeleteObject(&destFSRef)) { 382 + printf ("Cannot Delete Output File\n"); 383 + exit(1); 384 + } 385 + } 386 + } 387 + 388 + CAComponentDescription desc(type, subType, manu); 389 + 390 + CFPropertyListRef presetDict = ReadPresetFromPresetFile(auPresetFile); 391 + 392 + // the num of frames to use when processing the file with the Render call 393 + UInt32 maxFramesToUse = shortMemoryProfile ? 512 : 32768; 394 + 395 + // not set from command line 396 + if (userSetFrames > 0) { 397 + maxFramesToUse = userSetFrames; 398 + } 399 + 400 + // in some settings (for instance a delay with 100% feedback) tail time is essentially infinite 401 + // so you should safeguard the final OL render stage (post process) which is aimed at pulling the tail through 402 + // if you want to bypass this completely, just set this to zero. 403 + Float64 maxTailTimeSecs = 10.; 404 + 405 + #pragma mark - 406 + #pragma mark __ The driving code 407 + #pragma mark - 408 + 409 + try 410 + { 411 + CAComponent comp(desc); 412 + 413 + // CAAUProcessor's constructor throws... so make sure the component is valid 414 + if (comp.IsValid() == false) { 415 + printf ("Can't Find Component\n"); 416 + desc.Print(); 417 + exit(1); 418 + } 419 + 420 + CAAUProcessor processor(comp); 421 + processor.AU().Print(); 422 + 423 + CAAudioFile srcFile; 424 + CAAudioFile destFile; 425 + 426 + srcFile.Open(srcFilePath); 427 + 428 + CAStreamBasicDescription procFormat (srcFile.GetFileDataFormat()); 429 + procFormat.SetCanonical (srcFile.GetFileDataFormat().NumberChannels(), false); 430 + 431 + printf ("Processing Format:\n\t"); 432 + procFormat.Print(); 433 + 434 + 435 + if (!shortMemoryProfile) { 436 + FSRef parentDir; 437 + CFStringRef filename; 438 + PosixPathToParentFSRefAndName(destFilePath, parentDir, filename); 439 + destFile.CreateNew (parentDir, filename, 'AIFF', srcFile.GetFileDataFormat()); 440 + destFile.SetClientFormat (procFormat); 441 + } 442 + 443 + srcFile.SetClientFormat (procFormat); 444 + 445 + AUOutputBL outputList(procFormat); 446 + 447 + ReadBuffer* readBuf = NULL; 448 + 449 + #if !CAAF_USE_EXTAUDIOFILE 450 + UInt64 numInputSamples = srcFile.GetNumberPackets(); 451 + #else 452 + UInt64 numInputSamples = srcFile.GetNumberFrames(); 453 + #endif 454 + 455 + if (shortMemoryProfile) { 456 + readBuf = new ReadBuffer; 457 + readBuf->readData = new AUOutputBL(procFormat); 458 + readBuf->readFrames = 0; 459 + UInt32 numFrames = UInt32(procFormat.mSampleRate / 2); 460 + readBuf->readData->Allocate (numFrames); // half a second of audio data 461 + readBuf->readData->Prepare(); // half a second of audio data 462 + 463 + // read 1/2 second of audio into this read buffer 464 + srcFile.Read (numFrames, readBuf->readData->ABL()); 465 + 466 + sInputCallback.inputProc = MemoryInputCallback; 467 + sInputCallback.inputProcRefCon = readBuf; 468 + numInputSamples = numFrames; 469 + } 470 + else { 471 + if (desc.IsFConv()) { 472 + maxFramesToUse = userSetFrames == -1 ? 512 : maxFramesToUse; 473 + // some format converter's can call you several times in small granularities 474 + // so you can't use a large buffer to render or you won't return all of the input data 475 + // this also lessens the final difference between what you should get and what you do 476 + // converter units *really* should have a version that are offline AU's to 477 + // handle this for you. 478 + sInputCallback.inputProc = FConvInputCallback; 479 + } else 480 + sInputCallback.inputProc = InputCallback; 481 + 482 + sInputCallback.inputProcRefCon = &srcFile; 483 + } 484 + 485 + OSStatus result; 486 + require_noerr (result = processor.EstablishInputCallback (sInputCallback), home); 487 + require_noerr (result = processor.SetMaxFramesPerRender (maxFramesToUse), home); 488 + processor.SetMaxTailTime (maxTailTimeSecs); 489 + require_noerr (result = processor.Initialize (procFormat, numInputSamples), home); 490 + if (presetDict) { 491 + require_noerr (result = processor.SetAUPreset (presetDict), home); 492 + CFRelease (presetDict); 493 + } 494 + // this does ALL of the preflighting.. could be specialise for an OfflineAU type 495 + // to do this piecemeal and do a progress bar by using the OfflineAUPreflight method 496 + require_noerr (result = processor.Preflight (), home); 497 + 498 + bool isDone; isDone = false; 499 + bool needsPostProcessing; 500 + bool isSilence; 501 + UInt32 numFrames; numFrames = processor.MaxFramesPerRender(); 502 + 503 + #if CA_AU_PROFILE_TIME 504 + sReadTime = 0; 505 + sRenderTime = 0; 506 + #endif 507 + 508 + PRINT_MARKS(); 509 + // this is the render loop 510 + while (!isDone) 511 + { 512 + #if CA_AU_PROFILE_TIME 513 + UInt64 now = CAHostTimeBase::GetTheCurrentTime(); 514 + #endif 515 + outputList.Prepare(); // have to do this every time... 516 + require_noerr (result = processor.Render (outputList.ABL(), numFrames, isSilence, &isDone, 517 + &needsPostProcessing), home); 518 + #if CA_AU_PROFILE_TIME 519 + sRenderTime += (CAHostTimeBase::GetTheCurrentTime() - now); 520 + #endif 521 + 522 + if (!shortMemoryProfile) 523 + PRINT_PROGRESS(processor.GetOLPercentComplete()); 524 + else 525 + PRINT_PROGRESS(((processor.SampleTime() / numInputSamples) * 100.)); 526 + 527 + if (numFrames && !shortMemoryProfile) 528 + destFile.Write (numFrames, outputList.ABL()); 529 + } 530 + 531 + // this is the postprocessing if needed 532 + if (!shortMemoryProfile && needsPostProcessing) 533 + { 534 + isDone = false; 535 + numFrames = processor.MaxFramesPerRender(); 536 + while (!isDone) { 537 + outputList.Prepare(); // have to do this every time... 538 + #if CA_AU_PROFILE_TIME 539 + UInt64 now = CAHostTimeBase::GetTheCurrentTime(); 540 + #endif 541 + require_noerr (result = processor.PostProcess (outputList.ABL(), numFrames, 542 + isSilence, isDone), home); 543 + #if CA_AU_PROFILE_TIME 544 + sRenderTime += (CAHostTimeBase::GetTheCurrentTime() - now); 545 + #endif 546 + 547 + PRINT_PROGRESS(processor.GetOLPercentComplete()); 548 + 549 + if (numFrames && !shortMemoryProfile) 550 + destFile.Write (numFrames, outputList.ABL()); 551 + } 552 + } 553 + 554 + printf ("\n"); 555 + 556 + home: 557 + if (result) { 558 + printf ("Exit with bad result:%ld\n", result); 559 + exit(result); 560 + } 561 + 562 + if (readBuf) { 563 + delete readBuf->readData; 564 + delete readBuf; 565 + } 566 + 567 + #if CA_AU_PROFILE_TIME 568 + if (!shortMemoryProfile) { 569 + // this flushes any remaing data to be written to the disk. 570 + // the source file is closed in its destructor of course 571 + destFile.Close(); 572 + // open the file again, to get stats about it for profiling 573 + destFile.Open(destFilePath); 574 + } 575 + 576 + SInt64 numWritten; 577 + if (shortMemoryProfile) 578 + numWritten = 0; 579 + else { 580 + #if !CAAF_USE_EXTAUDIOFILE 581 + numWritten = destFile.GetNumberPackets(); 582 + #else 583 + numWritten = destFile.GetNumberFrames(); 584 + #endif 585 + } 586 + 587 + printf ("Read File Time:%.2f secs for %lld packets (%.1f secs), wrote %lld packets\n", 588 + (CAHostTimeBase::ConvertToNanos (sReadTime) / 1.0e9), 589 + numInputSamples, 590 + (numInputSamples / procFormat.mSampleRate), 591 + numWritten); 592 + 593 + if (!shortMemoryProfile) 594 + { 595 + #if !CAAF_USE_EXTAUDIOFILE 596 + UInt64 numOutputSamples = destFile.GetNumberPackets(); 597 + #else 598 + UInt64 numOutputSamples = destFile.GetNumberFrames(); 599 + #endif 600 + 601 + if (numOutputSamples == numInputSamples) { 602 + printf ("\tWrote the same number of packets as read\n"); 603 + } else { 604 + bool expectationMet = !desc.IsOffline(); // we don't have any expectations for offline AU's 605 + if (processor.LatencySampleCount() || processor.TailSampleCount()) { 606 + if (numOutputSamples - numInputSamples == processor.TailSampleCount()) 607 + expectationMet = true; 608 + if (expectationMet) 609 + printf ("Correctly wrote \'Read Size + Tail\'. "); 610 + printf ("AU reports (samples): %ld latency, %ld tail\n", 611 + processor.LatencySampleCount(), processor.TailSampleCount()); 612 + } 613 + if (expectationMet == false) 614 + { 615 + if (numOutputSamples > numInputSamples) { 616 + printf ("\tWrote %lld packets (%.2f secs) more than read\n", 617 + (numOutputSamples - numInputSamples), 618 + ((numOutputSamples - numInputSamples) / procFormat.mSampleRate)); 619 + } else { 620 + printf ("\tRead %lld packets (%.2f secs) more than wrote\n", 621 + (numInputSamples - numOutputSamples), 622 + ((numInputSamples - numOutputSamples) / procFormat.mSampleRate)); 623 + } 624 + } 625 + } 626 + } 627 + 628 + Float64 renderTimeSecs = CAHostTimeBase::ConvertToNanos (sRenderTime - sReadTime) / 1.0e9; 629 + printf ("Total Render Time:%.2f secs, using render slice size of %ld frames\n", 630 + renderTimeSecs, maxFramesToUse); 631 + 632 + Float64 cpuUsage; 633 + if (shortMemoryProfile) 634 + cpuUsage = (renderTimeSecs / 0.5) * 100.; 635 + else 636 + cpuUsage = (renderTimeSecs / (numInputSamples / procFormat.mSampleRate)) * 100.; 637 + printf ("CPU Usage for Render Time:%.2f%%\n", cpuUsage); 638 + 639 + CFStringRef str = comp.GetCompName(); 640 + UInt32 compNameLen = CFStringGetLength (str); 641 + 642 + CFStringRef presetName = NULL; 643 + if (auPresetFile) { 644 + CFPropertyListRef dict; 645 + if (processor.AU().GetAUPreset (dict) == noErr) { 646 + presetName = (CFStringRef)CFDictionaryGetValue((CFDictionaryRef)dict, CFSTR("name")); 647 + CFRelease (dict); 648 + } 649 + } 650 + 651 + UInt32 presetLen = presetName ? CFStringGetLength(presetName) : 0; 652 + 653 + char* cstr = (char*)malloc (compNameLen + presetLen + 2 + 1); 654 + CFStringGetCString (str, cstr, (CFStringGetLength (str) + 1), kCFStringEncodingASCII); 655 + if (presetName) { 656 + cstr[compNameLen] = ':'; 657 + cstr[compNameLen+1] = ':'; 658 + CFStringGetCString (presetName, cstr + compNameLen + 2, (CFStringGetLength (presetName) + 1), kCFStringEncodingASCII); 659 + } 660 + PerfResult("AudioUnitProcess", EndianU32_NtoB(comp.Desc().componentSubType), cstr, cpuUsage, "%realtime"); 661 + free (cstr); 662 + #endif 663 + 664 + 665 + } 666 + catch (CAXException &e) { 667 + char buf[256]; 668 + printf("Error: %s (%s)\n", e.mOperation, e.FormatError(buf, sizeof(buf))); 669 + exit(1); 670 + } 671 + catch (...) { 672 + printf("An unknown error occurred\n"); 673 + exit(1); 674 + } 675 + 676 + return 0; 677 + } 678 +
+461
src/CoreAudio/AudioFileTools/auprofile.cpp
··· 1 + /* Copyright: � Copyright 2005 Apple Computer, Inc. All rights reserved. 2 + 3 + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. 4 + ("Apple") in consideration of your agreement to the following terms, and your 5 + use, installation, modification or redistribution of this Apple software 6 + constitutes acceptance of these terms. If you do not agree with these terms, 7 + please do not use, install, modify or redistribute this Apple software. 8 + 9 + In consideration of your agreement to abide by the following terms, and subject 10 + to these terms, Apple grants you a personal, non-exclusive license, under Apple�s 11 + copyrights in this original Apple software (the "Apple Software"), to use, 12 + reproduce, modify and redistribute the Apple Software, with or without 13 + modifications, in source and/or binary forms; provided that if you redistribute 14 + the Apple Software in its entirety and without modifications, you must retain 15 + this notice and the following text and disclaimers in all such redistributions of 16 + the Apple Software. Neither the name, trademarks, service marks or logos of 17 + Apple Computer, Inc. may be used to endorse or promote products derived from the 18 + Apple Software without specific prior written permission from Apple. Except as 19 + expressly stated in this notice, no other rights or licenses, express or implied, 20 + are granted by Apple herein, including but not limited to any patent rights that 21 + may be infringed by your derivative works or by other works in which the Apple 22 + Software may be incorporated. 23 + 24 + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO 25 + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED 26 + WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 + PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN 28 + COMBINATION WITH YOUR PRODUCTS. 29 + 30 + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR 31 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 32 + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 + ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION 34 + OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT 35 + (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN 36 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + /*============================================================================= 39 + auprofile.cpp 40 + 41 + =============================================================================*/ 42 + 43 + /* 44 + auprofile 45 + - takes a source audio file, an AU and processes this for performance metrics 46 + */ 47 + 48 + #include "CAAUProcessor.h" 49 + #include "CAAudioFile.h" 50 + #include "CAXException.h" 51 + #include "CAHostTimeBase.h" 52 + #include "CAFilePathUtils.h" 53 + #include "CAAudioFileFormats.h" 54 + 55 + #if TARGET_OS_MAC 56 + #include <pthread.h> 57 + #include <mach/mach.h> 58 + #endif 59 + 60 + #if DEBUG 61 + #define VERBOSE 0 62 + #endif 63 + 64 + UInt64 sLastReadTime = 0; 65 + Float64 sMinTime = 9999999999.; // too big a time! 66 + Float64 sMaxTime = 0; 67 + 68 + #pragma mark __print helpers 69 + 70 + void PerfResult(const char *toolname, int group, const char *testname, double value, const char *units, const char *fmt="%.3f") 71 + { 72 + printf("<result tool='%s' group='%d' test='%s' value='", toolname, group, testname); 73 + printf(fmt, value); 74 + printf("' units='%s' />\n", units); 75 + } 76 + 77 + #pragma mark __Inpput Callback Definitions 78 + 79 + 80 + // the file is read into memory - the input's role is to parse through this memory 81 + 82 + struct ReadBuffer { 83 + AUOutputBL *readData; 84 + UInt64 totalInputFrames; 85 + UInt32 lastInputFrames; 86 + }; 87 + 88 + const int kEndOfInput = 12345; 89 + 90 + static OSStatus MemoryInputCallback (void *inRefCon, 91 + AudioUnitRenderActionFlags *ioActionFlags, 92 + const AudioTimeStamp *inTimeStamp, 93 + UInt32 inBusNumber, 94 + UInt32 inNumberFrames, 95 + AudioBufferList *ioData) 96 + { 97 + UInt64 now = CAHostTimeBase::GetTheCurrentTime(); 98 + OSStatus result = 0; 99 + 100 + ReadBuffer *readBuffer = (ReadBuffer*)inRefCon; 101 + if (inTimeStamp->mSampleTime >= readBuffer->totalInputFrames) { 102 + #if VERBOSE 103 + printf ("reading: %.0f past input: %.0f\n", inTimeStamp->mSampleTime, 104 + (double)readBuffer->totalInputFrames); 105 + #endif 106 + result = kEndOfInput; 107 + readBuffer->lastInputFrames = 0; 108 + goto end; 109 + } 110 + 111 + // can get pulled multiple times 112 + readBuffer->lastInputFrames += inNumberFrames; 113 + 114 + if (UInt64(inTimeStamp->mSampleTime + inNumberFrames) > readBuffer->totalInputFrames) { 115 + // first set this to zero as we're only going to read a partial number of frames 116 + AudioBuffer *buf = ioData->mBuffers; 117 + for (UInt32 i = ioData->mNumberBuffers; i--; ++buf) 118 + memset((Byte *)buf->mData, 0, buf->mDataByteSize); 119 + 120 + inNumberFrames = UInt32 (readBuffer->totalInputFrames - UInt64(inTimeStamp->mSampleTime)); 121 + } 122 + 123 + // copy data from the source to the ioData buffers 124 + { 125 + AudioBuffer *buf = ioData->mBuffers; 126 + AudioBuffer *rBuf = readBuffer->readData->ABL()->mBuffers; 127 + for (UInt32 i = ioData->mNumberBuffers; i--; ++buf, ++rBuf) { 128 + AudioBuffer readB = *rBuf; 129 + readB.mData = static_cast<Float32*>(rBuf->mData) + UInt32(inTimeStamp->mSampleTime); 130 + memcpy (buf->mData, readB.mData, (inNumberFrames * sizeof(Float32))); 131 + } 132 + } 133 + 134 + end: 135 + sLastReadTime += (CAHostTimeBase::GetTheCurrentTime() - now); 136 + 137 + return result; 138 + } 139 + 140 + #pragma mark __Utility Helpers 141 + 142 + CFPropertyListRef ReadPresetFromPresetFile (char* filePath) 143 + { 144 + if (!filePath) 145 + return NULL; 146 + 147 + FSRef ref; 148 + if (FSPathMakeRef((UInt8 *)filePath, &ref, NULL)) 149 + return NULL; 150 + 151 + CFDataRef resourceData = NULL; 152 + CFPropertyListRef theData = NULL; 153 + CFStringRef errString = NULL; 154 + CFURLRef fileURL = CFURLCreateFromFSRef (kCFAllocatorDefault, &ref); 155 + if (fileURL == NULL) { 156 + goto home; 157 + } 158 + 159 + SInt32 result; 160 + 161 + // Read the XML file. 162 + Boolean status; status = CFURLCreateDataAndPropertiesFromResource (kCFAllocatorDefault, fileURL, 163 + &resourceData, // place to put file data 164 + NULL, NULL, &result); 165 + if (status == false || result) { 166 + goto home; 167 + } 168 + 169 + theData = CFPropertyListCreateFromXMLData (kCFAllocatorDefault, resourceData, 170 + kCFPropertyListImmutable, &errString); 171 + if (theData == NULL || errString) { 172 + if (theData) 173 + CFRelease (theData); 174 + theData = NULL; 175 + goto home; 176 + } 177 + 178 + home: 179 + if (fileURL) 180 + CFRelease (fileURL); 181 + if (resourceData) 182 + CFRelease (resourceData); 183 + if (errString) 184 + CFRelease (errString); 185 + 186 + return theData; 187 + } 188 + 189 + #pragma mark __the setup code 190 + 191 + #define OFFLINE_AU_CMD "[-au TYPE SUBTYPE MANU] The Audio Unit component description\n\t" 192 + #define INPUT_FILE "[-i /Path/To/File] The file that is to be processed.\n\t" 193 + #define AU_PRESET_CMD "[-p /Path/To/AUPreset/File] Specify an AU Preset File to establish the state of the AU\n\t" 194 + #define USE_MAX_FRAMES "[-f max_frames] default is 4096" 195 + 196 + static char* usageStr = "Usage: auprofile\n\t" 197 + OFFLINE_AU_CMD 198 + INPUT_FILE 199 + AU_PRESET_CMD 200 + USE_MAX_FRAMES; 201 + 202 + int main(int argc, const char * argv[]) 203 + { 204 + #if TARGET_OS_MAC 205 + { 206 + thread_extended_policy_data_t theFixedPolicy; 207 + theFixedPolicy.timeshare = false; // set to true for a non-fixed thread 208 + thread_policy_set(pthread_mach_thread_np(pthread_self()), 209 + THREAD_EXTENDED_POLICY, 210 + (thread_policy_t)&theFixedPolicy, 211 + THREAD_EXTENDED_POLICY_COUNT); 212 + 213 + // We keep a reference to the spawning thread's priority around (initialized in the constructor), 214 + // and set the importance of the child thread relative to the spawning thread's priority. 215 + thread_precedence_policy_data_t thePrecedencePolicy; 216 + 217 + thePrecedencePolicy.importance = 63 - 36; 218 + thread_policy_set(pthread_mach_thread_np(pthread_self()), 219 + THREAD_PRECEDENCE_POLICY, 220 + (thread_policy_t)&thePrecedencePolicy, 221 + THREAD_PRECEDENCE_POLICY_COUNT); 222 + } 223 + #endif 224 + 225 + 226 + // These are the variables that are set up from the input parsing 227 + char* srcFilePath = NULL; 228 + char* auPresetFile = NULL; 229 + OSType manu, subType, type = 0; 230 + UInt32 numFrames = 4096; 231 + 232 + for (int i = 1; i < argc; ++i) 233 + { 234 + if (strcmp (argv[i], "-au") == 0) { 235 + if ( (i + 3) < argc ) { 236 + StrToOSType (argv[i + 1], type); 237 + StrToOSType (argv[i + 2], subType); 238 + StrToOSType (argv[i + 3], manu); 239 + i += 3; 240 + } else { 241 + printf ("Which Audio Unit:\n%s", usageStr); 242 + exit(1); 243 + } 244 + } 245 + else if (strcmp (argv[i], "-i") == 0) { 246 + srcFilePath = const_cast<char*>(argv[++i]); 247 + } 248 + else if (strcmp (argv[i], "-p") == 0) { 249 + auPresetFile = const_cast<char*>(argv[++i]); 250 + } 251 + else if (strcmp (argv[i], "-f") == 0) { 252 + sscanf(argv[++i], "%ld", &numFrames); 253 + } 254 + else { 255 + printf ("%s\n", usageStr); 256 + exit(1); 257 + } 258 + } 259 + 260 + if (!type || !srcFilePath) { 261 + printf ("%s\n", usageStr); 262 + exit(1); 263 + } 264 + 265 + CAComponentDescription desc(type, subType, manu); 266 + 267 + CFPropertyListRef presetDict = ReadPresetFromPresetFile(auPresetFile); 268 + 269 + #pragma mark - 270 + #pragma mark __ The driving code 271 + #pragma mark - 272 + 273 + try 274 + { 275 + CAComponent comp(desc); 276 + 277 + // CAAUProcessor's constructor throws... so make sure the component is valid 278 + if (comp.IsValid() == false) { 279 + printf ("Can't Find Component\n"); 280 + desc.Print(); 281 + exit(1); 282 + } 283 + 284 + CAAUProcessor processor(comp); 285 + processor.AU().Comp().Print(); 286 + 287 + CAAudioFile srcFile; 288 + 289 + srcFile.Open(srcFilePath); 290 + 291 + #if !CAAF_USE_EXTAUDIOFILE 292 + UInt64 numInputSamples = srcFile.GetNumberPackets(); 293 + #else 294 + UInt64 numInputSamples = srcFile.GetNumberFrames(); 295 + #endif 296 + 297 + Float64 inputSecs = (numInputSamples / srcFile.GetFileDataFormat().mSampleRate); 298 + 299 + CAStreamBasicDescription procFormat (srcFile.GetFileDataFormat()); 300 + procFormat.SetCanonical (srcFile.GetFileDataFormat().NumberChannels(), false); 301 + 302 + printf ("Processing file: %s, %.1f secs [proc: %ld frames]\n", srcFilePath, inputSecs, numFrames); 303 + #if VERBOSE 304 + printf("\t"); 305 + procFormat.Print(); 306 + #endif 307 + 308 + srcFile.SetClientFormat (procFormat); 309 + 310 + AUOutputBL outputList(procFormat); 311 + 312 + // read the entire file into memory 313 + ReadBuffer* readBuf = new ReadBuffer; 314 + readBuf->readData = new AUOutputBL(procFormat); 315 + readBuf->totalInputFrames = numInputSamples; 316 + readBuf->readData->Allocate (numInputSamples); 317 + readBuf->readData->Prepare(); 318 + UInt32 readSamps = (UInt32)numInputSamples; 319 + srcFile.Read (readSamps, readBuf->readData->ABL()); 320 + 321 + AURenderCallbackStruct inputCallback; 322 + inputCallback.inputProc = MemoryInputCallback; 323 + inputCallback.inputProcRefCon = readBuf; 324 + 325 + OSStatus result; 326 + require_noerr (result = processor.EstablishInputCallback (inputCallback), home); 327 + require_noerr (result = processor.SetMaxFramesPerRender (numFrames), home); 328 + require_noerr (result = processor.Initialize (procFormat, numInputSamples), home); 329 + if (presetDict) { 330 + require_noerr (result = processor.SetAUPreset (presetDict), home); 331 + CFRelease (presetDict); 332 + } 333 + // this does ALL of the preflighting.. could be specialise for an OfflineAU type 334 + // to do this piecemeal and do a progress bar by using the OfflineAUPreflight method 335 + readBuf->lastInputFrames = 0; 336 + require_noerr (result = processor.Preflight (), home); 337 + 338 + float mean; 339 + 340 + // now do the processing.... 341 + { 342 + const int kThrasherSize = 4000000; 343 + char* thrasher = new char[kThrasherSize]; 344 + 345 + bool isDone = false; 346 + 347 + UInt32 numMeasures = 0; 348 + Float64 totalMSqrd; 349 + Float64 totalM; 350 + 351 + int i = 0; 352 + int discardResults = 3; 353 + 354 + // this is the render loop 355 + while (!isDone) 356 + { 357 + bool isSilence, postProcess; 358 + 359 + outputList.Prepare(); // have to do this every time... 360 + readBuf->lastInputFrames = 0; 361 + sLastReadTime = 0; 362 + memset (thrasher, numMeasures, kThrasherSize); 363 + 364 + UInt64 now = CAHostTimeBase::GetTheCurrentTime(); 365 + require_noerr (result = processor.Render (outputList.ABL(), numFrames, isSilence, &isDone, &postProcess), home); 366 + UInt64 renderTime = (CAHostTimeBase::GetTheCurrentTime() - now); 367 + 368 + if (i++ < discardResults) continue; 369 + if (!readBuf->lastInputFrames) break; 370 + 371 + Float64 renderTimeSecs = CAHostTimeBase::ConvertToNanos (renderTime - sLastReadTime) / 1.0e9; 372 + 373 + Float64 cpuTime = (renderTimeSecs / (readBuf->lastInputFrames / procFormat.mSampleRate)) * 100.; 374 + numMeasures++; 375 + 376 + totalMSqrd += (cpuTime * cpuTime); 377 + totalM += cpuTime; 378 + 379 + if (cpuTime > sMaxTime) 380 + sMaxTime = cpuTime; 381 + if (cpuTime < sMinTime) 382 + sMinTime = cpuTime; 383 + 384 + #if VERBOSE 385 + // printf ("current measure: %.2f\n", cpuTime); 386 + if (numMeasures % 5 == 0) { 387 + Float64 mean = totalM / numMeasures; 388 + // stdDev = (sum of Xsquared -((sum of X)*(sum of X)/N)) / (N-1)) 389 + Float64 stdDev = sqrt ((totalMSqrd - ((totalM * totalM) / numMeasures)) / (numMeasures-1.0)); 390 + printf ("ave: %.2f, min: %.2f, max: %.2f, stdev: %.2f, numMeasures: %ld, current: %f\n", 391 + mean, sMinTime, sMaxTime, stdDev, numMeasures, cpuTime); 392 + } 393 + #endif 394 + } 395 + delete [] thrasher; 396 + 397 + mean = totalM / numMeasures; 398 + // stdDev = (sum of Xsquared -((sum of X)*(sum of X)/N)) / (N-1)) 399 + Float64 stdDev = sqrt ((totalMSqrd - ((totalM * totalM) / numMeasures)) / (numMeasures-1.0)); 400 + 401 + printf ("ave: %.2f, min: %.2f, max: %.2f, sd: %.2f, sd / mean: %.2f%%\n", 402 + mean, sMinTime, sMaxTime, stdDev, (stdDev / mean * 100.)); 403 + } 404 + 405 + // we don't care about post-processing 406 + 407 + home: 408 + if (result) { 409 + printf ("Exit with bad result:%ld\n", result); 410 + exit(result); 411 + } 412 + 413 + if (readBuf) { 414 + delete readBuf->readData; 415 + delete readBuf; 416 + } 417 + 418 + 419 + CFStringRef str = comp.GetCompName(); 420 + UInt32 compNameLen = CFStringGetLength (str); 421 + 422 + CFStringRef presetName = NULL; 423 + if (auPresetFile) { 424 + CFPropertyListRef dict; 425 + if (processor.AU().GetAUPreset (dict) == noErr) { 426 + presetName = (CFStringRef)CFDictionaryGetValue((CFDictionaryRef)dict, CFSTR("name")); 427 + CFRelease (dict); 428 + } 429 + } 430 + 431 + UInt32 presetLen = presetName ? CFStringGetLength(presetName) : 0; 432 + 433 + UInt32 groupID = comp.Desc().componentSubType; 434 + 435 + char* cstr = (char*)malloc (compNameLen + presetLen + 2 + 1); 436 + CFStringGetCString (str, cstr, (CFStringGetLength (str) + 1), kCFStringEncodingASCII); 437 + if (presetName) { 438 + cstr[compNameLen] = ':'; 439 + cstr[compNameLen+1] = ':'; 440 + CFStringGetCString (presetName, cstr + compNameLen + 2, (CFStringGetLength (presetName) + 1), kCFStringEncodingASCII); 441 + int len = strlen(cstr); 442 + for (int i = 0; i < len; ++i) 443 + groupID += cstr[i]; 444 + } 445 + PerfResult("AU Profile", EndianU32_NtoB(groupID), cstr, mean, "%realtime"); 446 + free (cstr); 447 + 448 + } 449 + catch (CAXException &e) { 450 + char buf[256]; 451 + printf("Error: %s (%s)\n", e.mOperation, e.FormatError(buf)); 452 + exit(1); 453 + } 454 + catch (...) { 455 + printf("An unknown error occurred\n"); 456 + exit(1); 457 + } 458 + 459 + return 0; 460 + } 461 +
+1
src/CoreAudio/CMakeLists.txt
··· 23 23 add_subdirectory(AudioToolbox) 24 24 add_subdirectory(CoreAudioComponent) 25 25 add_subdirectory(AFAVFormatComponent) 26 + add_subdirectory(AudioFileTools)
+1 -1
src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAAudioUnit.cpp
··· 48 48 49 49 #if !TARGET_OS_IPHONE 50 50 #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__) 51 - #include <CoreServices/../Frameworks/CarbonCore.framework/Headers/Components.h> 51 + #include <CoreServices/Components.h> 52 52 #include <dlfcn.h> 53 53 #else 54 54 #include <Components.h>
+1
src/CoreAudio/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAFilePathUtils.h
··· 63 63 #if !TARGET_OS_WIN32 64 64 #include <libgen.h> 65 65 #else 66 + #error 66 67 char* dirname(const char* inPath); 67 68 char* basename(const char* inPath); 68 69 #endif