aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2009-10-25 06:26:19 -0700
committerChris Robinson <[email protected]>2009-10-25 06:26:19 -0700
commitfe3a43e2d4bbc20cea32a2046404d8eabe9240ee (patch)
tree87414f1b75873a0811f8f7eeb299eaafcf1847ef /Alc
parente095047b0253d5503b5e243c8e18279e3c9b3af2 (diff)
Remove the format and frequency from the source, get them manually
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALu.c31
1 files changed, 24 insertions, 7 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<<FRACTIONBITS));
if(increment <= 0) increment = (1<<FRACTIONBITS);
@@ -914,6 +930,7 @@ another_source:
Matrix[FRONT_RIGHT][BACK_RIGHT] = 0.0f;
}
+ /* Get current buffer queue item */
BufferListItem = ALSource->queue;
for(i = 0;i < BuffersPlayed && BufferListItem;i++)
BufferListItem = BufferListItem->next;