diff options
author | Philipp Hahn <pmhahn@users.sourceforge.net> | 2002-07-08 15:16:11 +0000 |
---|---|---|
committer | Philipp Hahn <pmhahn@users.sourceforge.net> | 2002-07-08 15:16:11 +0000 |
commit | e8eebfc09200a9a18b8722698c3aa3ec6004e9c3 (patch) | |
tree | c20e2dfbcf5bdf4afdc2f29f167021c424f4d184 | |
parent | a84096a927188bdc62c959e87247809e89413a7f (diff) | |
download | xine-lib-e8eebfc09200a9a18b8722698c3aa3ec6004e9c3.tar.gz xine-lib-e8eebfc09200a9a18b8722698c3aa3ec6004e9c3.tar.bz2 |
Request period_TIME instead of period_SIZE
CVS patchset: 2228
CVS date: 2002/07/08 15:16:11
-rw-r--r-- | src/audio_out/audio_alsa_out.c | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/src/audio_out/audio_alsa_out.c b/src/audio_out/audio_alsa_out.c index 8d98bf6ab..c3bfd30c3 100644 --- a/src/audio_out/audio_alsa_out.c +++ b/src/audio_out/audio_alsa_out.c @@ -26,7 +26,7 @@ * (c) 2001 James Courtier-Dutton <James@superbug.demon.co.uk> * * - * $Id: audio_alsa_out.c,v 1.73 2002/07/03 07:54:27 pmhahn Exp $ + * $Id: audio_alsa_out.c,v 1.74 2002/07/08 15:16:11 pmhahn Exp $ */ #ifdef HAVE_CONFIG_H @@ -62,6 +62,8 @@ #define ALSA_LOG #define AO_OUT_ALSA_IFACE_VERSION 4 +#define BUFFER_TIME 100*1000 +#define PERIOD_TIME 10*1000 #define GAP_TOLERANCE 5000 #define MIXER_MASK_LEFT (1 << 0) @@ -161,7 +163,7 @@ static int ao_alsa_open(ao_driver_t *this_gen, uint32_t bits, uint32_t rate, int snd_pcm_hw_params_t *params; snd_pcm_sw_params_t *swparams; snd_pcm_sframes_t buffer_size; - snd_pcm_sframes_t period_size,tmp; + snd_pcm_sframes_t period_size; int err, dir; // int open_mode=1; //NONBLOCK int open_mode=0; //BLOCK @@ -303,28 +305,22 @@ static int ao_alsa_open(ao_driver_t *this_gen, uint32_t bits, uint32_t rate, int } /* set the ring-buffer time [us] (large enough for x us|y samples ...) */ dir=0; - err = snd_pcm_hw_params_set_buffer_time_near(this->audio_fd, params, 500000, &dir); + err = snd_pcm_hw_params_set_buffer_time_near(this->audio_fd, params, BUFFER_TIME, &dir); if (err < 0) { printf ("audio_alsa_out: buffer time not available\n"); goto __close; } buffer_size = snd_pcm_hw_params_get_buffer_size(params); /* set the period time [us] (interrupt every x us|y samples ...) */ -#warning "FIXME: 256 samples div 48kHz are less than 5ms. When ALSA resamples->BOOM" - for (period_size = 256; period_size < buffer_size; period_size *= 2) { - dir=0; - err = snd_pcm_hw_params_set_period_size_near(this->audio_fd, params, - period_size, &dir); - if (err < 0) { - printf ("audio_alsa_out: period size not available"); - continue; - } - tmp = snd_pcm_hw_params_get_period_size(params, NULL); - printf("audio_alsa_out:open:period_size=%ld tmp=%ld\n",period_size,tmp); - if (period_size == tmp) break; - }; - if (period_size >= buffer_size) { - printf ("audio_alsa_out: buffer time and period time match, could not use\n"); + dir=0; + err = snd_pcm_hw_params_set_period_time_near(this->audio_fd, params, PERIOD_TIME, &dir); + if (err < 0) { + printf ("audio_alsa_out: period time not available"); + goto __close; + } + period_size = snd_pcm_hw_params_get_period_size(params, NULL); + if (2*period_size >= buffer_size) { + printf ("audio_alsa_out: buffer to small, could not use\n"); goto __close; } /* Check for pause/resume support */ |