diff options
author | Chris Robinson <[email protected]> | 2009-10-25 05:34:47 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2009-10-25 05:34:47 -0700 |
commit | 31a106344f2efb5c444116002723cda1e2dea0b8 (patch) | |
tree | 4af7b9e2c9eeb8d341cebdfd47cf2e81ab44d494 /Alc | |
parent | b0a82aa420c4bbeb465a0ee0300517f25b2ca6af (diff) |
Calculate more store only once per loop
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/ALu.c | 58 |
1 files changed, 28 insertions, 30 deletions
@@ -867,9 +867,11 @@ another_source: 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; - if(Pitch > (float)MAX_PITCH) - Pitch = (float)MAX_PITCH; + if(Pitch > (float)MAX_PITCH) Pitch = (float)MAX_PITCH; + increment = (ALint)(Pitch*(ALfloat)(1L<<FRACTIONBITS)); + if(increment <= 0) increment = (1<<FRACTIONBITS); /* Compute the gain steps for each output channel */ if(ALSource->FirstStart) @@ -896,6 +898,21 @@ another_source: DummyBuffer); } + if(DuplicateStereo && Channels == 2) + { + Matrix[FRONT_LEFT][SIDE_LEFT] = 1.0f; + Matrix[FRONT_RIGHT][SIDE_RIGHT] = 1.0f; + Matrix[FRONT_LEFT][BACK_LEFT] = 1.0f; + Matrix[FRONT_RIGHT][BACK_RIGHT] = 1.0f; + } + else if(DuplicateStereo) + { + Matrix[FRONT_LEFT][SIDE_LEFT] = 0.0f; + Matrix[FRONT_RIGHT][SIDE_RIGHT] = 0.0f; + Matrix[FRONT_LEFT][BACK_LEFT] = 0.0f; + Matrix[FRONT_RIGHT][BACK_RIGHT] = 0.0f; + } + BufferListItem = ALSource->queue; for(i = 0;i < BuffersPlayed && BufferListItem;i++) BufferListItem = BufferListItem->next; @@ -925,19 +942,6 @@ another_source: wetGainStep[i] = (ALSource->Params.WetGains[i]- WetSend[i]) / rampLength; - /* Compute 18.14 fixed point step */ - increment = (ALint)(Pitch*(ALfloat)(1L<<FRACTIONBITS)); - if(increment <= 0) - increment = (1<<FRACTIONBITS); - - /* Figure out how many samples we can mix. */ - DataSize64 = DataSize; - DataSize64 <<= FRACTIONBITS; - DataPos64 = DataPosInt; - DataPos64 <<= FRACTIONBITS; - DataPos64 += DataPosFrac; - BufferSize = (ALuint)((DataSize64-DataPos64+(increment-1)) / increment); - if(BufferListItem->next) { ALbuffer *NextBuf = BufferListItem->next->buffer; @@ -958,22 +962,16 @@ another_source: } else memset(&Data[DataSize*Channels], 0, (ALBuffer->padding*Channels*Bytes)); - BufferSize = min(BufferSize, (SamplesToDo-j)); - if(DuplicateStereo && Channels == 2) - { - Matrix[FRONT_LEFT][SIDE_LEFT] = 1.0f; - Matrix[FRONT_RIGHT][SIDE_RIGHT] = 1.0f; - Matrix[FRONT_LEFT][BACK_LEFT] = 1.0f; - Matrix[FRONT_RIGHT][BACK_RIGHT] = 1.0f; - } - else if(DuplicateStereo) - { - Matrix[FRONT_LEFT][SIDE_LEFT] = 0.0f; - Matrix[FRONT_RIGHT][SIDE_RIGHT] = 0.0f; - Matrix[FRONT_LEFT][BACK_LEFT] = 0.0f; - Matrix[FRONT_RIGHT][BACK_RIGHT] = 0.0f; - } + /* Figure out how many samples we can mix. */ + DataSize64 = DataSize; + DataSize64 <<= FRACTIONBITS; + DataPos64 = DataPosInt; + DataPos64 <<= FRACTIONBITS; + DataPos64 += DataPosFrac; + BufferSize = (ALuint)((DataSize64-DataPos64+(increment-1)) / increment); + + BufferSize = min(BufferSize, (SamplesToDo-j)); /* Actual sample mixing loop */ k = 0; |