The PulseAudio sound server has been rewritten to use timer-based audio scheduling instead of the traditional interrupt-driven approach. This is the approach that is taken by other systems such as Apples CoreAudio and the Windows Vista audio subsystem and has a number of advantages, not the least in reduced power consumption.

+

The PulseAudio sound server has been rewritten to use timer-based audio scheduling instead of the traditional interrupt-driven approach. This is the approach that is taken by other systems such as Apples CoreAudio and the Windows Vista audio subsystem and has a number of advantages, not the least in reduced power consumption, minimization of drop-outs and flexible adjustment of the latency to the needs of the application.

== Owner ==

== Owner ==

−

* Name: Lennart Poettering

+

* Name: [[LennartPoettering| Lennart Poettering]]

== Current status ==

== Current status ==

* Targeted release: [[Releases/10| Fedora 10]]

* Targeted release: [[Releases/10| Fedora 10]]

−

* Last updated: 2008-04-09

+

* Last updated: 2008-09-09

−

* Percentage of completion: 50%

+

* Percentage of completion: 100%

+

+

The PulseAudio rework is mostly complete, but glitch-free exposes a number

+

of issues in the Alsa drivers: http://pulseaudio.org/wiki/AlsaIssues

== Detailed Description ==

== Detailed Description ==

Line 26:

Line 29:

highlights are:

highlights are:

−

* Less wakeups, reduced power consumption

+

* Fewer wakeups, reduced power consumption

* Dynamic latency adaption

* Dynamic latency adaption

* Less dependent on audio hardware

* Less dependent on audio hardware

Line 39:

Line 42:

* While doing the above, run powertop and observe that pulseaudio is not increasing the power consumption as much as it used to.

* While doing the above, run powertop and observe that pulseaudio is not increasing the power consumption as much as it used to.

* Repeat the above with different sound cards

* Repeat the above with different sound cards

+

+

Please note that the power-saving results are usually not as good as you might expect:

+

- For USB hw the wakeup rate is not dependant on the client parameters

+

- The HDA driver artificially limits the maximum size of the playback buffer to 370 ms at 44khz/2ch/16bit. The result of this is that at least one IRQ is triggered every 180 ms or so. Which hence results in already 6 interrupts per second. Which are in addition to a few timer interrupts. You can increase the buffer limit by touching some files in /proc/asound, however since fixing this limitation properly requires some non-trivial changes in alsa's internal memory management we won't be able to use longer buffers by default in F10. In theory however, we should be able to get the number of wakeups to 1 per second during music playback, it's just the underlying infrastructure that's lacking.

+

- Some clients query the latency very often. This will cause them to wakeup and as a result also PA to fulfill their query request. PA now includes some fancy algorithms to interpolate the latency information on the client so that the client can query the server less often. But some clients need to tought about that fact still.

+

+

While the power savings are unfortunately not visible on most platforms right now. The drop-out safety and automatic latency adjustment are. On USB this works fine and is visible by simple testing: play music and put load on the CPU and see that PA doesn't start to stutter. (Again, some clients are not really up to this yet, they ask for shorter buffers than necessary and thus artificially increase the wakeup rate).

== User Experience ==

== User Experience ==

Line 57:

Line 67:

If the glitch-free PulseAudio exhibits glitches that cannot be fixed in time for F10, we can just revert to the last 'traditional' PulseAudio release.

If the glitch-free PulseAudio exhibits glitches that cannot be fixed in time for F10, we can just revert to the last 'traditional' PulseAudio release.

+

+

To limit the problems with Alsa drivers, there is now a switch "tsched=0" for the module-hal-detect module which will disabled glitch-free mode for all sound cards globally. To use this edit /etc/pulse/default.pa and append "tsched=0" to the line "load-module module-hal-detect"

The PulseAudio sound server has been rewritten to use timer-based audio scheduling instead of the traditional interrupt-driven approach. This is the approach that is taken by other systems such as Apples CoreAudio and the Windows Vista audio subsystem and has a number of advantages, not the least in reduced power consumption, minimization of drop-outs and flexible adjustment of the latency to the needs of the application.

Play sound on the desktop in various ways, e.g. music in rhythmbox, or a video in totem, or some flash video in firefox. Verify that the sound experience is the same as on F9.

While doing the above, run powertop and observe that pulseaudio is not increasing the power consumption as much as it used to.

Repeat the above with different sound cards

Please note that the power-saving results are usually not as good as you might expect:
- For USB hw the wakeup rate is not dependant on the client parameters
- The HDA driver artificially limits the maximum size of the playback buffer to 370 ms at 44khz/2ch/16bit. The result of this is that at least one IRQ is triggered every 180 ms or so. Which hence results in already 6 interrupts per second. Which are in addition to a few timer interrupts. You can increase the buffer limit by touching some files in /proc/asound, however since fixing this limitation properly requires some non-trivial changes in alsa's internal memory management we won't be able to use longer buffers by default in F10. In theory however, we should be able to get the number of wakeups to 1 per second during music playback, it's just the underlying infrastructure that's lacking.
- Some clients query the latency very often. This will cause them to wakeup and as a result also PA to fulfill their query request. PA now includes some fancy algorithms to interpolate the latency information on the client so that the client can query the server less often. But some clients need to tought about that fact still.

While the power savings are unfortunately not visible on most platforms right now. The drop-out safety and automatic latency adjustment are. On USB this works fine and is visible by simple testing: play music and put load on the CPU and see that PA doesn't start to stutter. (Again, some clients are not really up to this yet, they ask for shorter buffers than necessary and thus artificially increase the wakeup rate).

The glitch-free logic will only be enabled on mmap()-capable ALSA devices and where hrtimers are available. The non-glitch-free logic will be preserved as compatibility code with older kernels and limited sound hardware or drivers.

From Lennarts writeup:

System timers on Unix are not very high precision. On traditional Linux with HZ=100 sleep times for timers are rounded up to multiples of 10ms. Only very recent Linux kernels with hrtimers can provide something better, but only on x86 and x86-64 until now. This makes the whole scheme unusable for low latency setups unless you run the very latest Linux. Also, hrtimers are not (yet) exposed in poll()/select(). It requires major jumping through loops to work around this limitation.

Generally, this works reliably only on newest ALSA, newest kernel, newest everything. It has pretty steep requirements on software and sometimes even on hardware.

If the glitch-free PulseAudio exhibits glitches that cannot be fixed in time for F10, we can just revert to the last 'traditional' PulseAudio release.

To limit the problems with Alsa drivers, there is now a switch "tsched=0" for the module-hal-detect module which will disabled glitch-free mode for all sound cards globally. To use this edit /etc/pulse/default.pa and append "tsched=0" to the line "load-module module-hal-detect"

The PulseAudio sound server has been rewritten to use timer-based audio scheduling instead of the traditional interrupt-driven approach. Timer-based scheduling may expose issues
in some Alsa drivers. To turn timer-based scheduling off, replace the line

Red Hat, Red Hat Enterprise Linux, the Shadowman logo, and JBoss are trademarks or registered trademarks of
Red Hat, Inc. or its subsidiaries in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the U.S. and other countries.
The Fedora Project is maintained and driven by the community and sponsored by Red Hat. This is a community
maintained site. Red Hat is not responsible for content.