# ----------------------------------------------------------------------------
# pyglet
# Copyright (c) 2006-2008 Alex Holkner
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
#  * Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#  * Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in
#    the documentation and/or other materials provided with the
#    distribution.
#  * Neither the name of pyglet nor the names of its
#    contributors may be used to endorse or promote products
#    derived from this software without specific prior written
#    permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# ----------------------------------------------------------------------------
'''Wrapper for openal

Generated with:
../tools/wraptypes/wrap.py /usr/include/AL/al.h -lopenal -olib_openal.py

.. Hacked to remove non-existent library functions.

TODO add alGetError check.

.. alListener3i and alListeneriv are present in my OS X 10.4 but not another
10.4 user's installation.  They've also been removed for compatibility.
'''

__docformat__ =  'restructuredtext'
__version__ = '$Id: lib_openal.py 2541 2009-12-31 04:31:11Z benjamin.coder.smith@gmail.com $'

import ctypes
from ctypes import *
import sys

import pyglet.lib

_lib = pyglet.lib.load_library('openal', win32='openal32',
        framework='/System/Library/Frameworks/OpenAL.framework')

_int_types = (c_int16, c_int32)
if hasattr(ctypes, 'c_int64'):
    # Some builds of ctypes apparently do not have c_int64
    # defined; it's a pretty good bet that these builds do not
    # have 64-bit pointers.
    _int_types += (ctypes.c_int64,)
for t in _int_types:
    if sizeof(t) == sizeof(c_size_t):
        c_ptrdiff_t = t

class c_void(Structure):
    # c_void_p is a buggy return type, converting to int, so
    # POINTER(None) == c_void_p is actually written as
    # POINTER(c_void), so it can be treated as a real pointer.
    _fields_ = [('dummy', c_int)]



