diff options
author | Chris Robinson <[email protected]> | 2010-08-03 23:10:00 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2010-08-03 23:10:00 -0700 |
commit | e74976e6451670c433ee09695125801c12e74e22 (patch) | |
tree | 227434c3dd5e975ada8f4318bd0d05f953f40de8 /OpenAL32 | |
parent | 91278608c5d342a9c4322bd6296d0eba9eb3af4c (diff) |
Use a callback to specify the source update method
Diffstat (limited to 'OpenAL32')
-rw-r--r-- | OpenAL32/Include/alSource.h | 2 | ||||
-rw-r--r-- | OpenAL32/Include/alu.h | 6 | ||||
-rw-r--r-- | OpenAL32/alSource.c | 16 |
3 files changed, 18 insertions, 6 deletions
diff --git a/OpenAL32/Include/alSource.h b/OpenAL32/Include/alSource.h index 0802cbaa..97ecbecf 100644 --- a/OpenAL32/Include/alSource.h +++ b/OpenAL32/Include/alSource.h @@ -101,10 +101,12 @@ typedef struct ALsource FILTER iirFilter; ALfloat history[OUTPUTCHANNELS*2]; } Params; + ALvoid (*Update)(struct ALsource *self, const ALCcontext *context); // Index to itself ALuint source; } ALsource; +#define ALsource_Update(s,a) ((s)->Update(s,a)) ALvoid ReleaseALSources(ALCcontext *Context); diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h index 55ddbaf6..bd28771f 100644 --- a/OpenAL32/Include/alu.h +++ b/OpenAL32/Include/alu.h @@ -177,7 +177,13 @@ static __inline ALint aluCart2LUTpos(ALfloat re, ALfloat im) return pos%LUT_NUM; } +struct ALsource; + ALvoid aluInitPanning(ALCdevice *Device); + +ALvoid CalcSourceParams(struct ALsource *ALSource, const ALCcontext *ALContext); +ALvoid CalcNonAttnSourceParams(struct ALsource *ALSource, const ALCcontext *ALContext); + ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size); ALvoid aluHandleDisconnect(ALCdevice *device); diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c index 6e5ed1e6..0db6f76b 100644 --- a/OpenAL32/alSource.c +++ b/OpenAL32/alSource.c @@ -574,6 +574,11 @@ AL_API ALvoid AL_APIENTRY alSourcei(ALuint source,ALenum eParam,ALint lValue) Source->queue = BufferListItem; Source->BuffersInQueue = 1; + if(aluChannelsFromFormat(buffer->format) == 1) + Source->Update = CalcSourceParams; + else + Source->Update = CalcNonAttnSourceParams; + // Increment reference counter for buffer buffer->refcount++; } @@ -1560,7 +1565,6 @@ AL_API ALvoid AL_APIENTRY alSourceQueueBuffers(ALuint source, ALsizei n, const A ALsizei i; ALbufferlistitem *BufferListStart; ALbufferlistitem *BufferList; - ALboolean HadFormat; ALint Frequency; ALint Format; @@ -1591,7 +1595,6 @@ AL_API ALvoid AL_APIENTRY alSourceQueueBuffers(ALuint source, ALsizei n, const A Frequency = -1; Format = -1; - HadFormat = AL_FALSE; // Check existing Queue (if any) for a valid Buffers and get its frequency and format BufferList = Source->queue; @@ -1601,7 +1604,6 @@ AL_API ALvoid AL_APIENTRY alSourceQueueBuffers(ALuint source, ALsizei n, const A { Frequency = BufferList->buffer->frequency; Format = BufferList->buffer->eOriginalFormat; - HadFormat = AL_TRUE; break; } BufferList = BufferList->next; @@ -1622,6 +1624,11 @@ AL_API ALvoid AL_APIENTRY alSourceQueueBuffers(ALuint source, ALsizei n, const A { Frequency = buffer->frequency; Format = buffer->eOriginalFormat; + if(aluChannelsFromFormat(buffer->format) == 1) + Source->Update = CalcSourceParams; + else + Source->Update = CalcNonAttnSourceParams; + Source->NeedsUpdate = AL_TRUE; } else if(Frequency != buffer->frequency || Format != buffer->eOriginalFormat) { @@ -1677,9 +1684,6 @@ AL_API ALvoid AL_APIENTRY alSourceQueueBuffers(ALuint source, ALsizei n, const A // Update number of buffers in queue Source->BuffersInQueue += n; - // If no previous format, mark the source dirty now that it may have one - if(!HadFormat) - Source->NeedsUpdate = AL_TRUE; done: ProcessContext(Context); |