~ubuntu-branches/ubuntu/quantal/openal-soft/quantal

« back to all changes in this revision

Viewing changes to Alc/ALu.c

  • Committer: Bazaar Package Importer
  • Author(s): Scott Ritchie
  • Date: 2010-04-16 15:20:20 UTC
  • mfrom: (0.2.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20100416152020-7gbp12lzhugfr2n0
Tags: 1:1.12.854-0ubuntu1
* New upstream release (LP: #565071)
  - Fully backwards compatible
  - Fixed playback when the PulseAudio buffer is calculated to be more than 64KB.
  - Restored compatibility with some older PulseAudio libs.
  - Alternative buffer sizing for PulseAudio, specified using a new config option.
  - Improved buffer size calculations, to prevent drastic latency changes when certain properties (such as ALC_FREQUENCY) are modified.
  - "Not broken" unlike 1.11.753, according to upstream
* Should fix some remaining crackling issues (LP: #351732, #516435)
* Should be ok to sync over; no extra patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
188
188
        }
189
189
    }
190
190
 
191
 
    for(i = 1;i < chans;i++)
 
191
    for(i = 0;i < chans;i++)
192
192
    {
193
 
        if(SpeakerAngle[i] <= SpeakerAngle[i-1])
194
 
        {
195
 
            AL_PRINT("Speaker %d of %d does not follow previous: %f > %f\n", i, chans,
196
 
                     SpeakerAngle[i-1] * 180.0f/M_PI, SpeakerAngle[i] * 180.0f/M_PI);
197
 
            SpeakerAngle[i] = SpeakerAngle[i-1] + 1 * M_PI/180.0f;
 
193
        int min = i;
 
194
        int i2;
 
195
 
 
196
        for(i2 = i+1;i2 < chans;i2++)
 
197
        {
 
198
            if(SpeakerAngle[i2] < SpeakerAngle[min])
 
199
                min = i2;
 
200
        }
 
201
 
 
202
        if(min != i)
 
203
        {
 
204
            ALfloat tmpf;
 
205
            ALint tmpi;
 
206
 
 
207
            tmpf = SpeakerAngle[i];
 
208
            SpeakerAngle[i] = SpeakerAngle[min];
 
209
            SpeakerAngle[min] = tmpf;
 
210
 
 
211
            tmpi = Speaker2Chan[i];
 
212
            Speaker2Chan[i] = Speaker2Chan[min];
 
213
            Speaker2Chan[min] = tmpi;
198
214
        }
199
215
    }
200
216
}
644
660
        case AL_EXPONENT_DISTANCE:
645
661
            if(Distance > 0.0f && MinDist > 0.0f)
646
662
            {
647
 
                flAttenuation = (ALfloat)pow(Distance/MinDist, -Rolloff);
 
663
                flAttenuation = aluPow(Distance/MinDist, -Rolloff);
648
664
                for(i = 0;i < NumSends;i++)
649
 
                    RoomAttenuation[i] = (ALfloat)pow(Distance/MinDist, -RoomRolloff[i]);
 
665
                    RoomAttenuation[i] = aluPow(Distance/MinDist, -RoomRolloff[i]);
650
666
            }
651
667
            break;
652
668
 
672
688
        absorb = (ALSource->AirAbsorptionFactor*AIRABSORBGAINDBHF) *
673
689
                 effectiveDist;
674
690
        // Convert dB to linear gain before applying
675
 
        absorb = pow(10.0, absorb/20.0);
 
691
        absorb = aluPow(10.0f, absorb/20.0f);
676
692
 
677
693
        DryGainHF *= absorb;
678
694
    }