AL_API = 0 	# /usr/include/AL/al.h:39
ALAPI = 0 	# /usr/include/AL/al.h:59
AL_INVALID = -1 	# /usr/include/AL/al.h:61
AL_ILLEGAL_ENUM = 0 	# /usr/include/AL/al.h:62
AL_ILLEGAL_COMMAND = 0 	# /usr/include/AL/al.h:63
ALboolean = c_int 	# Better return type than c_char, as generated
ALchar = c_char 	# /usr/include/AL/al.h:73
ALbyte = c_char 	# /usr/include/AL/al.h:76
ALubyte = c_ubyte 	# /usr/include/AL/al.h:79
ALshort = c_short 	# /usr/include/AL/al.h:82
ALushort = c_ushort 	# /usr/include/AL/al.h:85
ALint = c_int 	# /usr/include/AL/al.h:88
ALuint = c_uint 	# /usr/include/AL/al.h:91
ALsizei = c_int 	# /usr/include/AL/al.h:94
ALenum = c_int 	# /usr/include/AL/al.h:97
ALfloat = c_float 	# /usr/include/AL/al.h:100
ALdouble = c_double 	# /usr/include/AL/al.h:103
ALvoid = None 	# /usr/include/AL/al.h:106
AL_NONE = 0 	# /usr/include/AL/al.h:112
AL_FALSE = 0 	# /usr/include/AL/al.h:115
AL_TRUE = 1 	# /usr/include/AL/al.h:118
AL_SOURCE_RELATIVE = 514 	# /usr/include/AL/al.h:121
AL_CONE_INNER_ANGLE = 4097 	# /usr/include/AL/al.h:130
AL_CONE_OUTER_ANGLE = 4098 	# /usr/include/AL/al.h:137
AL_PITCH = 4099 	# /usr/include/AL/al.h:145
AL_POSITION = 4100 	# /usr/include/AL/al.h:157
AL_DIRECTION = 4101 	# /usr/include/AL/al.h:160
AL_VELOCITY = 4102 	# /usr/include/AL/al.h:163
AL_LOOPING = 4103 	# /usr/include/AL/al.h:171
AL_BUFFER = 4105 	# /usr/include/AL/al.h:178
AL_GAIN = 4106 	# /usr/include/AL/al.h:191
AL_MIN_GAIN = 4109 	# /usr/include/AL/al.h:200
AL_MAX_GAIN = 4110 	# /usr/include/AL/al.h:209
AL_ORIENTATION = 4111 	# /usr/include/AL/al.h:216
AL_SOURCE_STATE = 4112 	# /usr/include/AL/al.h:221
AL_INITIAL = 4113 	# /usr/include/AL/al.h:222
AL_PLAYING = 4114 	# /usr/include/AL/al.h:223
AL_PAUSED = 4115 	# /usr/include/AL/al.h:224
AL_STOPPED = 4116 	# /usr/include/AL/al.h:225
AL_BUFFERS_QUEUED = 4117 	# /usr/include/AL/al.h:230
AL_BUFFERS_PROCESSED = 4118 	# /usr/include/AL/al.h:231
AL_SEC_OFFSET = 4132 	# /usr/include/AL/al.h:236
AL_SAMPLE_OFFSET = 4133 	# /usr/include/AL/al.h:237
AL_BYTE_OFFSET = 4134 	# /usr/include/AL/al.h:238
AL_SOURCE_TYPE = 4135 	# /usr/include/AL/al.h:246
AL_STATIC = 4136 	# /usr/include/AL/al.h:247
AL_STREAMING = 4137 	# /usr/include/AL/al.h:248
AL_UNDETERMINED = 4144 	# /usr/include/AL/al.h:249
AL_FORMAT_MONO8 = 4352 	# /usr/include/AL/al.h:252
AL_FORMAT_MONO16 = 4353 	# /usr/include/AL/al.h:253
AL_FORMAT_STEREO8 = 4354 	# /usr/include/AL/al.h:254
AL_FORMAT_STEREO16 = 4355 	# /usr/include/AL/al.h:255
AL_REFERENCE_DISTANCE = 4128 	# /usr/include/AL/al.h:265
AL_ROLLOFF_FACTOR = 4129 	# /usr/include/AL/al.h:273
AL_CONE_OUTER_GAIN = 4130 	# /usr/include/AL/al.h:282
AL_MAX_DISTANCE = 4131 	# /usr/include/AL/al.h:292
AL_FREQUENCY = 8193 	# /usr/include/AL/al.h:300
AL_BITS = 8194 	# /usr/include/AL/al.h:301
AL_CHANNELS = 8195 	# /usr/include/AL/al.h:302
AL_SIZE = 8196 	# /usr/include/AL/al.h:303
AL_UNUSED = 8208 	# /usr/include/AL/al.h:310
AL_PENDING = 8209 	# /usr/include/AL/al.h:311
AL_PROCESSED = 8210 	# /usr/include/AL/al.h:312
AL_NO_ERROR = 0 	# /usr/include/AL/al.h:316
AL_INVALID_NAME = 40961 	# /usr/include/AL/al.h:321
AL_INVALID_ENUM = 40962 	# /usr/include/AL/al.h:326
AL_INVALID_VALUE = 40963 	# /usr/include/AL/al.h:331
AL_INVALID_OPERATION = 40964 	# /usr/include/AL/al.h:336
AL_OUT_OF_MEMORY = 40965 	# /usr/include/AL/al.h:342
AL_VENDOR = 45057 	# /usr/include/AL/al.h:346
AL_VERSION = 45058 	# /usr/include/AL/al.h:347
AL_RENDERER = 45059 	# /usr/include/AL/al.h:348
AL_EXTENSIONS = 45060 	# /usr/include/AL/al.h:349
AL_DOPPLER_FACTOR = 49152 	# /usr/include/AL/al.h:356
AL_DOPPLER_VELOCITY = 49153 	# /usr/include/AL/al.h:361
AL_SPEED_OF_SOUND = 49155 	# /usr/include/AL/al.h:366
AL_DISTANCE_MODEL = 53248 	# /usr/include/AL/al.h:375
AL_INVERSE_DISTANCE = 53249 	# /usr/include/AL/al.h:376
AL_INVERSE_DISTANCE_CLAMPED = 53250 	# /usr/include/AL/al.h:377
AL_LINEAR_DISTANCE = 53251 	# /usr/include/AL/al.h:378
AL_LINEAR_DISTANCE_CLAMPED = 53252 	# /usr/include/AL/al.h:379
AL_EXPONENT_DISTANCE = 53253 	# /usr/include/AL/al.h:380
AL_EXPONENT_DISTANCE_CLAMPED = 53254 	# /usr/include/AL/al.h:381
# /usr/include/AL/al.h:386
alEnable = _lib.alEnable
alEnable.restype = None
alEnable.argtypes = [ALenum]

# /usr/include/AL/al.h:388
alDisable = _lib.alDisable
alDisable.restype = None
alDisable.argtypes = [ALenum]

# /usr/include/AL/al.h:390
alIsEnabled = _lib.alIsEnabled
alIsEnabled.restype = ALboolean
alIsEnabled.argtypes = [ALenum]

# /usr/include/AL/al.h:396
alGetString = _lib.alGetString
alGetString.restype = POINTER(ALchar)
alGetString.argtypes = [ALenum]

