snd_next.m 67 KB

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