summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/ALu.c31
-rw-r--r--OpenAL32/Include/alSource.h2
-rw-r--r--OpenAL32/alSource.c6
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<<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;
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]);