diff options
author | Luo Jinghua <sunmoon1997@gmail.com> | 2009-03-17 19:49:14 +0800 |
---|---|---|
committer | Luo Jinghua <sunmoon1997@gmail.com> | 2009-03-17 19:49:14 +0800 |
commit | 3d69c22e8de1a3a3b831e800b2f2e1c393a44b26 (patch) | |
tree | e99961ad486d2f3ded2bd90983c475d947104888 /src | |
parent | 19983b98e9d8f8f3f5db747a483ffdcadc58cbbb (diff) |
AlsaDevice: fixes for previous commit.
Diffstat (limited to 'src')
-rw-r--r-- | src/device_alsa.cpp | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/device_alsa.cpp b/src/device_alsa.cpp index b9d51f0..d99ce88 100644 --- a/src/device_alsa.cpp +++ b/src/device_alsa.cpp @@ -91,6 +91,21 @@ namespace audiere { return 0; } + snd_pcm_uframes_t buffer_size; + status = snd_pcm_hw_params_get_buffer_size(hwparams, &buffer_size); + if (status < 0) { + ADR_LOG("Coudn't get buffer size."); + snd_pcm_close(pcm_handle); + return 0; + } + snd_pcm_uframes_t period_size; + status = snd_pcm_hw_params_get_period_size(hwparams, &period_size, NULL); + if (status < 0) { + ADR_LOG("Coudn't get period size."); + snd_pcm_close(pcm_handle); + return 0; + } + status = snd_pcm_sw_params_current(pcm_handle, swparams); if (status < 0) { ADR_LOG("Coudn't get software parameters."); @@ -109,14 +124,16 @@ namespace audiere { #else boundary = 0x7fffffff; #endif - status = snd_pcm_sw_params_set_start_threshold(pcm_handle, swparams, buffer); + status = snd_pcm_sw_params_set_start_threshold(pcm_handle, swparams, + period_size); if (status < 0) { ADR_LOG("Coudn't get hardware parameters."); snd_pcm_close(pcm_handle); return 0; } - status = snd_pcm_sw_params_set_stop_threshold(pcm_handle, swparams, buffer); + status = snd_pcm_sw_params_set_stop_threshold(pcm_handle, swparams, + boundary); if (status < 0) { ADR_LOG("Coudn't set stop threshold."); snd_pcm_close(pcm_handle); @@ -124,7 +141,8 @@ namespace audiere { } #if SND_LIB_VERSION >= 0x000901 - status = snd_pcm_sw_params_set_silence_size(pcm_handle, swparams, boundary); + status = snd_pcm_sw_params_set_silence_size(pcm_handle, swparams, + boundary); if (status < 0) { ADR_LOG("Coudn't set silence size."); snd_pcm_close(pcm_handle); |