Monday, January 25, 2016

Stuttering Sound Problems with KOTOR 2 in Linux

Sometimes I just have to shake my head in disbelief -- how do some things pass through QA?

I recently picked up Knights of the Old Republic 2 on Steam.  It's been on my list of games to play for a while and it being on sale at the time and also being Linux compatible made me pull the trigger on it.

Pretty quickly I noticed that the sound was stuttering really badly. After putting up with it for way too long, some google fu lead me to a Steam forum where the Windows users where saying that they had the same problems on multicore CPU's.   Apparently, setting the CPU affinity resolves the issue.  I can confirm that this is easy to do on Linux and it does solve the problem.

Start up KOTOR2, then Alt-Tab to a xterm and run the following:


ps -ef |grep KOTOR| grep -v grep|grep -v 'bin/sh' |awk '{print $2}'` | xarg taskset -p 03

This will figure out the PID of KOTOR2 process and lock it to the 4th CPU.  You can close the xterm at this point.  Now Alt-Tab back to KOTOR2 and the sound stuttering should be fixed.  The CPU's are counted from 0, so if you have a quad core, you can lock the process to CPU's 0 through 3.   Based on your rig, there might be a better CPU to lock too. One thing to look at is which CPU is handling various IRQ requests.  I didn't have to look into this even with an AMD FX-6300 so I would suspect any recent chipset wouldn't require any further tuning either.



https://steamcommunity.com/app/208580/discussions/0/648814842278312559/

http://manpages.ubuntu.com/manpages/lucid/man1/taskset.1.html

No comments: