2007-11-14 02:02:18 +00:00
|
|
|
/**
|
|
|
|
* OpenAL cross platform audio library
|
|
|
|
* Copyright (C) 1999-2000 by authors.
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
|
|
|
*/
|
|
|
|
|
2008-01-16 22:09:04 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2007-11-14 02:02:18 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include "alMain.h"
|
|
|
|
#include "AL/alc.h"
|
2009-08-16 07:54:08 +00:00
|
|
|
#include "AL/alext.h"
|
2007-11-14 02:02:18 +00:00
|
|
|
#include "alError.h"
|
2008-11-26 02:56:10 +00:00
|
|
|
#include "alSource.h"
|
2007-11-14 02:02:18 +00:00
|
|
|
#include "alState.h"
|
|
|
|
|
|
|
|
static const ALchar alVendor[] = "OpenAL Community";
|
2008-10-25 22:48:17 +00:00
|
|
|
static const ALchar alVersion[] = "1.1 ALSOFT "ALSOFT_VERSION;
|
2007-12-14 16:50:54 +00:00
|
|
|
static const ALchar alRenderer[] = "OpenAL Soft";
|
2007-11-14 02:02:18 +00:00
|
|
|
|
|
|
|
// Error Messages
|
|
|
|
static const ALchar alNoError[] = "No Error";
|
|
|
|
static const ALchar alErrInvalidName[] = "Invalid Name";
|
|
|
|
static const ALchar alErrInvalidEnum[] = "Invalid Enum";
|
|
|
|
static const ALchar alErrInvalidValue[] = "Invalid Value";
|
|
|
|
static const ALchar alErrInvalidOp[] = "Invalid Operation";
|
|
|
|
static const ALchar alErrOutOfMemory[] = "Out of Memory";
|
|
|
|
|
2010-03-19 21:34:18 +00:00
|
|
|
AL_API ALvoid AL_APIENTRY alEnable(ALenum capability)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
|
|
|
ALCcontext *Context;
|
2009-11-28 04:05:21 +00:00
|
|
|
ALboolean updateSources = AL_FALSE;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2009-08-16 21:09:23 +00:00
|
|
|
Context = GetContextSuspended();
|
2009-08-16 22:09:36 +00:00
|
|
|
if(!Context) return;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
switch(capability)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
2009-11-28 04:05:21 +00:00
|
|
|
case AL_SOURCE_DISTANCE_MODEL:
|
|
|
|
Context->SourceDistanceModel = AL_TRUE;
|
|
|
|
updateSources = AL_TRUE;
|
|
|
|
break;
|
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
default:
|
2010-03-17 00:35:51 +00:00
|
|
|
alSetError(Context, AL_INVALID_ENUM);
|
2009-08-16 22:09:36 +00:00
|
|
|
break;
|
2007-11-14 02:02:18 +00:00
|
|
|
}
|
2009-08-16 22:09:36 +00:00
|
|
|
|
2009-11-28 04:05:21 +00:00
|
|
|
if(updateSources)
|
|
|
|
{
|
2010-05-02 02:59:41 +00:00
|
|
|
ALsizei pos;
|
|
|
|
for(pos = 0;pos < Context->SourceMap.size;pos++)
|
2009-11-28 04:05:21 +00:00
|
|
|
{
|
2010-05-02 02:59:41 +00:00
|
|
|
ALsource *source = Context->SourceMap.array[pos].value;
|
2009-11-28 04:05:21 +00:00
|
|
|
source->NeedsUpdate = AL_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
ProcessContext(Context);
|
2007-11-14 02:02:18 +00:00
|
|
|
}
|
|
|
|
|
2010-03-19 21:34:18 +00:00
|
|
|
AL_API ALvoid AL_APIENTRY alDisable(ALenum capability)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
|
|
|
ALCcontext *Context;
|
2009-11-28 04:05:21 +00:00
|
|
|
ALboolean updateSources = AL_FALSE;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2009-08-16 21:09:23 +00:00
|
|
|
Context = GetContextSuspended();
|
2009-08-16 22:09:36 +00:00
|
|
|
if(!Context) return;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
switch(capability)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
2009-11-28 04:05:21 +00:00
|
|
|
case AL_SOURCE_DISTANCE_MODEL:
|
|
|
|
Context->SourceDistanceModel = AL_FALSE;
|
|
|
|
updateSources = AL_TRUE;
|
|
|
|
break;
|
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
default:
|
2010-03-17 00:35:51 +00:00
|
|
|
alSetError(Context, AL_INVALID_ENUM);
|
2009-08-16 22:09:36 +00:00
|
|
|
break;
|
2007-11-14 02:02:18 +00:00
|
|
|
}
|
2009-08-16 22:09:36 +00:00
|
|
|
|
2009-11-28 04:05:21 +00:00
|
|
|
if(updateSources)
|
|
|
|
{
|
2010-05-02 02:59:41 +00:00
|
|
|
ALsizei pos;
|
|
|
|
for(pos = 0;pos < Context->SourceMap.size;pos++)
|
2009-11-28 04:05:21 +00:00
|
|
|
{
|
2010-05-02 02:59:41 +00:00
|
|
|
ALsource *source = Context->SourceMap.array[pos].value;
|
2009-11-28 04:05:21 +00:00
|
|
|
source->NeedsUpdate = AL_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
ProcessContext(Context);
|
2007-11-14 02:02:18 +00:00
|
|
|
}
|
|
|
|
|
2010-03-19 21:34:18 +00:00
|
|
|
AL_API ALboolean AL_APIENTRY alIsEnabled(ALenum capability)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
|
|
|
ALCcontext *Context;
|
|
|
|
ALboolean value=AL_FALSE;
|
|
|
|
|
2009-08-16 21:09:23 +00:00
|
|
|
Context = GetContextSuspended();
|
2009-08-16 22:09:36 +00:00
|
|
|
if(!Context) return AL_FALSE;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
switch(capability)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
2009-11-28 04:05:21 +00:00
|
|
|
case AL_SOURCE_DISTANCE_MODEL:
|
|
|
|
value = Context->SourceDistanceModel;
|
|
|
|
break;
|
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
default:
|
2010-03-17 00:35:51 +00:00
|
|
|
alSetError(Context, AL_INVALID_ENUM);
|
2009-08-16 22:09:36 +00:00
|
|
|
break;
|
2007-11-14 02:02:18 +00:00
|
|
|
}
|
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
ProcessContext(Context);
|
|
|
|
|
2007-11-14 02:02:18 +00:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2010-03-19 21:34:18 +00:00
|
|
|
AL_API ALboolean AL_APIENTRY alGetBoolean(ALenum pname)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
|
|
|
ALCcontext *Context;
|
|
|
|
ALboolean value=AL_FALSE;
|
|
|
|
|
2009-08-16 21:09:23 +00:00
|
|
|
Context = GetContextSuspended();
|
2009-08-16 22:09:36 +00:00
|
|
|
if(!Context) return AL_FALSE;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
switch(pname)
|
|
|
|
{
|
|
|
|
case AL_DOPPLER_FACTOR:
|
|
|
|
if(Context->DopplerFactor != 0.0f)
|
|
|
|
value = AL_TRUE;
|
|
|
|
break;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
case AL_DOPPLER_VELOCITY:
|
|
|
|
if(Context->DopplerVelocity != 0.0f)
|
|
|
|
value = AL_TRUE;
|
|
|
|
break;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
case AL_DISTANCE_MODEL:
|
|
|
|
if(Context->DistanceModel == AL_INVERSE_DISTANCE_CLAMPED)
|
|
|
|
value = AL_TRUE;
|
|
|
|
break;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
case AL_SPEED_OF_SOUND:
|
|
|
|
if(Context->flSpeedOfSound != 0.0f)
|
|
|
|
value = AL_TRUE;
|
|
|
|
break;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
default:
|
2010-03-17 00:35:51 +00:00
|
|
|
alSetError(Context, AL_INVALID_ENUM);
|
2009-08-16 22:09:36 +00:00
|
|
|
break;
|
2007-11-14 02:02:18 +00:00
|
|
|
}
|
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
ProcessContext(Context);
|
|
|
|
|
2007-11-14 02:02:18 +00:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2010-03-19 21:34:18 +00:00
|
|
|
AL_API ALdouble AL_APIENTRY alGetDouble(ALenum pname)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
|
|
|
ALCcontext *Context;
|
|
|
|
ALdouble value = 0.0;
|
|
|
|
|
2009-08-16 21:09:23 +00:00
|
|
|
Context = GetContextSuspended();
|
2009-08-16 22:09:36 +00:00
|
|
|
if(!Context) return 0.0;
|
|
|
|
|
|
|
|
switch(pname)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
2009-08-16 22:09:36 +00:00
|
|
|
case AL_DOPPLER_FACTOR:
|
|
|
|
value = (double)Context->DopplerFactor;
|
|
|
|
break;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
case AL_DOPPLER_VELOCITY:
|
|
|
|
value = (double)Context->DopplerVelocity;
|
|
|
|
break;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
case AL_DISTANCE_MODEL:
|
|
|
|
value = (double)Context->DistanceModel;
|
|
|
|
break;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
case AL_SPEED_OF_SOUND:
|
|
|
|
value = (double)Context->flSpeedOfSound;
|
|
|
|
break;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
default:
|
2010-03-17 00:35:51 +00:00
|
|
|
alSetError(Context, AL_INVALID_ENUM);
|
2009-08-16 22:09:36 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ProcessContext(Context);
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2010-03-19 21:34:18 +00:00
|
|
|
AL_API ALfloat AL_APIENTRY alGetFloat(ALenum pname)
|
2009-08-16 22:09:36 +00:00
|
|
|
{
|
|
|
|
ALCcontext *Context;
|
|
|
|
ALfloat value = 0.0f;
|
|
|
|
|
|
|
|
Context = GetContextSuspended();
|
|
|
|
if(!Context) return 0.0f;
|
|
|
|
|
|
|
|
switch(pname)
|
|
|
|
{
|
|
|
|
case AL_DOPPLER_FACTOR:
|
|
|
|
value = Context->DopplerFactor;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AL_DOPPLER_VELOCITY:
|
|
|
|
value = Context->DopplerVelocity;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AL_DISTANCE_MODEL:
|
|
|
|
value = (float)Context->DistanceModel;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AL_SPEED_OF_SOUND:
|
|
|
|
value = Context->flSpeedOfSound;
|
|
|
|
break;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
default:
|
2010-03-17 00:35:51 +00:00
|
|
|
alSetError(Context, AL_INVALID_ENUM);
|
2009-08-16 22:09:36 +00:00
|
|
|
break;
|
2007-11-14 02:02:18 +00:00
|
|
|
}
|
2009-08-16 22:09:36 +00:00
|
|
|
|
|
|
|
ProcessContext(Context);
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2010-03-19 21:34:18 +00:00
|
|
|
AL_API ALint AL_APIENTRY alGetInteger(ALenum pname)
|
2009-08-16 22:09:36 +00:00
|
|
|
{
|
|
|
|
ALCcontext *Context;
|
|
|
|
ALint value = 0;
|
|
|
|
|
|
|
|
Context = GetContextSuspended();
|
|
|
|
if(!Context) return 0;
|
|
|
|
|
|
|
|
switch(pname)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
2009-08-16 22:09:36 +00:00
|
|
|
case AL_DOPPLER_FACTOR:
|
|
|
|
value = (ALint)Context->DopplerFactor;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AL_DOPPLER_VELOCITY:
|
|
|
|
value = (ALint)Context->DopplerVelocity;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AL_DISTANCE_MODEL:
|
|
|
|
value = (ALint)Context->DistanceModel;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AL_SPEED_OF_SOUND:
|
|
|
|
value = (ALint)Context->flSpeedOfSound;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2010-03-17 00:35:51 +00:00
|
|
|
alSetError(Context, AL_INVALID_ENUM);
|
2009-08-16 22:09:36 +00:00
|
|
|
break;
|
2007-11-14 02:02:18 +00:00
|
|
|
}
|
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
ProcessContext(Context);
|
|
|
|
|
2007-11-14 02:02:18 +00:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2010-03-19 21:34:18 +00:00
|
|
|
AL_API ALvoid AL_APIENTRY alGetBooleanv(ALenum pname,ALboolean *data)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
|
|
|
ALCcontext *Context;
|
|
|
|
|
2009-08-16 21:09:23 +00:00
|
|
|
Context = GetContextSuspended();
|
2009-08-16 22:09:36 +00:00
|
|
|
if(!Context) return;
|
|
|
|
|
|
|
|
if(data)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
2009-08-16 22:09:36 +00:00
|
|
|
switch(pname)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
|
|
|
case AL_DOPPLER_FACTOR:
|
2009-08-16 22:09:36 +00:00
|
|
|
*data = (ALboolean)((Context->DopplerFactor != 0.0f) ? AL_TRUE : AL_FALSE);
|
2007-11-14 02:02:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AL_DOPPLER_VELOCITY:
|
2009-08-16 22:09:36 +00:00
|
|
|
*data = (ALboolean)((Context->DopplerVelocity != 0.0f) ? AL_TRUE : AL_FALSE);
|
2007-11-14 02:02:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AL_DISTANCE_MODEL:
|
2009-08-16 22:09:36 +00:00
|
|
|
*data = (ALboolean)((Context->DistanceModel == AL_INVERSE_DISTANCE_CLAMPED) ? AL_TRUE : AL_FALSE);
|
2007-11-14 02:02:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AL_SPEED_OF_SOUND:
|
2009-08-16 22:09:36 +00:00
|
|
|
*data = (ALboolean)((Context->flSpeedOfSound != 0.0f) ? AL_TRUE : AL_FALSE);
|
2007-11-14 02:02:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2010-03-17 00:35:51 +00:00
|
|
|
alSetError(Context, AL_INVALID_ENUM);
|
2007-11-14 02:02:18 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-08-16 22:09:36 +00:00
|
|
|
// data is a NULL pointer
|
2010-03-17 00:35:51 +00:00
|
|
|
alSetError(Context, AL_INVALID_VALUE);
|
2007-11-14 02:02:18 +00:00
|
|
|
}
|
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
ProcessContext(Context);
|
2007-11-14 02:02:18 +00:00
|
|
|
}
|
|
|
|
|
2010-03-19 21:34:18 +00:00
|
|
|
AL_API ALvoid AL_APIENTRY alGetDoublev(ALenum pname,ALdouble *data)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
|
|
|
ALCcontext *Context;
|
|
|
|
|
2009-08-16 21:09:23 +00:00
|
|
|
Context = GetContextSuspended();
|
2009-08-16 22:09:36 +00:00
|
|
|
if(!Context) return;
|
|
|
|
|
|
|
|
if(data)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
2009-08-16 22:09:36 +00:00
|
|
|
switch(pname)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
|
|
|
case AL_DOPPLER_FACTOR:
|
2009-08-16 22:09:36 +00:00
|
|
|
*data = (double)Context->DopplerFactor;
|
2007-11-14 02:02:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AL_DOPPLER_VELOCITY:
|
2009-08-16 22:09:36 +00:00
|
|
|
*data = (double)Context->DopplerVelocity;
|
2007-11-14 02:02:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AL_DISTANCE_MODEL:
|
2009-08-16 22:09:36 +00:00
|
|
|
*data = (double)Context->DistanceModel;
|
2007-11-14 02:02:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AL_SPEED_OF_SOUND:
|
2009-08-16 22:09:36 +00:00
|
|
|
*data = (double)Context->flSpeedOfSound;
|
2009-08-16 07:54:08 +00:00
|
|
|
break;
|
|
|
|
|
2007-11-14 02:02:18 +00:00
|
|
|
default:
|
2010-03-17 00:35:51 +00:00
|
|
|
alSetError(Context, AL_INVALID_ENUM);
|
2007-11-14 02:02:18 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-08-16 22:09:36 +00:00
|
|
|
// data is a NULL pointer
|
2010-03-17 00:35:51 +00:00
|
|
|
alSetError(Context, AL_INVALID_VALUE);
|
2007-11-14 02:02:18 +00:00
|
|
|
}
|
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
ProcessContext(Context);
|
2007-11-14 02:02:18 +00:00
|
|
|
}
|
|
|
|
|
2010-03-19 21:34:18 +00:00
|
|
|
AL_API ALvoid AL_APIENTRY alGetFloatv(ALenum pname,ALfloat *data)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
|
|
|
ALCcontext *Context;
|
|
|
|
|
2009-08-16 21:09:23 +00:00
|
|
|
Context = GetContextSuspended();
|
2009-08-16 22:09:36 +00:00
|
|
|
if(!Context) return;
|
|
|
|
|
|
|
|
if(data)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
2009-08-16 22:09:36 +00:00
|
|
|
switch(pname)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
2009-08-16 22:09:36 +00:00
|
|
|
case AL_DOPPLER_FACTOR:
|
|
|
|
*data = Context->DopplerFactor;
|
|
|
|
break;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
case AL_DOPPLER_VELOCITY:
|
|
|
|
*data = Context->DopplerVelocity;
|
|
|
|
break;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
case AL_DISTANCE_MODEL:
|
|
|
|
*data = (float)Context->DistanceModel;
|
|
|
|
break;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
case AL_SPEED_OF_SOUND:
|
|
|
|
*data = Context->flSpeedOfSound;
|
|
|
|
break;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
default:
|
2010-03-17 00:35:51 +00:00
|
|
|
alSetError(Context, AL_INVALID_ENUM);
|
2009-08-16 22:09:36 +00:00
|
|
|
break;
|
2007-11-14 02:02:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-08-16 22:09:36 +00:00
|
|
|
// data is a NULL pointer
|
2010-03-17 00:35:51 +00:00
|
|
|
alSetError(Context, AL_INVALID_VALUE);
|
2007-11-14 02:02:18 +00:00
|
|
|
}
|
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
ProcessContext(Context);
|
2007-11-14 02:02:18 +00:00
|
|
|
}
|
|
|
|
|
2010-03-19 21:34:18 +00:00
|
|
|
AL_API ALvoid AL_APIENTRY alGetIntegerv(ALenum pname,ALint *data)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
|
|
|
ALCcontext *Context;
|
|
|
|
|
2009-08-16 21:09:23 +00:00
|
|
|
Context = GetContextSuspended();
|
2009-08-16 22:09:36 +00:00
|
|
|
if(!Context) return;
|
|
|
|
|
|
|
|
if(data)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
2009-08-16 22:09:36 +00:00
|
|
|
switch(pname)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
2009-08-16 22:09:36 +00:00
|
|
|
case AL_DOPPLER_FACTOR:
|
|
|
|
*data = (ALint)Context->DopplerFactor;
|
|
|
|
break;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
case AL_DOPPLER_VELOCITY:
|
|
|
|
*data = (ALint)Context->DopplerVelocity;
|
|
|
|
break;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
case AL_DISTANCE_MODEL:
|
|
|
|
*data = (ALint)Context->DistanceModel;
|
|
|
|
break;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
case AL_SPEED_OF_SOUND:
|
|
|
|
*data = (ALint)Context->flSpeedOfSound;
|
|
|
|
break;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
default:
|
2010-03-17 00:35:51 +00:00
|
|
|
alSetError(Context, AL_INVALID_ENUM);
|
2009-08-16 22:09:36 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-11-14 02:02:18 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-08-16 22:09:36 +00:00
|
|
|
// data is a NULL pointer
|
2010-03-17 00:35:51 +00:00
|
|
|
alSetError(Context, AL_INVALID_VALUE);
|
2007-11-14 02:02:18 +00:00
|
|
|
}
|
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
ProcessContext(Context);
|
2007-11-14 02:02:18 +00:00
|
|
|
}
|
|
|
|
|
2010-03-19 21:34:18 +00:00
|
|
|
AL_API const ALchar* AL_APIENTRY alGetString(ALenum pname)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
|
|
|
const ALchar *value;
|
|
|
|
ALCcontext *pContext;
|
|
|
|
|
2009-08-16 21:09:23 +00:00
|
|
|
pContext = GetContextSuspended();
|
2009-08-16 22:09:36 +00:00
|
|
|
if(!pContext) return NULL;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
|
|
|
switch(pname)
|
|
|
|
{
|
|
|
|
case AL_VENDOR:
|
|
|
|
value=alVendor;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AL_VERSION:
|
|
|
|
value=alVersion;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AL_RENDERER:
|
|
|
|
value=alRenderer;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AL_EXTENSIONS:
|
|
|
|
value=pContext->ExtensionList;//alExtensions;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AL_NO_ERROR:
|
|
|
|
value=alNoError;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AL_INVALID_NAME:
|
|
|
|
value=alErrInvalidName;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AL_INVALID_ENUM:
|
|
|
|
value=alErrInvalidEnum;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AL_INVALID_VALUE:
|
|
|
|
value=alErrInvalidValue;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AL_INVALID_OPERATION:
|
|
|
|
value=alErrInvalidOp;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AL_OUT_OF_MEMORY:
|
|
|
|
value=alErrOutOfMemory;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
value=NULL;
|
2010-03-17 00:35:51 +00:00
|
|
|
alSetError(pContext, AL_INVALID_ENUM);
|
2007-11-14 02:02:18 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ProcessContext(pContext);
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2010-03-19 21:34:18 +00:00
|
|
|
AL_API ALvoid AL_APIENTRY alDopplerFactor(ALfloat value)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
|
|
|
ALCcontext *Context;
|
2009-11-26 00:21:47 +00:00
|
|
|
ALboolean updateSources = AL_FALSE;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2009-08-16 21:09:23 +00:00
|
|
|
Context = GetContextSuspended();
|
2009-08-16 22:09:36 +00:00
|
|
|
if(!Context) return;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
if(value >= 0.0f)
|
2009-11-26 00:21:47 +00:00
|
|
|
{
|
2009-08-16 22:09:36 +00:00
|
|
|
Context->DopplerFactor = value;
|
2009-11-26 00:21:47 +00:00
|
|
|
updateSources = AL_TRUE;
|
|
|
|
}
|
2007-11-14 02:02:18 +00:00
|
|
|
else
|
2010-03-17 00:35:51 +00:00
|
|
|
alSetError(Context, AL_INVALID_VALUE);
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2009-11-26 00:21:47 +00:00
|
|
|
// Force updating the sources for these parameters, since even head-
|
|
|
|
// relative sources are affected
|
|
|
|
if(updateSources)
|
|
|
|
{
|
2010-05-02 02:59:41 +00:00
|
|
|
ALsizei pos;
|
|
|
|
for(pos = 0;pos < Context->SourceMap.size;pos++)
|
2009-11-26 00:21:47 +00:00
|
|
|
{
|
2010-05-02 02:59:41 +00:00
|
|
|
ALsource *source = Context->SourceMap.array[pos].value;
|
2009-11-26 00:21:47 +00:00
|
|
|
source->NeedsUpdate = AL_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
ProcessContext(Context);
|
2007-11-14 02:02:18 +00:00
|
|
|
}
|
|
|
|
|
2010-03-19 21:34:18 +00:00
|
|
|
AL_API ALvoid AL_APIENTRY alDopplerVelocity(ALfloat value)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
|
|
|
ALCcontext *Context;
|
2009-11-26 00:21:47 +00:00
|
|
|
ALboolean updateSources = AL_FALSE;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2009-08-16 21:09:23 +00:00
|
|
|
Context = GetContextSuspended();
|
2009-08-16 22:09:36 +00:00
|
|
|
if(!Context) return;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
if(value > 0.0f)
|
2009-11-26 00:21:47 +00:00
|
|
|
{
|
2009-08-16 22:09:36 +00:00
|
|
|
Context->DopplerVelocity=value;
|
2009-11-26 00:21:47 +00:00
|
|
|
updateSources = AL_TRUE;
|
|
|
|
}
|
2007-11-14 02:02:18 +00:00
|
|
|
else
|
2010-03-17 00:35:51 +00:00
|
|
|
alSetError(Context, AL_INVALID_VALUE);
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2009-11-26 00:21:47 +00:00
|
|
|
if(updateSources)
|
|
|
|
{
|
2010-05-02 02:59:41 +00:00
|
|
|
ALsizei pos;
|
|
|
|
for(pos = 0;pos < Context->SourceMap.size;pos++)
|
2009-11-26 00:21:47 +00:00
|
|
|
{
|
2010-05-02 02:59:41 +00:00
|
|
|
ALsource *source = Context->SourceMap.array[pos].value;
|
2009-11-26 00:21:47 +00:00
|
|
|
source->NeedsUpdate = AL_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
ProcessContext(Context);
|
2007-11-14 02:02:18 +00:00
|
|
|
}
|
|
|
|
|
2010-03-19 21:34:18 +00:00
|
|
|
AL_API ALvoid AL_APIENTRY alSpeedOfSound(ALfloat flSpeedOfSound)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
|
|
|
ALCcontext *pContext;
|
2009-11-26 00:21:47 +00:00
|
|
|
ALboolean updateSources = AL_FALSE;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2009-08-16 21:09:23 +00:00
|
|
|
pContext = GetContextSuspended();
|
2009-08-16 22:09:36 +00:00
|
|
|
if(!pContext) return;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
if(flSpeedOfSound > 0.0f)
|
2009-11-26 00:21:47 +00:00
|
|
|
{
|
2009-08-16 22:09:36 +00:00
|
|
|
pContext->flSpeedOfSound = flSpeedOfSound;
|
2009-11-26 00:21:47 +00:00
|
|
|
updateSources = AL_TRUE;
|
|
|
|
}
|
2007-11-14 02:02:18 +00:00
|
|
|
else
|
2010-03-17 00:35:51 +00:00
|
|
|
alSetError(pContext, AL_INVALID_VALUE);
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2009-11-26 00:21:47 +00:00
|
|
|
if(updateSources)
|
|
|
|
{
|
2010-05-02 02:59:41 +00:00
|
|
|
ALsizei pos;
|
|
|
|
for(pos = 0;pos < pContext->SourceMap.size;pos++)
|
2009-11-26 00:21:47 +00:00
|
|
|
{
|
2010-05-02 02:59:41 +00:00
|
|
|
ALsource *source = pContext->SourceMap.array[pos].value;
|
2009-11-26 00:21:47 +00:00
|
|
|
source->NeedsUpdate = AL_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
ProcessContext(pContext);
|
2007-11-14 02:02:18 +00:00
|
|
|
}
|
|
|
|
|
2010-03-19 21:34:18 +00:00
|
|
|
AL_API ALvoid AL_APIENTRY alDistanceModel(ALenum value)
|
2007-11-14 02:02:18 +00:00
|
|
|
{
|
|
|
|
ALCcontext *Context;
|
2009-11-28 04:05:21 +00:00
|
|
|
ALboolean updateSources = AL_FALSE;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2009-08-16 21:09:23 +00:00
|
|
|
Context = GetContextSuspended();
|
2009-08-16 22:09:36 +00:00
|
|
|
if(!Context) return;
|
|
|
|
|
|
|
|
switch(value)
|
|
|
|
{
|
|
|
|
case AL_NONE:
|
|
|
|
case AL_INVERSE_DISTANCE:
|
|
|
|
case AL_INVERSE_DISTANCE_CLAMPED:
|
|
|
|
case AL_LINEAR_DISTANCE:
|
|
|
|
case AL_LINEAR_DISTANCE_CLAMPED:
|
|
|
|
case AL_EXPONENT_DISTANCE:
|
|
|
|
case AL_EXPONENT_DISTANCE_CLAMPED:
|
|
|
|
Context->DistanceModel = value;
|
2009-11-28 04:05:21 +00:00
|
|
|
updateSources = !Context->SourceDistanceModel;
|
2009-08-16 22:09:36 +00:00
|
|
|
break;
|
2007-11-14 02:02:18 +00:00
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
default:
|
2010-03-17 00:35:51 +00:00
|
|
|
alSetError(Context, AL_INVALID_VALUE);
|
2009-08-16 22:09:36 +00:00
|
|
|
break;
|
2007-11-14 02:02:18 +00:00
|
|
|
}
|
|
|
|
|
2009-11-28 04:05:21 +00:00
|
|
|
if(updateSources)
|
|
|
|
{
|
2010-05-02 02:59:41 +00:00
|
|
|
ALsizei pos;
|
|
|
|
for(pos = 0;pos < Context->SourceMap.size;pos++)
|
2009-11-28 04:05:21 +00:00
|
|
|
{
|
2010-05-02 02:59:41 +00:00
|
|
|
ALsource *source = Context->SourceMap.array[pos].value;
|
2009-11-28 04:05:21 +00:00
|
|
|
source->NeedsUpdate = AL_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-16 22:09:36 +00:00
|
|
|
ProcessContext(Context);
|
2007-11-14 02:02:18 +00:00
|
|
|
}
|