openalext_interface.cpp 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. /*
  2. * WARNING: this is an autogenerated file and will be overwritten by
  3. * the extension interface script.
  4. */
  5. #include "s3eExt.h"
  6. #include "IwDebug.h"
  7. #include "s3eDevice.h"
  8. #include "openalext.h"
  9. #ifndef S3E_EXT_SKIP_LOADER_CALL_LOCK
  10. // For MIPs (and WP8) platform we do not have asm code for stack switching
  11. // implemented. So we make LoaderCallStart call manually to set GlobalLock
  12. #if defined __mips || defined S3E_ANDROID_X86 || (defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP))
  13. #define LOADER_CALL_LOCK
  14. #endif
  15. #endif
  16. /**
  17. * Definitions for functions types passed to/from s3eExt interface
  18. */
  19. typedef unsigned int(*_alGetError_t)();
  20. typedef void(*_alSourceQueueBuffers_t)(_ALuint sid, _ALsizei numEntries, const _ALuint* bids);
  21. typedef void(*_alSourceUnqueueBuffers_t)(_ALuint sid, _ALsizei numEntries, _ALuint* bids);
  22. typedef void(*_alGetSourcei_t)(_ALuint sid, _ALenum param, _ALint* value);
  23. typedef void(*_alGetSourcef_t)(_ALuint sid, _ALenum param, _ALfloat* value);
  24. typedef void(*_alSourcef_t)(_ALuint sid, _ALenum param, _ALfloat value);
  25. typedef void(*_alSourcei_t)(_ALuint sid, _ALenum param, _ALint value);
  26. typedef void(*_alSourcePlay_t)(_ALuint sid);
  27. typedef void(*_alSourceStop_t)(_ALuint sid);
  28. typedef void(*_alSourcePause_t)(_ALuint sid);
  29. typedef void(*_alGenSources_t)(_ALsizei n, _ALuint* sources);
  30. typedef void(*_alDeleteSources_t)(_ALsizei n, const _ALuint* sources);
  31. typedef void(*_alGenBuffers_t)(_ALsizei n, _ALuint* buffers);
  32. typedef void(*_alDeleteBuffers_t)(_ALsizei n, const _ALuint* buffers);
  33. typedef void(*_alBufferData_t)(_ALuint bid, _ALenum format, const _ALvoid* data, _ALsizei size, _ALsizei freq);
  34. typedef _ALCdevice*(*_alcOpenDevice_t)(const char* devicename);
  35. typedef void(*_alcCloseDevice_t)(_ALCdevice* device);
  36. typedef _ALCcontext *(*_alcCreateContext_t)(_ALCdevice* device, const _ALCint* attrlist);
  37. typedef _ALCboolean(*_alcMakeContextCurrent_t)(_ALCcontext* context);
  38. typedef void(*_alcProcessContext_t)(_ALCcontext* context);
  39. typedef void(*_alcSuspendContext_t)(_ALCcontext* context);
  40. typedef void(*_alcDestroyContext_t)(_ALCcontext* context);
  41. typedef _ALCcontext *(*_alcGetCurrentContext_t)();
  42. /**
  43. * struct that gets filled in by openalextRegister
  44. */
  45. typedef struct openalextFuncs
  46. {
  47. _alGetError_t m__alGetError;
  48. _alSourceQueueBuffers_t m__alSourceQueueBuffers;
  49. _alSourceUnqueueBuffers_t m__alSourceUnqueueBuffers;
  50. _alGetSourcei_t m__alGetSourcei;
  51. _alGetSourcef_t m__alGetSourcef;
  52. _alSourcef_t m__alSourcef;
  53. _alSourcei_t m__alSourcei;
  54. _alSourcePlay_t m__alSourcePlay;
  55. _alSourceStop_t m__alSourceStop;
  56. _alSourcePause_t m__alSourcePause;
  57. _alGenSources_t m__alGenSources;
  58. _alDeleteSources_t m__alDeleteSources;
  59. _alGenBuffers_t m__alGenBuffers;
  60. _alDeleteBuffers_t m__alDeleteBuffers;
  61. _alBufferData_t m__alBufferData;
  62. _alcOpenDevice_t m__alcOpenDevice;
  63. _alcCloseDevice_t m__alcCloseDevice;
  64. _alcCreateContext_t m__alcCreateContext;
  65. _alcMakeContextCurrent_t m__alcMakeContextCurrent;
  66. _alcProcessContext_t m__alcProcessContext;
  67. _alcSuspendContext_t m__alcSuspendContext;
  68. _alcDestroyContext_t m__alcDestroyContext;
  69. _alcGetCurrentContext_t m__alcGetCurrentContext;
  70. } openalextFuncs;
  71. static openalextFuncs g_Ext;
  72. static bool g_GotExt = false;
  73. static bool g_TriedExt = false;
  74. static bool g_TriedNoMsgExt = false;
  75. static bool _extLoad()
  76. {
  77. if (!g_GotExt && !g_TriedExt)
  78. {
  79. s3eResult res = s3eExtGetHash(0x37485935, &g_Ext, sizeof(g_Ext));
  80. if (res == S3E_RESULT_SUCCESS)
  81. g_GotExt = true;
  82. else
  83. s3eDebugAssertShow(S3E_MESSAGE_CONTINUE_STOP_IGNORE, "error loading extension: openalext");
  84. g_TriedExt = true;
  85. g_TriedNoMsgExt = true;
  86. }
  87. return g_GotExt;
  88. }
  89. static bool _extLoadNoMsg()
  90. {
  91. if (!g_GotExt && !g_TriedNoMsgExt)
  92. {
  93. s3eResult res = s3eExtGetHash(0x37485935, &g_Ext, sizeof(g_Ext));
  94. if (res == S3E_RESULT_SUCCESS)
  95. g_GotExt = true;
  96. g_TriedNoMsgExt = true;
  97. if (g_TriedExt)
  98. g_TriedExt = true;
  99. }
  100. return g_GotExt;
  101. }
  102. s3eBool openalextAvailable()
  103. {
  104. _extLoadNoMsg();
  105. return g_GotExt ? S3E_TRUE : S3E_FALSE;
  106. }
  107. unsigned int _alGetError()
  108. {
  109. IwTrace(OPENALEXT_VERBOSE, ("calling openalext[0] func: _alGetError"));
  110. if (!_extLoad())
  111. return 0;
  112. #ifdef LOADER_CALL_LOCK
  113. s3eDeviceLoaderCallStart(S3E_TRUE, NULL);
  114. #endif
  115. unsigned int ret = g_Ext.m__alGetError();
  116. #ifdef LOADER_CALL_LOCK
  117. s3eDeviceLoaderCallDone(S3E_TRUE, NULL);
  118. #endif
  119. return ret;
  120. }
  121. void _alSourceQueueBuffers(_ALuint sid, _ALsizei numEntries, const _ALuint* bids)
  122. {
  123. IwTrace(OPENALEXT_VERBOSE, ("calling openalext[1] func: _alSourceQueueBuffers"));
  124. if (!_extLoad())
  125. return;
  126. #ifdef LOADER_CALL_LOCK
  127. s3eDeviceLoaderCallStart(S3E_TRUE, NULL);
  128. #endif
  129. g_Ext.m__alSourceQueueBuffers(sid, numEntries, bids);
  130. #ifdef LOADER_CALL_LOCK
  131. s3eDeviceLoaderCallDone(S3E_TRUE, NULL);
  132. #endif
  133. return;
  134. }
  135. void _alSourceUnqueueBuffers(_ALuint sid, _ALsizei numEntries, _ALuint* bids)
  136. {
  137. IwTrace(OPENALEXT_VERBOSE, ("calling openalext[2] func: _alSourceUnqueueBuffers"));
  138. if (!_extLoad())
  139. return;
  140. #ifdef LOADER_CALL_LOCK
  141. s3eDeviceLoaderCallStart(S3E_TRUE, NULL);
  142. #endif
  143. g_Ext.m__alSourceUnqueueBuffers(sid, numEntries, bids);
  144. #ifdef LOADER_CALL_LOCK
  145. s3eDeviceLoaderCallDone(S3E_TRUE, NULL);
  146. #endif
  147. return;
  148. }
  149. void _alGetSourcei(_ALuint sid, _ALenum param, _ALint* value)
  150. {
  151. IwTrace(OPENALEXT_VERBOSE, ("calling openalext[3] func: _alGetSourcei"));
  152. if (!_extLoad())
  153. return;
  154. #ifdef LOADER_CALL_LOCK
  155. s3eDeviceLoaderCallStart(S3E_TRUE, NULL);
  156. #endif
  157. g_Ext.m__alGetSourcei(sid, param, value);
  158. #ifdef LOADER_CALL_LOCK
  159. s3eDeviceLoaderCallDone(S3E_TRUE, NULL);
  160. #endif
  161. return;
  162. }
  163. void _alGetSourcef(_ALuint sid, _ALenum param, _ALfloat* value)
  164. {
  165. IwTrace(OPENALEXT_VERBOSE, ("calling openalext[4] func: _alGetSourcef"));
  166. if (!_extLoad())
  167. return;
  168. #ifdef LOADER_CALL_LOCK
  169. s3eDeviceLoaderCallStart(S3E_TRUE, NULL);
  170. #endif
  171. g_Ext.m__alGetSourcef(sid, param, value);
  172. #ifdef LOADER_CALL_LOCK
  173. s3eDeviceLoaderCallDone(S3E_TRUE, NULL);
  174. #endif
  175. return;
  176. }
  177. void _alSourcef(_ALuint sid, _ALenum param, _ALfloat value)
  178. {
  179. IwTrace(OPENALEXT_VERBOSE, ("calling openalext[5] func: _alSourcef"));
  180. if (!_extLoad())
  181. return;
  182. #ifdef LOADER_CALL_LOCK
  183. s3eDeviceLoaderCallStart(S3E_TRUE, NULL);
  184. #endif
  185. g_Ext.m__alSourcef(sid, param, value);
  186. #ifdef LOADER_CALL_LOCK
  187. s3eDeviceLoaderCallDone(S3E_TRUE, NULL);
  188. #endif
  189. return;
  190. }
  191. void _alSourcei(_ALuint sid, _ALenum param, _ALint value)
  192. {
  193. IwTrace(OPENALEXT_VERBOSE, ("calling openalext[6] func: _alSourcei"));
  194. if (!_extLoad())
  195. return;
  196. #ifdef LOADER_CALL_LOCK
  197. s3eDeviceLoaderCallStart(S3E_TRUE, NULL);
  198. #endif
  199. g_Ext.m__alSourcei(sid, param, value);
  200. #ifdef LOADER_CALL_LOCK
  201. s3eDeviceLoaderCallDone(S3E_TRUE, NULL);
  202. #endif
  203. return;
  204. }
  205. void _alSourcePlay(_ALuint sid)
  206. {
  207. IwTrace(OPENALEXT_VERBOSE, ("calling openalext[7] func: _alSourcePlay"));
  208. if (!_extLoad())
  209. return;
  210. #ifdef LOADER_CALL_LOCK
  211. s3eDeviceLoaderCallStart(S3E_TRUE, NULL);
  212. #endif
  213. g_Ext.m__alSourcePlay(sid);
  214. #ifdef LOADER_CALL_LOCK
  215. s3eDeviceLoaderCallDone(S3E_TRUE, NULL);
  216. #endif
  217. return;
  218. }
  219. void _alSourceStop(_ALuint sid)
  220. {
  221. IwTrace(OPENALEXT_VERBOSE, ("calling openalext[8] func: _alSourceStop"));
  222. if (!_extLoad())
  223. return;
  224. #ifdef LOADER_CALL_LOCK
  225. s3eDeviceLoaderCallStart(S3E_TRUE, NULL);
  226. #endif
  227. g_Ext.m__alSourceStop(sid);
  228. #ifdef LOADER_CALL_LOCK
  229. s3eDeviceLoaderCallDone(S3E_TRUE, NULL);
  230. #endif
  231. return;
  232. }
  233. void _alSourcePause(_ALuint sid)
  234. {
  235. IwTrace(OPENALEXT_VERBOSE, ("calling openalext[9] func: _alSourcePause"));
  236. if (!_extLoad())
  237. return;
  238. #ifdef LOADER_CALL_LOCK
  239. s3eDeviceLoaderCallStart(S3E_TRUE, NULL);
  240. #endif
  241. g_Ext.m__alSourcePause(sid);
  242. #ifdef LOADER_CALL_LOCK
  243. s3eDeviceLoaderCallDone(S3E_TRUE, NULL);
  244. #endif
  245. return;
  246. }
  247. void _alGenSources(_ALsizei n, _ALuint* sources)
  248. {
  249. IwTrace(OPENALEXT_VERBOSE, ("calling openalext[10] func: _alGenSources"));
  250. if (!_extLoad())
  251. return;
  252. #ifdef LOADER_CALL_LOCK
  253. s3eDeviceLoaderCallStart(S3E_TRUE, NULL);
  254. #endif
  255. g_Ext.m__alGenSources(n, sources);
  256. #ifdef LOADER_CALL_LOCK
  257. s3eDeviceLoaderCallDone(S3E_TRUE, NULL);
  258. #endif
  259. return;
  260. }
  261. void _alDeleteSources(_ALsizei n, const _ALuint* sources)
  262. {
  263. IwTrace(OPENALEXT_VERBOSE, ("calling openalext[11] func: _alDeleteSources"));
  264. if (!_extLoad())
  265. return;
  266. #ifdef LOADER_CALL_LOCK
  267. s3eDeviceLoaderCallStart(S3E_TRUE, NULL);
  268. #endif
  269. g_Ext.m__alDeleteSources(n, sources);
  270. #ifdef LOADER_CALL_LOCK
  271. s3eDeviceLoaderCallDone(S3E_TRUE, NULL);
  272. #endif
  273. return;
  274. }
  275. void _alGenBuffers(_ALsizei n, _ALuint* buffers)
  276. {
  277. IwTrace(OPENALEXT_VERBOSE, ("calling openalext[12] func: _alGenBuffers"));
  278. if (!_extLoad())
  279. return;
  280. #ifdef LOADER_CALL_LOCK
  281. s3eDeviceLoaderCallStart(S3E_TRUE, NULL);
  282. #endif
  283. g_Ext.m__alGenBuffers(n, buffers);
  284. #ifdef LOADER_CALL_LOCK
  285. s3eDeviceLoaderCallDone(S3E_TRUE, NULL);
  286. #endif
  287. return;
  288. }
  289. void _alDeleteBuffers(_ALsizei n, const _ALuint* buffers)
  290. {
  291. IwTrace(OPENALEXT_VERBOSE, ("calling openalext[13] func: _alDeleteBuffers"));
  292. if (!_extLoad())
  293. return;
  294. #ifdef LOADER_CALL_LOCK
  295. s3eDeviceLoaderCallStart(S3E_TRUE, NULL);
  296. #endif
  297. g_Ext.m__alDeleteBuffers(n, buffers);
  298. #ifdef LOADER_CALL_LOCK
  299. s3eDeviceLoaderCallDone(S3E_TRUE, NULL);
  300. #endif
  301. return;
  302. }
  303. void _alBufferData(_ALuint bid, _ALenum format, const _ALvoid* data, _ALsizei size, _ALsizei freq)
  304. {
  305. IwTrace(OPENALEXT_VERBOSE, ("calling openalext[14] func: _alBufferData"));
  306. if (!_extLoad())
  307. return;
  308. #ifdef LOADER_CALL_LOCK
  309. s3eDeviceLoaderCallStart(S3E_TRUE, NULL);
  310. #endif
  311. g_Ext.m__alBufferData(bid, format, data, size, freq);
  312. #ifdef LOADER_CALL_LOCK
  313. s3eDeviceLoaderCallDone(S3E_TRUE, NULL);
  314. #endif
  315. return;
  316. }
  317. _ALCdevice* _alcOpenDevice(const char* devicename)
  318. {
  319. IwTrace(OPENALEXT_VERBOSE, ("calling openalext[15] func: _alcOpenDevice"));
  320. if (!_extLoad())
  321. return 0;
  322. #ifdef LOADER_CALL_LOCK
  323. s3eDeviceLoaderCallStart(S3E_TRUE, NULL);
  324. #endif
  325. _ALCdevice* ret = g_Ext.m__alcOpenDevice(devicename);
  326. #ifdef LOADER_CALL_LOCK
  327. s3eDeviceLoaderCallDone(S3E_TRUE, NULL);
  328. #endif
  329. return ret;
  330. }
  331. void _alcCloseDevice(_ALCdevice* device)
  332. {
  333. IwTrace(OPENALEXT_VERBOSE, ("calling openalext[16] func: _alcCloseDevice"));
  334. if (!_extLoad())
  335. return;
  336. #ifdef LOADER_CALL_LOCK
  337. s3eDeviceLoaderCallStart(S3E_TRUE, NULL);
  338. #endif
  339. g_Ext.m__alcCloseDevice(device);
  340. #ifdef LOADER_CALL_LOCK
  341. s3eDeviceLoaderCallDone(S3E_TRUE, NULL);
  342. #endif
  343. return;
  344. }
  345. _ALCcontext * _alcCreateContext(_ALCdevice* device, const _ALCint* attrlist)
  346. {
  347. IwTrace(OPENALEXT_VERBOSE, ("calling openalext[17] func: _alcCreateContext"));
  348. if (!_extLoad())
  349. return 0;
  350. #ifdef LOADER_CALL_LOCK
  351. s3eDeviceLoaderCallStart(S3E_TRUE, NULL);
  352. #endif
  353. _ALCcontext * ret = g_Ext.m__alcCreateContext(device, attrlist);
  354. #ifdef LOADER_CALL_LOCK
  355. s3eDeviceLoaderCallDone(S3E_TRUE, NULL);
  356. #endif
  357. return ret;
  358. }
  359. _ALCboolean _alcMakeContextCurrent(_ALCcontext* context)
  360. {
  361. IwTrace(OPENALEXT_VERBOSE, ("calling openalext[18] func: _alcMakeContextCurrent"));
  362. if (!_extLoad())
  363. return 0;
  364. #ifdef LOADER_CALL_LOCK
  365. s3eDeviceLoaderCallStart(S3E_TRUE, NULL);
  366. #endif
  367. _ALCboolean ret = g_Ext.m__alcMakeContextCurrent(context);
  368. #ifdef LOADER_CALL_LOCK
  369. s3eDeviceLoaderCallDone(S3E_TRUE, NULL);
  370. #endif
  371. return ret;
  372. }
  373. void _alcProcessContext(_ALCcontext* context)
  374. {
  375. IwTrace(OPENALEXT_VERBOSE, ("calling openalext[19] func: _alcProcessContext"));
  376. if (!_extLoad())
  377. return;
  378. #ifdef LOADER_CALL_LOCK
  379. s3eDeviceLoaderCallStart(S3E_TRUE, NULL);
  380. #endif
  381. g_Ext.m__alcProcessContext(context);
  382. #ifdef LOADER_CALL_LOCK
  383. s3eDeviceLoaderCallDone(S3E_TRUE, NULL);
  384. #endif
  385. return;
  386. }
  387. void _alcSuspendContext(_ALCcontext* context)
  388. {
  389. IwTrace(OPENALEXT_VERBOSE, ("calling openalext[20] func: _alcSuspendContext"));
  390. if (!_extLoad())
  391. return;
  392. #ifdef LOADER_CALL_LOCK
  393. s3eDeviceLoaderCallStart(S3E_TRUE, NULL);
  394. #endif
  395. g_Ext.m__alcSuspendContext(context);
  396. #ifdef LOADER_CALL_LOCK
  397. s3eDeviceLoaderCallDone(S3E_TRUE, NULL);
  398. #endif
  399. return;
  400. }
  401. void _alcDestroyContext(_ALCcontext* context)
  402. {
  403. IwTrace(OPENALEXT_VERBOSE, ("calling openalext[21] func: _alcDestroyContext"));
  404. if (!_extLoad())
  405. return;
  406. #ifdef LOADER_CALL_LOCK
  407. s3eDeviceLoaderCallStart(S3E_TRUE, NULL);
  408. #endif
  409. g_Ext.m__alcDestroyContext(context);
  410. #ifdef LOADER_CALL_LOCK
  411. s3eDeviceLoaderCallDone(S3E_TRUE, NULL);
  412. #endif
  413. return;
  414. }
  415. _ALCcontext * _alcGetCurrentContext()
  416. {
  417. IwTrace(OPENALEXT_VERBOSE, ("calling openalext[22] func: _alcGetCurrentContext"));
  418. if (!_extLoad())
  419. return 0;
  420. #ifdef LOADER_CALL_LOCK
  421. s3eDeviceLoaderCallStart(S3E_TRUE, NULL);
  422. #endif
  423. _ALCcontext * ret = g_Ext.m__alcGetCurrentContext();
  424. #ifdef LOADER_CALL_LOCK
  425. s3eDeviceLoaderCallDone(S3E_TRUE, NULL);
  426. #endif
  427. return ret;
  428. }