From fe3a43e2d4bbc20cea32a2046404d8eabe9240ee Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 25 Oct 2009 06:26:19 -0700 Subject: [PATCH] Remove the format and frequency from the source, get them manually --- Alc/ALu.c | 31 ++++++++++++++++++++++++------- OpenAL32/Include/alSource.h | 2 -- OpenAL32/alSource.c | 6 ------ 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/Alc/ALu.c b/Alc/ALu.c index d1ff8dec..a782ac16 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -832,10 +832,11 @@ static void MixSomeSources(ALCcontext *ALContext, float (*DryBuffer)[OUTPUTCHANN FILTER *DryFilter, *WetFilter[MAX_SENDS]; ALfloat WetSend[MAX_SENDS]; ALuint rampLength; - ALuint frequency; + ALuint DeviceFreq; ALint increment; ALuint DataPosInt, DataPosFrac; ALuint Channels, Bytes; + ALuint Frequency; ALuint BuffersPlayed; ALfloat Pitch; ALenum State; @@ -843,9 +844,9 @@ static void MixSomeSources(ALCcontext *ALContext, float (*DryBuffer)[OUTPUTCHANN if(!(ALSource=ALContext->Source)) return; - frequency = ALContext->Device->Frequency; + DeviceFreq = ALContext->Device->Frequency; - rampLength = frequency * MIN_RAMP_LENGTH / 1000; + rampLength = DeviceFreq * MIN_RAMP_LENGTH / 1000; rampLength = max(rampLength, SamplesToDo); another_source: @@ -858,18 +859,33 @@ another_source: } j = 0; + /* Find buffer format */ + Frequency = 0; + Channels = 0; + Bytes = 0; + BufferListItem = ALSource->queue; + while(BufferListItem != NULL) + { + ALbuffer *ALBuffer; + if((ALBuffer=BufferListItem->buffer) != NULL) + { + Channels = aluChannelsFromFormat(ALBuffer->format); + Bytes = aluBytesFromFormat(ALBuffer->format); + Frequency = ALBuffer->frequency; + break; + } + BufferListItem = BufferListItem->next; + } + /* Get source info */ BuffersPlayed = ALSource->BuffersPlayed; DataPosInt = ALSource->position; DataPosFrac = ALSource->position_fraction; - Channels = aluChannelsFromFormat(ALSource->Format); - Bytes = aluBytesFromFormat(ALSource->Format); - CalcSourceParams(ALContext, ALSource, (Channels==1)?AL_TRUE:AL_FALSE); /* Compute 18.14 fixed point step */ - Pitch = (ALSource->Params.Pitch*ALSource->Frequency) / frequency; + Pitch = (ALSource->Params.Pitch*Frequency) / DeviceFreq; if(Pitch > (float)MAX_PITCH) Pitch = (float)MAX_PITCH; increment = (ALint)(Pitch*(ALfloat)(1L<queue; for(i = 0;i < BuffersPlayed && BufferListItem;i++) BufferListItem = BufferListItem->next; diff --git a/OpenAL32/Include/alSource.h b/OpenAL32/Include/alSource.h index 7f18eee3..663a9e35 100644 --- a/OpenAL32/Include/alSource.h +++ b/OpenAL32/Include/alSource.h @@ -52,8 +52,6 @@ typedef struct ALsource ALuint position_fraction; struct ALbuffer *Buffer; - ALenum Format; - ALuint Frequency; struct ALbufferlistitem *queue; // Linked list of buffers in queue ALuint BuffersInQueue; // Number of buffers in queue diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c index 85b9c966..b606d9fd 100644 --- a/OpenAL32/alSource.c +++ b/OpenAL32/alSource.c @@ -535,9 +535,6 @@ ALAPI ALvoid ALAPIENTRY alSourcei(ALuint source,ALenum eParam,ALint lValue) // Source is now in STATIC mode pSource->lSourceType = AL_STATIC; - pSource->Format = buffer->format; - pSource->Frequency = buffer->frequency; - // Add the selected buffer to the queue pALBufferListItem = malloc(sizeof(ALbufferlistitem)); pALBufferListItem->buffer = buffer; @@ -1589,9 +1586,6 @@ ALAPI ALvoid ALAPIENTRY alSourceQueueBuffers( ALuint source, ALsizei n, const AL // Change Source Type ALSource->lSourceType = AL_STREAMING; - ALSource->Format = iFormat; - ALSource->Frequency = iFrequency; - if(buffers[0]) buffer = (ALbuffer*)ALTHUNK_LOOKUPENTRY(buffers[0]); -- 2.11.4.GIT