snd_next.m (68175B)
1 2 #import <servers/netname.h> 3 #import <libc.h> 4 5 #include "../client/client.h" 6 7 double snd_basetime; 8 port_t devPort; 9 10 extern port_t task_self_; 11 #define task_self() task_self_ 12 13 //======================================================================== 14 15 #ifndef _ntsoundNTSound 16 #define _ntsoundNTSound 17 18 /* Module NTSound */ 19 20 #include <mach/kern_return.h> 21 #include <mach/port.h> 22 #include <mach/message.h> 23 24 #ifndef mig_external 25 #define mig_external extern 26 #endif 27 28 #include <mach/std_types.h> 29 #include <mach/mach_types.h> 30 typedef short *sound_data_t; 31 32 #define NTSOUNDNAME "NEXTIME_Sound" 33 34 /* Routine ntsoundAcquire */ 35 mig_external kern_return_t ntsoundAcquire ( 36 port_t kern_serv_port, 37 port_t owner_port, 38 vm_offset_t *dmaAddress, 39 int *dmaSize, 40 int *success); 41 42 /* Routine ntsoundRelease */ 43 mig_external kern_return_t ntsoundRelease ( 44 port_t kern_serv_port, 45 port_t owner_port); 46 47 /* Routine ntsoundStart */ 48 mig_external kern_return_t ntsoundStart ( 49 port_t kern_serv_port, 50 port_t owner_port); 51 52 /* Routine ntsoundStop */ 53 mig_external kern_return_t ntsoundStop ( 54 port_t kern_serv_port, 55 port_t owner_port); 56 57 /* Routine ntsoundConfig */ 58 mig_external kern_return_t ntsoundConfig ( 59 port_t kern_serv_port, 60 port_t owner_port, 61 int channelCount, 62 int samplingRate, 63 int encoding, 64 int useInterrupts); 65 66 /* Routine ntsoundBytesProcessed */ 67 mig_external kern_return_t ntsoundBytesProcessed ( 68 port_t kern_serv_port, 69 port_t owner_port, 70 int *byte_count); 71 72 /* Routine ntsoundDMACount */ 73 mig_external kern_return_t ntsoundDMACount ( 74 port_t kern_serv_port, 75 port_t owner_port, 76 int *dma_count); 77 78 /* Routine ntsoundInterruptCount */ 79 mig_external kern_return_t ntsoundInterruptCount ( 80 port_t kern_serv_port, 81 port_t owner_port, 82 int *irq_count); 83 84 /* Routine ntsoundWrite */ 85 mig_external kern_return_t ntsoundWrite ( 86 port_t kern_serv_port, 87 port_t owner_port, 88 sound_data_t data, 89 unsigned int dataCnt, 90 int *actual_count); 91 92 /* Routine ntsoundSetVolume */ 93 mig_external kern_return_t ntsoundSetVolume ( 94 port_t kern_serv_port, 95 port_t owner_port, 96 int value); 97 98 /* Routine ntsoundWireRange */ 99 mig_external kern_return_t ntsoundWireRange ( 100 port_t device_port, 101 port_t token, 102 port_t task, 103 vm_offset_t addr, 104 vm_size_t size, 105 boolean_t wire); 106 107 #endif _ntsoundNTSound 108 109 //======================================================================== 110 111 extern port_t name_server_port; 112 113 #define NX_SoundDeviceParameterKeyBase 0 114 #define NX_SoundDeviceParameterValueBase 200 115 #define NX_SoundStreamParameterKeyBase 400 116 #define NX_SoundStreamParameterValueBase 600 117 #define NX_SoundParameterTagMax 799 118 119 typedef enum _NXSoundParameterTag { 120 NX_SoundDeviceBufferSize = NX_SoundDeviceParameterKeyBase, 121 NX_SoundDeviceBufferCount, 122 NX_SoundDeviceDetectPeaks, 123 NX_SoundDeviceRampUp, 124 NX_SoundDeviceRampDown, 125 NX_SoundDeviceInsertZeros, 126 NX_SoundDeviceDeemphasize, 127 NX_SoundDeviceMuteSpeaker, 128 NX_SoundDeviceMuteHeadphone, 129 NX_SoundDeviceMuteLineOut, 130 NX_SoundDeviceOutputLoudness, 131 NX_SoundDeviceOutputAttenuationStereo, 132 NX_SoundDeviceOutputAttenuationLeft, 133 NX_SoundDeviceOutputAttenuationRight, 134 NX_SoundDeviceAnalogInputSource, 135 NX_SoundDeviceMonitorAttenuation, 136 NX_SoundDeviceInputGainStereo, 137 NX_SoundDeviceInputGainLeft, 138 NX_SoundDeviceInputGainRight, 139 140 NX_SoundDeviceAnalogInputSource_Microphone 141 = NX_SoundDeviceParameterValueBase, 142 NX_SoundDeviceAnalogInputSource_LineIn, 143 144 NX_SoundStreamDataEncoding = NX_SoundStreamParameterKeyBase, 145 NX_SoundStreamSamplingRate, 146 NX_SoundStreamChannelCount, 147 NX_SoundStreamHighWaterMark, 148 NX_SoundStreamLowWaterMark, 149 NX_SoundStreamSource, 150 NX_SoundStreamSink, 151 NX_SoundStreamDetectPeaks, 152 NX_SoundStreamGainStereo, 153 NX_SoundStreamGainLeft, 154 NX_SoundStreamGainRight, 155 156 NX_SoundStreamDataEncoding_Linear16 = NX_SoundStreamParameterValueBase, 157 NX_SoundStreamDataEncoding_Linear8, 158 NX_SoundStreamDataEncoding_Mulaw8, 159 NX_SoundStreamDataEncoding_Alaw8, 160 NX_SoundStreamDataEncoding_AES, 161 NX_SoundStreamSource_Analog, 162 NX_SoundStreamSource_AES, 163 NX_SoundStreamSink_Analog, 164 NX_SoundStreamSink_AES 165 } NXSoundParameterTag; 166 167 //======================================================================== 168 169 //#include "NTSound.h" 170 #include <mach/mach_types.h> 171 #include <mach/message.h> 172 #include <mach/mig_errors.h> 173 #include <mach/msg_type.h> 174 #if !defined(KERNEL) && !defined(MIG_NO_STRINGS) 175 #include <strings.h> 176 #endif 177 /* LINTLIBRARY */ 178 179 extern port_t mig_get_reply_port(); 180 extern void mig_dealloc_reply_port(); 181 182 #ifndef mig_internal 183 #define mig_internal static 184 #endif 185 186 #ifndef TypeCheck 187 #define TypeCheck 1 188 #endif 189 190 #ifndef UseExternRCSId 191 #ifdef hc 192 #define UseExternRCSId 1 193 #endif 194 #endif 195 196 #ifndef UseStaticMsgType 197 #if !defined(hc) || defined(__STDC__) 198 #define UseStaticMsgType 1 199 #endif 200 #endif 201 202 #define msg_request_port msg_remote_port 203 #define msg_reply_port msg_local_port 204 205 206 /* Routine Acquire */ 207 mig_external kern_return_t ntsoundAcquire ( 208 port_t kern_serv_port, 209 port_t owner_port, 210 vm_offset_t *dmaAddress, 211 int *dmaSize, 212 int *success) 213 { 214 typedef struct { 215 msg_header_t Head; 216 msg_type_t owner_portType; 217 port_t owner_port; 218 } Request; 219 220 typedef struct { 221 msg_header_t Head; 222 msg_type_t RetCodeType; 223 kern_return_t RetCode; 224 msg_type_t dmaAddressType; 225 vm_offset_t dmaAddress; 226 msg_type_t dmaSizeType; 227 int dmaSize; 228 msg_type_t successType; 229 int success; 230 } Reply; 231 232 union { 233 Request In; 234 Reply Out; 235 } Mess; 236 237 register Request *InP = &Mess.In; 238 register Reply *OutP = &Mess.Out; 239 240 msg_return_t msg_result; 241 242 #if TypeCheck 243 boolean_t msg_simple; 244 #endif TypeCheck 245 246 unsigned int msg_size = 32; 247 248 #if UseStaticMsgType 249 static const msg_type_t owner_portType = { 250 /* msg_type_name = */ MSG_TYPE_PORT, 251 /* msg_type_size = */ 32, 252 /* msg_type_number = */ 1, 253 /* msg_type_inline = */ TRUE, 254 /* msg_type_longform = */ FALSE, 255 /* msg_type_deallocate = */ FALSE, 256 /* msg_type_unused = */ 0, 257 }; 258 #endif UseStaticMsgType 259 260 #if UseStaticMsgType 261 static const msg_type_t RetCodeCheck = { 262 /* msg_type_name = */ MSG_TYPE_INTEGER_32, 263 /* msg_type_size = */ 32, 264 /* msg_type_number = */ 1, 265 /* msg_type_inline = */ TRUE, 266 /* msg_type_longform = */ FALSE, 267 /* msg_type_deallocate = */ FALSE, 268 /* msg_type_unused = */ 0 269 }; 270 #endif UseStaticMsgType 271 272 #if UseStaticMsgType 273 static const msg_type_t dmaAddressCheck = { 274 /* msg_type_name = */ MSG_TYPE_INTEGER_32, 275 /* msg_type_size = */ 32, 276 /* msg_type_number = */ 1, 277 /* msg_type_inline = */ TRUE, 278 /* msg_type_longform = */ FALSE, 279 /* msg_type_deallocate = */ FALSE, 280 /* msg_type_unused = */ 0 281 }; 282 #endif UseStaticMsgType 283 284 #if UseStaticMsgType 285 static const msg_type_t dmaSizeCheck = { 286 /* msg_type_name = */ MSG_TYPE_INTEGER_32, 287 /* msg_type_size = */ 32, 288 /* msg_type_number = */ 1, 289 /* msg_type_inline = */ TRUE, 290 /* msg_type_longform = */ FALSE, 291 /* msg_type_deallocate = */ FALSE, 292 /* msg_type_unused = */ 0 293 }; 294 #endif UseStaticMsgType 295 296 #if UseStaticMsgType 297 static const msg_type_t successCheck = { 298 /* msg_type_name = */ MSG_TYPE_INTEGER_32, 299 /* msg_type_size = */ 32, 300 /* msg_type_number = */ 1, 301 /* msg_type_inline = */ TRUE, 302 /* msg_type_longform = */ FALSE, 303 /* msg_type_deallocate = */ FALSE, 304 /* msg_type_unused = */ 0 305 }; 306 #endif UseStaticMsgType 307 308 #if UseStaticMsgType 309 InP->owner_portType = owner_portType; 310 #else UseStaticMsgType 311 InP->owner_portType.msg_type_name = MSG_TYPE_PORT; 312 InP->owner_portType.msg_type_size = 32; 313 InP->owner_portType.msg_type_number = 1; 314 InP->owner_portType.msg_type_inline = TRUE; 315 InP->owner_portType.msg_type_longform = FALSE; 316 InP->owner_portType.msg_type_deallocate = FALSE; 317 #endif UseStaticMsgType 318 319 InP->owner_port /* owner_port */ = /* owner_port */ owner_port; 320 321 InP->Head.msg_simple = FALSE; 322 InP->Head.msg_size = msg_size; 323 InP->Head.msg_type = MSG_TYPE_NORMAL | MSG_TYPE_RPC; 324 InP->Head.msg_request_port = kern_serv_port; 325 InP->Head.msg_reply_port = mig_get_reply_port(); 326 InP->Head.msg_id = 1008; 327 328 msg_result = msg_rpc(&InP->Head, MSG_OPTION_NONE, sizeof(Reply), 0, 0); 329 if (msg_result != RPC_SUCCESS) { 330 if (msg_result == RCV_INVALID_PORT) 331 mig_dealloc_reply_port(); 332 return msg_result; 333 } 334 335 #if TypeCheck 336 msg_size = OutP->Head.msg_size; 337 msg_simple = OutP->Head.msg_simple; 338 #endif TypeCheck 339 340 if (OutP->Head.msg_id != 1108) 341 return MIG_REPLY_MISMATCH; 342 343 #if TypeCheck 344 if (((msg_size != 56) || (msg_simple != TRUE)) && 345 ((msg_size != sizeof(death_pill_t)) || 346 (msg_simple != TRUE) || 347 (OutP->RetCode == KERN_SUCCESS))) 348 return MIG_TYPE_ERROR; 349 #endif TypeCheck 350 351 #if TypeCheck 352 #if UseStaticMsgType 353 if (* (int *) &OutP->RetCodeType != * (int *) &RetCodeCheck) 354 #else UseStaticMsgType 355 if ((OutP->RetCodeType.msg_type_inline != TRUE) || 356 (OutP->RetCodeType.msg_type_longform != FALSE) || 357 (OutP->RetCodeType.msg_type_name != MSG_TYPE_INTEGER_32) || 358 (OutP->RetCodeType.msg_type_number != 1) || 359 (OutP->RetCodeType.msg_type_size != 32)) 360 #endif UseStaticMsgType 361 return MIG_TYPE_ERROR; 362 #endif TypeCheck 363 364 if (OutP->RetCode != KERN_SUCCESS) 365 return OutP->RetCode; 366 367 #if TypeCheck 368 #if UseStaticMsgType 369 if (* (int *) &OutP->dmaAddressType != * (int *) &dmaAddressCheck) 370 #else UseStaticMsgType 371 if ((OutP->dmaAddressType.msg_type_inline != TRUE) || 372 (OutP->dmaAddressType.msg_type_longform != FALSE) || 373 (OutP->dmaAddressType.msg_type_name != MSG_TYPE_INTEGER_32) || 374 (OutP->dmaAddressType.msg_type_number != 1) || 375 (OutP->dmaAddressType.msg_type_size != 32)) 376 #endif UseStaticMsgType 377 return MIG_TYPE_ERROR; 378 #endif TypeCheck 379 380 *dmaAddress /* dmaAddress */ = /* *dmaAddress */ OutP->dmaAddress; 381 382 #if TypeCheck 383 #if UseStaticMsgType 384 if (* (int *) &OutP->dmaSizeType != * (int *) &dmaSizeCheck) 385 #else UseStaticMsgType 386 if ((OutP->dmaSizeType.msg_type_inline != TRUE) || 387 (OutP->dmaSizeType.msg_type_longform != FALSE) || 388 (OutP->dmaSizeType.msg_type_name != MSG_TYPE_INTEGER_32) || 389 (OutP->dmaSizeType.msg_type_number != 1) || 390 (OutP->dmaSizeType.msg_type_size != 32)) 391 #endif UseStaticMsgType 392 return MIG_TYPE_ERROR; 393 #endif TypeCheck 394 395 *dmaSize /* dmaSize */ = /* *dmaSize */ OutP->dmaSize; 396 397 #if TypeCheck 398 #if UseStaticMsgType 399 if (* (int *) &OutP->successType != * (int *) &successCheck) 400 #else UseStaticMsgType 401 if ((OutP->successType.msg_type_inline != TRUE) || 402 (OutP->successType.msg_type_longform != FALSE) || 403 (OutP->successType.msg_type_name != MSG_TYPE_INTEGER_32) || 404 (OutP->successType.msg_type_number != 1) || 405 (OutP->successType.msg_type_size != 32)) 406 #endif UseStaticMsgType 407 return MIG_TYPE_ERROR; 408 #endif TypeCheck 409 410 *success /* success */ = /* *success */ OutP->success; 411 412 return OutP->RetCode; 413 } 414 415 /* Routine Release */ 416 mig_external kern_return_t ntsoundRelease ( 417 port_t kern_serv_port, 418 port_t owner_port) 419 { 420 typedef struct { 421 msg_header_t Head; 422 msg_type_t owner_portType; 423 port_t owner_port; 424 } Request; 425 426 typedef struct { 427 msg_header_t Head; 428 msg_type_t RetCodeType; 429 kern_return_t RetCode; 430 } Reply; 431 432 union { 433 Request In; 434 Reply Out; 435 } Mess; 436 437 register Request *InP = &Mess.In; 438 register Reply *OutP = &Mess.Out; 439 440 msg_return_t msg_result; 441 442 #if TypeCheck 443 boolean_t msg_simple; 444 #endif TypeCheck 445 446 unsigned int msg_size = 32; 447 448 #if UseStaticMsgType 449 static const msg_type_t owner_portType = { 450 /* msg_type_name = */ MSG_TYPE_PORT, 451 /* msg_type_size = */ 32, 452 /* msg_type_number = */ 1, 453 /* msg_type_inline = */ TRUE, 454 /* msg_type_longform = */ FALSE, 455 /* msg_type_deallocate = */ FALSE, 456 /* msg_type_unused = */ 0, 457 }; 458 #endif UseStaticMsgType 459 460 #if UseStaticMsgType 461 static const msg_type_t RetCodeCheck = { 462 /* msg_type_name = */ MSG_TYPE_INTEGER_32, 463 /* msg_type_size = */ 32, 464 /* msg_type_number = */ 1, 465 /* msg_type_inline = */ TRUE, 466 /* msg_type_longform = */ FALSE, 467 /* msg_type_deallocate = */ FALSE, 468 /* msg_type_unused = */ 0 469 }; 470 #endif UseStaticMsgType 471 472 #if UseStaticMsgType 473 InP->owner_portType = owner_portType; 474 #else UseStaticMsgType 475 InP->owner_portType.msg_type_name = MSG_TYPE_PORT; 476 InP->owner_portType.msg_type_size = 32; 477 InP->owner_portType.msg_type_number = 1; 478 InP->owner_portType.msg_type_inline = TRUE; 479 InP->owner_portType.msg_type_longform = FALSE; 480 InP->owner_portType.msg_type_deallocate = FALSE; 481 #endif UseStaticMsgType 482 483 InP->owner_port /* owner_port */ = /* owner_port */ owner_port; 484 485 InP->Head.msg_simple = FALSE; 486 InP->Head.msg_size = msg_size; 487 InP->Head.msg_type = MSG_TYPE_NORMAL | MSG_TYPE_RPC; 488 InP->Head.msg_request_port = kern_serv_port; 489 InP->Head.msg_reply_port = mig_get_reply_port(); 490 InP->Head.msg_id = 1009; 491 492 msg_result = msg_rpc(&InP->Head, MSG_OPTION_NONE, sizeof(Reply), 0, 0); 493 if (msg_result != RPC_SUCCESS) { 494 if (msg_result == RCV_INVALID_PORT) 495 mig_dealloc_reply_port(); 496 return msg_result; 497 } 498 499 #if TypeCheck 500 msg_size = OutP->Head.msg_size; 501 msg_simple = OutP->Head.msg_simple; 502 #endif TypeCheck 503 504 if (OutP->Head.msg_id != 1109) 505 return MIG_REPLY_MISMATCH; 506 507 #if TypeCheck 508 if (((msg_size != 32) || (msg_simple != TRUE)) && 509 ((msg_size != sizeof(death_pill_t)) || 510 (msg_simple != TRUE) || 511 (OutP->RetCode == KERN_SUCCESS))) 512 return MIG_TYPE_ERROR; 513 #endif TypeCheck 514 515 #if TypeCheck 516 #if UseStaticMsgType 517 if (* (int *) &OutP->RetCodeType != * (int *) &RetCodeCheck) 518 #else UseStaticMsgType 519 if ((OutP->RetCodeType.msg_type_inline != TRUE) || 520 (OutP->RetCodeType.msg_type_longform != FALSE) || 521 (OutP->RetCodeType.msg_type_name != MSG_TYPE_INTEGER_32) || 522 (OutP->RetCodeType.msg_type_number != 1) || 523 (OutP->RetCodeType.msg_type_size != 32)) 524 #endif UseStaticMsgType 525 return MIG_TYPE_ERROR; 526 #endif TypeCheck 527 528 if (OutP->RetCode != KERN_SUCCESS) 529 return OutP->RetCode; 530 531 return OutP->RetCode; 532 } 533 534 /* Routine Start */ 535 mig_external kern_return_t ntsoundStart ( 536 port_t kern_serv_port, 537 port_t owner_port) 538 { 539 typedef struct { 540 msg_header_t Head; 541 msg_type_t owner_portType; 542 port_t owner_port; 543 } Request; 544 545 typedef struct { 546 msg_header_t Head; 547 msg_type_t RetCodeType; 548 kern_return_t RetCode; 549 } Reply; 550 551 union { 552 Request In; 553 Reply Out; 554 } Mess; 555 556 register Request *InP = &Mess.In; 557 register Reply *OutP = &Mess.Out; 558 559 msg_return_t msg_result; 560 561 #if TypeCheck 562 boolean_t msg_simple; 563 #endif TypeCheck 564 565 unsigned int msg_size = 32; 566 567 #if UseStaticMsgType 568 static const msg_type_t owner_portType = { 569 /* msg_type_name = */ MSG_TYPE_PORT, 570 /* msg_type_size = */ 32, 571 /* msg_type_number = */ 1, 572 /* msg_type_inline = */ TRUE, 573 /* msg_type_longform = */ FALSE, 574 /* msg_type_deallocate = */ FALSE, 575 /* msg_type_unused = */ 0, 576 }; 577 #endif UseStaticMsgType 578 579 #if UseStaticMsgType 580 static const msg_type_t RetCodeCheck = { 581 /* msg_type_name = */ MSG_TYPE_INTEGER_32, 582 /* msg_type_size = */ 32, 583 /* msg_type_number = */ 1, 584 /* msg_type_inline = */ TRUE, 585 /* msg_type_longform = */ FALSE, 586 /* msg_type_deallocate = */ FALSE, 587 /* msg_type_unused = */ 0 588 }; 589 #endif UseStaticMsgType 590 591 #if UseStaticMsgType 592 InP->owner_portType = owner_portType; 593 #else UseStaticMsgType 594 InP->owner_portType.msg_type_name = MSG_TYPE_PORT; 595 InP->owner_portType.msg_type_size = 32; 596 InP->owner_portType.msg_type_number = 1; 597 InP->owner_portType.msg_type_inline = TRUE; 598 InP->owner_portType.msg_type_longform = FALSE; 599 InP->owner_portType.msg_type_deallocate = FALSE; 600 #endif UseStaticMsgType 601 602 InP->owner_port /* owner_port */ = /* owner_port */ owner_port; 603 604 InP->Head.msg_simple = FALSE; 605 InP->Head.msg_size = msg_size; 606 InP->Head.msg_type = MSG_TYPE_NORMAL | MSG_TYPE_RPC; 607 InP->Head.msg_request_port = kern_serv_port; 608 InP->Head.msg_reply_port = mig_get_reply_port(); 609 InP->Head.msg_id = 1010; 610 611 msg_result = msg_rpc(&InP->Head, MSG_OPTION_NONE, sizeof(Reply), 0, 0); 612 if (msg_result != RPC_SUCCESS) { 613 if (msg_result == RCV_INVALID_PORT) 614 mig_dealloc_reply_port(); 615 return msg_result; 616 } 617 618 #if TypeCheck 619 msg_size = OutP->Head.msg_size; 620 msg_simple = OutP->Head.msg_simple; 621 #endif TypeCheck 622 623 if (OutP->Head.msg_id != 1110) 624 return MIG_REPLY_MISMATCH; 625 626 #if TypeCheck 627 if (((msg_size != 32) || (msg_simple != TRUE)) && 628 ((msg_size != sizeof(death_pill_t)) || 629 (msg_simple != TRUE) || 630 (OutP->RetCode == KERN_SUCCESS))) 631 return MIG_TYPE_ERROR; 632 #endif TypeCheck 633 634 #if TypeCheck 635 #if UseStaticMsgType 636 if (* (int *) &OutP->RetCodeType != * (int *) &RetCodeCheck) 637 #else UseStaticMsgType 638 if ((OutP->RetCodeType.msg_type_inline != TRUE) || 639 (OutP->RetCodeType.msg_type_longform != FALSE) || 640 (OutP->RetCodeType.msg_type_name != MSG_TYPE_INTEGER_32) || 641 (OutP->RetCodeType.msg_type_number != 1) || 642 (OutP->RetCodeType.msg_type_size != 32)) 643 #endif UseStaticMsgType 644 return MIG_TYPE_ERROR; 645 #endif TypeCheck 646 647 if (OutP->RetCode != KERN_SUCCESS) 648 return OutP->RetCode; 649 650 return OutP->RetCode; 651 } 652 653 /* Routine Stop */ 654 mig_external kern_return_t ntsoundStop ( 655 port_t kern_serv_port, 656 port_t owner_port) 657 { 658 typedef struct { 659 msg_header_t Head; 660 msg_type_t owner_portType; 661 port_t owner_port; 662 } Request; 663 664 typedef struct { 665 msg_header_t Head; 666 msg_type_t RetCodeType; 667 kern_return_t RetCode; 668 } Reply; 669 670 union { 671 Request In; 672 Reply Out; 673 } Mess; 674 675 register Request *InP = &Mess.In; 676 register Reply *OutP = &Mess.Out; 677 678 msg_return_t msg_result; 679 680 #if TypeCheck 681 boolean_t msg_simple; 682 #endif TypeCheck 683 684 unsigned int msg_size = 32; 685 686 #if UseStaticMsgType 687 static const msg_type_t owner_portType = { 688 /* msg_type_name = */ MSG_TYPE_PORT, 689 /* msg_type_size = */ 32, 690 /* msg_type_number = */ 1, 691 /* msg_type_inline = */ TRUE, 692 /* msg_type_longform = */ FALSE, 693 /* msg_type_deallocate = */ FALSE, 694 /* msg_type_unused = */ 0, 695 }; 696 #endif UseStaticMsgType 697 698 #if UseStaticMsgType 699 static const msg_type_t RetCodeCheck = { 700 /* msg_type_name = */ MSG_TYPE_INTEGER_32, 701 /* msg_type_size = */ 32, 702 /* msg_type_number = */ 1, 703 /* msg_type_inline = */ TRUE, 704 /* msg_type_longform = */ FALSE, 705 /* msg_type_deallocate = */ FALSE, 706 /* msg_type_unused = */ 0 707 }; 708 #endif UseStaticMsgType 709 710 #if UseStaticMsgType 711 InP->owner_portType = owner_portType; 712 #else UseStaticMsgType 713 InP->owner_portType.msg_type_name = MSG_TYPE_PORT; 714 InP->owner_portType.msg_type_size = 32; 715 InP->owner_portType.msg_type_number = 1; 716 InP->owner_portType.msg_type_inline = TRUE; 717 InP->owner_portType.msg_type_longform = FALSE; 718 InP->owner_portType.msg_type_deallocate = FALSE; 719 #endif UseStaticMsgType 720 721 InP->owner_port /* owner_port */ = /* owner_port */ owner_port; 722 723 InP->Head.msg_simple = FALSE; 724 InP->Head.msg_size = msg_size; 725 InP->Head.msg_type = MSG_TYPE_NORMAL | MSG_TYPE_RPC; 726 InP->Head.msg_request_port = kern_serv_port; 727 InP->Head.msg_reply_port = mig_get_reply_port(); 728 InP->Head.msg_id = 1011; 729 730 msg_result = msg_rpc(&InP->Head, MSG_OPTION_NONE, sizeof(Reply), 0, 0); 731 if (msg_result != RPC_SUCCESS) { 732 if (msg_result == RCV_INVALID_PORT) 733 mig_dealloc_reply_port(); 734 return msg_result; 735 } 736 737 #if TypeCheck 738 msg_size = OutP->Head.msg_size; 739 msg_simple = OutP->Head.msg_simple; 740 #endif TypeCheck 741 742 if (OutP->Head.msg_id != 1111) 743 return MIG_REPLY_MISMATCH; 744 745 #if TypeCheck 746 if (((msg_size != 32) || (msg_simple != TRUE)) && 747 ((msg_size != sizeof(death_pill_t)) || 748 (msg_simple != TRUE) || 749 (OutP->RetCode == KERN_SUCCESS))) 750 return MIG_TYPE_ERROR; 751 #endif TypeCheck 752 753 #if TypeCheck 754 #if UseStaticMsgType 755 if (* (int *) &OutP->RetCodeType != * (int *) &RetCodeCheck) 756 #else UseStaticMsgType 757 if ((OutP->RetCodeType.msg_type_inline != TRUE) || 758 (OutP->RetCodeType.msg_type_longform != FALSE) || 759 (OutP->RetCodeType.msg_type_name != MSG_TYPE_INTEGER_32) || 760 (OutP->RetCodeType.msg_type_number != 1) || 761 (OutP->RetCodeType.msg_type_size != 32)) 762 #endif UseStaticMsgType 763 return MIG_TYPE_ERROR; 764 #endif TypeCheck 765 766 if (OutP->RetCode != KERN_SUCCESS) 767 return OutP->RetCode; 768 769 return OutP->RetCode; 770 } 771 772 /* Routine Config */ 773 mig_external kern_return_t ntsoundConfig ( 774 port_t kern_serv_port, 775 port_t owner_port, 776 int channelCount, 777 int samplingRate, 778 int encoding, 779 int useInterrupts) 780 { 781 typedef struct { 782 msg_header_t Head; 783 msg_type_t owner_portType; 784 port_t owner_port; 785 msg_type_t channelCountType; 786 int channelCount; 787 msg_type_t samplingRateType; 788 int samplingRate; 789 msg_type_t encodingType; 790 int encoding; 791 msg_type_t useInterruptsType; 792 int useInterrupts; 793 } Request; 794 795 typedef struct { 796 msg_header_t Head; 797 msg_type_t RetCodeType; 798 kern_return_t RetCode; 799 } Reply; 800 801 union { 802 Request In; 803 Reply Out; 804 } Mess; 805 806 register Request *InP = &Mess.In; 807 register Reply *OutP = &Mess.Out; 808 809 msg_return_t msg_result; 810 811 #if TypeCheck 812 boolean_t msg_simple; 813 #endif TypeCheck 814 815 unsigned int msg_size = 64; 816 817 #if UseStaticMsgType 818 static const msg_type_t owner_portType = { 819 /* msg_type_name = */ MSG_TYPE_PORT, 820 /* msg_type_size = */ 32, 821 /* msg_type_number = */ 1, 822 /* msg_type_inline = */ TRUE, 823 /* msg_type_longform = */ FALSE, 824 /* msg_type_deallocate = */ FALSE, 825 /* msg_type_unused = */ 0, 826 }; 827 #endif UseStaticMsgType 828 829 #if UseStaticMsgType 830 static const msg_type_t channelCountType = { 831 /* msg_type_name = */ MSG_TYPE_INTEGER_32, 832 /* msg_type_size = */ 32, 833 /* msg_type_number = */ 1, 834 /* msg_type_inline = */ TRUE, 835 /* msg_type_longform = */ FALSE, 836 /* msg_type_deallocate = */ FALSE, 837 /* msg_type_unused = */ 0, 838 }; 839 #endif UseStaticMsgType 840 841 #if UseStaticMsgType 842 static const msg_type_t samplingRateType = { 843 /* msg_type_name = */ MSG_TYPE_INTEGER_32, 844 /* msg_type_size = */ 32, 845 /* msg_type_number = */ 1, 846 /* msg_type_inline = */ TRUE, 847 /* msg_type_longform = */ FALSE, 848 /* msg_type_deallocate = */ FALSE, 849 /* msg_type_unused = */ 0, 850 }; 851 #endif UseStaticMsgType 852 853 #if UseStaticMsgType 854 static const msg_type_t encodingType = { 855 /* msg_type_name = */ MSG_TYPE_INTEGER_32, 856 /* msg_type_size = */ 32, 857 /* msg_type_number = */ 1, 858 /* msg_type_inline = */ TRUE, 859 /* msg_type_longform = */ FALSE, 860 /* msg_type_deallocate = */ FALSE, 861 /* msg_type_unused = */ 0, 862 }; 863 #endif UseStaticMsgType 864 865 #if UseStaticMsgType 866 static const msg_type_t useInterruptsType = { 867 /* msg_type_name = */ MSG_TYPE_INTEGER_32, 868 /* msg_type_size = */ 32, 869 /* msg_type_number = */ 1, 870 /* msg_type_inline = */ TRUE, 871 /* msg_type_longform = */ FALSE, 872 /* msg_type_deallocate = */ FALSE, 873 /* msg_type_unused = */ 0, 874 }; 875 #endif UseStaticMsgType 876 877 #if UseStaticMsgType 878 static const msg_type_t RetCodeCheck = { 879 /* msg_type_name = */ MSG_TYPE_INTEGER_32, 880 /* msg_type_size = */ 32, 881 /* msg_type_number = */ 1, 882 /* msg_type_inline = */ TRUE, 883 /* msg_type_longform = */ FALSE, 884 /* msg_type_deallocate = */ FALSE, 885 /* msg_type_unused = */ 0 886 }; 887 #endif UseStaticMsgType 888 889 #if UseStaticMsgType 890 InP->owner_portType = owner_portType; 891 #else UseStaticMsgType 892 InP->owner_portType.msg_type_name = MSG_TYPE_PORT; 893 InP->owner_portType.msg_type_size = 32; 894 InP->owner_portType.msg_type_number = 1; 895 InP->owner_portType.msg_type_inline = TRUE; 896 InP->owner_portType.msg_type_longform = FALSE; 897 InP->owner_portType.msg_type_deallocate = FALSE; 898 #endif UseStaticMsgType 899 900 InP->owner_port /* owner_port */ = /* owner_port */ owner_port; 901 902 #if UseStaticMsgType 903 InP->channelCountType = channelCountType; 904 #else UseStaticMsgType 905 InP->channelCountType.msg_type_name = MSG_TYPE_INTEGER_32; 906 InP->channelCountType.msg_type_size = 32; 907 InP->channelCountType.msg_type_number = 1; 908 InP->channelCountType.msg_type_inline = TRUE; 909 InP->channelCountType.msg_type_longform = FALSE; 910 InP->channelCountType.msg_type_deallocate = FALSE; 911 #endif UseStaticMsgType 912 913 InP->channelCount /* channelCount */ = /* channelCount */ channelCount; 914 915 #if UseStaticMsgType 916 InP->samplingRateType = samplingRateType; 917 #else UseStaticMsgType 918 InP->samplingRateType.msg_type_name = MSG_TYPE_INTEGER_32; 919 InP->samplingRateType.msg_type_size = 32; 920 InP->samplingRateType.msg_type_number = 1; 921 InP->samplingRateType.msg_type_inline = TRUE; 922 InP->samplingRateType.msg_type_longform = FALSE; 923 InP->samplingRateType.msg_type_deallocate = FALSE; 924 #endif UseStaticMsgType 925 926 InP->samplingRate /* samplingRate */ = /* samplingRate */ samplingRate; 927 928 #if UseStaticMsgType 929 InP->encodingType = encodingType; 930 #else UseStaticMsgType 931 InP->encodingType.msg_type_name = MSG_TYPE_INTEGER_32; 932 InP->encodingType.msg_type_size = 32; 933 InP->encodingType.msg_type_number = 1; 934 InP->encodingType.msg_type_inline = TRUE; 935 InP->encodingType.msg_type_longform = FALSE; 936 InP->encodingType.msg_type_deallocate = FALSE; 937 #endif UseStaticMsgType 938 939 InP->encoding /* encoding */ = /* encoding */ encoding; 940 941 #if UseStaticMsgType 942 InP->useInterruptsType = useInterruptsType; 943 #else UseStaticMsgType 944 InP->useInterruptsType.msg_type_name = MSG_TYPE_INTEGER_32; 945 InP->useInterruptsType.msg_type_size = 32; 946 InP->useInterruptsType.msg_type_number = 1; 947 InP->useInterruptsType.msg_type_inline = TRUE; 948 InP->useInterruptsType.msg_type_longform = FALSE; 949 InP->useInterruptsType.msg_type_deallocate = FALSE; 950 #endif UseStaticMsgType 951 952 InP->useInterrupts /* useInterrupts */ = /* useInterrupts */ useInterrupts; 953 954 InP->Head.msg_simple = FALSE; 955 InP->Head.msg_size = msg_size; 956 InP->Head.msg_type = MSG_TYPE_NORMAL | MSG_TYPE_RPC; 957 InP->Head.msg_request_port = kern_serv_port; 958 InP->Head.msg_reply_port = mig_get_reply_port(); 959 InP->Head.msg_id = 1012; 960 961 msg_result = msg_rpc(&InP->Head, MSG_OPTION_NONE, sizeof(Reply), 0, 0); 962 if (msg_result != RPC_SUCCESS) { 963 if (msg_result == RCV_INVALID_PORT) 964 mig_dealloc_reply_port(); 965 return msg_result; 966 } 967 968 #if TypeCheck 969 msg_size = OutP->Head.msg_size; 970 msg_simple = OutP->Head.msg_simple; 971 #endif TypeCheck 972 973 if (OutP->Head.msg_id != 1112) 974 return MIG_REPLY_MISMATCH; 975 976 #if TypeCheck 977 if (((msg_size != 32) || (msg_simple != TRUE)) && 978 ((msg_size != sizeof(death_pill_t)) || 979 (msg_simple != TRUE) || 980 (OutP->RetCode == KERN_SUCCESS))) 981 return MIG_TYPE_ERROR; 982 #endif TypeCheck 983 984 #if TypeCheck 985 #if UseStaticMsgType 986 if (* (int *) &OutP->RetCodeType != * (int *) &RetCodeCheck) 987 #else UseStaticMsgType 988 if ((OutP->RetCodeType.msg_type_inline != TRUE) || 989 (OutP->RetCodeType.msg_type_longform != FALSE) || 990 (OutP->RetCodeType.msg_type_name != MSG_TYPE_INTEGER_32) || 991 (OutP->RetCodeType.msg_type_number != 1) || 992 (OutP->RetCodeType.msg_type_size != 32)) 993 #endif UseStaticMsgType 994 return MIG_TYPE_ERROR; 995 #endif TypeCheck 996 997 if (OutP->RetCode != KERN_SUCCESS) 998 return OutP->RetCode; 999 1000 return OutP->RetCode; 1001 } 1002 1003 /* Routine BytesProcessed */ 1004 mig_external kern_return_t ntsoundBytesProcessed ( 1005 port_t kern_serv_port, 1006 port_t owner_port, 1007 int *byte_count) 1008 { 1009 typedef struct { 1010 msg_header_t Head; 1011 msg_type_t owner_portType; 1012 port_t owner_port; 1013 } Request; 1014 1015 typedef struct { 1016 msg_header_t Head; 1017 msg_type_t RetCodeType; 1018 kern_return_t RetCode; 1019 msg_type_t byte_countType; 1020 int byte_count; 1021 } Reply; 1022 1023 union { 1024 Request In; 1025 Reply Out; 1026 } Mess; 1027 1028 register Request *InP = &Mess.In; 1029 register Reply *OutP = &Mess.Out; 1030 1031 msg_return_t msg_result; 1032 1033 #if TypeCheck 1034 boolean_t msg_simple; 1035 #endif TypeCheck 1036 1037 unsigned int msg_size = 32; 1038 1039 #if UseStaticMsgType 1040 static const msg_type_t owner_portType = { 1041 /* msg_type_name = */ MSG_TYPE_PORT, 1042 /* msg_type_size = */ 32, 1043 /* msg_type_number = */ 1, 1044 /* msg_type_inline = */ TRUE, 1045 /* msg_type_longform = */ FALSE, 1046 /* msg_type_deallocate = */ FALSE, 1047 /* msg_type_unused = */ 0, 1048 }; 1049 #endif UseStaticMsgType 1050 1051 #if UseStaticMsgType 1052 static const msg_type_t RetCodeCheck = { 1053 /* msg_type_name = */ MSG_TYPE_INTEGER_32, 1054 /* msg_type_size = */ 32, 1055 /* msg_type_number = */ 1, 1056 /* msg_type_inline = */ TRUE, 1057 /* msg_type_longform = */ FALSE, 1058 /* msg_type_deallocate = */ FALSE, 1059 /* msg_type_unused = */ 0 1060 }; 1061 #endif UseStaticMsgType 1062 1063 #if UseStaticMsgType 1064 static const msg_type_t byte_countCheck = { 1065 /* msg_type_name = */ MSG_TYPE_INTEGER_32, 1066 /* msg_type_size = */ 32, 1067 /* msg_type_number = */ 1, 1068 /* msg_type_inline = */ TRUE, 1069 /* msg_type_longform = */ FALSE, 1070 /* msg_type_deallocate = */ FALSE, 1071 /* msg_type_unused = */ 0 1072 }; 1073 #endif UseStaticMsgType 1074 1075 #if UseStaticMsgType 1076 InP->owner_portType = owner_portType; 1077 #else UseStaticMsgType 1078 InP->owner_portType.msg_type_name = MSG_TYPE_PORT; 1079 InP->owner_portType.msg_type_size = 32; 1080 InP->owner_portType.msg_type_number = 1; 1081 InP->owner_portType.msg_type_inline = TRUE; 1082 InP->owner_portType.msg_type_longform = FALSE; 1083 InP->owner_portType.msg_type_deallocate = FALSE; 1084 #endif UseStaticMsgType 1085 1086 InP->owner_port /* owner_port */ = /* owner_port */ owner_port; 1087 1088 InP->Head.msg_simple = FALSE; 1089 InP->Head.msg_size = msg_size; 1090 InP->Head.msg_type = MSG_TYPE_NORMAL | MSG_TYPE_RPC; 1091 InP->Head.msg_request_port = kern_serv_port; 1092 InP->Head.msg_reply_port = mig_get_reply_port(); 1093 InP->Head.msg_id = 1013; 1094 1095 msg_result = msg_rpc(&InP->Head, MSG_OPTION_NONE, sizeof(Reply), 0, 0); 1096 if (msg_result != RPC_SUCCESS) { 1097 if (msg_result == RCV_INVALID_PORT) 1098 mig_dealloc_reply_port(); 1099 return msg_result; 1100 } 1101 1102 #if TypeCheck 1103 msg_size = OutP->Head.msg_size; 1104 msg_simple = OutP->Head.msg_simple; 1105 #endif TypeCheck 1106 1107 if (OutP->Head.msg_id != 1113) 1108 return MIG_REPLY_MISMATCH; 1109 1110 #if TypeCheck 1111 if (((msg_size != 40) || (msg_simple != TRUE)) && 1112 ((msg_size != sizeof(death_pill_t)) || 1113 (msg_simple != TRUE) || 1114 (OutP->RetCode == KERN_SUCCESS))) 1115 return MIG_TYPE_ERROR; 1116 #endif TypeCheck 1117 1118 #if TypeCheck 1119 #if UseStaticMsgType 1120 if (* (int *) &OutP->RetCodeType != * (int *) &RetCodeCheck) 1121 #else UseStaticMsgType 1122 if ((OutP->RetCodeType.msg_type_inline != TRUE) || 1123 (OutP->RetCodeType.msg_type_longform != FALSE) || 1124 (OutP->RetCodeType.msg_type_name != MSG_TYPE_INTEGER_32) || 1125 (OutP->RetCodeType.msg_type_number != 1) || 1126 (OutP->RetCodeType.msg_type_size != 32)) 1127 #endif UseStaticMsgType 1128 return MIG_TYPE_ERROR; 1129 #endif TypeCheck 1130 1131 if (OutP->RetCode != KERN_SUCCESS) 1132 return OutP->RetCode; 1133 1134 #if TypeCheck 1135 #if UseStaticMsgType 1136 if (* (int *) &OutP->byte_countType != * (int *) &byte_countCheck) 1137 #else UseStaticMsgType 1138 if ((OutP->byte_countType.msg_type_inline != TRUE) || 1139 (OutP->byte_countType.msg_type_longform != FALSE) || 1140 (OutP->byte_countType.msg_type_name != MSG_TYPE_INTEGER_32) || 1141 (OutP->byte_countType.msg_type_number != 1) || 1142 (OutP->byte_countType.msg_type_size != 32)) 1143 #endif UseStaticMsgType 1144 return MIG_TYPE_ERROR; 1145 #endif TypeCheck 1146 1147 *byte_count /* byte_count */ = /* *byte_count */ OutP->byte_count; 1148 1149 return OutP->RetCode; 1150 } 1151 1152 /* Routine DMACount */ 1153 mig_external kern_return_t ntsoundDMACount ( 1154 port_t kern_serv_port, 1155 port_t owner_port, 1156 int *dma_count) 1157 { 1158 typedef struct { 1159 msg_header_t Head; 1160 msg_type_t owner_portType; 1161 port_t owner_port; 1162 } Request; 1163 1164 typedef struct { 1165 msg_header_t Head; 1166 msg_type_t RetCodeType; 1167 kern_return_t RetCode; 1168 msg_type_t dma_countType; 1169 int dma_count; 1170 } Reply; 1171 1172 union { 1173 Request In; 1174 Reply Out; 1175 } Mess; 1176 1177 register Request *InP = &Mess.In; 1178 register Reply *OutP = &Mess.Out; 1179 1180 msg_return_t msg_result; 1181 1182 #if TypeCheck 1183 boolean_t msg_simple; 1184 #endif TypeCheck 1185 1186 unsigned int msg_size = 32; 1187 1188 #if UseStaticMsgType 1189 static const msg_type_t owner_portType = { 1190 /* msg_type_name = */ MSG_TYPE_PORT, 1191 /* msg_type_size = */ 32, 1192 /* msg_type_number = */ 1, 1193 /* msg_type_inline = */ TRUE, 1194 /* msg_type_longform = */ FALSE, 1195 /* msg_type_deallocate = */ FALSE, 1196 /* msg_type_unused = */ 0, 1197 }; 1198 #endif UseStaticMsgType 1199 1200 #if UseStaticMsgType 1201 static const msg_type_t RetCodeCheck = { 1202 /* msg_type_name = */ MSG_TYPE_INTEGER_32, 1203 /* msg_type_size = */ 32, 1204 /* msg_type_number = */ 1, 1205 /* msg_type_inline = */ TRUE, 1206 /* msg_type_longform = */ FALSE, 1207 /* msg_type_deallocate = */ FALSE, 1208 /* msg_type_unused = */ 0 1209 }; 1210 #endif UseStaticMsgType 1211 1212 #if UseStaticMsgType 1213 static const msg_type_t dma_countCheck = { 1214 /* msg_type_name = */ MSG_TYPE_INTEGER_32, 1215 /* msg_type_size = */ 32, 1216 /* msg_type_number = */ 1, 1217 /* msg_type_inline = */ TRUE, 1218 /* msg_type_longform = */ FALSE, 1219 /* msg_type_deallocate = */ FALSE, 1220 /* msg_type_unused = */ 0 1221 }; 1222 #endif UseStaticMsgType 1223 1224 #if UseStaticMsgType 1225 InP->owner_portType = owner_portType; 1226 #else UseStaticMsgType 1227 InP->owner_portType.msg_type_name = MSG_TYPE_PORT; 1228 InP->owner_portType.msg_type_size = 32; 1229 InP->owner_portType.msg_type_number = 1; 1230 InP->owner_portType.msg_type_inline = TRUE; 1231 InP->owner_portType.msg_type_longform = FALSE; 1232 InP->owner_portType.msg_type_deallocate = FALSE; 1233 #endif UseStaticMsgType 1234 1235 InP->owner_port /* owner_port */ = /* owner_port */ owner_port; 1236 1237 InP->Head.msg_simple = FALSE; 1238 InP->Head.msg_size = msg_size; 1239 InP->Head.msg_type = MSG_TYPE_NORMAL | MSG_TYPE_RPC; 1240 InP->Head.msg_request_port = kern_serv_port; 1241 InP->Head.msg_reply_port = mig_get_reply_port(); 1242 InP->Head.msg_id = 1014; 1243 1244 msg_result = msg_rpc(&InP->Head, MSG_OPTION_NONE, sizeof(Reply), 0, 0); 1245 if (msg_result != RPC_SUCCESS) { 1246 if (msg_result == RCV_INVALID_PORT) 1247 mig_dealloc_reply_port(); 1248 return msg_result; 1249 } 1250 1251 #if TypeCheck 1252 msg_size = OutP->Head.msg_size; 1253 msg_simple = OutP->Head.msg_simple; 1254 #endif TypeCheck 1255 1256 if (OutP->Head.msg_id != 1114) 1257 return MIG_REPLY_MISMATCH; 1258 1259 #if TypeCheck 1260 if (((msg_size != 40) || (msg_simple != TRUE)) && 1261 ((msg_size != sizeof(death_pill_t)) || 1262 (msg_simple != TRUE) || 1263 (OutP->RetCode == KERN_SUCCESS))) 1264 return MIG_TYPE_ERROR; 1265 #endif TypeCheck 1266 1267 #if TypeCheck 1268 #if UseStaticMsgType 1269 if (* (int *) &OutP->RetCodeType != * (int *) &RetCodeCheck) 1270 #else UseStaticMsgType 1271 if ((OutP->RetCodeType.msg_type_inline != TRUE) || 1272 (OutP->RetCodeType.msg_type_longform != FALSE) || 1273 (OutP->RetCodeType.msg_type_name != MSG_TYPE_INTEGER_32) || 1274 (OutP->RetCodeType.msg_type_number != 1) || 1275 (OutP->RetCodeType.msg_type_size != 32)) 1276 #endif UseStaticMsgType 1277 return MIG_TYPE_ERROR; 1278 #endif TypeCheck 1279 1280 if (OutP->RetCode != KERN_SUCCESS) 1281 return OutP->RetCode; 1282 1283 #if TypeCheck 1284 #if UseStaticMsgType 1285 if (* (int *) &OutP->dma_countType != * (int *) &dma_countCheck) 1286 #else UseStaticMsgType 1287 if ((OutP->dma_countType.msg_type_inline != TRUE) || 1288 (OutP->dma_countType.msg_type_longform != FALSE) || 1289 (OutP->dma_countType.msg_type_name != MSG_TYPE_INTEGER_32) || 1290 (OutP->dma_countType.msg_type_number != 1) || 1291 (OutP->dma_countType.msg_type_size != 32)) 1292 #endif UseStaticMsgType 1293 return MIG_TYPE_ERROR; 1294 #endif TypeCheck 1295 1296 *dma_count /* dma_count */ = /* *dma_count */ OutP->dma_count; 1297 1298 return OutP->RetCode; 1299 } 1300 1301 /* Routine InterruptCount */ 1302 mig_external kern_return_t ntsoundInterruptCount ( 1303 port_t kern_serv_port, 1304 port_t owner_port, 1305 int *irq_count) 1306 { 1307 typedef struct { 1308 msg_header_t Head; 1309 msg_type_t owner_portType; 1310 port_t owner_port; 1311 } Request; 1312 1313 typedef struct { 1314 msg_header_t Head; 1315 msg_type_t RetCodeType; 1316 kern_return_t RetCode; 1317 msg_type_t irq_countType; 1318 int irq_count; 1319 } Reply; 1320 1321 union { 1322 Request In; 1323 Reply Out; 1324 } Mess; 1325 1326 register Request *InP = &Mess.In; 1327 register Reply *OutP = &Mess.Out; 1328 1329 msg_return_t msg_result; 1330 1331 #if TypeCheck 1332 boolean_t msg_simple; 1333 #endif TypeCheck 1334 1335 unsigned int msg_size = 32; 1336 1337 #if UseStaticMsgType 1338 static const msg_type_t owner_portType = { 1339 /* msg_type_name = */ MSG_TYPE_PORT, 1340 /* msg_type_size = */ 32, 1341 /* msg_type_number = */ 1, 1342 /* msg_type_inline = */ TRUE, 1343 /* msg_type_longform = */ FALSE, 1344 /* msg_type_deallocate = */ FALSE, 1345 /* msg_type_unused = */ 0, 1346 }; 1347 #endif UseStaticMsgType 1348 1349 #if UseStaticMsgType 1350 static const msg_type_t RetCodeCheck = { 1351 /* msg_type_name = */ MSG_TYPE_INTEGER_32, 1352 /* msg_type_size = */ 32, 1353 /* msg_type_number = */ 1, 1354 /* msg_type_inline = */ TRUE, 1355 /* msg_type_longform = */ FALSE, 1356 /* msg_type_deallocate = */ FALSE, 1357 /* msg_type_unused = */ 0 1358 }; 1359 #endif UseStaticMsgType 1360 1361 #if UseStaticMsgType 1362 static const msg_type_t irq_countCheck = { 1363 /* msg_type_name = */ MSG_TYPE_INTEGER_32, 1364 /* msg_type_size = */ 32, 1365 /* msg_type_number = */ 1, 1366 /* msg_type_inline = */ TRUE, 1367 /* msg_type_longform = */ FALSE, 1368 /* msg_type_deallocate = */ FALSE, 1369 /* msg_type_unused = */ 0 1370 }; 1371 #endif UseStaticMsgType 1372 1373 #if UseStaticMsgType 1374 InP->owner_portType = owner_portType; 1375 #else UseStaticMsgType 1376 InP->owner_portType.msg_type_name = MSG_TYPE_PORT; 1377 InP->owner_portType.msg_type_size = 32; 1378 InP->owner_portType.msg_type_number = 1; 1379 InP->owner_portType.msg_type_inline = TRUE; 1380 InP->owner_portType.msg_type_longform = FALSE; 1381 InP->owner_portType.msg_type_deallocate = FALSE; 1382 #endif UseStaticMsgType 1383 1384 InP->owner_port /* owner_port */ = /* owner_port */ owner_port; 1385 1386 InP->Head.msg_simple = FALSE; 1387 InP->Head.msg_size = msg_size; 1388 InP->Head.msg_type = MSG_TYPE_NORMAL | MSG_TYPE_RPC; 1389 InP->Head.msg_request_port = kern_serv_port; 1390 InP->Head.msg_reply_port = mig_get_reply_port(); 1391 InP->Head.msg_id = 1015; 1392 1393 msg_result = msg_rpc(&InP->Head, MSG_OPTION_NONE, sizeof(Reply), 0, 0); 1394 if (msg_result != RPC_SUCCESS) { 1395 if (msg_result == RCV_INVALID_PORT) 1396 mig_dealloc_reply_port(); 1397 return msg_result; 1398 } 1399 1400 #if TypeCheck 1401 msg_size = OutP->Head.msg_size; 1402 msg_simple = OutP->Head.msg_simple; 1403 #endif TypeCheck 1404 1405 if (OutP->Head.msg_id != 1115) 1406 return MIG_REPLY_MISMATCH; 1407 1408 #if TypeCheck 1409 if (((msg_size != 40) || (msg_simple != TRUE)) && 1410 ((msg_size != sizeof(death_pill_t)) || 1411 (msg_simple != TRUE) || 1412 (OutP->RetCode == KERN_SUCCESS))) 1413 return MIG_TYPE_ERROR; 1414 #endif TypeCheck 1415 1416 #if TypeCheck 1417 #if UseStaticMsgType 1418 if (* (int *) &OutP->RetCodeType != * (int *) &RetCodeCheck) 1419 #else UseStaticMsgType 1420 if ((OutP->RetCodeType.msg_type_inline != TRUE) || 1421 (OutP->RetCodeType.msg_type_longform != FALSE) || 1422 (OutP->RetCodeType.msg_type_name != MSG_TYPE_INTEGER_32) || 1423 (OutP->RetCodeType.msg_type_number != 1) || 1424 (OutP->RetCodeType.msg_type_size != 32)) 1425 #endif UseStaticMsgType 1426 return MIG_TYPE_ERROR; 1427 #endif TypeCheck 1428 1429 if (OutP->RetCode != KERN_SUCCESS) 1430 return OutP->RetCode; 1431 1432 #if TypeCheck 1433 #if UseStaticMsgType 1434 if (* (int *) &OutP->irq_countType != * (int *) &irq_countCheck) 1435 #else UseStaticMsgType 1436 if ((OutP->irq_countType.msg_type_inline != TRUE) || 1437 (OutP->irq_countType.msg_type_longform != FALSE) || 1438 (OutP->irq_countType.msg_type_name != MSG_TYPE_INTEGER_32) || 1439 (OutP->irq_countType.msg_type_number != 1) || 1440 (OutP->irq_countType.msg_type_size != 32)) 1441 #endif UseStaticMsgType 1442 return MIG_TYPE_ERROR; 1443 #endif TypeCheck 1444 1445 *irq_count /* irq_count */ = /* *irq_count */ OutP->irq_count; 1446 1447 return OutP->RetCode; 1448 } 1449 1450 /* Routine Write */ 1451 mig_external kern_return_t ntsoundWrite ( 1452 port_t kern_serv_port, 1453 port_t owner_port, 1454 sound_data_t data, 1455 unsigned int dataCnt, 1456 int *actual_count) 1457 { 1458 typedef struct { 1459 msg_header_t Head; 1460 msg_type_t owner_portType; 1461 port_t owner_port; 1462 msg_type_long_t dataType; 1463 short data[7000]; 1464 } Request; 1465 1466 typedef struct { 1467 msg_header_t Head; 1468 msg_type_t RetCodeType; 1469 kern_return_t RetCode; 1470 msg_type_t actual_countType; 1471 int actual_count; 1472 } Reply; 1473 1474 union { 1475 Request In; 1476 Reply Out; 1477 } Mess; 1478 1479 register Request *InP = &Mess.In; 1480 register Reply *OutP = &Mess.Out; 1481 1482 msg_return_t msg_result; 1483 1484 #if TypeCheck 1485 boolean_t msg_simple; 1486 #endif TypeCheck 1487 1488 unsigned int msg_size = 44; 1489 /* Maximum request size 14044 */ 1490 unsigned int msg_size_delta; 1491 1492 #if UseStaticMsgType 1493 static const msg_type_t owner_portType = { 1494 /* msg_type_name = */ MSG_TYPE_PORT, 1495 /* msg_type_size = */ 32, 1496 /* msg_type_number = */ 1, 1497 /* msg_type_inline = */ TRUE, 1498 /* msg_type_longform = */ FALSE, 1499 /* msg_type_deallocate = */ FALSE, 1500 /* msg_type_unused = */ 0, 1501 }; 1502 #endif UseStaticMsgType 1503 1504 #if UseStaticMsgType 1505 static const msg_type_long_t dataType = { 1506 { 1507 /* msg_type_name = */ 0, 1508 /* msg_type_size = */ 0, 1509 /* msg_type_number = */ 0, 1510 /* msg_type_inline = */ TRUE, 1511 /* msg_type_longform = */ TRUE, 1512 /* msg_type_deallocate = */ FALSE, 1513 }, 1514 /* msg_type_long_name = */ MSG_TYPE_INTEGER_16, 1515 /* msg_type_long_size = */ 16, 1516 /* msg_type_long_number = */ 7000, 1517 }; 1518 #endif UseStaticMsgType 1519 1520 #if UseStaticMsgType 1521 static const msg_type_t RetCodeCheck = { 1522 /* msg_type_name = */ MSG_TYPE_INTEGER_32, 1523 /* msg_type_size = */ 32, 1524 /* msg_type_number = */ 1, 1525 /* msg_type_inline = */ TRUE, 1526 /* msg_type_longform = */ FALSE, 1527 /* msg_type_deallocate = */ FALSE, 1528 /* msg_type_unused = */ 0 1529 }; 1530 #endif UseStaticMsgType 1531 1532 #if UseStaticMsgType 1533 static const msg_type_t actual_countCheck = { 1534 /* msg_type_name = */ MSG_TYPE_INTEGER_32, 1535 /* msg_type_size = */ 32, 1536 /* msg_type_number = */ 1, 1537 /* msg_type_inline = */ TRUE, 1538 /* msg_type_longform = */ FALSE, 1539 /* msg_type_deallocate = */ FALSE, 1540 /* msg_type_unused = */ 0 1541 }; 1542 #endif UseStaticMsgType 1543 1544 #if UseStaticMsgType 1545 InP->owner_portType = owner_portType; 1546 #else UseStaticMsgType 1547 InP->owner_portType.msg_type_name = MSG_TYPE_PORT; 1548 InP->owner_portType.msg_type_size = 32; 1549 InP->owner_portType.msg_type_number = 1; 1550 InP->owner_portType.msg_type_inline = TRUE; 1551 InP->owner_portType.msg_type_longform = FALSE; 1552 InP->owner_portType.msg_type_deallocate = FALSE; 1553 #endif UseStaticMsgType 1554 1555 InP->owner_port /* owner_port */ = /* owner_port */ owner_port; 1556 1557 #if UseStaticMsgType 1558 InP->dataType = dataType; 1559 #else UseStaticMsgType 1560 InP->dataType.msg_type_long_name = MSG_TYPE_INTEGER_16; 1561 InP->dataType.msg_type_long_size = 16; 1562 InP->dataType.msg_type_header.msg_type_inline = TRUE; 1563 InP->dataType.msg_type_header.msg_type_longform = TRUE; 1564 InP->dataType.msg_type_header.msg_type_deallocate = FALSE; 1565 #endif UseStaticMsgType 1566 1567 if (dataCnt > 7000) 1568 return MIG_ARRAY_TOO_LARGE; 1569 bcopy((char *) data, (char *) InP->data, 2 * dataCnt); 1570 1571 InP->dataType.msg_type_long_number /* dataCnt */ = /* dataType.msg_type_long_number */ dataCnt; 1572 1573 msg_size_delta = (2 * dataCnt + 3) & ~3; 1574 msg_size += msg_size_delta; 1575 1576 InP->Head.msg_simple = FALSE; 1577 InP->Head.msg_size = msg_size; 1578 InP->Head.msg_type = MSG_TYPE_NORMAL | MSG_TYPE_RPC; 1579 InP->Head.msg_request_port = kern_serv_port; 1580 InP->Head.msg_reply_port = mig_get_reply_port(); 1581 InP->Head.msg_id = 1016; 1582 1583 msg_result = msg_rpc(&InP->Head, MSG_OPTION_NONE, sizeof(Reply), 0, 0); 1584 if (msg_result != RPC_SUCCESS) { 1585 if (msg_result == RCV_INVALID_PORT) 1586 mig_dealloc_reply_port(); 1587 return msg_result; 1588 } 1589 1590 #if TypeCheck 1591 msg_size = OutP->Head.msg_size; 1592 msg_simple = OutP->Head.msg_simple; 1593 #endif TypeCheck 1594 1595 if (OutP->Head.msg_id != 1116) 1596 return MIG_REPLY_MISMATCH; 1597 1598 #if TypeCheck 1599 if (((msg_size != 40) || (msg_simple != TRUE)) && 1600 ((msg_size != sizeof(death_pill_t)) || 1601 (msg_simple != TRUE) || 1602 (OutP->RetCode == KERN_SUCCESS))) 1603 return MIG_TYPE_ERROR; 1604 #endif TypeCheck 1605 1606 #if TypeCheck 1607 #if UseStaticMsgType 1608 if (* (int *) &OutP->RetCodeType != * (int *) &RetCodeCheck) 1609 #else UseStaticMsgType 1610 if ((OutP->RetCodeType.msg_type_inline != TRUE) || 1611 (OutP->RetCodeType.msg_type_longform != FALSE) || 1612 (OutP->RetCodeType.msg_type_name != MSG_TYPE_INTEGER_32) || 1613 (OutP->RetCodeType.msg_type_number != 1) || 1614 (OutP->RetCodeType.msg_type_size != 32)) 1615 #endif UseStaticMsgType 1616 return MIG_TYPE_ERROR; 1617 #endif TypeCheck 1618 1619 if (OutP->RetCode != KERN_SUCCESS) 1620 return OutP->RetCode; 1621 1622 #if TypeCheck 1623 #if UseStaticMsgType 1624 if (* (int *) &OutP->actual_countType != * (int *) &actual_countCheck) 1625 #else UseStaticMsgType 1626 if ((OutP->actual_countType.msg_type_inline != TRUE) || 1627 (OutP->actual_countType.msg_type_longform != FALSE) || 1628 (OutP->actual_countType.msg_type_name != MSG_TYPE_INTEGER_32) || 1629 (OutP->actual_countType.msg_type_number != 1) || 1630 (OutP->actual_countType.msg_type_size != 32)) 1631 #endif UseStaticMsgType 1632 return MIG_TYPE_ERROR; 1633 #endif TypeCheck 1634 1635 *actual_count /* actual_count */ = /* *actual_count */ OutP->actual_count; 1636 1637 return OutP->RetCode; 1638 } 1639 1640 /* Routine SetVolume */ 1641 mig_external kern_return_t ntsoundSetVolume ( 1642 port_t kern_serv_port, 1643 port_t owner_port, 1644 int value) 1645 { 1646 typedef struct { 1647 msg_header_t Head; 1648 msg_type_t owner_portType; 1649 port_t owner_port; 1650 msg_type_t valueType; 1651 int value; 1652 } Request; 1653 1654 typedef struct { 1655 msg_header_t Head; 1656 msg_type_t RetCodeType; 1657 kern_return_t RetCode; 1658 } Reply; 1659 1660 union { 1661 Request In; 1662 Reply Out; 1663 } Mess; 1664 1665 register Request *InP = &Mess.In; 1666 register Reply *OutP = &Mess.Out; 1667 1668 msg_return_t msg_result; 1669 1670 #if TypeCheck 1671 boolean_t msg_simple; 1672 #endif TypeCheck 1673 1674 unsigned int msg_size = 40; 1675 1676 #if UseStaticMsgType 1677 static const msg_type_t owner_portType = { 1678 /* msg_type_name = */ MSG_TYPE_PORT, 1679 /* msg_type_size = */ 32, 1680 /* msg_type_number = */ 1, 1681 /* msg_type_inline = */ TRUE, 1682 /* msg_type_longform = */ FALSE, 1683 /* msg_type_deallocate = */ FALSE, 1684 /* msg_type_unused = */ 0, 1685 }; 1686 #endif UseStaticMsgType 1687 1688 #if UseStaticMsgType 1689 static const msg_type_t valueType = { 1690 /* msg_type_name = */ MSG_TYPE_INTEGER_32, 1691 /* msg_type_size = */ 32, 1692 /* msg_type_number = */ 1, 1693 /* msg_type_inline = */ TRUE, 1694 /* msg_type_longform = */ FALSE, 1695 /* msg_type_deallocate = */ FALSE, 1696 /* msg_type_unused = */ 0, 1697 }; 1698 #endif UseStaticMsgType 1699 1700 #if UseStaticMsgType 1701 static const msg_type_t RetCodeCheck = { 1702 /* msg_type_name = */ MSG_TYPE_INTEGER_32, 1703 /* msg_type_size = */ 32, 1704 /* msg_type_number = */ 1, 1705 /* msg_type_inline = */ TRUE, 1706 /* msg_type_longform = */ FALSE, 1707 /* msg_type_deallocate = */ FALSE, 1708 /* msg_type_unused = */ 0 1709 }; 1710 #endif UseStaticMsgType 1711 1712 #if UseStaticMsgType 1713 InP->owner_portType = owner_portType; 1714 #else UseStaticMsgType 1715 InP->owner_portType.msg_type_name = MSG_TYPE_PORT; 1716 InP->owner_portType.msg_type_size = 32; 1717 InP->owner_portType.msg_type_number = 1; 1718 InP->owner_portType.msg_type_inline = TRUE; 1719 InP->owner_portType.msg_type_longform = FALSE; 1720 InP->owner_portType.msg_type_deallocate = FALSE; 1721 #endif UseStaticMsgType 1722 1723 InP->owner_port /* owner_port */ = /* owner_port */ owner_port; 1724 1725 #if UseStaticMsgType 1726 InP->valueType = valueType; 1727 #else UseStaticMsgType 1728 InP->valueType.msg_type_name = MSG_TYPE_INTEGER_32; 1729 InP->valueType.msg_type_size = 32; 1730 InP->valueType.msg_type_number = 1; 1731 InP->valueType.msg_type_inline = TRUE; 1732 InP->valueType.msg_type_longform = FALSE; 1733 InP->valueType.msg_type_deallocate = FALSE; 1734 #endif UseStaticMsgType 1735 1736 InP->value /* value */ = /* value */ value; 1737 1738 InP->Head.msg_simple = FALSE; 1739 InP->Head.msg_size = msg_size; 1740 InP->Head.msg_type = MSG_TYPE_NORMAL | MSG_TYPE_RPC; 1741 InP->Head.msg_request_port = kern_serv_port; 1742 InP->Head.msg_reply_port = mig_get_reply_port(); 1743 InP->Head.msg_id = 1017; 1744 1745 msg_result = msg_rpc(&InP->Head, MSG_OPTION_NONE, sizeof(Reply), 0, 0); 1746 if (msg_result != RPC_SUCCESS) { 1747 if (msg_result == RCV_INVALID_PORT) 1748 mig_dealloc_reply_port(); 1749 return msg_result; 1750 } 1751 1752 #if TypeCheck 1753 msg_size = OutP->Head.msg_size; 1754 msg_simple = OutP->Head.msg_simple; 1755 #endif TypeCheck 1756 1757 if (OutP->Head.msg_id != 1117) 1758 return MIG_REPLY_MISMATCH; 1759 1760 #if TypeCheck 1761 if (((msg_size != 32) || (msg_simple != TRUE)) && 1762 ((msg_size != sizeof(death_pill_t)) || 1763 (msg_simple != TRUE) || 1764 (OutP->RetCode == KERN_SUCCESS))) 1765 return MIG_TYPE_ERROR; 1766 #endif TypeCheck 1767 1768 #if TypeCheck 1769 #if UseStaticMsgType 1770 if (* (int *) &OutP->RetCodeType != * (int *) &RetCodeCheck) 1771 #else UseStaticMsgType 1772 if ((OutP->RetCodeType.msg_type_inline != TRUE) || 1773 (OutP->RetCodeType.msg_type_longform != FALSE) || 1774 (OutP->RetCodeType.msg_type_name != MSG_TYPE_INTEGER_32) || 1775 (OutP->RetCodeType.msg_type_number != 1) || 1776 (OutP->RetCodeType.msg_type_size != 32)) 1777 #endif UseStaticMsgType 1778 return MIG_TYPE_ERROR; 1779 #endif TypeCheck 1780 1781 if (OutP->RetCode != KERN_SUCCESS) 1782 return OutP->RetCode; 1783 1784 return OutP->RetCode; 1785 } 1786 1787 /* Routine WireRange */ 1788 mig_external kern_return_t ntsoundWireRange ( 1789 port_t device_port, 1790 port_t token, 1791 port_t task, 1792 vm_offset_t addr, 1793 vm_size_t size, 1794 boolean_t wire) 1795 { 1796 typedef struct { 1797 msg_header_t Head; 1798 msg_type_t tokenType; 1799 port_t token; 1800 msg_type_t taskType; 1801 port_t task; 1802 msg_type_t addrType; 1803 vm_offset_t addr; 1804 msg_type_t sizeType; 1805 vm_size_t size; 1806 msg_type_t wireType; 1807 boolean_t wire; 1808 } Request; 1809 1810 typedef struct { 1811 msg_header_t Head; 1812 msg_type_t RetCodeType; 1813 kern_return_t RetCode; 1814 } Reply; 1815 1816 union { 1817 Request In; 1818 Reply Out; 1819 } Mess; 1820 1821 register Request *InP = &Mess.In; 1822 register Reply *OutP = &Mess.Out; 1823 1824 msg_return_t msg_result; 1825 1826 #if TypeCheck 1827 boolean_t msg_simple; 1828 #endif TypeCheck 1829 1830 unsigned int msg_size = 64; 1831 1832 #if UseStaticMsgType 1833 static const msg_type_t tokenType = { 1834 /* msg_type_name = */ MSG_TYPE_PORT, 1835 /* msg_type_size = */ 32, 1836 /* msg_type_number = */ 1, 1837 /* msg_type_inline = */ TRUE, 1838 /* msg_type_longform = */ FALSE, 1839 /* msg_type_deallocate = */ FALSE, 1840 /* msg_type_unused = */ 0, 1841 }; 1842 #endif UseStaticMsgType 1843 1844 #if UseStaticMsgType 1845 static const msg_type_t taskType = { 1846 /* msg_type_name = */ MSG_TYPE_PORT, 1847 /* msg_type_size = */ 32, 1848 /* msg_type_number = */ 1, 1849 /* msg_type_inline = */ TRUE, 1850 /* msg_type_longform = */ FALSE, 1851 /* msg_type_deallocate = */ FALSE, 1852 /* msg_type_unused = */ 0, 1853 }; 1854 #endif UseStaticMsgType 1855 1856 #if UseStaticMsgType 1857 static const msg_type_t addrType = { 1858 /* msg_type_name = */ MSG_TYPE_INTEGER_32, 1859 /* msg_type_size = */ 32, 1860 /* msg_type_number = */ 1, 1861 /* msg_type_inline = */ TRUE, 1862 /* msg_type_longform = */ FALSE, 1863 /* msg_type_deallocate = */ FALSE, 1864 /* msg_type_unused = */ 0, 1865 }; 1866 #endif UseStaticMsgType 1867 1868 #if UseStaticMsgType 1869 static const msg_type_t sizeType = { 1870 /* msg_type_name = */ MSG_TYPE_INTEGER_32, 1871 /* msg_type_size = */ 32, 1872 /* msg_type_number = */ 1, 1873 /* msg_type_inline = */ TRUE, 1874 /* msg_type_longform = */ FALSE, 1875 /* msg_type_deallocate = */ FALSE, 1876 /* msg_type_unused = */ 0, 1877 }; 1878 #endif UseStaticMsgType 1879 1880 #if UseStaticMsgType 1881 static const msg_type_t wireType = { 1882 /* msg_type_name = */ MSG_TYPE_BOOLEAN, 1883 /* msg_type_size = */ 32, 1884 /* msg_type_number = */ 1, 1885 /* msg_type_inline = */ TRUE, 1886 /* msg_type_longform = */ FALSE, 1887 /* msg_type_deallocate = */ FALSE, 1888 /* msg_type_unused = */ 0, 1889 }; 1890 #endif UseStaticMsgType 1891 1892 #if UseStaticMsgType 1893 static const msg_type_t RetCodeCheck = { 1894 /* msg_type_name = */ MSG_TYPE_INTEGER_32, 1895 /* msg_type_size = */ 32, 1896 /* msg_type_number = */ 1, 1897 /* msg_type_inline = */ TRUE, 1898 /* msg_type_longform = */ FALSE, 1899 /* msg_type_deallocate = */ FALSE, 1900 /* msg_type_unused = */ 0 1901 }; 1902 #endif UseStaticMsgType 1903 1904 #if UseStaticMsgType 1905 InP->tokenType = tokenType; 1906 #else UseStaticMsgType 1907 InP->tokenType.msg_type_name = MSG_TYPE_PORT; 1908 InP->tokenType.msg_type_size = 32; 1909 InP->tokenType.msg_type_number = 1; 1910 InP->tokenType.msg_type_inline = TRUE; 1911 InP->tokenType.msg_type_longform = FALSE; 1912 InP->tokenType.msg_type_deallocate = FALSE; 1913 #endif UseStaticMsgType 1914 1915 InP->token /* token */ = /* token */ token; 1916 1917 #if UseStaticMsgType 1918 InP->taskType = taskType; 1919 #else UseStaticMsgType 1920 InP->taskType.msg_type_name = MSG_TYPE_PORT; 1921 InP->taskType.msg_type_size = 32; 1922 InP->taskType.msg_type_number = 1; 1923 InP->taskType.msg_type_inline = TRUE; 1924 InP->taskType.msg_type_longform = FALSE; 1925 InP->taskType.msg_type_deallocate = FALSE; 1926 #endif UseStaticMsgType 1927 1928 InP->task /* task */ = /* task */ task; 1929 1930 #if UseStaticMsgType 1931 InP->addrType = addrType; 1932 #else UseStaticMsgType 1933 InP->addrType.msg_type_name = MSG_TYPE_INTEGER_32; 1934 InP->addrType.msg_type_size = 32; 1935 InP->addrType.msg_type_number = 1; 1936 InP->addrType.msg_type_inline = TRUE; 1937 InP->addrType.msg_type_longform = FALSE; 1938 InP->addrType.msg_type_deallocate = FALSE; 1939 #endif UseStaticMsgType 1940 1941 InP->addr /* addr */ = /* addr */ addr; 1942 1943 #if UseStaticMsgType 1944 InP->sizeType = sizeType; 1945 #else UseStaticMsgType 1946 InP->sizeType.msg_type_name = MSG_TYPE_INTEGER_32; 1947 InP->sizeType.msg_type_size = 32; 1948 InP->sizeType.msg_type_number = 1; 1949 InP->sizeType.msg_type_inline = TRUE; 1950 InP->sizeType.msg_type_longform = FALSE; 1951 InP->sizeType.msg_type_deallocate = FALSE; 1952 #endif UseStaticMsgType 1953 1954 InP->size /* size */ = /* size */ size; 1955 1956 #if UseStaticMsgType 1957 InP->wireType = wireType; 1958 #else UseStaticMsgType 1959 InP->wireType.msg_type_name = MSG_TYPE_BOOLEAN; 1960 InP->wireType.msg_type_size = 32; 1961 InP->wireType.msg_type_number = 1; 1962 InP->wireType.msg_type_inline = TRUE; 1963 InP->wireType.msg_type_longform = FALSE; 1964 InP->wireType.msg_type_deallocate = FALSE; 1965 #endif UseStaticMsgType 1966 1967 InP->wire /* wire */ = /* wire */ wire; 1968 1969 InP->Head.msg_simple = FALSE; 1970 InP->Head.msg_size = msg_size; 1971 InP->Head.msg_type = MSG_TYPE_NORMAL | MSG_TYPE_RPC; 1972 InP->Head.msg_request_port = device_port; 1973 InP->Head.msg_reply_port = mig_get_reply_port(); 1974 InP->Head.msg_id = 1018; 1975 1976 msg_result = msg_rpc(&InP->Head, MSG_OPTION_NONE, sizeof(Reply), 0, 0); 1977 if (msg_result != RPC_SUCCESS) { 1978 if (msg_result == RCV_INVALID_PORT) 1979 mig_dealloc_reply_port(); 1980 return msg_result; 1981 } 1982 1983 #if TypeCheck 1984 msg_size = OutP->Head.msg_size; 1985 msg_simple = OutP->Head.msg_simple; 1986 #endif TypeCheck 1987 1988 if (OutP->Head.msg_id != 1118) 1989 return MIG_REPLY_MISMATCH; 1990 1991 #if TypeCheck 1992 if (((msg_size != 32) || (msg_simple != TRUE)) && 1993 ((msg_size != sizeof(death_pill_t)) || 1994 (msg_simple != TRUE) || 1995 (OutP->RetCode == KERN_SUCCESS))) 1996 return MIG_TYPE_ERROR; 1997 #endif TypeCheck 1998 1999 #if TypeCheck 2000 #if UseStaticMsgType 2001 if (* (int *) &OutP->RetCodeType != * (int *) &RetCodeCheck) 2002 #else UseStaticMsgType 2003 if ((OutP->RetCodeType.msg_type_inline != TRUE) || 2004 (OutP->RetCodeType.msg_type_longform != FALSE) || 2005 (OutP->RetCodeType.msg_type_name != MSG_TYPE_INTEGER_32) || 2006 (OutP->RetCodeType.msg_type_number != 1) || 2007 (OutP->RetCodeType.msg_type_size != 32)) 2008 #endif UseStaticMsgType 2009 return MIG_TYPE_ERROR; 2010 #endif TypeCheck 2011 2012 if (OutP->RetCode != KERN_SUCCESS) 2013 return OutP->RetCode; 2014 2015 return OutP->RetCode; 2016 } 2017 2018 2019 //======================================================================== 2020 2021 /* 2022 ================== 2023 SNDDMA_Init 2024 2025 Try to find a sound device to mix for. 2026 Returns false if nothing is found. 2027 ================== 2028 */ 2029 qboolean SNDDMA_Init(void) 2030 { 2031 int err; 2032 int i; 2033 byte *buf; 2034 int bufsize; 2035 int progress, oldprogress; 2036 2037 shm = &sn; 2038 shm->channels = 2; 2039 shm->samplebits = 16; 2040 shm->speed = 11025; 2041 2042 err = netname_look_up(name_server_port,"", NTSOUNDNAME,&devPort); 2043 if (err) 2044 { 2045 Com_Printf("SNDDMA_Init: Cannot access theater driver\n"); 2046 return false; 2047 } 2048 2049 err = ntsoundAcquire(devPort,task_self(),(vm_offset_t *)&buf,&bufsize,&i); 2050 if (err || !i) 2051 { 2052 Com_Printf("SNDDMA_Init: Sound driver is busy or messed up\n"); 2053 return false; 2054 } 2055 2056 err = ntsoundConfig(devPort,task_self(),shm->channels,(int)shm->speed, 2057 NX_SoundStreamDataEncoding_Linear16, 1); 2058 if (err) 2059 { 2060 Com_Printf("SNDDMA_Init: ntsoundConfig error: %d\n",err); 2061 return false; 2062 } 2063 else 2064 Com_Printf("SNDDMA_Init: Configured for %d Hz, %d channels\n" 2065 ,(int)shm->speed,shm->channels); 2066 // printf ("buf: 0x%x\n", buf); 2067 // printf ("bufsize: %d\n", bufsize); 2068 2069 bzero(buf,bufsize); 2070 2071 // ntsoundSetVolume(devPort,task_self(),5); 2072 ntsoundStart(devPort,task_self()); 2073 2074 shm->soundalive = true; 2075 shm->splitbuffer = false; 2076 shm->samples = bufsize/(shm->samplebits/8); 2077 shm->samplepos = 0; 2078 shm->submission_chunk = 1; 2079 shm->buffer = buf; 2080 2081 // 2082 // find a buffer crossing point for pos testing 2083 // 2084 2085 ntsoundBytesProcessed(devPort,task_self(),&oldprogress); 2086 do 2087 { 2088 ntsoundBytesProcessed(devPort,task_self(),&progress); 2089 } while (progress == oldprogress); 2090 snd_basetime = Sys_DoubleTime() - progress/(11025*2); 2091 2092 return true; 2093 } 2094 2095 /* 2096 ============== 2097 SNDDMA_GetDMAPos 2098 2099 return the current sample position (in mono samples read) 2100 inside the recirculating dma buffer, so the mixing code will know 2101 how many sample are required to fill it up. 2102 =============== 2103 */ 2104 int SNDDMA_GetDMAPos(void) 2105 { 2106 int progress; 2107 2108 #if 0 2109 ntsoundBytesProcessed(devPort,task_self(),&progress); 2110 // ntsoundDMACount(devPort,task_self(),&progress); 2111 2112 //printf ("(%i / %f) ", progress, (float)(Sys_DoubleTime ())); 2113 progress += 2048; 2114 progress >>= 1; 2115 #else 2116 2117 progress = (Sys_DoubleTime() - snd_basetime)*11025*2; 2118 progress += 8192; 2119 progress &= ~1; 2120 #endif 2121 2122 progress &= (shm->samples-1); 2123 2124 return progress; 2125 } 2126 2127 2128 /* 2129 ============== 2130 SNDDMA_Submit 2131 2132 Reset the sound device for exiting 2133 =============== 2134 */ 2135 void SNDDMA_Submit(void) 2136 { 2137 } 2138 2139 /* 2140 ============== 2141 SNDDMA_Shutdown 2142 2143 Reset the sound device for exiting 2144 =============== 2145 */ 2146 void SNDDMA_Shutdown(void) 2147 { 2148 ntsoundStop(devPort,task_self()); 2149 ntsoundRelease(devPort,task_self()); 2150 } 2151