root/trunk/al/alut.d

Revision 158, 2.6 kB (checked in by jpelcis, 2 years ago)

Improved Mac OS X support.

Line 
1 module c.al.alut;
2
3 /*
4  * OpenAL cross platform audio library
5  * Copyright  (C) 1999-2000 by authors.
6  * This library is free software; you can redistribute it and/or
7  *  modify it under the terms of the GNU Library General Public
8  *  License as published by the Free Software Foundation; either
9  *  version 2 of the License, or  (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  *  Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  *  License along with this library; if not, write to the
18  *  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  *  Boston, MA  02111-1307, USA.
20  * Or go to http://www.gnu.org/copyleft/lgpl.html
21  */
22
23 private import c.al.altypes;
24 private import std.loader;
25
26 private HXModule alutdrv;
27
28 private void* getProc (char[] procname) {
29     void* symbol = ExeModule_GetSymbol (alutdrv, procname);
30     if (symbol == null) {
31         printf("Failed to load alut function " ~ procname ~ ".\n");
32     }
33     return (symbol);
34 }
35
36 static this() {
37     version (Windows) {
38         alutdrv = ExeModule_Load("OpenAL32.dll");
39     } else version (linux) {
40         alutdrv = ExeModule_Load("libalut.so");
41     } else version (darwin) {
42         alutdrv = ExeModule_Load("/System/Library/Frameworks/ALUT.framework");
43     }
44     alutInit = cast(pfalutInit)getProc("alutInit");
45     alutExit = cast(pfalutExit)getProc("alutExit");
46     alutLoadWAVFile = cast(pfalutLoadWAVFile)getProc("alutLoadWAVFile");
47     alutLoadWAVMemory = cast(pfalutLoadWAVMemory)getProc("alutLoadWAVMemory");
48     alutUnloadWAV = cast(pfalutUnloadWAV)getProc("alutUnloadWAV");
49 }
50
51 static ~this() {
52     ExeModule_Release(alutdrv);
53 }
54
55 typedef void function(int*, char*[]) pfalutInit;
56 typedef void function() pfalutExit;
57
58 /* Windows and Linux versions have a loop parameter, Macintosh doesn't */
59 version (darwin) {
60     typedef void function(ALbyte*, ALenum*, ALvoid**, ALsizei*, ALsizei*) pfalutLoadWAVFile;
61     typedef void function(ALbyte*, ALenum*, ALvoid**, ALsizei*, ALsizei*) pfalutLoadWAVMemory;
62 } else {
63     typedef void function(ALbyte*, ALenum*, ALvoid**, ALsizei*, ALsizei*, ALboolean*) pfalutLoadWAVFile;
64     typedef void function(ALbyte*, ALenum*, ALvoid**, ALsizei*, ALsizei*, ALboolean*) pfalutLoadWAVMemory;
65 }
66 typedef void function(ALenum, ALvoid*, ALsizei, ALsizei) pfalutUnloadWAV;
67
68 pfalutInit      alutInit;
69 pfalutExit      alutExit;
70 pfalutLoadWAVFile   alutLoadWAVFile;
71 pfalutLoadWAVMemory alutLoadWAVMemory;
72 pfalutUnloadWAV     alutUnloadWAV;
Note: See TracBrowser for help on using the browser.