722
738
    {
723
739
        ALeffectslot *Slot = ALSource->Send[i].Slot;
724
740
 
725
 
        if(Slot && Slot->effect.type != AL_EFFECT_NULL)
726
 
        {
727
 
            if(Slot->AuxSendAuto)
 
741
        if(!Slot || Slot->effect.type == AL_EFFECT_NULL)
 
742
        {
 
743
            ALSource->Params.WetGains[i] = 0.0f;
 
744
            WetGainHF[i] = 1.0f;
 
745
            continue;
 
746
        }
 
747
 
 
748
        if(Slot->AuxSendAuto)
 
749
        {
 
750
            if(ALSource->WetGainAuto)
 
751
                WetGain[i] *= ConeVolume;
 
752
            if(ALSource->WetGainHFAuto)
 
753
                WetGainHF[i] *= ConeHF;
 
754
 
 
755
            // Clamp to Min/Max Gain
 
756
            WetGain[i] = __min(WetGain[i],MaxVolume);
 
757
            WetGain[i] = __max(WetGain[i],MinVolume);
 
758
 
 
759
            if(Slot->effect.type == AL_EFFECT_REVERB ||
 
760
               Slot->effect.type == AL_EFFECT_EAXREVERB)
728
761
            {
729
 
                if(ALSource->WetGainAuto)
730
 
                    WetGain[i] *= ConeVolume;
731
 
                if(ALSource->WetGainHFAuto)
732
 
                    WetGainHF[i] *= ConeHF;
733
 
 
734
 
                // Clamp to Min/Max Gain
735
 
                WetGain[i] = __min(WetGain[i],MaxVolume);
736
 
                WetGain[i] = __max(WetGain[i],MinVolume);
737
 
 
738
 
                if(Slot->effect.type == AL_EFFECT_REVERB ||
739
 
                   Slot->effect.type == AL_EFFECT_EAXREVERB)
740
 
                {
741
 
                    /* Apply a decay-time transformation to the wet path,
742
 
                     * based on the attenuation of the dry path.
743
 
                     *
744
 
                     * Using the approximate (effective) source to listener
745
 
                     * distance, the initial decay of the reverb effect is
746
 
                     * calculated and applied to the wet path.
747
 
                     */
748
 
                    WetGain[i] *= pow(10.0, effectiveDist /
 
762
                /* Apply a decay-time transformation to the wet path, based on
 
763
                 * the attenuation of the dry path.
 
764
                 *
 
765
                 * Using the approximate (effective) source to listener
 
766
                 * distance, the initial decay of the reverb effect is
 
767
                 * calculated and applied to the wet path.
 
768
                 */
 
769
                WetGain[i] *= aluPow(10.0f, effectiveDist /
749
770
                                            (SPEEDOFSOUNDMETRESPERSEC *
750
771
                                             Slot->effect.Reverb.DecayTime) *
751
772
                                            -60.0 / 20.0);
752
773
 
753
 
                    WetGainHF[i] *= pow(10.0,
754
 
                                        log10(Slot->effect.Reverb.AirAbsorptionGainHF) *
755
 
                                        ALSource->AirAbsorptionFactor * effectiveDist);
756
 
                }
757
 
            }
758
 
            else
759
 
            {
760
 
                // If the slot's auxiliary send auto is off, the data sent to
761
 
                // the effect slot is the same as the dry path, sans filter
762
 
                // effects
763
 
                WetGain[i] = DryMix;
764
 
                WetGainHF[i] = DryGainHF;
765
 
            }
766
 
 
767
 
            switch(ALSource->Send[i].WetFilter.type)
768
 
            {
769
 
                case AL_FILTER_LOWPASS:
770
 
                    WetGain[i] *= ALSource->Send[i].WetFilter.Gain;
771
 
                    WetGainHF[i] *= ALSource->Send[i].WetFilter.GainHF;
772
 
                    break;
773
 
            }
774
 
            ALSource->Params.WetGains[i] = WetGain[i] * ListenerGain;
 
774
                WetGainHF[i] *= aluPow(10.0f,
 
775
                                       log10(Slot->effect.Reverb.AirAbsorptionGainHF) *
 
776
                                       ALSource->AirAbsorptionFactor * effectiveDist);
 
777
            }
775
778
        }
776
779
        else
777
780
        {
778
 
            ALSource->Params.WetGains[i] = 0.0f;
779
 
            WetGainHF[i] = 1.0f;
780
 
        }
 
781
            /* If the slot's auxiliary send auto is off, the data sent to the
 
782
             * effect slot is the same as the dry path, sans filter effects */
 
783
            WetGain[i] = DryMix;
 
784
            WetGainHF[i] = DryGainHF;
 
785
        }
 
786
 
 
787
        switch(ALSource->Send[i].WetFilter.type)
 
788
        {
 
789
            case AL_FILTER_LOWPASS:
 
790
                WetGain[i] *= ALSource->Send[i].WetFilter.Gain;
 
791
                WetGainHF[i] *= ALSource->Send[i].WetFilter.GainHF;
 
792
                break;
 
793
        }
 
794
        ALSource->Params.WetGains[i] = WetGain[i] * ListenerGain;
781
795
    }
782
796
    for(i = NumSends;i < MAX_SENDS;i++)
783
797
    {
902
916
    ALfloat Pitch;
903
917
    ALenum State;
904
918
 
905
 
    if(!(ALSource=ALContext->Source))
 
919
    if(!(ALSource=ALContext->SourceList))
906
920
        return;
907
921
 
908
922
    DeviceFreq = ALContext->Device->Frequency;
960
974
    increment = (ALint)(Pitch*(ALfloat)(1L<<FRACTIONBITS));
961
975
    if(increment <= 0)  increment = (1<<FRACTIONBITS);
962
976
 
963
 
    /* Compute the gain steps for each output channel */
964
977
    if(ALSource->FirstStart)
965
978
    {
966
979
        for(i = 0;i < OUTPUTCHANNELS;i++)
1360
1373
            MixSomeSources(ALContext, DryBuffer, SamplesToDo);
1361
1374
 
1362
1375
            /* effect slot processing */
1363
 
            ALEffectSlot = ALContext->AuxiliaryEffectSlot;
 
1376
            ALEffectSlot = ALContext->EffectSlotList;
1364
1377
            while(ALEffectSlot)
1365
1378
            {
1366
1379
                if(ALEffectSlot->EffectState)
1494
1507
 
1495
1508
        SuspendContext(device->Contexts[i]);
1496
1509
 
1497
 
        source = device->Contexts[i]->Source;
 
1510
        source = device->Contexts[i]->SourceList;
1498
1511
        while(source)
1499
1512
        {
1500
1513
            if(source->state == AL_PLAYING)