Skip to content

Commit f13a758

Browse files
committed
Merge branch 'wip/openal': OpenAL bugfixes and improvements
2 parents 5d0d46d + bcca037 commit f13a758

File tree

1 file changed

+28
-18
lines changed

1 file changed

+28
-18
lines changed

src/client/snd_dma.cpp

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,12 @@ void S_Init( void )
392392
s_numChannels++;
393393
}
394394

395+
if (alIsExtensionPresent("AL_SOFT_direct_channels") == AL_TRUE) {
396+
// play stereo background music without virtualized output speakers
397+
ALenum alDirectChannelsSoft = alGetEnumValue("AL_DIRECT_CHANNELS_SOFT");
398+
alSourcei(s_channels[0].alSource, alDirectChannelsSoft, AL_TRUE);
399+
}
400+
395401
// Generate AL Buffers for streaming audio playback (used for MP3s)
396402
ch = s_channels + 1;
397403
for (i = 1; i < s_numChannels; i++, ch++)
@@ -1758,6 +1764,20 @@ void S_AddRealLoopingSound( int entityNum, const vec3_t origin, const vec3_t vel
17581764
//
17591765
static qboolean LoopSound_ChannelInit(loopSound_t *pLoopSound, int iLeftVol, int iRightVol)
17601766
{
1767+
#ifdef USE_OPENAL
1768+
if (s_UseOpenAL)
1769+
{
1770+
if (numLoopChannels == s_numChannels)
1771+
return qfalse;
1772+
}
1773+
else
1774+
#endif
1775+
{
1776+
if (numLoopChannels == MAX_CHANNELS) {
1777+
return qfalse;
1778+
}
1779+
}
1780+
17611781
// allocate a channel
17621782
//
17631783
channel_t *ch = &loop_channels[numLoopChannels];
@@ -1790,20 +1810,6 @@ static qboolean LoopSound_ChannelInit(loopSound_t *pLoopSound, int iLeftVol, int
17901810

17911811
numLoopChannels++;
17921812

1793-
#ifdef USE_OPENAL
1794-
if (s_UseOpenAL)
1795-
{
1796-
if (numLoopChannels == s_numChannels)
1797-
return qfalse;
1798-
}
1799-
else
1800-
#endif
1801-
{
1802-
if (numLoopChannels == MAX_CHANNELS) {
1803-
return qfalse;
1804-
}
1805-
}
1806-
18071813
return qtrue;
18081814
}
18091815

@@ -2437,14 +2443,12 @@ void S_Update_(void) {
24372443
{
24382444
alSourcef(s_channels[source].alSource, AL_REFERENCE_DISTANCE, 768.0f);
24392445
alSourcef(s_channels[source].alSource, AL_MAX_DISTANCE, 2018.0f);
2440-
alSourcef(s_channels[source].alSource, AL_ROLLOFF_FACTOR, 1.0f);
24412446
alSourcef(s_channels[source].alSource, AL_GAIN, ((float)(ch->master_vol) * s_volume->value) / 255.0f);
24422447
}
24432448
else
24442449
{
24452450
alSourcef(s_channels[source].alSource, AL_REFERENCE_DISTANCE, 256.f);
24462451
alSourcef(s_channels[source].alSource, AL_MAX_DISTANCE, 1506.f);
2447-
alSourcef(s_channels[source].alSource, AL_ROLLOFF_FACTOR, 1.0f);
24482452
alSourcef(s_channels[source].alSource, AL_GAIN, ((float)(ch->master_vol) * s_volume->value) / 255.f);
24492453
}
24502454
}
@@ -2754,7 +2758,6 @@ void UpdateLoopingSounds()
27542758
channel_t *ch;
27552759
loopSound_t *loop;
27562760
float pos[3];
2757-
float fVolume = 0.003922f; // 1.f / 255.f
27582761

27592762
#ifdef DEBUG
27602763
// Clear AL Error State
@@ -2802,7 +2805,14 @@ void UpdateLoopingSounds()
28022805
}
28032806

28042807
alSourcei(s_channels[source].alSource, AL_LOOPING, AL_TRUE);
2805-
alSourcef(s_channels[source].alSource, AL_GAIN, (float)(ch->master_vol) * s_volume->value * fVolume);
2808+
alSourcef(s_channels[source].alSource, AL_GAIN, (float)(ch->master_vol) * s_volume->value / 255.0f);
2809+
2810+
if (s_bEAX) {
2811+
alSourcef(s_channels[source].alSource, AL_REFERENCE_DISTANCE, 400.f);
2812+
} else {
2813+
alSourcef(s_channels[source].alSource, AL_REFERENCE_DISTANCE, 256.f);
2814+
alSourcef(s_channels[source].alSource, AL_MAX_DISTANCE, 1506.f);
2815+
}
28062816

28072817
if (s_bEALFileLoaded)
28082818
UpdateEAXBuffer(ch);

0 commit comments

Comments
 (0)