# /usr/include/AL/al.h:398
alGetBooleanv = _lib.alGetBooleanv
alGetBooleanv.restype = None
alGetBooleanv.argtypes = [ALenum, POINTER(ALboolean)]

# /usr/include/AL/al.h:400
alGetIntegerv = _lib.alGetIntegerv
alGetIntegerv.restype = None
alGetIntegerv.argtypes = [ALenum, POINTER(ALint)]

# /usr/include/AL/al.h:402
alGetFloatv = _lib.alGetFloatv
alGetFloatv.restype = None
alGetFloatv.argtypes = [ALenum, POINTER(ALfloat)]

# /usr/include/AL/al.h:404
alGetDoublev = _lib.alGetDoublev
alGetDoublev.restype = None
alGetDoublev.argtypes = [ALenum, POINTER(ALdouble)]

# /usr/include/AL/al.h:406
alGetBoolean = _lib.alGetBoolean
alGetBoolean.restype = ALboolean
alGetBoolean.argtypes = [ALenum]

# /usr/include/AL/al.h:408
alGetInteger = _lib.alGetInteger
alGetInteger.restype = ALint
alGetInteger.argtypes = [ALenum]

# /usr/include/AL/al.h:410
alGetFloat = _lib.alGetFloat
alGetFloat.restype = ALfloat
alGetFloat.argtypes = [ALenum]

# /usr/include/AL/al.h:412
alGetDouble = _lib.alGetDouble
alGetDouble.restype = ALdouble
alGetDouble.argtypes = [ALenum]

# /usr/include/AL/al.h:419
alGetError = _lib.alGetError
alGetError.restype = ALenum
alGetError.argtypes = []

# /usr/include/AL/al.h:427
alIsExtensionPresent = _lib.alIsExtensionPresent
alIsExtensionPresent.restype = ALboolean
alIsExtensionPresent.argtypes = [POINTER(ALchar)]

# /usr/include/AL/al.h:429
alGetProcAddress = _lib.alGetProcAddress
alGetProcAddress.restype = POINTER(c_void)
alGetProcAddress.argtypes = [POINTER(ALchar)]

# /usr/include/AL/al.h:431
alGetEnumValue = _lib.alGetEnumValue
alGetEnumValue.restype = ALenum
alGetEnumValue.argtypes = [POINTER(ALchar)]

# /usr/include/AL/al.h:450
alListenerf = _lib.alListenerf
alListenerf.restype = None
alListenerf.argtypes = [ALenum, ALfloat]

# /usr/include/AL/al.h:452
alListener3f = _lib.alListener3f
alListener3f.restype = None
alListener3f.argtypes = [ALenum, ALfloat, ALfloat, ALfloat]

# /usr/include/AL/al.h:454
alListenerfv = _lib.alListenerfv
alListenerfv.restype = None
alListenerfv.argtypes = [ALenum, POINTER(ALfloat)]

# /usr/include/AL/al.h:456
alListeneri = _lib.alListeneri
alListeneri.restype = None
alListeneri.argtypes = [ALenum, ALint]

# /usr/include/AL/al.h:458
#alListener3i = _lib.alListener3i
#alListener3i.restype = None
#alListener3i.argtypes = [ALenum, ALint, ALint, ALint]

# /usr/include/AL/al.h:460
#alListeneriv = _lib.alListeneriv
#alListeneriv.restype = None
#alListeneriv.argtypes = [ALenum, POINTER(ALint)]

# /usr/include/AL/al.h:465
alGetListenerf = _lib.alGetListenerf
alGetListenerf.restype = None
alGetListenerf.argtypes = [ALenum, POINTER(ALfloat)]

# /usr/include/AL/al.h:467
alGetListener3f = _lib.alGetListener3f
alGetListener3f.restype = None
alGetListener3f.argtypes = [ALenum, POINTER(ALfloat), POINTER(ALfloat), POINTER(ALfloat)]

# /usr/include/AL/al.h:469
alGetListenerfv = _lib.alGetListenerfv
alGetListenerfv.restype = None
alGetListenerfv.argtypes = [ALenum, POINTER(ALfloat)]

# /usr/include/AL/al.h:471
alGetListeneri = _lib.alGetListeneri
alGetListeneri.restype = None
alGetListeneri.argtypes = [ALenum, POINTER(ALint)]

# /usr/include/AL/al.h:473
alGetListener3i = _lib.alGetListener3i
alGetListener3i.restype = None
alGetListener3i.argtypes = [ALenum, POINTER(ALint), POINTER(ALint), POINTER(ALint)]

# /usr/include/AL/al.h:475
alGetListeneriv = _lib.alGetListeneriv
alGetListeneriv.restype = None
alGetListeneriv.argtypes = [ALenum, POINTER(ALint)]

