Merge pull request #561 from alexey-lysiuk/openal_numsources

Handle inability of OpenAL to return number of sources
This commit is contained in:
coelckers 2016-02-13 12:44:56 +01:00
commit 71f230dc08
1 changed files with 14 additions and 1 deletions

View File

@ -781,7 +781,20 @@ OpenALSoundRenderer::OpenALSoundRenderer()
alcGetIntegerv(Device, ALC_MONO_SOURCES, 1, &numMono);
alcGetIntegerv(Device, ALC_STEREO_SOURCES, 1, &numStereo);
Sources.Resize(MIN<int>(MAX<int>(*snd_channels, 2), numMono+numStereo));
// OpenAL specification doesn't require alcGetIntegerv() to return
// meaningful values for ALC_MONO_SOURCES and ALC_MONO_SOURCES.
// At least Apple's OpenAL implementation returns zeroes,
// although it can generate reasonable number of sources.
const int numChannels = MAX<int>(*snd_channels, 2);
int numSources = numMono + numStereo;
if (0 == numSources)
{
numSources = numChannels;
}
Sources.Resize(MIN<int>(numChannels, numSources));
for(size_t i = 0;i < Sources.Size();i++)
{
alGenSources(1, &Sources[i]);