1/**********************************************************************************************************************************
2*
3*   OpenAL cross platform audio library
4*   Copyright (c) 2004, Apple Computer, Inc. All rights reserved.
5*
6*   Redistribution and use in source and binary forms, with or without modification, are permitted provided
7*   that the following conditions are met:
8*
9*   1.  Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
10*   2.  Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
11*       disclaimer in the documentation and/or other materials provided with the distribution.
12*   3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of its contributors may be used to endorse or promote
13*       products derived from this software without specific prior written permission.
14*
15*   THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16*   THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS
17*   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
18*   TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
19*   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
20*   USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21*
22**********************************************************************************************************************************/
23
24#ifndef __OAL_IMP__
25#define __OAL_IMP__
26
27#include "al.h"
28#include "alc.h"
29#include "oalOSX.h"
30#include <Carbon/Carbon.h>
31#include <map>
32
33typedef ALvoid			(*alSourceNotificationProc) (ALuint sid, ALuint	notificationID, ALvoid*	userData);
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39// added for OSX Extension
40ALC_API ALvoid alcMacOSXRenderingQuality (ALint value);
41ALC_API ALvoid alMacOSXRenderChannelCount (ALint value);
42ALC_API ALvoid alcMacOSXMixerMaxiumumBusses (ALint value);
43ALC_API ALvoid alcMacOSXMixerOutputRate(ALdouble value);
44
45ALC_API ALint alcMacOSXGetRenderingQuality ();
46ALC_API ALint alMacOSXGetRenderChannelCount ();
47ALC_API ALint alcMacOSXGetMixerMaxiumumBusses ();
48ALC_API ALdouble alcMacOSXGetMixerOutputRate();
49
50AL_API ALvoid AL_APIENTRY alSetInteger (ALenum pname, ALint value);
51AL_API ALvoid AL_APIENTRY alSetDouble (ALenum pname, ALdouble value);
52
53AL_API ALvoid	AL_APIENTRY	alBufferDataStatic (ALint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq);
54
55// source notifications
56AL_API ALenum alSourceAddNotification (ALuint sid, ALuint notificationID, alSourceNotificationProc notifyProc, ALvoid* userData);
57AL_API ALvoid alSourceRemoveNotification (ALuint	sid, ALuint notificationID, alSourceNotificationProc notifyProc, ALvoid* userData);
58
59// source spatialization
60AL_API ALvoid alSourceRenderingQuality (ALuint sid, ALint value);
61AL_API ALint  alSourceGetRenderingQuality (ALuint sid);
62
63// added for ASA (Apple Environmental Audio)
64
65ALC_API ALenum  alcASAGetSource(ALuint property, ALuint source, ALvoid *data, ALuint* dataSize);
66ALC_API ALenum  alcASASetSource(ALuint property, ALuint source, ALvoid *data, ALuint dataSize);
67ALC_API ALenum  alcASAGetListener(ALuint property, ALvoid *data, ALuint* dataSize);
68ALC_API ALenum  alcASASetListener(ALuint property, ALvoid *data, ALuint dataSize);
69
70// 3DMixer output capturer
71ALC_API ALvoid  alcOutputCapturerPrepare( ALCuint frequency, ALCenum format, ALCsizei buffersize );
72ALC_API ALvoid  alcOutputCapturerStart();
73ALC_API ALvoid  alcOutputCapturerStop();
74ALC_API ALint   alcOutputCapturerAvailableSamples();
75ALC_API ALvoid  alcOutputCapturerSamples( ALCvoid *buffer, ALCsizei samples );
76
77// Used internally but no longer available via a header file. Some OpenAL applications may have been built with a header
78// that defined these constants so keep defining them.
79
80#define ALC_SPATIAL_RENDERING_QUALITY        0xF002
81#define ALC_MIXER_OUTPUT_RATE		         0xF003
82#define ALC_MIXER_MAXIMUM_BUSSES             0xF004
83#define ALC_RENDER_CHANNEL_COUNT             0xF005
84
85// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
86
87#define AL_FORMAT_MONO_FLOAT32               0x10010
88#define AL_FORMAT_STEREO_FLOAT32             0x10011
89
90// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
91// Continue exporting these deprectaed APIs to prevent runtime link errors
92
93#ifdef TARGET_OS_MAC
94   #if TARGET_OS_MAC
95       #pragma export on
96   #endif
97#endif
98
99
100AL_API ALvoid	AL_APIENTRY alHint( ALenum target, ALenum mode );
101
102#ifdef TARGET_OS_MAC
103   #if TARGET_OS_MAC
104      #pragma export off
105   #endif
106#endif
107
108#ifdef __cplusplus
109}
110#endif
111
112// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
113// development build flags
114#define	USE_AU_TRACER 					0
115#define LOG_GRAPH_AND_MIXER_CHANGES		0
116#define GET_OVERLOAD_NOTIFICATIONS 		0
117#define	LOG_IO 							0
118
119#if LOG_IO
120	#include  "AudioLogger.h"
121#endif
122
123// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
124
125#define AL_MAXBUFFERS 1024
126#define AL_MAXSOURCES 256
127
128#define kDefaultMaximumMixerBusCount    64
129#define kDopplerDefault                 0
130
131enum {
132		kRogerBeepType	= 'rogr',
133		kDistortionType	= 'dist'
134};
135
136#define	THROW_RESULT		if(result != noErr) throw static_cast<OSStatus>(result);
137
138enum {
139		kUnknown3DMixerVersion	= 0,
140		kUnsupported3DMixer		= 1,
141		k3DMixerVersion_1_3		= 13,
142		k3DMixerVersion_2_0,
143		k3DMixerVersion_2_1,
144		k3DMixerVersion_2_2,
145		k3DMixerVersion_2_3
146};
147
148enum {
149		kUnknownAUState	= -1,
150		kAUIsNotPresent	= 0,
151		kAUIsPresent	= 1
152};
153// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
154
155void	alSetError (ALenum errorCode);
156UInt32	Get3DMixerVersion ();
157ALCint  IsDistortionPresent();
158ALCint  IsRogerBeepPresent();
159
160#endif
161
162