Remove the format and frequency from the source, get them manually

This commit is contained in:
Chris Robinson 2009-10-25 06:26:19 -07:00
parent e095047b02
commit fe3a43e2d4
3 changed files with 24 additions and 15 deletions

View File

@ -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;

View File

@ -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

View File

@ -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]);