aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/ALu.c71
-rw-r--r--OpenAL32/Include/alSource.h2
-rw-r--r--OpenAL32/alSource.c6
3 files changed, 40 insertions, 39 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 680ee001..e3edd64d 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -835,8 +835,9 @@ static void MixSomeSources(ALCcontext *ALContext, float (*DryBuffer)[OUTPUTCHANN
ALuint frequency;
ALint increment;
ALuint DataPosInt, DataPosFrac;
- ALboolean FirstStart;
+ ALuint Channels, Bytes;
ALuint BuffersPlayed;
+ ALfloat Pitch;
ALenum State;
if(!(ALSource=ALContext->Source))
@@ -861,12 +862,30 @@ another_source:
BuffersPlayed = ALSource->BuffersPlayed;
DataPosInt = ALSource->position;
DataPosFrac = ALSource->position_fraction;
- FirstStart = ALSource->FirstStart;
- for(i = 0;i < OUTPUTCHANNELS;i++)
- DrySend[i] = ALSource->DryGains[i];
- for(i = 0;i < MAX_SENDS;i++)
- WetSend[i] = ALSource->WetGains[i];
+ Channels = aluChannelsFromFormat(ALSource->Format);
+ Bytes = aluBytesFromFormat(ALSource->Format);
+
+ CalcSourceParams(ALContext, ALSource, (Channels==1)?AL_TRUE:AL_FALSE);
+ Pitch = (ALSource->Params.Pitch*ALSource->Frequency) / frequency;
+ if(Pitch > (float)MAX_PITCH)
+ Pitch = (float)MAX_PITCH;
+
+ /* Compute the gain steps for each output channel */
+ if(ALSource->FirstStart)
+ {
+ for(i = 0;i < OUTPUTCHANNELS;i++)
+ DrySend[i] = ALSource->Params.DryGains[i];
+ for(i = 0;i < MAX_SENDS;i++)
+ WetSend[i] = ALSource->Params.WetGains[i];
+ }
+ else
+ {
+ for(i = 0;i < OUTPUTCHANNELS;i++)
+ DrySend[i] = ALSource->DryGains[i];
+ for(i = 0;i < MAX_SENDS;i++)
+ WetSend[i] = ALSource->WetGains[i];
+ }
DryFilter = &ALSource->Params.iirFilter;
for(i = 0;i < MAX_SENDS;i++)
@@ -886,53 +905,27 @@ another_source:
ALuint DataSize = 0;
ALbuffer *ALBuffer;
ALshort *Data;
- ALuint Channels, Bytes;
ALuint BufferSize;
- ALfloat Pitch;
/* Get buffer info */
if((ALBuffer=BufferListItem->buffer) != NULL)
{
Data = ALBuffer->data;
- Channels = aluChannelsFromFormat(ALBuffer->format);
- Bytes = aluBytesFromFormat(ALBuffer->format);
DataSize = ALBuffer->size;
DataSize /= Channels * Bytes;
}
if(DataPosInt >= DataSize)
goto skipmix;
- CalcSourceParams(ALContext, ALSource, (Channels==1)?AL_TRUE:AL_FALSE);
- Pitch = (ALSource->Params.Pitch*ALBuffer->frequency) / frequency;
-
/* Compute the gain steps for each output channel */
- if(FirstStart)
- {
- FirstStart = AL_FALSE;
- for(i = 0;i < OUTPUTCHANNELS;i++)
- {
- DrySend[i] = ALSource->Params.DryGains[i];
- dryGainStep[i] = 0.0f;
- }
- for(i = 0;i < MAX_SENDS;i++)
- {
- WetSend[i] = ALSource->Params.WetGains[i];
- wetGainStep[i] = 0.0f;
- }
- }
- else
- {
- for(i = 0;i < OUTPUTCHANNELS;i++)
- dryGainStep[i] = (ALSource->Params.DryGains[i]-
- DrySend[i]) / rampLength;
- for(i = 0;i < MAX_SENDS;i++)
- wetGainStep[i] = (ALSource->Params.WetGains[i]-
- WetSend[i]) / rampLength;
- }
+ for(i = 0;i < OUTPUTCHANNELS;i++)
+ dryGainStep[i] = (ALSource->Params.DryGains[i]-
+ DrySend[i]) / rampLength;
+ for(i = 0;i < MAX_SENDS;i++)
+ wetGainStep[i] = (ALSource->Params.WetGains[i]-
+ WetSend[i]) / rampLength;
/* Compute 18.14 fixed point step */
- if(Pitch > (float)MAX_PITCH)
- Pitch = (float)MAX_PITCH;
increment = (ALint)(Pitch*(ALfloat)(1L<<FRACTIONBITS));
if(increment <= 0)
increment = (1<<FRACTIONBITS);
@@ -1158,7 +1151,7 @@ another_source:
for(i = 0;i < MAX_SENDS;i++)
ALSource->WetGains[i] = WetSend[i];
- ALSource->FirstStart = FirstStart;
+ ALSource->FirstStart = AL_FALSE;
if((ALSource=ALSource->next) != NULL)
goto another_source;
diff --git a/OpenAL32/Include/alSource.h b/OpenAL32/Include/alSource.h
index 663a9e35..7f18eee3 100644
--- a/OpenAL32/Include/alSource.h
+++ b/OpenAL32/Include/alSource.h
@@ -52,6 +52,8 @@ 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 b606d9fd..85b9c966 100644
--- a/OpenAL32/alSource.c
+++ b/OpenAL32/alSource.c
@@ -535,6 +535,9 @@ 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;
@@ -1586,6 +1589,9 @@ 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]);