LoadOAL.mac.cpp 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. // TODO: Implement OpenAL loading code which is currently stubbed out.
  23. #if defined(__MACOSX__) && !defined(TORQUE_OS_MAC)
  24. #define TORQUE_OS_MAC
  25. #endif
  26. #include "console/console.h"
  27. #include <err.h>
  28. #include <string.h>
  29. #include <dlfcn.h>
  30. #include "sfx/openal/LoadOAL.h"
  31. void* openal_library = NULL;
  32. ALboolean LoadOAL10Library(char *szOALFullPathName, LPOPENALFNTABLE lpOALFnTable)
  33. {
  34. // TODO: Implement this.
  35. if (!lpOALFnTable)
  36. return AL_FALSE;
  37. if (szOALFullPathName)
  38. openal_library = dlopen(szOALFullPathName, RTLD_NOW);
  39. else
  40. {
  41. #ifdef TORQUE_DEBUG
  42. openal_library = dlopen("@rpath/libopenald.1.23.1.dylib", RTLD_NOW);
  43. if (openal_library == NULL)
  44. {
  45. openal_library = dlopen("@rpath/libopenald.1.dylib", RTLD_NOW);
  46. }
  47. #else
  48. openal_library = dlopen("@rpath/libopenal.1.23.1.dylib", RTLD_NOW);
  49. if (openal_library == NULL)
  50. {
  51. openal_library = dlopen("@rpath/libopenal .1.dylib", RTLD_NOW);
  52. }
  53. #endif
  54. }
  55. if (openal_library == NULL)
  56. {
  57. Con::errorf("Failed to load OpenAL shared library. Sound will not be available");
  58. return AL_FALSE;
  59. }
  60. memset(lpOALFnTable, 0, sizeof(OPENALFNTABLE));
  61. lpOALFnTable->alEnable = (LPALENABLE)dlsym(openal_library,"alEnable");
  62. if (lpOALFnTable->alEnable == NULL)
  63. {
  64. warn("Failed to retrieve 'alEnable' function address\n");
  65. return AL_FALSE;
  66. }
  67. lpOALFnTable->alDisable = (LPALDISABLE)dlsym(openal_library,"alDisable");
  68. if (lpOALFnTable->alDisable == NULL)
  69. {
  70. warn("Failed to retrieve 'alDisable' function address\n");
  71. return AL_FALSE;
  72. }
  73. lpOALFnTable->alIsEnabled = (LPALISENABLED)dlsym(openal_library,"alIsEnabled");
  74. if (lpOALFnTable->alIsEnabled == NULL)
  75. {
  76. warn("Failed to retrieve 'alIsEnabled' function address\n");
  77. return AL_FALSE;
  78. }
  79. lpOALFnTable->alGetBoolean = (LPALGETBOOLEAN)dlsym(openal_library,"alGetBoolean");
  80. if (lpOALFnTable->alGetBoolean == NULL)
  81. {
  82. warn("Failed to retrieve 'alGetBoolean' function address\n");
  83. return AL_FALSE;
  84. }
  85. lpOALFnTable->alGetInteger = (LPALGETINTEGER)dlsym(openal_library,"alGetInteger");
  86. if (lpOALFnTable->alGetInteger == NULL)
  87. {
  88. warn("Failed to retrieve 'alGetInteger' function address\n");
  89. return AL_FALSE;
  90. }
  91. lpOALFnTable->alGetFloat = (LPALGETFLOAT)dlsym(openal_library,"alGetFloat");
  92. if (lpOALFnTable->alGetFloat == NULL)
  93. {
  94. warn("Failed to retrieve 'alGetFloat' function address\n");
  95. return AL_FALSE;
  96. }
  97. lpOALFnTable->alGetDouble = (LPALGETDOUBLE)dlsym(openal_library,"alGetDouble");
  98. if (lpOALFnTable->alGetDouble == NULL)
  99. {
  100. warn("Failed to retrieve 'alGetDouble' function address\n");
  101. return AL_FALSE;
  102. }
  103. lpOALFnTable->alGetBooleanv = (LPALGETBOOLEANV)dlsym(openal_library,"alGetBooleanv");
  104. if (lpOALFnTable->alGetBooleanv == NULL)
  105. {
  106. warn("Failed to retrieve 'alGetBooleanv' function address\n");
  107. return AL_FALSE;
  108. }
  109. lpOALFnTable->alGetIntegerv = (LPALGETINTEGERV)dlsym(openal_library,"alGetIntegerv");
  110. if (lpOALFnTable->alGetIntegerv == NULL)
  111. {
  112. warn("Failed to retrieve 'alGetIntegerv' function address\n");
  113. return AL_FALSE;
  114. }
  115. lpOALFnTable->alGetFloatv = (LPALGETFLOATV)dlsym(openal_library,"alGetFloatv");
  116. if (lpOALFnTable->alGetFloatv == NULL)
  117. {
  118. warn("Failed to retrieve 'alGetFloatv' function address\n");
  119. return AL_FALSE;
  120. }
  121. lpOALFnTable->alGetDoublev = (LPALGETDOUBLEV)dlsym(openal_library,"alGetDoublev");
  122. if (lpOALFnTable->alGetDoublev == NULL)
  123. {
  124. warn("Failed to retrieve 'alGetDoublev' function address\n");
  125. return AL_FALSE;
  126. }
  127. lpOALFnTable->alGetString = (LPALGETSTRING)dlsym(openal_library,"alGetString");
  128. if (lpOALFnTable->alGetString == NULL)
  129. {
  130. warn("Failed to retrieve 'alGetString' function address\n");
  131. return AL_FALSE;
  132. }
  133. lpOALFnTable->alGetError = (LPALGETERROR)dlsym(openal_library,"alGetError");
  134. if (lpOALFnTable->alGetError == NULL)
  135. {
  136. warn("Failed to retrieve 'alGetError' function address\n");
  137. return AL_FALSE;
  138. }
  139. lpOALFnTable->alIsExtensionPresent = (LPALISEXTENSIONPRESENT)dlsym(openal_library,"alIsExtensionPresent");
  140. if (lpOALFnTable->alIsExtensionPresent == NULL)
  141. {
  142. warn("Failed to retrieve 'alIsExtensionPresent' function address\n");
  143. return AL_FALSE;
  144. }
  145. lpOALFnTable->alGetProcAddress = (LPALGETPROCADDRESS)dlsym(openal_library,"alGetProcAddress");
  146. if (lpOALFnTable->alGetProcAddress == NULL)
  147. {
  148. warn("Failed to retrieve 'alGetProcAddress' function address\n");
  149. return AL_FALSE;
  150. }
  151. lpOALFnTable->alGetEnumValue = (LPALGETENUMVALUE)dlsym(openal_library,"alGetEnumValue");
  152. if (lpOALFnTable->alGetEnumValue == NULL)
  153. {
  154. warn("Failed to retrieve 'alGetEnumValue' function address\n");
  155. return AL_FALSE;
  156. }
  157. lpOALFnTable->alListeneri = (LPALLISTENERI)dlsym(openal_library,"alListeneri");
  158. if (lpOALFnTable->alListeneri == NULL)
  159. {
  160. warn("Failed to retrieve 'alListeneri' function address\n");
  161. return AL_FALSE;
  162. }
  163. lpOALFnTable->alListenerf = (LPALLISTENERF)dlsym(openal_library,"alListenerf");
  164. if (lpOALFnTable->alListenerf == NULL)
  165. {
  166. warn("Failed to retrieve 'alListenerf' function address\n");
  167. return AL_FALSE;
  168. }
  169. lpOALFnTable->alListener3f = (LPALLISTENER3F)dlsym(openal_library,"alListener3f");
  170. if (lpOALFnTable->alListener3f == NULL)
  171. {
  172. warn("Failed to retrieve 'alListener3f' function address\n");
  173. return AL_FALSE;
  174. }
  175. lpOALFnTable->alListenerfv = (LPALLISTENERFV)dlsym(openal_library,"alListenerfv");
  176. if (lpOALFnTable->alListenerfv == NULL)
  177. {
  178. warn("Failed to retrieve 'alListenerfv' function address\n");
  179. return AL_FALSE;
  180. }
  181. lpOALFnTable->alGetListeneri = (LPALGETLISTENERI)dlsym(openal_library,"alGetListeneri");
  182. if (lpOALFnTable->alGetListeneri == NULL)
  183. {
  184. warn("Failed to retrieve 'alGetListeneri' function address\n");
  185. return AL_FALSE;
  186. }
  187. lpOALFnTable->alGetListenerf =(LPALGETLISTENERF)dlsym(openal_library,"alGetListenerf");
  188. if (lpOALFnTable->alGetListenerf == NULL)
  189. {
  190. warn("Failed to retrieve 'alGetListenerf' function address\n");
  191. return AL_FALSE;
  192. }
  193. lpOALFnTable->alGetListener3f = (LPALGETLISTENER3F)dlsym(openal_library,"alGetListener3f");
  194. if (lpOALFnTable->alGetListener3f == NULL)
  195. {
  196. warn("Failed to retrieve 'alGetListener3f' function address\n");
  197. return AL_FALSE;
  198. }
  199. lpOALFnTable->alGetListenerfv = (LPALGETLISTENERFV)dlsym(openal_library,"alGetListenerfv");
  200. if (lpOALFnTable->alGetListenerfv == NULL)
  201. {
  202. warn("Failed to retrieve 'alGetListenerfv' function address\n");
  203. return AL_FALSE;
  204. }
  205. lpOALFnTable->alGenSources = (LPALGENSOURCES)dlsym(openal_library,"alGenSources");
  206. if (lpOALFnTable->alGenSources == NULL)
  207. {
  208. warn("Failed to retrieve 'alGenSources' function address\n");
  209. return AL_FALSE;
  210. }
  211. lpOALFnTable->alDeleteSources = (LPALDELETESOURCES)dlsym(openal_library,"alDeleteSources");
  212. if (lpOALFnTable->alDeleteSources == NULL)
  213. {
  214. warn("Failed to retrieve 'alDeleteSources' function address\n");
  215. return AL_FALSE;
  216. }
  217. lpOALFnTable->alIsSource = (LPALISSOURCE)dlsym(openal_library,"alIsSource");
  218. if (lpOALFnTable->alIsSource == NULL)
  219. {
  220. warn("Failed to retrieve 'alIsSource' function address\n");
  221. return AL_FALSE;
  222. }
  223. lpOALFnTable->alSourcei = (LPALSOURCEI)dlsym(openal_library,"alSourcei");
  224. if (lpOALFnTable->alSourcei == NULL)
  225. {
  226. warn("Failed to retrieve 'alSourcei' function address\n");
  227. return AL_FALSE;
  228. }
  229. lpOALFnTable->alSourcef = (LPALSOURCEF)dlsym(openal_library,"alSourcef");
  230. if (lpOALFnTable->alSourcef == NULL)
  231. {
  232. warn("Failed to retrieve 'alSourcef' function address\n");
  233. return AL_FALSE;
  234. }
  235. lpOALFnTable->alSource3f = (LPALSOURCE3F)dlsym(openal_library,"alSource3f");
  236. if (lpOALFnTable->alSource3f == NULL)
  237. {
  238. warn("Failed to retrieve 'alSource3f' function address\n");
  239. return AL_FALSE;
  240. }
  241. lpOALFnTable->alSourcefv = (LPALSOURCEFV)dlsym(openal_library,"alSourcefv");
  242. if (lpOALFnTable->alSourcefv == NULL)
  243. {
  244. warn("Failed to retrieve 'alSourcefv' function address\n");
  245. return AL_FALSE;
  246. }
  247. lpOALFnTable->alGetSourcei = (LPALGETSOURCEI)dlsym(openal_library,"alGetSourcei");
  248. if (lpOALFnTable->alGetSourcei == NULL)
  249. {
  250. warn("Failed to retrieve 'alGetSourcei' function address\n");
  251. return AL_FALSE;
  252. }
  253. lpOALFnTable->alGetSourcef = (LPALGETSOURCEF)dlsym(openal_library,"alGetSourcef");
  254. if (lpOALFnTable->alGetSourcef == NULL)
  255. {
  256. warn("Failed to retrieve 'alGetSourcef' function address\n");
  257. return AL_FALSE;
  258. }
  259. lpOALFnTable->alGetSourcefv = (LPALGETSOURCEFV)dlsym(openal_library,"alGetSourcefv");
  260. if (lpOALFnTable->alGetSourcefv == NULL)
  261. {
  262. warn("Failed to retrieve 'alGetSourcefv' function address\n");
  263. return AL_FALSE;
  264. }
  265. lpOALFnTable->alSourcePlayv = (LPALSOURCEPLAYV)dlsym(openal_library,"alSourcePlayv");
  266. if (lpOALFnTable->alSourcePlayv == NULL)
  267. {
  268. warn("Failed to retrieve 'alSourcePlayv' function address\n");
  269. return AL_FALSE;
  270. }
  271. lpOALFnTable->alSourceStopv = (LPALSOURCESTOPV)dlsym(openal_library,"alSourceStopv");
  272. if (lpOALFnTable->alSourceStopv == NULL)
  273. {
  274. warn("Failed to retrieve 'alSourceStopv' function address\n");
  275. return AL_FALSE;
  276. }
  277. lpOALFnTable->alSourcePlay = (LPALSOURCEPLAY)dlsym(openal_library,"alSourcePlay");
  278. if (lpOALFnTable->alSourcePlay == NULL)
  279. {
  280. warn("Failed to retrieve 'alSourcePlay' function address\n");
  281. return AL_FALSE;
  282. }
  283. lpOALFnTable->alSourcePause = (LPALSOURCEPAUSE)dlsym(openal_library,"alSourcePause");
  284. if (lpOALFnTable->alSourcePause == NULL)
  285. {
  286. warn("Failed to retrieve 'alSourcePause' function address\n");
  287. return AL_FALSE;
  288. }
  289. lpOALFnTable->alSourceStop = (LPALSOURCESTOP)dlsym(openal_library,"alSourceStop");
  290. if (lpOALFnTable->alSourceStop == NULL)
  291. {
  292. warn("Failed to retrieve 'alSourceStop' function address\n");
  293. return AL_FALSE;
  294. }
  295. lpOALFnTable->alSourceRewind = (LPALSOURCEREWIND)dlsym(openal_library,"alSourceRewind");
  296. if (lpOALFnTable->alSourceRewind == NULL)
  297. {
  298. warn("Failed to retrieve 'alSourceRewind' function address\n");
  299. return AL_FALSE;
  300. }
  301. lpOALFnTable->alGenBuffers = (LPALGENBUFFERS)dlsym(openal_library,"alGenBuffers");
  302. if (lpOALFnTable->alGenBuffers == NULL)
  303. {
  304. warn("Failed to retrieve 'alGenBuffers' function address\n");
  305. return AL_FALSE;
  306. }
  307. lpOALFnTable->alDeleteBuffers = (LPALDELETEBUFFERS)dlsym(openal_library,"alDeleteBuffers");
  308. if (lpOALFnTable->alDeleteBuffers == NULL)
  309. {
  310. warn("Failed to retrieve 'alDeleteBuffers' function address\n");
  311. return AL_FALSE;
  312. }
  313. lpOALFnTable->alIsBuffer = (LPALISBUFFER)dlsym(openal_library,"alIsBuffer");
  314. if (lpOALFnTable->alIsBuffer == NULL)
  315. {
  316. warn("Failed to retrieve 'alIsBuffer' function address\n");
  317. return AL_FALSE;
  318. }
  319. lpOALFnTable->alBufferData = (LPALBUFFERDATA)dlsym(openal_library,"alBufferData");
  320. if (lpOALFnTable->alBufferData == NULL)
  321. {
  322. warn("Failed to retrieve 'alBufferData' function address\n");
  323. return AL_FALSE;
  324. }
  325. lpOALFnTable->alGetBufferi = (LPALGETBUFFERI)dlsym(openal_library,"alGetBufferi");
  326. if (lpOALFnTable->alGetBufferi == NULL)
  327. {
  328. warn("Failed to retrieve 'alGetBufferi' function address\n");
  329. return AL_FALSE;
  330. }
  331. lpOALFnTable->alGetBufferf = (LPALGETBUFFERF)dlsym(openal_library,"alGetBufferf");
  332. if (lpOALFnTable->alGetBufferf == NULL)
  333. {
  334. warn("Failed to retrieve 'alGetBufferf' function address\n");
  335. return AL_FALSE;
  336. }
  337. lpOALFnTable->alSourceQueueBuffers = (LPALSOURCEQUEUEBUFFERS)dlsym(openal_library,"alSourceQueueBuffers");
  338. if (lpOALFnTable->alSourceQueueBuffers == NULL)
  339. {
  340. warn("Failed to retrieve 'alSourceQueueBuffers' function address\n");
  341. return AL_FALSE;
  342. }
  343. lpOALFnTable->alSourceUnqueueBuffers = (LPALSOURCEUNQUEUEBUFFERS)dlsym(openal_library,"alSourceUnqueueBuffers");
  344. if (lpOALFnTable->alSourceUnqueueBuffers == NULL)
  345. {
  346. warn("Failed to retrieve 'alSourceUnqueueBuffers' function address\n");
  347. return AL_FALSE;
  348. }
  349. lpOALFnTable->alDistanceModel = (LPALDISTANCEMODEL)dlsym(openal_library,"alDistanceModel");
  350. if (lpOALFnTable->alDistanceModel == NULL)
  351. {
  352. warn("Failed to retrieve 'alDistanceModel' function address\n");
  353. return AL_FALSE;
  354. }
  355. lpOALFnTable->alDopplerFactor = (LPALDOPPLERFACTOR)dlsym(openal_library,"alDopplerFactor");
  356. if (lpOALFnTable->alDopplerFactor == NULL)
  357. {
  358. warn("Failed to retrieve 'alDopplerFactor' function address\n");
  359. return AL_FALSE;
  360. }
  361. lpOALFnTable->alDopplerVelocity = (LPALDOPPLERVELOCITY)dlsym(openal_library,"alDopplerVelocity");
  362. if (lpOALFnTable->alDopplerVelocity == NULL)
  363. {
  364. warn("Failed to retrieve 'alDopplerVelocity' function address\n");
  365. return AL_FALSE;
  366. }
  367. lpOALFnTable->alcGetString = (LPALCGETSTRING)dlsym(openal_library,"alcGetString");
  368. if (lpOALFnTable->alcGetString == NULL)
  369. {
  370. warn("Failed to retrieve 'alcGetString' function address\n");
  371. return AL_FALSE;
  372. }
  373. lpOALFnTable->alcGetIntegerv = (LPALCGETINTEGERV)dlsym(openal_library,"alcGetIntegerv");
  374. if (lpOALFnTable->alcGetIntegerv == NULL)
  375. {
  376. warn("Failed to retrieve 'alcGetIntegerv' function address\n");
  377. return AL_FALSE;
  378. }
  379. lpOALFnTable->alcOpenDevice = (LPALCOPENDEVICE)dlsym(openal_library,"alcOpenDevice");
  380. if (lpOALFnTable->alcOpenDevice == NULL)
  381. {
  382. warn("Failed to retrieve 'alcOpenDevice' function address\n");
  383. return AL_FALSE;
  384. }
  385. lpOALFnTable->alcCloseDevice = (LPALCCLOSEDEVICE)dlsym(openal_library,"alcCloseDevice");
  386. if (lpOALFnTable->alcCloseDevice == NULL)
  387. {
  388. warn("Failed to retrieve 'alcCloseDevice' function address\n");
  389. return AL_FALSE;
  390. }
  391. lpOALFnTable->alcCreateContext = (LPALCCREATECONTEXT)dlsym(openal_library,"alcCreateContext");
  392. if (lpOALFnTable->alcCreateContext == NULL)
  393. {
  394. warn("Failed to retrieve 'alcCreateContext' function address\n");
  395. return AL_FALSE;
  396. }
  397. lpOALFnTable->alcMakeContextCurrent = (LPALCMAKECONTEXTCURRENT)dlsym(openal_library,"alcMakeContextCurrent");
  398. if (lpOALFnTable->alcMakeContextCurrent == NULL)
  399. {
  400. warn("Failed to retrieve 'alcMakeContextCurrent' function address\n");
  401. return AL_FALSE;
  402. }
  403. lpOALFnTable->alcProcessContext = (LPALCPROCESSCONTEXT)dlsym(openal_library,"alcProcessContext");
  404. if (lpOALFnTable->alcProcessContext == NULL)
  405. {
  406. warn("Failed to retrieve 'alcProcessContext' function address\n");
  407. return AL_FALSE;
  408. }
  409. lpOALFnTable->alcGetCurrentContext = (LPALCGETCURRENTCONTEXT)dlsym(openal_library,"alcGetCurrentContext");
  410. if (lpOALFnTable->alcGetCurrentContext == NULL)
  411. {
  412. warn("Failed to retrieve 'alcGetCurrentContext' function address\n");
  413. return AL_FALSE;
  414. }
  415. lpOALFnTable->alcGetContextsDevice = (LPALCGETCONTEXTSDEVICE)dlsym(openal_library,"alcGetContextsDevice");
  416. if (lpOALFnTable->alcGetContextsDevice == NULL)
  417. {
  418. warn("Failed to retrieve 'alcGetContextsDevice' function address\n");
  419. return AL_FALSE;
  420. }
  421. lpOALFnTable->alcSuspendContext = (LPALCSUSPENDCONTEXT)dlsym(openal_library,"alcSuspendContext");
  422. if (lpOALFnTable->alcSuspendContext == NULL)
  423. {
  424. warn("Failed to retrieve 'alcSuspendContext' function address\n");
  425. return AL_FALSE;
  426. }
  427. lpOALFnTable->alcDestroyContext = (LPALCDESTROYCONTEXT)dlsym(openal_library,"alcDestroyContext");
  428. if (lpOALFnTable->alcDestroyContext == NULL)
  429. {
  430. warn("Failed to retrieve 'alcDestroyContext' function address\n");
  431. return AL_FALSE;
  432. }
  433. lpOALFnTable->alcGetError = (LPALCGETERROR)dlsym(openal_library,"alcGetError");
  434. if (lpOALFnTable->alcGetError == NULL)
  435. {
  436. warn("Failed to retrieve 'alcGetError' function address\n");
  437. return AL_FALSE;
  438. }
  439. lpOALFnTable->alcIsExtensionPresent = (LPALCISEXTENSIONPRESENT)dlsym(openal_library,"alcIsExtensionPresent");
  440. if (lpOALFnTable->alcIsExtensionPresent == NULL)
  441. {
  442. warn("Failed to retrieve 'alcIsExtensionPresent' function address\n");
  443. return AL_FALSE;
  444. }
  445. lpOALFnTable->alcGetProcAddress = (LPALCGETPROCADDRESS)dlsym(openal_library,"alcGetProcAddress");
  446. if (lpOALFnTable->alcGetProcAddress == NULL)
  447. {
  448. warn("Failed to retrieve 'alcGetProcAddress' function address\n");
  449. return AL_FALSE;
  450. }
  451. lpOALFnTable->alcGetEnumValue = (LPALCGETENUMVALUE)dlsym(openal_library,"alcGetEnumValue");
  452. if (lpOALFnTable->alcGetEnumValue == NULL)
  453. {
  454. warn("Failed to retrieve 'alcGetEnumValue' function address\n");
  455. return AL_FALSE;
  456. }
  457. #if defined(AL_ALEXT_PROTOTYPES)
  458. //efx
  459. lpOALFnTable->alGenEffects = (LPALGENEFFECTS)dlsym(openal_library, "alGenEffects");
  460. if (lpOALFnTable->alGenEffects == NULL)
  461. {
  462. warn("Failed to retrieve 'alGenEffects' function address\n");
  463. return AL_FALSE;
  464. }
  465. lpOALFnTable->alEffecti = (LPALEFFECTI)dlsym(openal_library, "alEffecti");
  466. if (lpOALFnTable->alEffecti == NULL)
  467. {
  468. warn("Failed to retrieve 'alEffecti' function address\n");
  469. return AL_FALSE;
  470. }
  471. lpOALFnTable->alEffectiv = (LPALEFFECTIV)dlsym(openal_library, "alEffectiv");
  472. if (lpOALFnTable->alEffectiv == NULL)
  473. {
  474. warn("Failed to retrieve 'alEffectiv' function address\n");
  475. return AL_FALSE;
  476. }
  477. lpOALFnTable->alEffectf = (LPALEFFECTF)dlsym(openal_library, "alEffectf");
  478. if (lpOALFnTable->alEffectf == NULL)
  479. {
  480. warn("Failed to retrieve 'alEffectf' function address\n");
  481. return AL_FALSE;
  482. }
  483. lpOALFnTable->alEffectfv = (LPALEFFECTFV)dlsym(openal_library, "alEffectfv");
  484. if (lpOALFnTable->alEffectfv == NULL)
  485. {
  486. warn("Failed to retrieve 'alEffectfv' function address\n");
  487. return AL_FALSE;
  488. }
  489. lpOALFnTable->alGetEffecti = (LPALGETEFFECTI)dlsym(openal_library, "alGetEffecti");
  490. if (lpOALFnTable->alGetEffecti == NULL)
  491. {
  492. warn("Failed to retrieve 'alGetEffecti' function address\n");
  493. return AL_FALSE;
  494. }
  495. lpOALFnTable->alGetEffectiv = (LPALGETEFFECTIV)dlsym(openal_library, "alGetEffectiv");
  496. if (lpOALFnTable->alGetEffectiv == NULL)
  497. {
  498. warn("Failed to retrieve 'alGetEffectiv' function address\n");
  499. return AL_FALSE;
  500. }
  501. lpOALFnTable->alGetEffectf = (LPALGETEFFECTF)dlsym(openal_library, "alGetEffectf");
  502. if (lpOALFnTable->alGetEffectf == NULL)
  503. {
  504. warn("Failed to retrieve 'alGetEffectf' function address\n");
  505. return AL_FALSE;
  506. }
  507. lpOALFnTable->alGetEffectfv = (LPALGETEFFECTFV)dlsym(openal_library, "alGetEffectfv");
  508. if (lpOALFnTable->alGetEffectfv == NULL)
  509. {
  510. warn("Failed to retrieve 'alGetEffectfv' function address\n");
  511. return AL_FALSE;
  512. }
  513. lpOALFnTable->alDeleteEffects = (LPALDELETEEFFECTS)dlsym(openal_library, "alDeleteEffects");
  514. if (lpOALFnTable->alDeleteEffects == NULL)
  515. {
  516. warn("Failed to retrieve 'alDeleteEffects' function address\n");
  517. return AL_FALSE;
  518. }
  519. lpOALFnTable->alIsEffect = (LPALISEFFECT)dlsym(openal_library, "alIsEffect");
  520. if (lpOALFnTable->alIsEffect == NULL)
  521. {
  522. warn("Failed to retrieve 'alIsEffect' function address\n");
  523. return AL_FALSE;
  524. }
  525. lpOALFnTable->alAuxiliaryEffectSlotf = (LPALAUXILIARYEFFECTSLOTF)dlsym(openal_library, "alAuxiliaryEffectSlotf");
  526. if (lpOALFnTable->alAuxiliaryEffectSlotf == NULL)
  527. {
  528. warn("Failed to retrieve 'alAuxiliaryEffectSlotf' function address\n");
  529. return AL_FALSE;
  530. }
  531. lpOALFnTable->alAuxiliaryEffectSlotfv = (LPALAUXILIARYEFFECTSLOTFV)dlsym(openal_library, "alAuxiliaryEffectSlotfv");
  532. if (lpOALFnTable->alAuxiliaryEffectSlotfv == NULL)
  533. {
  534. warn("Failed to retrieve 'alAuxiliaryEffectSlotfv' function address\n");
  535. return AL_FALSE;
  536. }
  537. lpOALFnTable->alAuxiliaryEffectSloti = (LPALAUXILIARYEFFECTSLOTI)dlsym(openal_library, "alAuxiliaryEffectSloti");
  538. if (lpOALFnTable->alAuxiliaryEffectSloti == NULL)
  539. {
  540. warn("Failed to retrieve 'alAuxiliaryEffectSloti' function address\n");
  541. return AL_FALSE;
  542. }
  543. lpOALFnTable->alAuxiliaryEffectSlotiv = (LPALAUXILIARYEFFECTSLOTIV)dlsym(openal_library, "alAuxiliaryEffectSlotiv");
  544. if (lpOALFnTable->alAuxiliaryEffectSlotiv == NULL)
  545. {
  546. warn("Failed to retrieve 'alAuxiliaryEffectSlotiv' function address\n");
  547. return AL_FALSE;
  548. }
  549. lpOALFnTable->alIsAuxiliaryEffectSlot = (LPALISAUXILIARYEFFECTSLOT)dlsym(openal_library, "alIsAuxiliaryEffectSlot");
  550. if (lpOALFnTable->alIsAuxiliaryEffectSlot == NULL)
  551. {
  552. warn("Failed to retrieve 'alIsAuxiliaryEffectSlot' function address\n");
  553. return AL_FALSE;
  554. }
  555. lpOALFnTable->alGenAuxiliaryEffectSlots = (LPALGENAUXILIARYEFFECTSLOTS)dlsym(openal_library, "alGenAuxiliaryEffectSlots");
  556. if (lpOALFnTable->alGenAuxiliaryEffectSlots == NULL)
  557. {
  558. warn("Failed to retrieve 'alGenAuxiliaryEffectSlots' function address\n");
  559. return AL_FALSE;
  560. }
  561. lpOALFnTable->alDeleteAuxiliaryEffectSlots = (LPALDELETEAUXILIARYEFFECTSLOTS)dlsym(openal_library, "alDeleteAuxiliaryEffectSlots");
  562. if (lpOALFnTable->alDeleteAuxiliaryEffectSlots == NULL)
  563. {
  564. warn("Failed to retrieve 'alDeleteAuxiliaryEffectSlots' function address\n");
  565. return AL_FALSE;
  566. }
  567. lpOALFnTable->alGetAuxiliaryEffectSlotf = (LPALGETAUXILIARYEFFECTSLOTF)dlsym(openal_library, "alGetAuxiliaryEffectSlotf");
  568. if (lpOALFnTable->alGetAuxiliaryEffectSlotf == NULL)
  569. {
  570. warn("Failed to retrieve 'alGetAuxiliaryEffectSlotf' function address\n");
  571. return AL_FALSE;
  572. }
  573. lpOALFnTable->alGetAuxiliaryEffectSlotfv = (LPALGETAUXILIARYEFFECTSLOTFV)dlsym(openal_library, "alGetAuxiliaryEffectSlotfv");
  574. if (lpOALFnTable->alGetAuxiliaryEffectSlotfv == NULL)
  575. {
  576. warn("Failed to retrieve 'alGetAuxiliaryEffectSlotfv' function address\n");
  577. return AL_FALSE;
  578. }
  579. lpOALFnTable->alGetAuxiliaryEffectSloti = (LPALGETAUXILIARYEFFECTSLOTI)dlsym(openal_library, "alGetAuxiliaryEffectSloti");
  580. if (lpOALFnTable->alGetAuxiliaryEffectSloti == NULL)
  581. {
  582. warn("Failed to retrieve 'alGetAuxiliaryEffectSloti' function address\n");
  583. return AL_FALSE;
  584. }
  585. lpOALFnTable->alGetAuxiliaryEffectSlotiv = (LPALGETAUXILIARYEFFECTSLOTIV)dlsym(openal_library, "alGetAuxiliaryEffectSlotiv");
  586. if (lpOALFnTable->alGetAuxiliaryEffectSlotiv == NULL)
  587. {
  588. warn("Failed to retrieve 'alGetAuxiliaryEffectSlotiv' function address\n");
  589. return AL_FALSE;
  590. }
  591. lpOALFnTable->alSource3i = (LPALSOURCE3I)dlsym(openal_library, "alSource3i");
  592. if (lpOALFnTable->alSource3i == NULL)
  593. {
  594. warn("Failed to retrieve 'alSource3i' function address\n");
  595. return AL_FALSE;
  596. }
  597. #endif
  598. return AL_TRUE;
  599. }
  600. ALvoid UnloadOAL10Library()
  601. {
  602. if (openal_library != NULL)
  603. dlclose(openal_library);
  604. }