2007-11-13 18:02:18 -08: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
|
2014-08-18 14:11:03 +02:00
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2007-11-13 18:02:18 -08:00
|
|
|
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
|
|
|
*/
|
|
|
|
|
2008-01-16 14:09:04 -08:00
|
|
|
#include "config.h"
|
|
|
|
|
2016-12-21 01:08:33 -08:00
|
|
|
#include "version.h"
|
|
|
|
|
2019-07-28 11:28:36 -07:00
|
|
|
#include <atomic>
|
2018-11-19 09:51:29 -08:00
|
|
|
#include <cmath>
|
2019-07-28 11:28:36 -07:00
|
|
|
#include <cstdlib>
|
|
|
|
#include <cstring>
|
|
|
|
#include <mutex>
|
2018-11-17 23:02:27 -08:00
|
|
|
|
2019-07-28 11:28:36 -07:00
|
|
|
#include "AL/al.h"
|
|
|
|
#include "AL/alc.h"
|
|
|
|
#include "AL/alext.h"
|
|
|
|
|
2018-11-17 23:02:27 -08:00
|
|
|
#include "alcontext.h"
|
2019-04-10 13:44:46 -07:00
|
|
|
#include "alexcpt.h"
|
2019-07-28 11:28:36 -07:00
|
|
|
#include "almalloc.h"
|
2019-08-05 22:40:19 -07:00
|
|
|
#include "alnumeric.h"
|
2019-05-26 21:28:51 -07:00
|
|
|
#include "alspan.h"
|
2019-07-28 11:28:36 -07:00
|
|
|
#include "alu.h"
|
|
|
|
#include "atomic.h"
|
2019-07-29 15:57:48 -07:00
|
|
|
#include "event.h"
|
2019-07-28 11:28:36 -07:00
|
|
|
#include "inprogext.h"
|
|
|
|
#include "opthelpers.h"
|
2019-08-12 03:59:52 -07:00
|
|
|
#include "strutils.h"
|
2012-09-14 03:10:12 -07:00
|
|
|
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2018-11-16 06:45:24 -08:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
constexpr ALchar alVendor[] = "OpenAL Community";
|
|
|
|
constexpr ALchar alVersion[] = "1.1 ALSOFT " ALSOFT_VERSION;
|
|
|
|
constexpr ALchar alRenderer[] = "OpenAL Soft";
|
2007-11-13 18:02:18 -08:00
|
|
|
|
|
|
|
// Error Messages
|
2018-11-16 06:45:24 -08:00
|
|
|
constexpr ALchar alNoError[] = "No Error";
|
|
|
|
constexpr ALchar alErrInvalidName[] = "Invalid Name";
|
|
|
|
constexpr ALchar alErrInvalidEnum[] = "Invalid Enum";
|
|
|
|
constexpr ALchar alErrInvalidValue[] = "Invalid Value";
|
|
|
|
constexpr ALchar alErrInvalidOp[] = "Invalid Operation";
|
|
|
|
constexpr ALchar alErrOutOfMemory[] = "Out of Memory";
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2017-04-21 04:15:08 -07:00
|
|
|
/* Resampler strings */
|
2018-11-16 06:45:24 -08:00
|
|
|
constexpr ALchar alPointResampler[] = "Nearest";
|
|
|
|
constexpr ALchar alLinearResampler[] = "Linear";
|
|
|
|
constexpr ALchar alCubicResampler[] = "Cubic";
|
|
|
|
constexpr ALchar alBSinc12Resampler[] = "11th order Sinc";
|
|
|
|
constexpr ALchar alBSinc24Resampler[] = "23rd order Sinc";
|
|
|
|
|
|
|
|
} // namespace
|
2017-04-21 04:15:08 -07:00
|
|
|
|
2017-10-16 05:22:22 -07:00
|
|
|
/* WARNING: Non-standard export! Not part of any extension, or exposed in the
|
|
|
|
* alcFunctions list.
|
|
|
|
*/
|
2018-11-16 06:45:24 -08:00
|
|
|
extern "C" AL_API const ALchar* AL_APIENTRY alsoft_get_version(void)
|
2019-04-10 13:44:46 -07:00
|
|
|
START_API_FUNC
|
2017-10-16 05:22:22 -07:00
|
|
|
{
|
2019-08-12 03:59:52 -07:00
|
|
|
static const auto spoof = al::getenv("ALSOFT_SPOOF_VERSION");
|
|
|
|
if(spoof) return spoof->c_str();
|
2017-10-16 05:22:22 -07:00
|
|
|
return ALSOFT_VERSION;
|
|
|
|
}
|
2019-04-10 13:44:46 -07:00
|
|
|
END_API_FUNC
|
2017-10-16 05:22:22 -07:00
|
|
|
|
2017-09-27 09:36:34 -07:00
|
|
|
#define DO_UPDATEPROPS() do { \
|
2019-07-30 09:05:54 -07:00
|
|
|
if(!context->mDeferUpdates.load(std::memory_order_acquire)) \
|
2018-11-16 06:45:24 -08:00
|
|
|
UpdateContextProps(context.get()); \
|
2017-09-27 09:36:34 -07:00
|
|
|
else \
|
2019-07-30 09:05:54 -07:00
|
|
|
context->mPropsClean.clear(std::memory_order_release); \
|
2017-09-27 09:36:34 -07:00
|
|
|
} while(0)
|
|
|
|
|
|
|
|
|
2010-03-19 14:34:18 -07:00
|
|
|
AL_API ALvoid AL_APIENTRY alEnable(ALenum capability)
|
2019-04-10 13:44:46 -07:00
|
|
|
START_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2018-11-16 06:45:24 -08:00
|
|
|
ContextRef context{GetContextRef()};
|
2019-08-04 11:59:14 -07:00
|
|
|
if UNLIKELY(!context) return;
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2019-07-30 09:05:54 -07:00
|
|
|
std::lock_guard<std::mutex> _{context->mPropLock};
|
2013-10-07 08:50:17 -07:00
|
|
|
switch(capability)
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2013-10-07 08:50:17 -07:00
|
|
|
case AL_SOURCE_DISTANCE_MODEL:
|
2019-07-30 09:05:54 -07:00
|
|
|
context->mSourceDistanceModel = AL_TRUE;
|
2017-09-27 09:36:34 -07:00
|
|
|
DO_UPDATEPROPS();
|
2013-10-07 08:50:17 -07:00
|
|
|
break;
|
2009-11-27 20:05:21 -08:00
|
|
|
|
2013-10-07 08:50:17 -07:00
|
|
|
default:
|
2019-07-30 21:32:05 -07:00
|
|
|
context->setError(AL_INVALID_VALUE, "Invalid enable property 0x%04x", capability);
|
2007-11-13 18:02:18 -08:00
|
|
|
}
|
|
|
|
}
|
2019-04-10 13:44:46 -07:00
|
|
|
END_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2010-03-19 14:34:18 -07:00
|
|
|
AL_API ALvoid AL_APIENTRY alDisable(ALenum capability)
|
2019-04-10 13:44:46 -07:00
|
|
|
START_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2018-11-16 06:45:24 -08:00
|
|
|
ContextRef context{GetContextRef()};
|
2019-08-04 11:59:14 -07:00
|
|
|
if UNLIKELY(!context) return;
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2019-07-30 09:05:54 -07:00
|
|
|
std::lock_guard<std::mutex> _{context->mPropLock};
|
2013-10-07 08:50:17 -07:00
|
|
|
switch(capability)
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2013-10-07 08:50:17 -07:00
|
|
|
case AL_SOURCE_DISTANCE_MODEL:
|
2019-07-30 09:05:54 -07:00
|
|
|
context->mSourceDistanceModel = AL_FALSE;
|
2017-09-27 09:36:34 -07:00
|
|
|
DO_UPDATEPROPS();
|
2013-10-07 08:50:17 -07:00
|
|
|
break;
|
2009-11-27 20:05:21 -08:00
|
|
|
|
2013-10-07 08:50:17 -07:00
|
|
|
default:
|
2019-07-30 21:32:05 -07:00
|
|
|
context->setError(AL_INVALID_VALUE, "Invalid disable property 0x%04x", capability);
|
2007-11-13 18:02:18 -08:00
|
|
|
}
|
|
|
|
}
|
2019-04-10 13:44:46 -07:00
|
|
|
END_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2010-03-19 14:34:18 -07:00
|
|
|
AL_API ALboolean AL_APIENTRY alIsEnabled(ALenum capability)
|
2019-04-10 13:44:46 -07:00
|
|
|
START_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2018-11-16 06:45:24 -08:00
|
|
|
ContextRef context{GetContextRef()};
|
2019-08-04 11:59:14 -07:00
|
|
|
if UNLIKELY(!context) return AL_FALSE;
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2019-07-30 09:05:54 -07:00
|
|
|
std::lock_guard<std::mutex> _{context->mPropLock};
|
2018-11-16 06:45:24 -08:00
|
|
|
ALboolean value{AL_FALSE};
|
2013-10-07 08:50:17 -07:00
|
|
|
switch(capability)
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2013-10-07 08:50:17 -07:00
|
|
|
case AL_SOURCE_DISTANCE_MODEL:
|
2019-07-30 09:05:54 -07:00
|
|
|
value = context->mSourceDistanceModel;
|
2013-10-07 08:50:17 -07:00
|
|
|
break;
|
2009-11-27 20:05:21 -08:00
|
|
|
|
2013-10-07 08:50:17 -07:00
|
|
|
default:
|
2019-07-30 21:32:05 -07:00
|
|
|
context->setError(AL_INVALID_VALUE, "Invalid is enabled property 0x%04x", capability);
|
2007-11-13 18:02:18 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
2019-04-10 13:44:46 -07:00
|
|
|
END_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2010-03-19 14:34:18 -07:00
|
|
|
AL_API ALboolean AL_APIENTRY alGetBoolean(ALenum pname)
|
2019-04-10 13:44:46 -07:00
|
|
|
START_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2018-11-16 06:45:24 -08:00
|
|
|
ContextRef context{GetContextRef()};
|
2019-08-04 11:59:14 -07:00
|
|
|
if UNLIKELY(!context) return AL_FALSE;
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2019-07-30 09:05:54 -07:00
|
|
|
std::lock_guard<std::mutex> _{context->mPropLock};
|
2018-11-16 06:45:24 -08:00
|
|
|
ALboolean value{AL_FALSE};
|
2013-10-07 08:50:17 -07:00
|
|
|
switch(pname)
|
2009-08-16 15:09:36 -07:00
|
|
|
{
|
2013-10-07 08:50:17 -07:00
|
|
|
case AL_DOPPLER_FACTOR:
|
2019-07-30 09:05:54 -07:00
|
|
|
if(context->mDopplerFactor != 0.0f)
|
2013-10-07 08:50:17 -07:00
|
|
|
value = AL_TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AL_DOPPLER_VELOCITY:
|
2019-07-30 09:05:54 -07:00
|
|
|
if(context->mDopplerVelocity != 0.0f)
|
2013-10-07 08:50:17 -07:00
|
|
|
value = AL_TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AL_DISTANCE_MODEL:
|
2018-11-18 03:39:32 -08:00
|
|
|
if(context->mDistanceModel == DistanceModel::Default)
|
2013-10-07 08:50:17 -07:00
|
|
|
value = AL_TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AL_SPEED_OF_SOUND:
|
2019-07-30 09:05:54 -07:00
|
|
|
if(context->mSpeedOfSound != 0.0f)
|
2013-10-07 08:50:17 -07:00
|
|
|
value = AL_TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AL_DEFERRED_UPDATES_SOFT:
|
2019-07-30 09:05:54 -07:00
|
|
|
if(context->mDeferUpdates.load(std::memory_order_acquire))
|
2016-08-26 19:46:46 -07:00
|
|
|
value = AL_TRUE;
|
2013-10-07 08:50:17 -07:00
|
|
|
break;
|
|
|
|
|
2016-08-28 18:21:09 -07:00
|
|
|
case AL_GAIN_LIMIT_SOFT:
|
2019-07-30 09:05:54 -07:00
|
|
|
if(GAIN_MIX_MAX/context->mGainBoost != 0.0f)
|
2016-08-28 18:21:09 -07:00
|
|
|
value = AL_TRUE;
|
|
|
|
break;
|
|
|
|
|
2017-04-21 04:15:08 -07:00
|
|
|
case AL_NUM_RESAMPLERS_SOFT:
|
|
|
|
/* Always non-0. */
|
|
|
|
value = AL_TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AL_DEFAULT_RESAMPLER_SOFT:
|
|
|
|
value = ResamplerDefault ? AL_TRUE : AL_FALSE;
|
|
|
|
break;
|
|
|
|
|
2013-10-07 08:50:17 -07:00
|
|
|
default:
|
2019-07-30 21:32:05 -07:00
|
|
|
context->setError(AL_INVALID_VALUE, "Invalid boolean property 0x%04x", pname);
|
2007-11-13 18:02:18 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
2019-04-10 13:44:46 -07:00
|
|
|
END_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2010-03-19 14:34:18 -07:00
|
|
|
AL_API ALdouble AL_APIENTRY alGetDouble(ALenum pname)
|
2019-04-10 13:44:46 -07:00
|
|
|
START_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2018-11-16 06:45:24 -08:00
|
|
|
ContextRef context{GetContextRef()};
|
2019-08-04 11:59:14 -07:00
|
|
|
if UNLIKELY(!context) return 0.0;
|
2009-08-16 15:09:36 -07:00
|
|
|
|
2019-07-30 09:05:54 -07:00
|
|
|
std::lock_guard<std::mutex> _{context->mPropLock};
|
2018-11-16 06:45:24 -08:00
|
|
|
ALdouble value{0.0};
|
2013-10-07 08:50:17 -07:00
|
|
|
switch(pname)
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2013-10-07 08:50:17 -07:00
|
|
|
case AL_DOPPLER_FACTOR:
|
2019-09-12 06:29:32 -07:00
|
|
|
value = context->mDopplerFactor;
|
2013-10-07 08:50:17 -07:00
|
|
|
break;
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2013-10-07 08:50:17 -07:00
|
|
|
case AL_DOPPLER_VELOCITY:
|
2019-09-12 06:29:32 -07:00
|
|
|
value = context->mDopplerVelocity;
|
2013-10-07 08:50:17 -07:00
|
|
|
break;
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2013-10-07 08:50:17 -07:00
|
|
|
case AL_DISTANCE_MODEL:
|
2019-01-08 19:42:44 +01:00
|
|
|
value = static_cast<ALdouble>(context->mDistanceModel);
|
2013-10-07 08:50:17 -07:00
|
|
|
break;
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2013-10-07 08:50:17 -07:00
|
|
|
case AL_SPEED_OF_SOUND:
|
2019-09-12 06:29:32 -07:00
|
|
|
value = context->mSpeedOfSound;
|
2013-10-07 08:50:17 -07:00
|
|
|
break;
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2013-10-07 08:50:17 -07:00
|
|
|
case AL_DEFERRED_UPDATES_SOFT:
|
2019-07-30 09:05:54 -07:00
|
|
|
if(context->mDeferUpdates.load(std::memory_order_acquire))
|
2019-01-08 19:42:44 +01:00
|
|
|
value = static_cast<ALdouble>(AL_TRUE);
|
2013-10-07 08:50:17 -07:00
|
|
|
break;
|
2011-07-16 16:59:20 -07:00
|
|
|
|
2016-08-28 18:21:09 -07:00
|
|
|
case AL_GAIN_LIMIT_SOFT:
|
2019-09-12 06:29:32 -07:00
|
|
|
value = ALdouble{GAIN_MIX_MAX}/context->mGainBoost;
|
2016-08-28 18:21:09 -07:00
|
|
|
break;
|
|
|
|
|
2017-04-21 04:15:08 -07:00
|
|
|
case AL_NUM_RESAMPLERS_SOFT:
|
2019-01-08 19:42:44 +01:00
|
|
|
value = static_cast<ALdouble>(ResamplerMax + 1);
|
2017-04-21 04:15:08 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AL_DEFAULT_RESAMPLER_SOFT:
|
2019-01-08 19:42:44 +01:00
|
|
|
value = static_cast<ALdouble>(ResamplerDefault);
|
2017-04-21 04:15:08 -07:00
|
|
|
break;
|
|
|
|
|
2013-10-07 08:50:17 -07:00
|
|
|
default:
|
2019-07-30 21:32:05 -07:00
|
|
|
context->setError(AL_INVALID_VALUE, "Invalid double property 0x%04x", pname);
|
2009-08-16 15:09:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
2019-04-10 13:44:46 -07:00
|
|
|
END_API_FUNC
|
2009-08-16 15:09:36 -07:00
|
|
|
|
2010-03-19 14:34:18 -07:00
|
|
|
AL_API ALfloat AL_APIENTRY alGetFloat(ALenum pname)
|
2019-04-10 13:44:46 -07:00
|
|
|
START_API_FUNC
|
2009-08-16 15:09:36 -07:00
|
|
|
{
|
2018-11-16 06:45:24 -08:00
|
|
|
ContextRef context{GetContextRef()};
|
2019-08-04 11:59:14 -07:00
|
|
|
if UNLIKELY(!context) return 0.0f;
|
2009-08-16 15:09:36 -07:00
|
|
|
|
2019-07-30 09:05:54 -07:00
|
|
|
std::lock_guard<std::mutex> _{context->mPropLock};
|
2018-11-16 06:45:24 -08:00
|
|
|
ALfloat value{0.0f};
|
2013-10-07 08:50:17 -07:00
|
|
|
switch(pname)
|
2009-08-16 15:09:36 -07:00
|
|
|
{
|
2013-10-07 08:50:17 -07:00
|
|
|
case AL_DOPPLER_FACTOR:
|
2019-07-30 09:05:54 -07:00
|
|
|
value = context->mDopplerFactor;
|
2013-10-07 08:50:17 -07:00
|
|
|
break;
|
2009-08-16 15:09:36 -07:00
|
|
|
|
2013-10-07 08:50:17 -07:00
|
|
|
case AL_DOPPLER_VELOCITY:
|
2019-07-30 09:05:54 -07:00
|
|
|
value = context->mDopplerVelocity;
|
2013-10-07 08:50:17 -07:00
|
|
|
break;
|
2009-08-16 15:09:36 -07:00
|
|
|
|
2013-10-07 08:50:17 -07:00
|
|
|
case AL_DISTANCE_MODEL:
|
2019-01-08 19:42:44 +01:00
|
|
|
value = static_cast<ALfloat>(context->mDistanceModel);
|
2013-10-07 08:50:17 -07:00
|
|
|
break;
|
2009-08-16 15:09:36 -07:00
|
|
|
|
2013-10-07 08:50:17 -07:00
|
|
|
case AL_SPEED_OF_SOUND:
|
2019-07-30 09:05:54 -07:00
|
|
|
value = context->mSpeedOfSound;
|
2013-10-07 08:50:17 -07:00
|
|
|
break;
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2013-10-07 08:50:17 -07:00
|
|
|
case AL_DEFERRED_UPDATES_SOFT:
|
2019-07-30 09:05:54 -07:00
|
|
|
if(context->mDeferUpdates.load(std::memory_order_acquire))
|
2019-01-08 19:42:44 +01:00
|
|
|
value = static_cast<ALfloat>(AL_TRUE);
|
2013-10-07 08:50:17 -07:00
|
|
|
break;
|
2011-07-16 16:59:20 -07:00
|
|
|
|
2016-08-28 18:21:09 -07:00
|
|
|
case AL_GAIN_LIMIT_SOFT:
|
2019-07-30 09:05:54 -07:00
|
|
|
value = GAIN_MIX_MAX/context->mGainBoost;
|
2016-08-28 18:21:09 -07:00
|
|
|
break;
|
|
|
|
|
2017-04-21 04:15:08 -07:00
|
|
|
case AL_NUM_RESAMPLERS_SOFT:
|
2019-01-08 19:42:44 +01:00
|
|
|
value = static_cast<ALfloat>(ResamplerMax + 1);
|
2017-04-21 04:15:08 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AL_DEFAULT_RESAMPLER_SOFT:
|
2019-01-08 19:42:44 +01:00
|
|
|
value = static_cast<ALfloat>(ResamplerDefault);
|
2017-04-21 04:15:08 -07:00
|
|
|
break;
|
|
|
|
|
2013-10-07 08:50:17 -07:00
|
|
|
default:
|
2019-07-30 21:32:05 -07:00
|
|
|
context->setError(AL_INVALID_VALUE, "Invalid float property 0x%04x", pname);
|
2007-11-13 18:02:18 -08:00
|
|
|
}
|
2009-08-16 15:09:36 -07:00
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
2019-04-10 13:44:46 -07:00
|
|
|
END_API_FUNC
|
2009-08-16 15:09:36 -07:00
|
|
|
|
2010-03-19 14:34:18 -07:00
|
|
|
AL_API ALint AL_APIENTRY alGetInteger(ALenum pname)
|
2019-04-10 13:44:46 -07:00
|
|
|
START_API_FUNC
|
2009-08-16 15:09:36 -07:00
|
|
|
{
|
2018-11-16 06:45:24 -08:00
|
|
|
ContextRef context{GetContextRef()};
|
2019-08-04 11:59:14 -07:00
|
|
|
if UNLIKELY(!context) return 0;
|
2009-08-16 15:09:36 -07:00
|
|
|
|
2019-07-30 09:05:54 -07:00
|
|
|
std::lock_guard<std::mutex> _{context->mPropLock};
|
2018-11-16 06:45:24 -08:00
|
|
|
ALint value{0};
|
2013-10-07 08:50:17 -07:00
|
|
|
switch(pname)
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2013-10-07 08:50:17 -07:00
|
|
|
case AL_DOPPLER_FACTOR:
|
2019-07-30 09:05:54 -07:00
|
|
|
value = static_cast<ALint>(context->mDopplerFactor);
|
2013-10-07 08:50:17 -07:00
|
|
|
break;
|
2009-08-16 15:09:36 -07:00
|
|
|
|
2013-10-07 08:50:17 -07:00
|
|
|
case AL_DOPPLER_VELOCITY:
|
2019-07-30 09:05:54 -07:00
|
|
|
value = static_cast<ALint>(context->mDopplerVelocity);
|
2013-10-07 08:50:17 -07:00
|
|
|
break;
|
2009-08-16 15:09:36 -07:00
|
|
|
|
2013-10-07 08:50:17 -07:00
|
|
|
case AL_DISTANCE_MODEL:
|
2019-01-08 19:42:44 +01:00
|
|
|
value = static_cast<ALint>(context->mDistanceModel);
|
2013-10-07 08:50:17 -07:00
|
|
|
break;
|
2009-08-16 15:09:36 -07:00
|
|
|
|
2013-10-07 08:50:17 -07:00
|
|
|
case AL_SPEED_OF_SOUND:
|
2019-07-30 09:05:54 -07:00
|
|
|
value = static_cast<ALint>(context->mSpeedOfSound);
|
2013-10-07 08:50:17 -07:00
|
|
|
break;
|
2009-08-16 15:09:36 -07:00
|
|
|
|
2013-10-07 08:50:17 -07:00
|
|
|
case AL_DEFERRED_UPDATES_SOFT:
|
2019-07-30 09:05:54 -07:00
|
|
|
if(context->mDeferUpdates.load(std::memory_order_acquire))
|
2019-09-12 06:29:32 -07:00
|
|
|
value = AL_TRUE;
|
2013-10-07 08:50:17 -07:00
|
|
|
break;
|
2011-07-16 16:59:20 -07:00
|
|
|
|
2016-08-28 18:21:09 -07:00
|
|
|
case AL_GAIN_LIMIT_SOFT:
|
2019-07-30 09:05:54 -07:00
|
|
|
value = static_cast<ALint>(GAIN_MIX_MAX/context->mGainBoost);
|
2016-08-28 18:21:09 -07:00
|
|
|
break;
|
|
|
|
|
2017-04-21 04:15:08 -07:00
|
|
|
case AL_NUM_RESAMPLERS_SOFT:
|
|
|
|
value = ResamplerMax + 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AL_DEFAULT_RESAMPLER_SOFT:
|
|
|
|
value = ResamplerDefault;
|
|
|
|
break;
|
|
|
|
|
2013-10-07 08:50:17 -07:00
|
|
|
default:
|
2019-07-30 21:32:05 -07:00
|
|
|
context->setError(AL_INVALID_VALUE, "Invalid integer property 0x%04x", pname);
|
2007-11-13 18:02:18 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
2019-04-10 13:44:46 -07:00
|
|
|
END_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2018-11-16 06:45:24 -08:00
|
|
|
extern "C" AL_API ALint64SOFT AL_APIENTRY alGetInteger64SOFT(ALenum pname)
|
2019-04-10 13:44:46 -07:00
|
|
|
START_API_FUNC
|
2013-11-28 01:53:05 -08:00
|
|
|
{
|
2018-11-16 06:45:24 -08:00
|
|
|
ContextRef context{GetContextRef()};
|
2019-08-04 11:59:14 -07:00
|
|
|
if UNLIKELY(!context) return 0_i64;
|
2013-11-28 01:53:05 -08:00
|
|
|
|
2019-07-30 09:05:54 -07:00
|
|
|
std::lock_guard<std::mutex> _{context->mPropLock};
|
2018-11-16 06:45:24 -08:00
|
|
|
ALint64SOFT value{0};
|
2013-11-28 01:53:05 -08:00
|
|
|
switch(pname)
|
|
|
|
{
|
|
|
|
case AL_DOPPLER_FACTOR:
|
2019-09-11 06:47:56 -07:00
|
|
|
value = static_cast<ALint64SOFT>(context->mDopplerFactor);
|
2013-11-28 01:53:05 -08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AL_DOPPLER_VELOCITY:
|
2019-09-11 06:47:56 -07:00
|
|
|
value = static_cast<ALint64SOFT>(context->mDopplerVelocity);
|
2013-11-28 01:53:05 -08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AL_DISTANCE_MODEL:
|
2019-09-11 06:47:56 -07:00
|
|
|
value = static_cast<ALint64SOFT>(context->mDistanceModel);
|
2013-11-28 01:53:05 -08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AL_SPEED_OF_SOUND:
|
2019-09-11 06:47:56 -07:00
|
|
|
value = static_cast<ALint64SOFT>(context->mSpeedOfSound);
|
2013-11-28 01:53:05 -08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AL_DEFERRED_UPDATES_SOFT:
|
2019-07-30 09:05:54 -07:00
|
|
|
if(context->mDeferUpdates.load(std::memory_order_acquire))
|
2019-09-11 06:47:56 -07:00
|
|
|
value = AL_TRUE;
|
2013-11-28 01:53:05 -08:00
|
|
|
break;
|
|
|
|
|
2016-08-28 18:21:09 -07:00
|
|
|
case AL_GAIN_LIMIT_SOFT:
|
2019-09-11 06:47:56 -07:00
|
|
|
value = static_cast<ALint64SOFT>(GAIN_MIX_MAX/context->mGainBoost);
|
2016-08-28 18:21:09 -07:00
|
|
|
break;
|
|
|
|
|
2017-04-21 04:15:08 -07:00
|
|
|
case AL_NUM_RESAMPLERS_SOFT:
|
2019-09-11 06:47:56 -07:00
|
|
|
value = static_cast<ALint64SOFT>(ResamplerMax + 1);
|
2017-04-21 04:15:08 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case AL_DEFAULT_RESAMPLER_SOFT:
|
2019-09-11 06:47:56 -07:00
|
|
|
value = static_cast<ALint64SOFT>(ResamplerDefault);
|
2017-04-21 04:15:08 -07:00
|
|
|
break;
|
|
|
|
|
2013-11-28 01:53:05 -08:00
|
|
|
default:
|
2019-07-30 21:32:05 -07:00
|
|
|
context->setError(AL_INVALID_VALUE, "Invalid integer64 property 0x%04x", pname);
|
2013-11-28 01:53:05 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
2019-04-10 13:44:46 -07:00
|
|
|
END_API_FUNC
|
2013-11-28 01:53:05 -08:00
|
|
|
|
2018-01-23 18:25:59 -08:00
|
|
|
AL_API void* AL_APIENTRY alGetPointerSOFT(ALenum pname)
|
2019-04-10 13:44:46 -07:00
|
|
|
START_API_FUNC
|
2018-01-23 18:25:59 -08:00
|
|
|
{
|
2018-11-16 06:45:24 -08:00
|
|
|
ContextRef context{GetContextRef()};
|
2019-08-04 11:59:14 -07:00
|
|
|
if UNLIKELY(!context) return nullptr;
|
2018-01-23 18:25:59 -08:00
|
|
|
|
2019-07-30 09:05:54 -07:00
|
|
|
std::lock_guard<std::mutex> _{context->mPropLock};
|
2018-11-16 06:45:24 -08:00
|
|
|
void *value{nullptr};
|
2018-01-23 18:25:59 -08:00
|
|
|
switch(pname)
|
|
|
|
{
|
2018-01-25 23:52:09 -08:00
|
|
|
case AL_EVENT_CALLBACK_FUNCTION_SOFT:
|
2019-07-30 09:05:54 -07:00
|
|
|
value = reinterpret_cast<void*>(context->mEventCb);
|
2018-01-25 23:52:09 -08:00
|
|
|
break;
|
2018-01-23 18:25:59 -08:00
|
|
|
|
2018-01-25 23:52:09 -08:00
|
|
|
case AL_EVENT_CALLBACK_USER_PARAM_SOFT:
|
2019-07-30 09:05:54 -07:00
|
|
|
value = context->mEventParam;
|
2018-01-25 23:52:09 -08:00
|
|
|
break;
|
2018-01-23 18:25:59 -08:00
|
|
|
|
2018-01-25 23:52:09 -08:00
|
|
|
default:
|
2019-07-30 21:32:05 -07:00
|
|
|
context->setError(AL_INVALID_VALUE, "Invalid pointer property 0x%04x", pname);
|
2018-01-23 18:25:59 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
2019-04-10 13:44:46 -07:00
|
|
|
END_API_FUNC
|
2018-01-23 18:25:59 -08:00
|
|
|
|
2018-01-24 18:30:32 -08:00
|
|
|
AL_API ALvoid AL_APIENTRY alGetBooleanv(ALenum pname, ALboolean *values)
|
2019-04-10 13:44:46 -07:00
|
|
|
START_API_FUNC
|
2018-01-23 18:25:59 -08:00
|
|
|
{
|
|
|
|
if(values)
|
|
|
|
{
|
|
|
|
switch(pname)
|
|
|
|
{
|
2018-01-24 18:30:32 -08:00
|
|
|
case AL_DOPPLER_FACTOR:
|
|
|
|
case AL_DOPPLER_VELOCITY:
|
|
|
|
case AL_DISTANCE_MODEL:
|
|
|
|
case AL_SPEED_OF_SOUND:
|
|
|
|
case AL_DEFERRED_UPDATES_SOFT:
|
|
|
|
case AL_GAIN_LIMIT_SOFT:
|
|
|
|
case AL_NUM_RESAMPLERS_SOFT:
|
|
|
|
case AL_DEFAULT_RESAMPLER_SOFT:
|
|
|
|
values[0] = alGetBoolean(pname);
|
2018-01-23 18:25:59 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-16 06:45:24 -08:00
|
|
|
ContextRef context{GetContextRef()};
|
2019-08-04 11:59:14 -07:00
|
|
|
if UNLIKELY(!context) return;
|
2018-01-23 18:25:59 -08:00
|
|
|
|
2018-01-24 17:07:01 -08:00
|
|
|
if(!values)
|
2019-07-30 21:32:05 -07:00
|
|
|
context->setError(AL_INVALID_VALUE, "NULL pointer");
|
2018-11-16 06:45:24 -08:00
|
|
|
else switch(pname)
|
2018-01-23 18:25:59 -08:00
|
|
|
{
|
|
|
|
default:
|
2019-07-30 21:32:05 -07:00
|
|
|
context->setError(AL_INVALID_VALUE, "Invalid boolean-vector property 0x%04x", pname);
|
2018-01-23 18:25:59 -08:00
|
|
|
}
|
|
|
|
}
|
2019-04-10 13:44:46 -07:00
|
|
|
END_API_FUNC
|
2018-01-23 18:25:59 -08:00
|
|
|
|
2018-01-24 18:30:32 -08:00
|
|
|
AL_API ALvoid AL_APIENTRY alGetDoublev(ALenum pname, ALdouble *values)
|
2019-04-10 13:44:46 -07:00
|
|
|
START_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2012-04-24 02:51:57 -07:00
|
|
|
if(values)
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2009-08-16 15:09:36 -07:00
|
|
|
switch(pname)
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
|
|
|
case AL_DOPPLER_FACTOR:
|
|
|
|
case AL_DOPPLER_VELOCITY:
|
|
|
|
case AL_DISTANCE_MODEL:
|
|
|
|
case AL_SPEED_OF_SOUND:
|
2011-07-16 16:59:20 -07:00
|
|
|
case AL_DEFERRED_UPDATES_SOFT:
|
2016-08-28 18:21:09 -07:00
|
|
|
case AL_GAIN_LIMIT_SOFT:
|
2017-04-21 04:15:08 -07:00
|
|
|
case AL_NUM_RESAMPLERS_SOFT:
|
|
|
|
case AL_DEFAULT_RESAMPLER_SOFT:
|
2018-01-24 18:30:32 -08:00
|
|
|
values[0] = alGetDouble(pname);
|
2011-07-11 00:51:18 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-16 06:45:24 -08:00
|
|
|
ContextRef context{GetContextRef()};
|
2019-08-04 11:59:14 -07:00
|
|
|
if UNLIKELY(!context) return;
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2018-01-24 17:07:01 -08:00
|
|
|
if(!values)
|
2019-07-30 21:32:05 -07:00
|
|
|
context->setError(AL_INVALID_VALUE, "NULL pointer");
|
2018-11-16 06:45:24 -08:00
|
|
|
else switch(pname)
|
2011-07-11 00:51:18 -07:00
|
|
|
{
|
2013-10-07 08:50:17 -07:00
|
|
|
default:
|
2019-07-30 21:32:05 -07:00
|
|
|
context->setError(AL_INVALID_VALUE, "Invalid double-vector property 0x%04x", pname);
|
2007-11-13 18:02:18 -08:00
|
|
|
}
|
|
|
|
}
|
2019-04-10 13:44:46 -07:00
|
|
|
END_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2018-01-24 18:30:32 -08:00
|
|
|
AL_API ALvoid AL_APIENTRY alGetFloatv(ALenum pname, ALfloat *values)
|
2019-04-10 13:44:46 -07:00
|
|
|
START_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2012-04-24 02:51:57 -07:00
|
|
|
if(values)
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2009-08-16 15:09:36 -07:00
|
|
|
switch(pname)
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
|
|
|
case AL_DOPPLER_FACTOR:
|
|
|
|
case AL_DOPPLER_VELOCITY:
|
|
|
|
case AL_DISTANCE_MODEL:
|
|
|
|
case AL_SPEED_OF_SOUND:
|
2011-07-16 16:59:20 -07:00
|
|
|
case AL_DEFERRED_UPDATES_SOFT:
|
2016-08-28 18:21:09 -07:00
|
|
|
case AL_GAIN_LIMIT_SOFT:
|
2017-04-21 04:15:08 -07:00
|
|
|
case AL_NUM_RESAMPLERS_SOFT:
|
|
|
|
case AL_DEFAULT_RESAMPLER_SOFT:
|
2018-01-24 18:30:32 -08:00
|
|
|
values[0] = alGetFloat(pname);
|
2011-07-11 00:51:18 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-16 06:45:24 -08:00
|
|
|
ContextRef context{GetContextRef()};
|
2019-08-04 11:59:14 -07:00
|
|
|
if UNLIKELY(!context) return;
|
2009-08-16 00:54:08 -07:00
|
|
|
|
2018-01-24 17:07:01 -08:00
|
|
|
if(!values)
|
2019-07-30 21:32:05 -07:00
|
|
|
context->setError(AL_INVALID_VALUE, "NULL pointer");
|
2018-11-16 06:45:24 -08:00
|
|
|
else switch(pname)
|
2011-07-11 00:51:18 -07:00
|
|
|
{
|
2013-10-07 08:50:17 -07:00
|
|
|
default:
|
2019-07-30 21:32:05 -07:00
|
|
|
context->setError(AL_INVALID_VALUE, "Invalid float-vector property 0x%04x", pname);
|
2007-11-13 18:02:18 -08:00
|
|
|
}
|
|
|
|
}
|
2019-04-10 13:44:46 -07:00
|
|
|
END_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2018-01-24 18:30:32 -08:00
|
|
|
AL_API ALvoid AL_APIENTRY alGetIntegerv(ALenum pname, ALint *values)
|
2019-04-10 13:44:46 -07:00
|
|
|
START_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2012-04-24 02:51:57 -07:00
|
|
|
if(values)
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2009-08-16 15:09:36 -07:00
|
|
|
switch(pname)
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2009-08-16 15:09:36 -07:00
|
|
|
case AL_DOPPLER_FACTOR:
|
|
|
|
case AL_DOPPLER_VELOCITY:
|
|
|
|
case AL_DISTANCE_MODEL:
|
|
|
|
case AL_SPEED_OF_SOUND:
|
2011-07-16 16:59:20 -07:00
|
|
|
case AL_DEFERRED_UPDATES_SOFT:
|
2016-08-28 18:21:09 -07:00
|
|
|
case AL_GAIN_LIMIT_SOFT:
|
2017-04-21 04:15:08 -07:00
|
|
|
case AL_NUM_RESAMPLERS_SOFT:
|
|
|
|
case AL_DEFAULT_RESAMPLER_SOFT:
|
2018-01-24 18:30:32 -08:00
|
|
|
values[0] = alGetInteger(pname);
|
2011-07-11 00:51:18 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-16 06:45:24 -08:00
|
|
|
ContextRef context{GetContextRef()};
|
2019-08-04 11:59:14 -07:00
|
|
|
if UNLIKELY(!context) return;
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2018-01-24 17:07:01 -08:00
|
|
|
if(!values)
|
2019-07-30 21:32:05 -07:00
|
|
|
context->setError(AL_INVALID_VALUE, "NULL pointer");
|
2018-11-16 06:45:24 -08:00
|
|
|
else switch(pname)
|
2011-07-11 00:51:18 -07:00
|
|
|
{
|
2013-10-07 08:50:17 -07:00
|
|
|
default:
|
2019-07-30 21:32:05 -07:00
|
|
|
context->setError(AL_INVALID_VALUE, "Invalid integer-vector property 0x%04x", pname);
|
2007-11-13 18:02:18 -08:00
|
|
|
}
|
|
|
|
}
|
2019-04-10 13:44:46 -07:00
|
|
|
END_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2018-11-16 06:45:24 -08:00
|
|
|
extern "C" AL_API void AL_APIENTRY alGetInteger64vSOFT(ALenum pname, ALint64SOFT *values)
|
2019-04-10 13:44:46 -07:00
|
|
|
START_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2012-04-24 02:51:57 -07:00
|
|
|
if(values)
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2009-08-16 15:09:36 -07:00
|
|
|
switch(pname)
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2009-08-16 15:09:36 -07:00
|
|
|
case AL_DOPPLER_FACTOR:
|
|
|
|
case AL_DOPPLER_VELOCITY:
|
|
|
|
case AL_DISTANCE_MODEL:
|
|
|
|
case AL_SPEED_OF_SOUND:
|
2011-07-16 16:59:20 -07:00
|
|
|
case AL_DEFERRED_UPDATES_SOFT:
|
2016-08-28 18:21:09 -07:00
|
|
|
case AL_GAIN_LIMIT_SOFT:
|
2017-04-21 04:15:08 -07:00
|
|
|
case AL_NUM_RESAMPLERS_SOFT:
|
|
|
|
case AL_DEFAULT_RESAMPLER_SOFT:
|
2018-01-24 18:30:32 -08:00
|
|
|
values[0] = alGetInteger64SOFT(pname);
|
2011-07-11 00:51:18 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-16 06:45:24 -08:00
|
|
|
ContextRef context{GetContextRef()};
|
2019-08-04 11:59:14 -07:00
|
|
|
if UNLIKELY(!context) return;
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2018-01-24 17:07:01 -08:00
|
|
|
if(!values)
|
2019-07-30 21:32:05 -07:00
|
|
|
context->setError(AL_INVALID_VALUE, "NULL pointer");
|
2018-11-16 06:45:24 -08:00
|
|
|
else switch(pname)
|
2011-07-11 00:51:18 -07:00
|
|
|
{
|
2013-10-07 08:50:17 -07:00
|
|
|
default:
|
2019-07-30 21:32:05 -07:00
|
|
|
context->setError(AL_INVALID_VALUE, "Invalid integer64-vector property 0x%04x", pname);
|
2007-11-13 18:02:18 -08:00
|
|
|
}
|
|
|
|
}
|
2019-04-10 13:44:46 -07:00
|
|
|
END_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2018-01-24 18:30:32 -08:00
|
|
|
AL_API void AL_APIENTRY alGetPointervSOFT(ALenum pname, void **values)
|
2019-04-10 13:44:46 -07:00
|
|
|
START_API_FUNC
|
2013-11-28 01:53:05 -08:00
|
|
|
{
|
|
|
|
if(values)
|
|
|
|
{
|
|
|
|
switch(pname)
|
|
|
|
{
|
2018-01-24 18:30:32 -08:00
|
|
|
case AL_EVENT_CALLBACK_FUNCTION_SOFT:
|
|
|
|
case AL_EVENT_CALLBACK_USER_PARAM_SOFT:
|
|
|
|
values[0] = alGetPointerSOFT(pname);
|
2013-11-28 01:53:05 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-16 06:45:24 -08:00
|
|
|
ContextRef context{GetContextRef()};
|
2019-08-04 11:59:14 -07:00
|
|
|
if UNLIKELY(!context) return;
|
2013-11-28 01:53:05 -08:00
|
|
|
|
2018-01-24 17:07:01 -08:00
|
|
|
if(!values)
|
2019-07-30 21:32:05 -07:00
|
|
|
context->setError(AL_INVALID_VALUE, "NULL pointer");
|
2018-11-16 06:45:24 -08:00
|
|
|
else switch(pname)
|
2013-11-28 01:53:05 -08:00
|
|
|
{
|
|
|
|
default:
|
2019-07-30 21:32:05 -07:00
|
|
|
context->setError(AL_INVALID_VALUE, "Invalid pointer-vector property 0x%04x", pname);
|
2013-11-28 01:53:05 -08:00
|
|
|
}
|
|
|
|
}
|
2019-04-10 13:44:46 -07:00
|
|
|
END_API_FUNC
|
2013-11-28 01:53:05 -08:00
|
|
|
|
2010-03-19 14:34:18 -07:00
|
|
|
AL_API const ALchar* AL_APIENTRY alGetString(ALenum pname)
|
2019-04-10 13:44:46 -07:00
|
|
|
START_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2018-11-16 06:45:24 -08:00
|
|
|
ContextRef context{GetContextRef()};
|
2019-08-04 11:59:14 -07:00
|
|
|
if UNLIKELY(!context) return nullptr;
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2018-11-16 06:45:24 -08:00
|
|
|
const ALchar *value{nullptr};
|
2013-10-07 08:50:17 -07:00
|
|
|
switch(pname)
|
2012-04-24 02:51:57 -07:00
|
|
|
{
|
2013-10-07 08:50:17 -07:00
|
|
|
case AL_VENDOR:
|
|
|
|
value = alVendor;
|
|
|
|
break;
|
2012-04-24 02:51:57 -07:00
|
|
|
|
2013-10-07 08:50:17 -07:00
|
|
|
case AL_VERSION:
|
|
|
|
value = alVersion;
|
|
|
|
break;
|
2012-04-24 02:51:57 -07:00
|
|
|
|
2013-10-07 08:50:17 -07:00
|
|
|
case AL_RENDERER:
|
|
|
|
value = alRenderer;
|
|
|
|
break;
|
2012-04-24 02:51:57 -07:00
|
|
|
|
2013-10-07 08:50:17 -07:00
|
|
|
case AL_EXTENSIONS:
|
2019-07-30 09:05:54 -07:00
|
|
|
value = context->mExtensionList;
|
2013-10-07 08:50:17 -07:00
|
|
|
break;
|
2012-04-24 02:51:57 -07:00
|
|
|
|
2013-10-07 08:50:17 -07:00
|
|
|
case AL_NO_ERROR:
|
|
|
|
value = alNoError;
|
|
|
|
break;
|
2012-04-24 02:51:57 -07:00
|
|
|
|
2013-10-07 08:50:17 -07:00
|
|
|
case AL_INVALID_NAME:
|
|
|
|
value = alErrInvalidName;
|
|
|
|
break;
|
2012-04-24 02:51:57 -07:00
|
|
|
|
2013-10-07 08:50:17 -07:00
|
|
|
case AL_INVALID_ENUM:
|
|
|
|
value = alErrInvalidEnum;
|
|
|
|
break;
|
2012-04-24 02:51:57 -07:00
|
|
|
|
2013-10-07 08:50:17 -07:00
|
|
|
case AL_INVALID_VALUE:
|
|
|
|
value = alErrInvalidValue;
|
|
|
|
break;
|
2012-04-24 02:51:57 -07:00
|
|
|
|
2013-10-07 08:50:17 -07:00
|
|
|
case AL_INVALID_OPERATION:
|
|
|
|
value = alErrInvalidOp;
|
|
|
|
break;
|
2012-04-24 02:51:57 -07:00
|
|
|
|
2013-10-07 08:50:17 -07:00
|
|
|
case AL_OUT_OF_MEMORY:
|
|
|
|
value = alErrOutOfMemory;
|
|
|
|
break;
|
2012-04-24 02:51:57 -07:00
|
|
|
|
2013-10-07 08:50:17 -07:00
|
|
|
default:
|
2019-07-30 21:32:05 -07:00
|
|
|
context->setError(AL_INVALID_VALUE, "Invalid string property 0x%04x", pname);
|
2012-04-24 02:51:57 -07:00
|
|
|
}
|
2007-11-13 18:02:18 -08:00
|
|
|
return value;
|
|
|
|
}
|
2019-04-10 13:44:46 -07:00
|
|
|
END_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2010-03-19 14:34:18 -07:00
|
|
|
AL_API ALvoid AL_APIENTRY alDopplerFactor(ALfloat value)
|
2019-04-10 13:44:46 -07:00
|
|
|
START_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2018-11-16 06:45:24 -08:00
|
|
|
ContextRef context{GetContextRef()};
|
2019-08-04 11:59:14 -07:00
|
|
|
if UNLIKELY(!context) return;
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2018-11-19 09:51:29 -08:00
|
|
|
if(!(value >= 0.0f && std::isfinite(value)))
|
2019-07-30 21:32:05 -07:00
|
|
|
context->setError(AL_INVALID_VALUE, "Doppler factor %f out of range", value);
|
2018-01-25 15:59:59 -08:00
|
|
|
else
|
|
|
|
{
|
2019-07-30 09:05:54 -07:00
|
|
|
std::lock_guard<std::mutex> _{context->mPropLock};
|
|
|
|
context->mDopplerFactor = value;
|
2018-01-25 15:59:59 -08:00
|
|
|
DO_UPDATEPROPS();
|
|
|
|
}
|
2007-11-13 18:02:18 -08:00
|
|
|
}
|
2019-04-10 13:44:46 -07:00
|
|
|
END_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2010-03-19 14:34:18 -07:00
|
|
|
AL_API ALvoid AL_APIENTRY alDopplerVelocity(ALfloat value)
|
2019-04-10 13:44:46 -07:00
|
|
|
START_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2018-11-16 06:45:24 -08:00
|
|
|
ContextRef context{GetContextRef()};
|
2019-08-04 11:59:14 -07:00
|
|
|
if UNLIKELY(!context) return;
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2019-07-30 09:05:54 -07:00
|
|
|
if((context->mEnabledEvts.load(std::memory_order_relaxed)&EventType_Deprecated))
|
2018-01-24 18:42:00 -08:00
|
|
|
{
|
2019-07-30 09:05:54 -07:00
|
|
|
std::lock_guard<std::mutex> _{context->mEventCbLock};
|
|
|
|
ALbitfieldSOFT enabledevts{context->mEnabledEvts.load(std::memory_order_relaxed)};
|
|
|
|
if((enabledevts&EventType_Deprecated) && context->mEventCb)
|
2019-09-12 06:29:32 -07:00
|
|
|
{
|
|
|
|
static constexpr ALCchar msg[] =
|
|
|
|
"alDopplerVelocity is deprecated in AL1.1, use alSpeedOfSound";
|
|
|
|
const ALsizei msglen{sizeof(msg)-1};
|
2019-07-30 09:05:54 -07:00
|
|
|
(*context->mEventCb)(AL_EVENT_TYPE_DEPRECATED_SOFT, 0, 0, msglen, msg,
|
2019-09-12 06:29:32 -07:00
|
|
|
context->mEventParam);
|
|
|
|
}
|
2018-01-24 18:42:00 -08:00
|
|
|
}
|
|
|
|
|
2018-11-19 09:51:29 -08:00
|
|
|
if(!(value >= 0.0f && std::isfinite(value)))
|
2019-07-30 21:32:05 -07:00
|
|
|
context->setError(AL_INVALID_VALUE, "Doppler velocity %f out of range", value);
|
2018-01-25 15:59:59 -08:00
|
|
|
else
|
|
|
|
{
|
2019-07-30 09:05:54 -07:00
|
|
|
std::lock_guard<std::mutex> _{context->mPropLock};
|
|
|
|
context->mDopplerVelocity = value;
|
2018-01-25 15:59:59 -08:00
|
|
|
DO_UPDATEPROPS();
|
|
|
|
}
|
2007-11-13 18:02:18 -08:00
|
|
|
}
|
2019-04-10 13:44:46 -07:00
|
|
|
END_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2012-04-19 22:50:11 -07:00
|
|
|
AL_API ALvoid AL_APIENTRY alSpeedOfSound(ALfloat value)
|
2019-04-10 13:44:46 -07:00
|
|
|
START_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2018-11-16 06:45:24 -08:00
|
|
|
ContextRef context{GetContextRef()};
|
2019-08-04 11:59:14 -07:00
|
|
|
if UNLIKELY(!context) return;
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2018-11-19 09:51:29 -08:00
|
|
|
if(!(value > 0.0f && std::isfinite(value)))
|
2019-07-30 21:32:05 -07:00
|
|
|
context->setError(AL_INVALID_VALUE, "Speed of sound %f out of range", value);
|
2018-01-25 15:59:59 -08:00
|
|
|
else
|
|
|
|
{
|
2019-07-30 09:05:54 -07:00
|
|
|
std::lock_guard<std::mutex> _{context->mPropLock};
|
|
|
|
context->mSpeedOfSound = value;
|
2018-01-25 15:59:59 -08:00
|
|
|
DO_UPDATEPROPS();
|
|
|
|
}
|
2007-11-13 18:02:18 -08:00
|
|
|
}
|
2019-04-10 13:44:46 -07:00
|
|
|
END_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2010-03-19 14:34:18 -07:00
|
|
|
AL_API ALvoid AL_APIENTRY alDistanceModel(ALenum value)
|
2019-04-10 13:44:46 -07:00
|
|
|
START_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2018-11-16 06:45:24 -08:00
|
|
|
ContextRef context{GetContextRef()};
|
2019-08-04 11:59:14 -07:00
|
|
|
if UNLIKELY(!context) return;
|
2009-08-16 15:09:36 -07:00
|
|
|
|
2013-10-07 08:50:17 -07:00
|
|
|
if(!(value == AL_INVERSE_DISTANCE || value == AL_INVERSE_DISTANCE_CLAMPED ||
|
|
|
|
value == AL_LINEAR_DISTANCE || value == AL_LINEAR_DISTANCE_CLAMPED ||
|
|
|
|
value == AL_EXPONENT_DISTANCE || value == AL_EXPONENT_DISTANCE_CLAMPED ||
|
|
|
|
value == AL_NONE))
|
2019-07-30 21:32:05 -07:00
|
|
|
context->setError(AL_INVALID_VALUE, "Distance model 0x%04x out of range", value);
|
2018-01-25 15:59:59 -08:00
|
|
|
else
|
|
|
|
{
|
2019-07-30 09:05:54 -07:00
|
|
|
std::lock_guard<std::mutex> _{context->mPropLock};
|
2018-11-18 03:39:32 -08:00
|
|
|
context->mDistanceModel = static_cast<DistanceModel>(value);
|
2019-07-30 09:05:54 -07:00
|
|
|
if(!context->mSourceDistanceModel)
|
2018-01-25 15:59:59 -08:00
|
|
|
DO_UPDATEPROPS();
|
|
|
|
}
|
2007-11-13 18:02:18 -08:00
|
|
|
}
|
2019-04-10 13:44:46 -07:00
|
|
|
END_API_FUNC
|
2011-07-16 16:59:20 -07:00
|
|
|
|
|
|
|
|
|
|
|
AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void)
|
2019-04-10 13:44:46 -07:00
|
|
|
START_API_FUNC
|
2011-07-16 16:59:20 -07:00
|
|
|
{
|
2018-11-16 06:45:24 -08:00
|
|
|
ContextRef context{GetContextRef()};
|
2019-08-04 11:59:14 -07:00
|
|
|
if UNLIKELY(!context) return;
|
2011-07-16 16:59:20 -07:00
|
|
|
|
2019-07-30 14:13:05 -07:00
|
|
|
context->deferUpdates();
|
2011-07-16 16:59:20 -07:00
|
|
|
}
|
2019-04-10 13:44:46 -07:00
|
|
|
END_API_FUNC
|
2011-07-16 16:59:20 -07:00
|
|
|
|
|
|
|
AL_API ALvoid AL_APIENTRY alProcessUpdatesSOFT(void)
|
2019-04-10 13:44:46 -07:00
|
|
|
START_API_FUNC
|
2011-07-16 16:59:20 -07:00
|
|
|
{
|
2018-11-16 06:45:24 -08:00
|
|
|
ContextRef context{GetContextRef()};
|
2019-08-04 11:59:14 -07:00
|
|
|
if UNLIKELY(!context) return;
|
2011-07-16 16:59:20 -07:00
|
|
|
|
2019-07-30 14:13:05 -07:00
|
|
|
context->processUpdates();
|
2011-07-16 16:59:20 -07:00
|
|
|
}
|
2019-04-10 13:44:46 -07:00
|
|
|
END_API_FUNC
|
2017-04-21 04:15:08 -07:00
|
|
|
|
|
|
|
|
|
|
|
AL_API const ALchar* AL_APIENTRY alGetStringiSOFT(ALenum pname, ALsizei index)
|
2019-04-10 13:44:46 -07:00
|
|
|
START_API_FUNC
|
2017-04-21 04:15:08 -07:00
|
|
|
{
|
|
|
|
const char *ResamplerNames[] = {
|
|
|
|
alPointResampler, alLinearResampler,
|
2018-01-07 05:32:07 -08:00
|
|
|
alCubicResampler, alBSinc12Resampler,
|
2017-08-27 10:16:36 -07:00
|
|
|
alBSinc24Resampler,
|
2017-04-21 04:15:08 -07:00
|
|
|
};
|
2019-05-26 21:28:51 -07:00
|
|
|
static_assert(al::size(ResamplerNames) == ResamplerMax+1, "Incorrect ResamplerNames list");
|
2017-04-21 04:15:08 -07:00
|
|
|
|
2018-11-16 06:45:24 -08:00
|
|
|
ContextRef context{GetContextRef()};
|
2019-08-04 11:59:14 -07:00
|
|
|
if UNLIKELY(!context) return nullptr;
|
2017-04-21 04:15:08 -07:00
|
|
|
|
2018-11-16 06:45:24 -08:00
|
|
|
const ALchar *value{nullptr};
|
2017-04-21 04:15:08 -07:00
|
|
|
switch(pname)
|
|
|
|
{
|
|
|
|
case AL_RESAMPLER_NAME_SOFT:
|
2019-05-26 21:28:51 -07:00
|
|
|
if(index < 0 || static_cast<size_t>(index) >= al::size(ResamplerNames))
|
2019-07-30 21:32:05 -07:00
|
|
|
context->setError(AL_INVALID_VALUE, "Resampler name index %d out of range", index);
|
2018-11-16 06:45:24 -08:00
|
|
|
else
|
|
|
|
value = ResamplerNames[index];
|
2017-04-21 04:15:08 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2019-07-30 21:32:05 -07:00
|
|
|
context->setError(AL_INVALID_VALUE, "Invalid string indexed property");
|
2017-04-21 04:15:08 -07:00
|
|
|
}
|
|
|
|
return value;
|
|
|
|
}
|
2019-04-10 13:44:46 -07:00
|
|
|
END_API_FUNC
|
2017-09-27 08:55:42 -07:00
|
|
|
|
|
|
|
|
|
|
|
void UpdateContextProps(ALCcontext *context)
|
|
|
|
{
|
|
|
|
/* Get an unused proprty container, or allocate a new one as needed. */
|
2019-07-30 09:05:54 -07:00
|
|
|
ALcontextProps *props{context->mFreeContextProps.load(std::memory_order_acquire)};
|
2017-09-27 08:55:42 -07:00
|
|
|
if(!props)
|
2019-08-13 22:25:59 -07:00
|
|
|
props = new ALcontextProps{};
|
2017-09-27 08:55:42 -07:00
|
|
|
else
|
|
|
|
{
|
2018-12-24 19:29:01 -08:00
|
|
|
ALcontextProps *next;
|
2017-09-27 08:55:42 -07:00
|
|
|
do {
|
2018-11-19 03:21:58 -08:00
|
|
|
next = props->next.load(std::memory_order_relaxed);
|
2019-07-30 09:05:54 -07:00
|
|
|
} while(context->mFreeContextProps.compare_exchange_weak(props, next,
|
2018-11-19 03:21:58 -08:00
|
|
|
std::memory_order_seq_cst, std::memory_order_acquire) == 0);
|
2017-09-27 08:55:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy in current property values. */
|
2019-07-30 09:05:54 -07:00
|
|
|
props->DopplerFactor = context->mDopplerFactor;
|
|
|
|
props->DopplerVelocity = context->mDopplerVelocity;
|
|
|
|
props->SpeedOfSound = context->mSpeedOfSound;
|
2017-09-27 08:55:42 -07:00
|
|
|
|
2019-07-30 09:05:54 -07:00
|
|
|
props->SourceDistanceModel = context->mSourceDistanceModel;
|
2018-11-18 03:39:32 -08:00
|
|
|
props->mDistanceModel = context->mDistanceModel;
|
2017-09-27 08:55:42 -07:00
|
|
|
|
|
|
|
/* Set the new container for updating internal parameters. */
|
2019-07-30 09:05:54 -07:00
|
|
|
props = context->mUpdate.exchange(props, std::memory_order_acq_rel);
|
2017-09-27 08:55:42 -07:00
|
|
|
if(props)
|
|
|
|
{
|
|
|
|
/* If there was an unused update container, put it back in the
|
|
|
|
* freelist.
|
|
|
|
*/
|
2019-07-30 09:05:54 -07:00
|
|
|
AtomicReplaceHead(context->mFreeContextProps, props);
|
2017-09-27 08:55:42 -07:00
|
|
|
}
|
|
|
|
}
|