From 20f976ddc7aaa894aba85afc4d3776cc8cd8a874 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Thu, 29 Mar 2012 03:02:26 +0400 Subject: [PATCH 1/2] probably openal initialization fix --- apps/openmw/mwsound/openal_output.cpp | 37 ++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwsound/openal_output.cpp b/apps/openmw/mwsound/openal_output.cpp index 5122b3a5a..97a399689 100644 --- a/apps/openmw/mwsound/openal_output.cpp +++ b/apps/openmw/mwsound/openal_output.cpp @@ -426,6 +426,12 @@ void OpenAL_Output::init(const std::string &devname) else std::cout << "Opened \""< attrs(size); +// alcGetIntegerv( mDevice, ALC_ALL_ATTRIBUTES, size, &attrs[0] ); +// for(int i=0; i(maxmono+maxstereo, 256); - for(size_t i = 0;i < maxtotal;i++) + ALCuint maxtotal = 256;//std::min(maxmono+maxstereo, 256); + bool stop = false; + for(size_t i = 0;i < maxtotal && !stop;i++) { ALuint src = 0; alGenSources(1, &src); - throwALerror(); - mFreeSources.push_back(src); + + ALenum err = alGetError(); + if(err != AL_NO_ERROR) + { + stop = true; + std::cout << "Stopping source generation at " << i << std::endl; + } + else + { + mFreeSources.push_back(src); + } + //throwALerror(); } } catch(std::exception &e) From b6aa8925f49ae38958074549ea9722916ab6ebf8 Mon Sep 17 00:00:00 2001 From: Nikolay Kasyanov Date: Fri, 30 Mar 2012 00:12:38 +0400 Subject: [PATCH 2/2] (Temporary) workaround for broken OpenAL implementations that doesn't return meaningful max counts of sources --- apps/openmw/mwsound/openal_output.cpp | 53 ++++++++++++--------------- 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/apps/openmw/mwsound/openal_output.cpp b/apps/openmw/mwsound/openal_output.cpp index 97a399689..041759683 100644 --- a/apps/openmw/mwsound/openal_output.cpp +++ b/apps/openmw/mwsound/openal_output.cpp @@ -426,12 +426,6 @@ void OpenAL_Output::init(const std::string &devname) else std::cout << "Opened \""< attrs(size); -// alcGetIntegerv( mDevice, ALC_ALL_ATTRIBUTES, size, &attrs[0] ); -// for(int i=0; i(maxmono+maxstereo, 256); - bool stop = false; - for(size_t i = 0;i < maxtotal && !stop;i++) + ALCuint maxtotal = std::min(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)