mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-14 01:19:59 +00:00
(Temporary) workaround for broken OpenAL implementations that doesn't return meaningful max counts of sources
This commit is contained in:
parent
0897a2a4cb
commit
b6aa8925f4
@ -426,12 +426,6 @@ void OpenAL_Output::init(const std::string &devname)
|
||||
else
|
||||
std::cout << "Opened \""<<alcGetString(mDevice, ALC_DEVICE_SPECIFIER)<<"\"" << std::endl;
|
||||
|
||||
ALCint params[5];
|
||||
// params[0] = ALC_MONO_SOURCES;
|
||||
// params[1] = 10;
|
||||
// params[2] = ALC_STEREO_SOURCES;
|
||||
// params[3] = 10;
|
||||
// params[4] = 0;
|
||||
mContext = alcCreateContext(mDevice, NULL);
|
||||
if(!mContext || alcMakeContextCurrent(mContext) == ALC_FALSE)
|
||||
fail(std::string("Failed to setup context: ")+alcGetString(mDevice, alcGetError(mDevice)));
|
||||
@ -439,18 +433,6 @@ void OpenAL_Output::init(const std::string &devname)
|
||||
alDistanceModel(AL_LINEAR_DISTANCE_CLAMPED);
|
||||
throwALerror();
|
||||
|
||||
// ALCint size;
|
||||
// alcGetIntegerv( mDevice, ALC_ATTRIBUTES_SIZE, 1, &size);
|
||||
// std::vector<ALCint> attrs(size);
|
||||
// alcGetIntegerv( mDevice, ALC_ALL_ATTRIBUTES, size, &attrs[0] );
|
||||
// for(int i=0; i<attrs.size(); ++i)
|
||||
// {
|
||||
// if( attrs[i] == ALC_MONO_SOURCES )
|
||||
// {
|
||||
// std::cout << "max mono sources: " << attrs.at(i+1) << std::endl;
|
||||
// }
|
||||
// }
|
||||
|
||||
ALCint maxmono=0, maxstereo=0;
|
||||
alcGetIntegerv(mDevice, ALC_MONO_SOURCES, 1, &maxmono);
|
||||
alcGetIntegerv(mDevice, ALC_STEREO_SOURCES, 1, &maxstereo);
|
||||
@ -458,24 +440,35 @@ void OpenAL_Output::init(const std::string &devname)
|
||||
|
||||
try
|
||||
{
|
||||
ALCuint maxtotal = 256;//std::min<ALCuint>(maxmono+maxstereo, 256);
|
||||
bool stop = false;
|
||||
for(size_t i = 0;i < maxtotal && !stop;i++)
|
||||
ALCuint maxtotal = std::min<ALCuint>(maxmono+maxstereo, 256);
|
||||
if (maxtotal == 0) // workaround for broken implementations
|
||||
{
|
||||
ALuint src = 0;
|
||||
alGenSources(1, &src);
|
||||
|
||||
ALenum err = alGetError();
|
||||
if(err != AL_NO_ERROR)
|
||||
maxtotal = 256;
|
||||
bool stop = false;
|
||||
for(size_t i = 0;i < maxtotal && !stop;i++) // generate source until error returned
|
||||
{
|
||||
stop = true;
|
||||
std::cout << "Stopping source generation at " << i << std::endl;
|
||||
ALuint src = 0;
|
||||
alGenSources(1, &src);
|
||||
ALenum err = alGetError();
|
||||
if(err != AL_NO_ERROR)
|
||||
{
|
||||
stop = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
mFreeSources.push_back(src);
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
else // normal case
|
||||
{
|
||||
for(size_t i = 0;i < maxtotal;i++)
|
||||
{
|
||||
ALuint src = 0;
|
||||
alGenSources(1, &src);
|
||||
throwALerror();
|
||||
mFreeSources.push_back(src);
|
||||
}
|
||||
//throwALerror();
|
||||
}
|
||||
}
|
||||
catch(std::exception &e)
|
||||
|
Loading…
x
Reference in New Issue
Block a user