# /usr/include/AL/al.h:512
alGenSources = _lib.alGenSources
alGenSources.restype = None
alGenSources.argtypes = [ALsizei, POINTER(ALuint)]

# /usr/include/AL/al.h:515
alDeleteSources = _lib.alDeleteSources
alDeleteSources.restype = None
alDeleteSources.argtypes = [ALsizei, POINTER(ALuint)]

# /usr/include/AL/al.h:518
alIsSource = _lib.alIsSource
alIsSource.restype = ALboolean
alIsSource.argtypes = [ALuint]

# /usr/include/AL/al.h:523
alSourcef = _lib.alSourcef
alSourcef.restype = None
alSourcef.argtypes = [ALuint, ALenum, ALfloat]

# /usr/include/AL/al.h:525
alSource3f = _lib.alSource3f
alSource3f.restype = None
alSource3f.argtypes = [ALuint, ALenum, ALfloat, ALfloat, ALfloat]

# /usr/include/AL/al.h:527
alSourcefv = _lib.alSourcefv
alSourcefv.restype = None
alSourcefv.argtypes = [ALuint, ALenum, POINTER(ALfloat)]

# /usr/include/AL/al.h:529
alSourcei = _lib.alSourcei
alSourcei.restype = None
alSourcei.argtypes = [ALuint, ALenum, ALint]

# /usr/include/AL/al.h:531
#alSource3i = _lib.alSource3i
#alSource3i.restype = None
#alSource3i.argtypes = [ALuint, ALenum, ALint, ALint, ALint]

# /usr/include/AL/al.h:533
#alSourceiv = _lib.alSourceiv
#alSourceiv.restype = None
#alSourceiv.argtypes = [ALuint, ALenum, POINTER(ALint)]

# /usr/include/AL/al.h:538
alGetSourcef = _lib.alGetSourcef
alGetSourcef.restype = None
alGetSourcef.argtypes = [ALuint, ALenum, POINTER(ALfloat)]

# /usr/include/AL/al.h:540
alGetSource3f = _lib.alGetSource3f
alGetSource3f.restype = None
alGetSource3f.argtypes = [ALuint, ALenum, POINTER(ALfloat), POINTER(ALfloat), POINTER(ALfloat)]

# /usr/include/AL/al.h:542
alGetSourcefv = _lib.alGetSourcefv
alGetSourcefv.restype = None
alGetSourcefv.argtypes = [ALuint, ALenum, POINTER(ALfloat)]

# /usr/include/AL/al.h:544
alGetSourcei = _lib.alGetSourcei
alGetSourcei.restype = None
alGetSourcei.argtypes = [ALuint, ALenum, POINTER(ALint)]

# /usr/include/AL/al.h:546
#alGetSource3i = _lib.alGetSource3i
#alGetSource3i.restype = None
#alGetSource3i.argtypes = [ALuint, ALenum, POINTER(ALint), POINTER(ALint), POINTER(ALint)]

# /usr/include/AL/al.h:548
alGetSourceiv = _lib.alGetSourceiv
alGetSourceiv.restype = None
alGetSourceiv.argtypes = [ALuint, ALenum, POINTER(ALint)]

# /usr/include/AL/al.h:556
alSourcePlayv = _lib.alSourcePlayv
alSourcePlayv.restype = None
alSourcePlayv.argtypes = [ALsizei, POINTER(ALuint)]

# /usr/include/AL/al.h:559
alSourceStopv = _lib.alSourceStopv
alSourceStopv.restype = None
alSourceStopv.argtypes = [ALsizei, POINTER(ALuint)]

# /usr/include/AL/al.h:562
alSourceRewindv = _lib.alSourceRewindv
alSourceRewindv.restype = None
alSourceRewindv.argtypes = [ALsizei, POINTER(ALuint)]

# /usr/include/AL/al.h:565
alSourcePausev = _lib.alSourcePausev
alSourcePausev.restype = None
alSourcePausev.argtypes = [ALsizei, POINTER(ALuint)]

# /usr/include/AL/al.h:572
alSourcePlay = _lib.alSourcePlay
alSourcePlay.restype = None
alSourcePlay.argtypes = [ALuint]

# /usr/include/AL/al.h:575
alSourceStop = _lib.alSourceStop
alSourceStop.restype = None
alSourceStop.argtypes = [ALuint]

# /usr/include/AL/al.h:578
alSourceRewind = _lib.alSourceRewind
alSourceRewind.restype = None
alSourceRewind.argtypes = [ALuint]

# /usr/include/AL/al.h:581
alSourcePause = _lib.alSourcePause
alSourcePause.restype = None