summaryrefslogtreecommitdiffstats
path: root/src/modules/alsa/alsa-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-11-22 21:40:15 +0100
committerLennart Poettering <lennart@poettering.net>2009-11-22 21:40:15 +0100
commit675957b9e41d5a92d8cbff3d4fcbcec4965806da (patch)
tree1e0ac45967e965f9ef2db0784a93c1743e2b399b /src/modules/alsa/alsa-util.c
parent9708ecd6483ac9037c82a2a2a935e97d027f6b1b (diff)
parent5aa5c6c196b23acabca3e2c8a6724cb08485acdc (diff)
Merge branch 'master' of ssh://rootserver/home/lennart/git/public/pulseaudio
Diffstat (limited to 'src/modules/alsa/alsa-util.c')
-rw-r--r--src/modules/alsa/alsa-util.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c
index b8d13575..52f12599 100644
--- a/src/modules/alsa/alsa-util.c
+++ b/src/modules/alsa/alsa-util.c
@@ -259,6 +259,10 @@ int pa_alsa_set_hw_params(
goto finish;
}
+ /* We ignore very small sampling rate deviations */
+ if (_ss.rate >= ss->rate*.95 && _ss.rate <= ss->rate*1.05)
+ _ss.rate = ss->rate;
+
if (require_exact_channel_number) {
if ((ret = snd_pcm_hw_params_set_channels(pcm_handle, hwparams, _ss.channels)) < 0) {
pa_log_debug("snd_pcm_hw_params_set_channels(%u) failed: %s", _ss.channels, pa_alsa_strerror(ret));
@@ -303,7 +307,7 @@ int pa_alsa_set_hw_params(
if (set_buffer_size(pcm_handle, hwparams_copy, _buffer_size) >= 0 &&
set_period_size(pcm_handle, hwparams_copy, _period_size) >= 0 &&
snd_pcm_hw_params(pcm_handle, hwparams_copy) >= 0) {
- pa_log_debug("Set buffer size first, period size second.");
+ pa_log_debug("Set buffer size first (to %lu samples), period size second (to %lu samples).", (unsigned long) _buffer_size, (unsigned long) _period_size);
goto success;
}
@@ -311,7 +315,7 @@ int pa_alsa_set_hw_params(
if (set_period_size(pcm_handle, hwparams_copy, _period_size) >= 0 &&
set_buffer_size(pcm_handle, hwparams_copy, _buffer_size) >= 0 &&
snd_pcm_hw_params(pcm_handle, hwparams_copy) >= 0) {
- pa_log_debug("Set period size first, buffer size second.");
+ pa_log_debug("Set period size first (to %lu samples), buffer size second (to %lu samples).", (unsigned long) _period_size, (unsigned long) _buffer_size);
goto success;
}
}
@@ -322,7 +326,7 @@ int pa_alsa_set_hw_params(
/* Third try: set only buffer size */
if (set_buffer_size(pcm_handle, hwparams_copy, _buffer_size) >= 0 &&
snd_pcm_hw_params(pcm_handle, hwparams_copy) >= 0) {
- pa_log_debug("Set only buffer size second.");
+ pa_log_debug("Set only buffer size (to %lu samples).", (unsigned long) _buffer_size);
goto success;
}
}
@@ -333,7 +337,7 @@ int pa_alsa_set_hw_params(
/* Fourth try: set only period size */
if (set_period_size(pcm_handle, hwparams_copy, _period_size) >= 0 &&
snd_pcm_hw_params(pcm_handle, hwparams_copy) >= 0) {
- pa_log_debug("Set only period size second.");
+ pa_log_debug("Set only period size (to %lu samples).", (unsigned long) _period_size);
goto success;
}
}
@@ -374,9 +378,7 @@ success:
goto finish;
}
- /* If the sample rate deviates too much, we need to resample */
- if (_ss.rate < ss->rate*.95 || _ss.rate > ss->rate*1.05)
- ss->rate = _ss.rate;
+ ss->rate = _ss.rate;
ss->channels = _ss.channels;
ss->format = _ss.format;