Allow dedicated CPU time for high priority sources
parent
5616a5e90d
commit
81eb51319d
|
@ -1193,6 +1193,7 @@ static ALvoid InitContext(ALCcontext *pContext)
|
|||
pContext->DopplerFactor = int2ALfp(1);
|
||||
pContext->DopplerVelocity = int2ALfp(1);
|
||||
pContext->flSpeedOfSound = float2ALfp(SPEEDOFSOUNDMETRESPERSEC);
|
||||
pContext->PrioritySlots = 0;
|
||||
|
||||
pContext->ExtensionList = alExtList;
|
||||
}
|
||||
|
|
|
@ -449,6 +449,9 @@ struct ALCcontext_struct
|
|||
ALsizei ActiveSourceCount;
|
||||
ALsizei MaxActiveSources;
|
||||
|
||||
// Apportable Extension
|
||||
ALsizei PrioritySlots;
|
||||
|
||||
ALCdevice *Device;
|
||||
const ALCchar *ExtensionList;
|
||||
|
||||
|
|
|
@ -52,6 +52,9 @@ typedef struct ALsource
|
|||
ALboolean bLooping;
|
||||
ALenum DistanceModel;
|
||||
|
||||
// Apportably Extension
|
||||
ALuint priority;
|
||||
|
||||
resampler_t Resampler;
|
||||
|
||||
ALenum state;
|
||||
|
|
|
@ -176,6 +176,10 @@ static const ALenums enumeration[] = {
|
|||
{ "AL_EXPONENT_DISTANCE", AL_EXPONENT_DISTANCE },
|
||||
{ "AL_EXPONENT_DISTANCE_CLAMPED", AL_EXPONENT_DISTANCE_CLAMPED },
|
||||
|
||||
// Apportable Extensions
|
||||
{ "AL_PRIORITY", AL_PRIORITY },
|
||||
{ "AL_PRIORITY_SLOTS", AL_PRIORITY_SLOTS },
|
||||
|
||||
// Filter types
|
||||
{ "AL_FILTER_TYPE", AL_FILTER_TYPE },
|
||||
{ "AL_FILTER_NULL", AL_FILTER_NULL },
|
||||
|
|
|
@ -193,6 +193,10 @@ AL_API ALvoid AL_APIENTRY alListeneri(ALenum eParam, ALint lValue)
|
|||
|
||||
switch(eParam)
|
||||
{
|
||||
case AL_PRIORITY_SLOTS:
|
||||
pContext->PrioritySlots = (ALsizei)lValue;
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(pContext, AL_INVALID_ENUM);
|
||||
break;
|
||||
|
@ -397,6 +401,10 @@ AL_API ALvoid AL_APIENTRY alGetListeneri(ALenum eParam, ALint *plValue)
|
|||
{
|
||||
switch(eParam)
|
||||
{
|
||||
case AL_PRIORITY_SLOTS:
|
||||
*plValue = (ALint)pContext->PrioritySlots;
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(pContext, AL_INVALID_ENUM);
|
||||
break;
|
||||
|
|
|
@ -695,6 +695,10 @@ AL_API ALvoid AL_APIENTRY alSourcei(ALuint source,ALenum eParam,ALint lValue)
|
|||
alSetError(pContext, AL_INVALID_VALUE);
|
||||
break;
|
||||
|
||||
case AL_PRIORITY:
|
||||
Source->priority = lValue;
|
||||
break;
|
||||
|
||||
default:
|
||||
alSetError(pContext, AL_INVALID_ENUM);
|
||||
break;
|
||||
|
@ -1307,17 +1311,6 @@ AL_API ALvoid AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef MAX_SOURCES_LOW
|
||||
// Apportable: Cap the number of active source that are playing
|
||||
if (Context->ActiveSourceCount + n > alc_max_sources) {
|
||||
LOGV("Skipping starting some sources due to lack of CPU time");
|
||||
if (Context->ActiveSourceCount > alc_max_sources) {
|
||||
n = 0;
|
||||
} else {
|
||||
n = alc_max_sources - Context->ActiveSourceCount;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
while(Context->MaxActiveSources-Context->ActiveSourceCount < n)
|
||||
{
|
||||
|
@ -1338,16 +1331,18 @@ AL_API ALvoid AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources)
|
|||
Context->MaxActiveSources = newcount;
|
||||
}
|
||||
|
||||
#ifdef MAX_SOURCES_LOW
|
||||
//Apportable Need to give the ALC platform code a hint for setting Source limit based on performance
|
||||
// LOGI("Playing %d/%d ActiveSources", Context->ActiveSourceCount, alc_max_sources);
|
||||
alc_active_sources = Context->ActiveSourceCount;
|
||||
#endif
|
||||
|
||||
for(i = 0;i < n;i++)
|
||||
{
|
||||
Source = (ALsource*)ALTHUNK_LOOKUPENTRY(sources[i]);
|
||||
|
||||
#ifdef MAX_SOURCES_LOW
|
||||
if (Context->ActiveSourceCount >= (alc_max_sources - Context->PrioritySlots) && Source->priority < 127) {
|
||||
LOGV("Skipping starting source %d due to lack of CPU time.", sources[i]);
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Check that there is a queue containing at least one non-null, non zero length AL Buffer
|
||||
BufferList = Source->queue;
|
||||
while(BufferList)
|
||||
|
@ -1403,6 +1398,11 @@ AL_API ALvoid AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef MAX_SOURCES_LOW
|
||||
//Apportable Need to give the ALC platform code a hint for setting Source limit based on performance
|
||||
alc_active_sources = Context->ActiveSourceCount;
|
||||
#endif
|
||||
|
||||
done:
|
||||
ProcessContext(Context);
|
||||
}
|
||||
|
@ -1813,6 +1813,7 @@ static ALvoid InitSourceParams(ALsource *Source)
|
|||
Source->NeedsUpdate = AL_TRUE;
|
||||
|
||||
Source->Buffer = NULL;
|
||||
Source->priority = 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -360,6 +360,17 @@ typedef void ALvoid;
|
|||
#define AL_EXPONENT_DISTANCE 0xD005
|
||||
#define AL_EXPONENT_DISTANCE_CLAMPED 0xD006
|
||||
|
||||
|
||||
/**
|
||||
* Priority
|
||||
*
|
||||
* Apportable Extension.
|
||||
* Used to prevent dynamic throttling of this source
|
||||
*
|
||||
*/
|
||||
#define AL_PRIORITY 0xE001
|
||||
#define AL_PRIORITY_SLOTS 0xE002
|
||||
|
||||
/*
|
||||
* Renderer State management
|
||||
*/
|
||||
|
|
|
@ -452,6 +452,15 @@ typedef void ALvoid;
|
|||
#define AL_EXPONENT_DISTANCE 0xD005
|
||||
#define AL_EXPONENT_DISTANCE_CLAMPED 0xD006
|
||||
|
||||
/**
|
||||
* Priority
|
||||
*
|
||||
* Apportable Extension.
|
||||
* Used to prevent dynamic throttling of this source.
|
||||
*
|
||||
*/
|
||||
#define AL_PRIORITY 0xE001
|
||||
#define AL_PRIORITY_SLOTS 0xE002
|
||||
/*
|
||||
* Renderer State management
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue