Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > irrKlang
Irrklang 1.5 causing heavy hickups for some users

oogst
Registered User
Quote
2014-11-03 15:50:38

A while ago we update from Irrklang 1.4 to 1.5 and this turned out to make our game Awesomenauts unplayable for some users: every second the game would freeze for around 0.1 seconds, which is really bad for the game experience.

The issue was so rare that we could not reproduce it ourselves, but I know that hundreds of users suffered from this (Awesomenauts has a lot of units sold on PC so that still makes it a rare issue). We sent users various executables to try but no matter how we changed our audio code, the issue remained there.

We finally just reverted Irrklang back to 1.4 and then the issue was instantly gone.

Since we couldn't reproduce the issue ourselves I wasn't able to experiment with it too much. Also, since we were getting so many complaints we had to fix it quickly as soon as we found out reverting to 1.4 fixed it.

Note that we call irrKlangEngine->update() from a separate thread and I tried a couple of different update frequencies.

PS. This is something we handled last July. I totally forgot to post it here, but I see that 1.5 is still the latest Irrklang version so I suppose this remains just as relevant.


niko
Moderator
Quote
2014-11-03 20:28:09

Well, that's strange. From what you wrote, it seems you are running irrKlang in single-threaded mode?

Also, what version are you using? I guess 32 bit, statically linked?


oogst
Registered User
Quote
2014-11-04 09:42:11

This is our complete initialisation and threading code:

PCSoundManager::PCSoundManager()
{
fileFactory = new IrrklangFileFactory();

irrklang::E_SOUND_OUTPUT_DRIVER driver = irrklang::ESOD_WIN_MM;
ifdef _MAC
driver = irrklang::ESOD_CORE_AUDIO;
endif

// Create single-threaded audio engine
irrKlangEngine = irrklang::createIrrKlangDevice(driver, irrklang::ESEO_LOAD_PLUGINS | irrklang::ESEO_USE_3D_BUFFERS | irrklang::ESEO_PRINT_DEBUG_INFO_TO_DEBUGGER | irrklang::ESEO_PRINT_DEBUG_INFO_TO_STDOUT);
if (irrKlangEngine == NULL)
{
irrKlangEngine = createAnySoundDevice();
}

if (irrKlangEngine != NULL)
{
irrKlangEngine->addFileFactory(fileFactory);
irrklangUpdateThread = new Thread("irrUpdThr", &irrklangThreadUpdateFunction, this);
}
}


irrklang::ISoundEngine* PCSoundManager::createAnySoundDevice()
{
irrklang::ISoundEngine* device = NULL;

for (unsigned int driver = irrklang::ESOD_AUTO_DETECT; driver < irrklang::ESOD_COUNT && device == NULL; driver++)
{
device = createAnySoundDeviceWithDriver(static_cast<irrklang::E_SOUND_OUTPUT_DRIVER>(driver));
}

return device;
}


irrklang::ISoundEngine* PCSoundManager::createAnySoundDeviceWithDriver(irrklang::E_SOUND_OUTPUT_DRIVER driver)
{
irrklang::ISoundDeviceList* deviceList = irrklang::createSoundDeviceList();
irrklang::ISoundEngine* device = NULL;

for (int deviceNumber = 0; deviceNumber < deviceList->getDeviceCount() && device == NULL; deviceNumber++)
{
const char* deviceID = deviceList->getDeviceID(deviceNumber);

device = irrklang::createIrrKlangDevice(driver, irrklang::ESEO_DEFAULT_OPTIONS, deviceID);
}

return device;
}


void PCSoundManager::irrklangThreadUpdateFunction(void* args)
{
PCSoundManager* sm = reinterpret_cast<PCSoundManager*>(args);
FrameTimer* timer = FrameTimer::create();
float timeElapsed = 0;

//Irrklang documentation says Irrklang prefers to be updated several times per frame
const float minTimeToWait = 1.0f / 180.0f;

while (updateThreadShouldKeepRunning)
{
if (timeElapsed >= minTimeToWait)
{
timeElapsed = 0;
sm->irrKlangEngine->update();
}

timeElapsed += timer->getTimeSincePreviousCall();

//Check whether we need to wait before another update can be done
if (timeElapsed < minTimeToWait)
{
//Sleep until minTimeToWait has passed
Thread::sleepInMicroseconds((unsigned int)((minTimeToWait - timeElapsed) * 1000000));
}
else
{
//We'd like to do another update right away, since updating apparently took a bit of time and we
//want to update often, but let's first yield to allow others to take the CPU is they need to.
Thread::yieldCallingThread();
}
}

delete timer;
}



niko
Moderator
Quote
2014-11-05 09:11:41

Difficult to say what happened there. The code looks ok for me. Do you have any info about what hardware those users have?


oogst
Registered User
Quote
2014-11-05 09:44:37

No, sorry, I don't know any hardware patterns for these users. I realize this is all very little info to go with...


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Inter?ational" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact