diff options
author | Pierre-Louis Bossart <bossart.nospam@gmail.com> | 2011-01-31 13:20:27 -0600 |
---|---|---|
committer | Colin Guthrie <cguthrie@mandriva.org> | 2011-02-01 09:41:02 +0000 |
commit | 051d82133f0ae6a57bf66fd200bc8e3591a7d5ca (patch) | |
tree | 0d593b1a20ecd97f53fc614fd4850690ec2f6802 /src/modules | |
parent | 9498440dc67376832f6d4cc0af79498643c7c3de (diff) |
alsa: disable period wakeups in tsched mode if possible
This patch reflects a new capability that Lennart was wishing
for. Wish granted...
Re-submitting it now that alsa-lib 1.0.24
provides additional entry points to disable period
wakeups in timer-scheduling mode if hardware can
work without it (HDAudio, oxygen and Intel SST).
Example with standard playback on HDAudio output
Before change:
Top causes for wakeups:
3.8% ( 5.4) [hda_intel] <interrupt>
2.8% ( 4.0) alsa-sink
After change:
Top causes for wakeups:
2.3% ( 3.0) alsa-sink
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@intel.com>
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/alsa/alsa-util.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c index 5a726ffe..786e664d 100644 --- a/src/modules/alsa/alsa-util.c +++ b/src/modules/alsa/alsa-util.c @@ -251,6 +251,22 @@ int pa_alsa_set_hw_params( if (!pa_alsa_pcm_is_hw(pcm_handle)) _use_tsched = FALSE; +#if (SND_LIB_VERSION >= ((1<<16)|(0<<8)|24)) /* API additions in 1.0.24 */ + if (_use_tsched) { + + /* try to disable period wakeups if hardware can do so */ + if (snd_pcm_hw_params_can_disable_period_wakeup(hwparams)) { + + if (snd_pcm_hw_params_set_period_wakeup(pcm_handle, hwparams, FALSE) < 0) + /* don't bail, keep going with default mode with period wakeups */ + pa_log_debug("snd_pcm_hw_params_set_period_wakeup() failed: %s", pa_alsa_strerror(ret)); + else + pa_log_info("Trying to disable ALSA period wakeups, using timers only"); + } else + pa_log_info("cannot disable ALSA period wakeups"); + } +#endif + if ((ret = set_format(pcm_handle, hwparams, &_ss.format)) < 0) goto finish; @@ -378,6 +394,18 @@ success: goto finish; } +#if (SND_LIB_VERSION >= ((1<<16)|(0<<8)|24)) /* API additions in 1.0.24 */ + if (_use_tsched) { + unsigned int no_wakeup; + /* see if period wakeups were disabled */ + snd_pcm_hw_params_get_period_wakeup(pcm_handle, hwparams, &no_wakeup); + if (no_wakeup == 0) + pa_log_info("ALSA period wakeups disabled"); + else + pa_log_info("ALSA period wakeups were not disabled"); + } +#endif + ss->rate = _ss.rate; ss->channels = _ss.channels; ss->format = _ss.format; |