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]; FILTER *DryFilter, *WetFilter[MAX_SENDS];
ALfloat WetSend[MAX_SENDS]; ALfloat WetSend[MAX_SENDS];
ALuint rampLength; ALuint rampLength;
ALuint frequency; ALuint DeviceFreq;
ALint increment; ALint increment;
ALuint DataPosInt, DataPosFrac; ALuint DataPosInt, DataPosFrac;
ALuint Channels, Bytes; ALuint Channels, Bytes;
ALuint Frequency;
ALuint BuffersPlayed; ALuint BuffersPlayed;
ALfloat Pitch; ALfloat Pitch;
ALenum State; ALenum State;
@ -843,9 +844,9 @@ static void MixSomeSources(ALCcontext *ALContext, float (*DryBuffer)[OUTPUTCHANN
if(!(ALSource=ALContext->Source)) if(!(ALSource=ALContext->Source))
return; 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); rampLength = max(rampLength, SamplesToDo);
another_source: another_source:
@ -858,18 +859,33 @@ another_source:
} }
j = 0; 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 */ /* Get source info */
BuffersPlayed = ALSource->BuffersPlayed; BuffersPlayed = ALSource->BuffersPlayed;
DataPosInt = ALSource->position; DataPosInt = ALSource->position;
DataPosFrac = ALSource->position_fraction; DataPosFrac = ALSource->position_fraction;
Channels = aluChannelsFromFormat(ALSource->Format);
Bytes = aluBytesFromFormat(ALSource->Format);
CalcSourceParams(ALContext, ALSource, (Channels==1)?AL_TRUE:AL_FALSE); CalcSourceParams(ALContext, ALSource, (Channels==1)?AL_TRUE:AL_FALSE);
/* Compute 18.14 fixed point step */ /* 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; if(Pitch > (float)MAX_PITCH) Pitch = (float)MAX_PITCH;
increment = (ALint)(Pitch*(ALfloat)(1L<<FRACTIONBITS)); increment = (ALint)(Pitch*(ALfloat)(1L<<FRACTIONBITS));
if(increment <= 0) increment = (1<<FRACTIONBITS); if(increment <= 0) increment = (1<<FRACTIONBITS);
@ -914,6 +930,7 @@ another_source:
Matrix[FRONT_RIGHT][BACK_RIGHT] = 0.0f; Matrix[FRONT_RIGHT][BACK_RIGHT] = 0.0f;
} }
/* Get current buffer queue item */
BufferListItem = ALSource->queue; BufferListItem = ALSource->queue;
for(i = 0;i < BuffersPlayed && BufferListItem;i++) for(i = 0;i < BuffersPlayed && BufferListItem;i++)
BufferListItem = BufferListItem->next; BufferListItem = BufferListItem->next;

View File

@ -52,8 +52,6 @@ typedef struct ALsource
ALuint position_fraction; ALuint position_fraction;
struct ALbuffer *Buffer; struct ALbuffer *Buffer;
ALenum Format;
ALuint Frequency;
struct ALbufferlistitem *queue; // Linked list of buffers in queue struct ALbufferlistitem *queue; // Linked list of buffers in queue
ALuint BuffersInQueue; // Number 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 // Source is now in STATIC mode
pSource->lSourceType = AL_STATIC; pSource->lSourceType = AL_STATIC;
pSource->Format = buffer->format;
pSource->Frequency = buffer->frequency;
// Add the selected buffer to the queue // Add the selected buffer to the queue
pALBufferListItem = malloc(sizeof(ALbufferlistitem)); pALBufferListItem = malloc(sizeof(ALbufferlistitem));
pALBufferListItem->buffer = buffer; pALBufferListItem->buffer = buffer;
@ -1589,9 +1586,6 @@ ALAPI ALvoid ALAPIENTRY alSourceQueueBuffers( ALuint source, ALsizei n, const AL
// Change Source Type // Change Source Type
ALSource->lSourceType = AL_STREAMING; ALSource->lSourceType = AL_STREAMING;
ALSource->Format = iFormat;
ALSource->Frequency = iFrequency;
if(buffers[0]) if(buffers[0])
buffer = (ALbuffer*)ALTHUNK_LOOKUPENTRY(buffers[0]); buffer = (ALbuffer*)ALTHUNK_LOOKUPENTRY(buffers[0]);