Plan for Roelf "TheRoDent" Diedericks
by Roelf "TheRoDent" Diedericks · 10/30/2003 (2:27 am) · 0 comments
I discovered some un-goodness in the Torque linux audio layer. For a while now, I suspected my soundcard since I could never get any proper positional audio out of Legends.
Firstly the openAL context for Linux was created with an internal mixing rate of 22050. This seemed to be the root cause of the loss of positional audio. Also during the initialization of OpenAL on Linux, the default device specifier was sdl, so that the audio would get funneled through the SDL abstraction, which to me was just overhead.
I modified the linux audio layer to use a 44100 mixing and output rate by default, and to attempt native, arts, esd and then sdl access for the sound device.
Instant positional audio, and the doppler effects started working as expected. Well, almost.
Turns out there is a rather huge difference in the defaults for OpenAL contexts between Windows and Linux, so I added some sane defaults for the doppler velocity and factors.
All in all, legends' linux sound is now pretty much on par with the windows version, except for some clicking and hissing which I'm suspecting is the fault of the Linux implementation.
Another interesting problem was the latest head changes in the Platform::process code. John Quiggly added sleep timing code and a command line argument that would override Platform::process to either use nanosleep, or a tight loop depending on how the timing went.
Platform::process is quite important, since any latency in it will result in higher ping for players. The problem is that on Linux, the lowest amount of latency generally achieved when asking for a 1ms nanosleep, is 15-18ms, depending on kernel latency.
I modified the code quite a bit, seeing as I made an interesting discovery. A 0ms nanosleep, yields a 9ms latency.
There are 3 scenarios:
1. Use a 1ms nanosleep, and achieve 18ms latency.
2. Use a 0ms nanosleep, and achieve 9ms latency.
3. Don't use sleep at all, but suffer from high CPU usage, and timing determined by the kernel scheduler, which is dependant on system load.
The best overall result was achieved with a 0ms nanosleep. This still yields time to the kernel (due to the syscall) and achieves a reasonably stable/accurate timer.
Some kernels though, treat a 0ms nanosleep as an immediate return and once again causes high CPU usage. Thus this isn't the default behaviour on Legends dedicated servers, but from testing, most systems don't seem to mind a 0ms sleep.
Anyway, some interesting times up ahead, and lots more improvements to be made on the Linux version.
Fonts, and font support is the next big issue.
Firstly the openAL context for Linux was created with an internal mixing rate of 22050. This seemed to be the root cause of the loss of positional audio. Also during the initialization of OpenAL on Linux, the default device specifier was sdl, so that the audio would get funneled through the SDL abstraction, which to me was just overhead.
I modified the linux audio layer to use a 44100 mixing and output rate by default, and to attempt native, arts, esd and then sdl access for the sound device.
Instant positional audio, and the doppler effects started working as expected. Well, almost.
Turns out there is a rather huge difference in the defaults for OpenAL contexts between Windows and Linux, so I added some sane defaults for the doppler velocity and factors.
All in all, legends' linux sound is now pretty much on par with the windows version, except for some clicking and hissing which I'm suspecting is the fault of the Linux implementation.
Another interesting problem was the latest head changes in the Platform::process code. John Quiggly added sleep timing code and a command line argument that would override Platform::process to either use nanosleep, or a tight loop depending on how the timing went.
Platform::process is quite important, since any latency in it will result in higher ping for players. The problem is that on Linux, the lowest amount of latency generally achieved when asking for a 1ms nanosleep, is 15-18ms, depending on kernel latency.
I modified the code quite a bit, seeing as I made an interesting discovery. A 0ms nanosleep, yields a 9ms latency.
There are 3 scenarios:
1. Use a 1ms nanosleep, and achieve 18ms latency.
2. Use a 0ms nanosleep, and achieve 9ms latency.
3. Don't use sleep at all, but suffer from high CPU usage, and timing determined by the kernel scheduler, which is dependant on system load.
The best overall result was achieved with a 0ms nanosleep. This still yields time to the kernel (due to the syscall) and achieves a reasonably stable/accurate timer.
Some kernels though, treat a 0ms nanosleep as an immediate return and once again causes high CPU usage. Thus this isn't the default behaviour on Legends dedicated servers, but from testing, most systems don't seem to mind a 0ms sleep.
Anyway, some interesting times up ahead, and lots more improvements to be made on the Linux version.
Fonts, and font support is the next big issue.
About the author