2 * OpenAL cross platform audio library
3 * Copyright (C) 1999-2007 by authors.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 * Or go to http://www.gnu.org/copyleft/lgpl.html
21 #define _CRT_SECURE_NO_DEPRECATE // get rid of sprintf security warnings on VS2005
38 * AL Buffers are shared amoung Contexts, so we store the list of generated Buffers
39 * as a global variable in this module. (A valid context is not required to make
40 * AL Buffer function calls
48 static ALbuffer
*g_pBuffers
= NULL
; // Linked List of Buffers
49 static ALuint g_uiBufferCount
= 0; // Buffer Count
51 static const long g_IMAStep_size
[89]={ // IMA ADPCM Stepsize table
52 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31,
53 34, 37, 41, 45, 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, 130, 143,
54 157, 173, 190, 209, 230, 253, 279, 307, 337, 371, 408, 449, 494, 544, 598, 658,
55 724, 796, 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024,
56 3327, 3660, 4026, 4428, 4871, 5358, 5894, 6484, 7132, 7845, 8630, 9493,10442,11487,12635,13899,
57 15289,16818,18500,20350,22358,24633,27086,29794,32767
60 static const long g_IMACodeword_4
[16]={ // IMA4 ADPCM Codeword decode table
61 1, 3, 5, 7, 9, 11, 13, 15,
62 -1,-3,-5,-7,-9,-11,-13,-15,
65 static const long g_IMAIndex_adjust_4
[16]={ // IMA4 ADPCM Step index adjust decode table
66 -1,-1,-1,-1, 2, 4, 6, 8,
67 -1,-1,-1,-1, 2, 4, 6, 8
71 * alGenBuffers(ALsizei n, ALuint *puiBuffers)
73 * Generates n AL Buffers, and stores the Buffers Names in the array pointed to by puiBuffers
75 ALAPI ALvoid ALAPIENTRY
alGenBuffers(ALsizei n
,ALuint
*puiBuffers
)
80 Context
= alcGetCurrentContext();
81 SuspendContext(Context
);
83 // Check that we are actually generation some Buffers
86 // Check the pointer is valid (and points to enough memory to store Buffer Names)
87 if (!IsBadWritePtr((void*)puiBuffers
, n
* sizeof(ALuint
)))
89 ALbuffer
**list
= &g_pBuffers
;
91 list
= &(*list
)->next
;
93 // Create all the new Buffers
96 *list
= calloc(1, sizeof(ALbuffer
));
99 puiBuffers
[i
] = (ALuint
)ALTHUNK_ADDENTRY(*list
);
100 (*list
)->state
= UNUSED
;
104 list
= &(*list
)->next
;
108 // If we didn't create all the Buffers, we must have run out of memory
110 alSetError(AL_OUT_OF_MEMORY
);
114 // Pointer does not point to enough memory to write Buffer names
115 alSetError(AL_INVALID_VALUE
);
119 ProcessContext(Context
);
125 * alDeleteBuffers(ALsizei n, ALuint *puiBuffers)
127 * Deletes the n AL Buffers pointed to by puiBuffers
129 ALAPI ALvoid ALAPIENTRY
alDeleteBuffers(ALsizei n
, const ALuint
*puiBuffers
)
134 ALboolean bFailed
= AL_FALSE
;
136 Context
= alcGetCurrentContext();
137 SuspendContext(Context
);
139 // Check we are actually Deleting some Buffers
142 if ((ALuint
)n
<= g_uiBufferCount
)
144 // Check that all the buffers are valid and can actually be deleted
145 for (i
= 0; i
< n
; i
++)
147 // Check for valid Buffer ID (can be NULL buffer)
148 if (alIsBuffer(puiBuffers
[i
]))
150 // If not the NULL buffer, check that the reference count is 0
151 ALBuf
= ((ALbuffer
*)ALTHUNK_LOOKUPENTRY(puiBuffers
[i
]));
154 if (ALBuf
->refcount
!= 0)
156 // Buffer still in use, cannot be deleted
157 alSetError(AL_INVALID_OPERATION
);
165 alSetError(AL_INVALID_NAME
);
170 // If all the Buffers were valid (and have Reference Counts of 0), then we can delete them
173 for (i
= 0; i
< n
; i
++)
175 ALBuf
=((ALbuffer
*)ALTHUNK_LOOKUPENTRY(puiBuffers
[i
]));
178 ALbuffer
**list
= &g_pBuffers
;
179 while(*list
&& *list
!= ALBuf
)
180 list
= &(*list
)->next
;
183 *list
= (*list
)->next
;
185 // Release the memory used to store audio data
188 // Release buffer structure
189 ALTHUNK_REMOVEENTRY(puiBuffers
[i
]);
190 memset(ALBuf
, 0, sizeof(ALbuffer
));
198 alSetError(AL_INVALID_NAME
);
201 alSetError(AL_INVALID_VALUE
);
203 ProcessContext(Context
);
210 * alIsBuffer(ALuint uiBuffer)
212 * Checks if ulBuffer is a valid Buffer Name
214 ALAPI ALboolean ALAPIENTRY
alIsBuffer(ALuint uiBuffer
)
217 ALboolean result
=AL_FALSE
;
221 Context
= alcGetCurrentContext();
222 SuspendContext(Context
);
226 TgtALBuf
= (ALbuffer
*)ALTHUNK_LOOKUPENTRY(uiBuffer
);
228 // Check through list of generated buffers for uiBuffer
232 if (ALBuf
== TgtALBuf
)
247 ProcessContext(Context
);
253 * alBufferData(ALuint buffer,ALenum format,ALvoid *data,ALsizei size,ALsizei freq)
255 * Fill buffer with audio data
257 ALAPI ALvoid ALAPIENTRY
alBufferData(ALuint buffer
,ALenum format
,const ALvoid
*data
,ALsizei size
,ALsizei freq
)
259 ALuint
*IMAData
,IMACode
;
262 ALint LeftSample
,LeftIndex
;
263 ALint RightSample
,RightIndex
;
264 ALuint LeftIMACode
,RightIMACode
;
268 Context
= alcGetCurrentContext();
269 SuspendContext(Context
);
271 if (alIsBuffer(buffer
) && (buffer
!= 0))
273 ALBuf
=((ALbuffer
*)ALTHUNK_LOOKUPENTRY(buffer
));
274 if ((ALBuf
->refcount
==0)&&(data
))
278 case AL_FORMAT_MONO8
:
281 // 8bit Samples are converted to 16 bit here
282 // Allocate 8 extra samples (16 bytes)
283 ALBuf
->data
=realloc(ALBuf
->data
,16+(size
/sizeof(ALubyte
))*(1*sizeof(ALshort
)));
286 ALBuf
->format
= AL_FORMAT_MONO16
;
287 ALBuf
->eOriginalFormat
= AL_FORMAT_MONO8
;
288 for (i
=0;i
<(ALsizei
)(size
/sizeof(ALubyte
));i
++)
289 ALBuf
->data
[i
]=(ALshort
)((((ALubyte
*)data
)[i
]-128)<<8);
290 memset(&(ALBuf
->data
[size
/sizeof(ALubyte
)]), 0, 16);
291 ALBuf
->size
=size
/sizeof(ALubyte
)*1*sizeof(ALshort
);
292 ALBuf
->frequency
=freq
;
295 alSetError(AL_OUT_OF_MEMORY
);
298 alSetError(AL_INVALID_VALUE
);
301 case AL_FORMAT_MONO16
:
304 // Allocate 8 extra samples (16 bytes)
305 ALBuf
->data
=realloc(ALBuf
->data
,16+(size
/sizeof(ALshort
))*(1*sizeof(ALshort
)));
308 ALBuf
->format
= AL_FORMAT_MONO16
;
309 ALBuf
->eOriginalFormat
= AL_FORMAT_MONO16
;
310 memcpy(ALBuf
->data
,data
,size
/sizeof(ALshort
)*1*sizeof(ALshort
));
311 memset(&(ALBuf
->data
[size
/sizeof(ALshort
)]), 0, 16);
312 ALBuf
->size
=size
/sizeof(ALshort
)*1*sizeof(ALshort
);
313 ALBuf
->frequency
=freq
;
316 alSetError(AL_OUT_OF_MEMORY
);
319 alSetError(AL_INVALID_VALUE
);
322 case AL_FORMAT_STEREO8
:
325 // 8bit Samples are converted to 16 bit here
326 // Allocate 8 extra samples (32 bytes)
327 ALBuf
->data
=realloc(ALBuf
->data
,32+(size
/sizeof(ALubyte
))*(1*sizeof(ALshort
)));
330 ALBuf
->format
= AL_FORMAT_STEREO16
;
331 ALBuf
->eOriginalFormat
= AL_FORMAT_STEREO8
;
332 for (i
=0;i
<(ALsizei
)(size
/sizeof(ALubyte
));i
++)
333 ALBuf
->data
[i
]=(ALshort
)((((ALubyte
*)data
)[i
]-128)<<8);
334 memset(&(ALBuf
->data
[size
/sizeof(ALubyte
)]), 0, 32);
335 ALBuf
->size
=size
/sizeof(ALubyte
)*1*sizeof(ALshort
);
336 ALBuf
->frequency
=freq
;
339 alSetError(AL_OUT_OF_MEMORY
);
342 alSetError(AL_INVALID_VALUE
);
345 case AL_FORMAT_STEREO16
:
348 // Allocate 8 extra samples (32 bytes)
349 ALBuf
->data
=realloc(ALBuf
->data
,32+(size
/sizeof(ALshort
))*(1*sizeof(ALshort
)));
352 ALBuf
->format
= AL_FORMAT_STEREO16
;
353 ALBuf
->eOriginalFormat
= AL_FORMAT_STEREO16
;
354 memcpy(ALBuf
->data
,data
,size
/sizeof(ALshort
)*1*sizeof(ALshort
));
355 memset(&(ALBuf
->data
[size
/sizeof(ALshort
)]), 0, 32);
356 ALBuf
->size
=size
/sizeof(ALshort
)*1*sizeof(ALshort
);
357 ALBuf
->frequency
=freq
;
360 alSetError(AL_OUT_OF_MEMORY
);
363 alSetError(AL_INVALID_VALUE
);
366 case AL_FORMAT_MONO_IMA4
:
367 // Here is where things vary:
368 // nVidia and Apple use 64+1 samples per block => block_size=36 bytes
369 // Most PC sound software uses 2040+1 samples per block -> block_size=1024 bytes
372 // Allocate 8 extra samples (16 bytes)
373 ALBuf
->data
=realloc(ALBuf
->data
,16+(size
/36)*(65*sizeof(ALshort
)));
376 ALBuf
->format
= AL_FORMAT_MONO16
;
377 ALBuf
->eOriginalFormat
= AL_FORMAT_MONO_IMA4
;
378 IMAData
=(ALuint
*)data
;
379 for (i
=0;i
<size
/36;i
++)
381 Sample
=((ALshort
*)IMAData
)[0];
382 Index
=((ALshort
*)IMAData
)[1];
384 Index
=Index
<0?0:Index
;
385 Index
=Index
>88?88:Index
;
387 ALBuf
->data
[i
*65]=(short)Sample
;
396 Sample
+=((g_IMAStep_size
[Index
]*g_IMACodeword_4
[IMACode
&15])/8);
397 Index
+=g_IMAIndex_adjust_4
[IMACode
&15];
398 if (Sample
<-32768) Sample
=-32768;
399 else if (Sample
>32767) Sample
=32767;
400 if (Index
<0) Index
=0;
401 else if (Index
>88) Index
=88;
402 ALBuf
->data
[i
*65+j
+k
]=(short)Sample
;
405 Sample
+=((g_IMAStep_size
[Index
]*g_IMACodeword_4
[IMACode
&15])/8);
406 Index
+=g_IMAIndex_adjust_4
[IMACode
&15];
407 if (Sample
<-32768) Sample
=-32768;
408 else if (Sample
>32767) Sample
=32767;
409 if (Index
<0) Index
=0;
410 else if (Index
>88) Index
=88;
411 ALBuf
->data
[i
*65+j
+k
+1]=(short)Sample
;
417 memset(&(ALBuf
->data
[(size
/36*65)]), 0, 16);
418 ALBuf
->size
=size
/36*65*sizeof(ALshort
);
419 ALBuf
->frequency
=freq
;
422 alSetError(AL_OUT_OF_MEMORY
);
425 alSetError(AL_INVALID_VALUE
);
428 case AL_FORMAT_STEREO_IMA4
:
429 // Here is where things vary:
430 // nVidia and Apple use 64+1 samples per channel per block => block_size=72 bytes
431 // Most PC sound software uses 2040+1 samples per channel per block -> block_size=2048 bytes
434 // Allocate 8 extra samples (32 bytes)
435 ALBuf
->data
=realloc(ALBuf
->data
,32+(size
/72)*(2*65*sizeof(ALshort
)));
438 ALBuf
->format
= AL_FORMAT_STEREO16
;
439 ALBuf
->eOriginalFormat
= AL_FORMAT_STEREO_IMA4
;
440 IMAData
=(ALuint
*)data
;
441 for (i
=0;i
<size
/72;i
++)
443 LeftSample
=((ALshort
*)IMAData
)[0];
444 LeftIndex
=((ALshort
*)IMAData
)[1];
446 LeftIndex
=LeftIndex
<0?0:LeftIndex
;
447 LeftIndex
=LeftIndex
>88?88:LeftIndex
;
449 ALBuf
->data
[i
*2*65]=(short)LeftSample
;
453 RightSample
=((ALshort
*)IMAData
)[0];
454 RightIndex
=((ALshort
*)IMAData
)[1];
456 RightIndex
=RightIndex
<0?0:RightIndex
;
457 RightIndex
=RightIndex
>88?88:RightIndex
;
459 ALBuf
->data
[i
*2*65+1]=(short)RightSample
;
463 for (j
=2;j
<130;j
+=16)
465 LeftIMACode
=IMAData
[0];
466 RightIMACode
=IMAData
[1];
469 LeftSample
+=((g_IMAStep_size
[LeftIndex
]*g_IMACodeword_4
[LeftIMACode
&15])/8);
470 LeftIndex
+=g_IMAIndex_adjust_4
[LeftIMACode
&15];
471 if (LeftSample
<-32768) LeftSample
=-32768;
472 else if (LeftSample
>32767) LeftSample
=32767;
473 if (LeftIndex
<0) LeftIndex
=0;
474 else if (LeftIndex
>88) LeftIndex
=88;
475 ALBuf
->data
[i
*2*65+j
+k
]=(short)LeftSample
;
478 RightSample
+=((g_IMAStep_size
[RightIndex
]*g_IMACodeword_4
[RightIMACode
&15])/8);
479 RightIndex
+=g_IMAIndex_adjust_4
[RightIMACode
&15];
480 if (RightSample
<-32768) RightSample
=-32768;
481 else if (RightSample
>32767) RightSample
=32767;
482 if (RightIndex
<0) RightIndex
=0;
483 else if (RightIndex
>88) RightIndex
=88;
484 ALBuf
->data
[i
*2*65+j
+k
+1]=(short)RightSample
;
487 LeftSample
+=((g_IMAStep_size
[LeftIndex
]*g_IMACodeword_4
[LeftIMACode
&15])/8);
488 LeftIndex
+=g_IMAIndex_adjust_4
[LeftIMACode
&15];
489 if (LeftSample
<-32768) LeftSample
=-32768;
490 else if (LeftSample
>32767) LeftSample
=32767;
491 if (LeftIndex
<0) LeftIndex
=0;
492 else if (LeftIndex
>88) LeftIndex
=88;
493 ALBuf
->data
[i
*2*65+j
+k
+2]=(short)LeftSample
;
496 RightSample
+=((g_IMAStep_size
[RightIndex
]*g_IMACodeword_4
[RightIMACode
&15])/8);
497 RightIndex
+=g_IMAIndex_adjust_4
[RightIMACode
&15];
498 if (RightSample
<-32768) RightSample
=-32768;
499 else if (RightSample
>32767) RightSample
=32767;
500 if (RightIndex
<0) RightIndex
=0;
501 else if (RightIndex
>88) RightIndex
=88;
502 ALBuf
->data
[i
*2*65+j
+k
+3]=(short)RightSample
;
508 memset(&(ALBuf
->data
[(size
/72*2*65)]), 0, 32);
509 ALBuf
->size
=size
/72*2*65*sizeof(ALshort
);
510 ALBuf
->frequency
=freq
;
513 alSetError(AL_OUT_OF_MEMORY
);
516 alSetError(AL_INVALID_VALUE
);
520 alSetError(AL_INVALID_ENUM
);
526 // Buffer is in use, or data is a NULL pointer
527 alSetError(AL_INVALID_VALUE
);
532 // Invalid Buffer Name
533 alSetError(AL_INVALID_NAME
);
536 ProcessContext(Context
);
540 ALAPI
void ALAPIENTRY
alBufferf(ALuint buffer
, ALenum eParam
, ALfloat flValue
)
542 ALCcontext
*pContext
;
547 pContext
= alcGetCurrentContext();
548 SuspendContext(pContext
);
550 if (alIsBuffer(buffer
) && (buffer
!= 0))
552 pBuffer
= ((ALbuffer
*)ALTHUNK_LOOKUPENTRY(buffer
));
557 alSetError(AL_INVALID_ENUM
);
563 alSetError(AL_INVALID_NAME
);
566 ProcessContext(pContext
);
570 ALAPI
void ALAPIENTRY
alBuffer3f(ALuint buffer
, ALenum eParam
, ALfloat flValue1
, ALfloat flValue2
, ALfloat flValue3
)
572 ALCcontext
*pContext
;
579 pContext
= alcGetCurrentContext();
580 SuspendContext(pContext
);
582 if (alIsBuffer(buffer
) && (buffer
!= 0))
584 pBuffer
= ((ALbuffer
*)ALTHUNK_LOOKUPENTRY(buffer
));
589 alSetError(AL_INVALID_ENUM
);
595 alSetError(AL_INVALID_NAME
);
598 ProcessContext(pContext
);
602 ALAPI
void ALAPIENTRY
alBufferfv(ALuint buffer
, ALenum eParam
, const ALfloat
* flValues
)
604 ALCcontext
*pContext
;
609 pContext
= alcGetCurrentContext();
610 SuspendContext(pContext
);
612 if (alIsBuffer(buffer
) && (buffer
!= 0))
614 pBuffer
= ((ALbuffer
*)ALTHUNK_LOOKUPENTRY(buffer
));
619 alSetError(AL_INVALID_ENUM
);
625 alSetError(AL_INVALID_NAME
);
628 ProcessContext(pContext
);
632 ALAPI
void ALAPIENTRY
alBufferi(ALuint buffer
, ALenum eParam
, ALint lValue
)
634 ALCcontext
*pContext
;
639 pContext
= alcGetCurrentContext();
640 SuspendContext(pContext
);
642 if (alIsBuffer(buffer
) && (buffer
!= 0))
644 pBuffer
= ((ALbuffer
*)ALTHUNK_LOOKUPENTRY(buffer
));
649 alSetError(AL_INVALID_ENUM
);
655 alSetError(AL_INVALID_NAME
);
658 ProcessContext(pContext
);
662 ALAPI
void ALAPIENTRY
alBuffer3i( ALuint buffer
, ALenum eParam
, ALint lValue1
, ALint lValue2
, ALint lValue3
)
664 ALCcontext
*pContext
;
671 pContext
= alcGetCurrentContext();
672 SuspendContext(pContext
);
674 if (alIsBuffer(buffer
) && (buffer
!= 0))
676 pBuffer
= ((ALbuffer
*)ALTHUNK_LOOKUPENTRY(buffer
));
681 alSetError(AL_INVALID_ENUM
);
687 alSetError(AL_INVALID_NAME
);
690 ProcessContext(pContext
);
694 ALAPI
void ALAPIENTRY
alBufferiv(ALuint buffer
, ALenum eParam
, const ALint
* plValues
)
696 ALCcontext
*pContext
;
701 pContext
= alcGetCurrentContext();
702 SuspendContext(pContext
);
704 if (alIsBuffer(buffer
) && (buffer
!= 0))
706 pBuffer
= ((ALbuffer
*)ALTHUNK_LOOKUPENTRY(buffer
));
711 alSetError(AL_INVALID_ENUM
);
717 alSetError(AL_INVALID_NAME
);
720 ProcessContext(pContext
);
724 ALAPI ALvoid ALAPIENTRY
alGetBufferf(ALuint buffer
, ALenum eParam
, ALfloat
*pflValue
)
726 ALCcontext
*pContext
;
729 pContext
= alcGetCurrentContext();
730 SuspendContext(pContext
);
734 if (alIsBuffer(buffer
) && (buffer
!= 0))
736 pBuffer
= ((ALbuffer
*)ALTHUNK_LOOKUPENTRY(buffer
));
741 alSetError(AL_INVALID_ENUM
);
747 alSetError(AL_INVALID_NAME
);
752 alSetError(AL_INVALID_VALUE
);
755 ProcessContext(pContext
);
759 ALAPI
void ALAPIENTRY
alGetBuffer3f(ALuint buffer
, ALenum eParam
, ALfloat
* pflValue1
, ALfloat
* pflValue2
, ALfloat
* pflValue3
)
761 ALCcontext
*pContext
;
764 pContext
= alcGetCurrentContext();
765 SuspendContext(pContext
);
767 if ((pflValue1
) && (pflValue2
) && (pflValue3
))
769 if (alIsBuffer(buffer
) && (buffer
!= 0))
771 pBuffer
= ((ALbuffer
*)ALTHUNK_LOOKUPENTRY(buffer
));
776 alSetError(AL_INVALID_ENUM
);
782 alSetError(AL_INVALID_NAME
);
787 alSetError(AL_INVALID_VALUE
);
790 ProcessContext(pContext
);
794 ALAPI
void ALAPIENTRY
alGetBufferfv(ALuint buffer
, ALenum eParam
, ALfloat
* pflValues
)
796 ALCcontext
*pContext
;
799 pContext
= alcGetCurrentContext();
800 SuspendContext(pContext
);
804 if (alIsBuffer(buffer
) && (buffer
!= 0))
806 pBuffer
= ((ALbuffer
*)ALTHUNK_LOOKUPENTRY(buffer
));
811 alSetError(AL_INVALID_ENUM
);
817 alSetError(AL_INVALID_NAME
);
822 alSetError(AL_INVALID_VALUE
);
825 ProcessContext(pContext
);
829 ALAPI ALvoid ALAPIENTRY
alGetBufferi(ALuint buffer
, ALenum eParam
, ALint
*plValue
)
831 ALCcontext
*pContext
;
834 pContext
= alcGetCurrentContext();
835 SuspendContext(pContext
);
839 if (alIsBuffer(buffer
) && (buffer
!= 0))
841 pBuffer
= ((ALbuffer
*)ALTHUNK_LOOKUPENTRY(buffer
));
846 *plValue
= pBuffer
->frequency
;
850 *plValue
= (((pBuffer
->format
==AL_FORMAT_MONO8
)||(pBuffer
->format
==AL_FORMAT_STEREO8
))?8:16);
854 *plValue
= (((pBuffer
->format
==AL_FORMAT_MONO8
)||(pBuffer
->format
==AL_FORMAT_MONO16
))?1:2);
858 *plValue
= pBuffer
->size
;
862 alSetError(AL_INVALID_ENUM
);
868 alSetError(AL_INVALID_NAME
);
873 alSetError(AL_INVALID_VALUE
);
876 ProcessContext(pContext
);
880 ALAPI
void ALAPIENTRY
alGetBuffer3i(ALuint buffer
, ALenum eParam
, ALint
* plValue1
, ALint
* plValue2
, ALint
* plValue3
)
882 ALCcontext
*pContext
;
885 pContext
= alcGetCurrentContext();
886 SuspendContext(pContext
);
888 if ((plValue1
) && (plValue2
) && (plValue3
))
890 if (alIsBuffer(buffer
) && (buffer
!= 0))
892 pBuffer
= ((ALbuffer
*)ALTHUNK_LOOKUPENTRY(buffer
));
897 alSetError(AL_INVALID_ENUM
);
903 alSetError(AL_INVALID_NAME
);
908 alSetError(AL_INVALID_VALUE
);
911 ProcessContext(pContext
);
915 ALAPI
void ALAPIENTRY
alGetBufferiv(ALuint buffer
, ALenum eParam
, ALint
* plValues
)
917 ALCcontext
*pContext
;
920 pContext
= alcGetCurrentContext();
921 SuspendContext(pContext
);
925 if (alIsBuffer(buffer
) && (buffer
!= 0))
927 pBuffer
= ((ALbuffer
*)ALTHUNK_LOOKUPENTRY(buffer
));
935 alGetBufferi(buffer
, eParam
, plValues
);
939 alSetError(AL_INVALID_ENUM
);
945 alSetError(AL_INVALID_NAME
);
950 alSetError(AL_INVALID_VALUE
);
953 ProcessContext(pContext
);
960 * INTERNAL FN : Called by DLLMain on exit to destroy any buffers that still exist
962 ALvoid
ReleaseALBuffers(ALvoid
)
965 ALbuffer
*ALBufferTemp
;
968 if(g_uiBufferCount
> 0)
970 sprintf(szDebug
, "OpenAL32 : DllMain() %d Buffer(s) NOT deleted\n", g_uiBufferCount
);
971 OutputDebugString(szDebug
);
975 ALBuffer
= g_pBuffers
;
978 // Release sample data
979 free(ALBuffer
->data
);
981 // Release Buffer structure
982 ALBufferTemp
= ALBuffer
;
983 ALBuffer
= ALBuffer
->next
;
984 memset(ALBufferTemp
, 0, sizeof(ALbuffer
));