≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
Irrklang 1.5 causing heavy hickups for some users
Posted by:
(you are not logged in)
Enter the missing letter in: "Internation?l"
(you are not logged in)
Text:
[quote][b][/b] wrote: This is our complete initialisation and threading code: [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; }[/code][/quote]
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