From cda80f7d3b0a8adf778028ac5a33496b7123ef8b Mon Sep 17 00:00:00 2001 From: Andre Date: Mon, 17 Apr 2006 22:31:32 +0200 Subject: [PATCH] make chunk_size a local var and rename it to period_size --- play.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/play.c b/play.c index ab541345..38203b40 100644 --- a/play.c +++ b/play.c @@ -34,7 +34,6 @@ #define FORMAT SND_PCM_FORMAT_S16_LE static snd_pcm_t *handle; -static snd_pcm_uframes_t chunk_size; static unsigned char *audiobuf; static size_t bytes_per_frame; static struct timeval *start_time; @@ -85,6 +84,7 @@ static int alsa_init(void) int err; snd_pcm_info_t *info; snd_output_t *log; + snd_pcm_uframes_t period_size; snd_pcm_info_alloca(&info); if (snd_output_stdio_attach(&log, stderr, 0) < 0) @@ -119,17 +119,17 @@ static int alsa_init(void) return -E_SET_BUFFER_TIME; if (snd_pcm_hw_params(handle, hwparams) < 0) return -E_HW_PARAMS; - snd_pcm_hw_params_get_period_size(hwparams, &chunk_size, 0); + snd_pcm_hw_params_get_period_size(hwparams, &period_size, 0); snd_pcm_hw_params_get_buffer_size(hwparams, &buffer_size); - PARA_DEBUG_LOG("buffer size: %lu, period_size: %lu\n", buffer_size, chunk_size); - if (chunk_size == buffer_size) + PARA_DEBUG_LOG("buffer size: %lu, period_size: %lu\n", buffer_size, period_size); + if (period_size == buffer_size) return -E_BAD_PERIOD; snd_pcm_sw_params_current(handle, swparams); err = snd_pcm_sw_params_get_xfer_align(swparams, &xfer_align); if (err < 0 || !xfer_align) return -E_GET_XFER; // snd_pcm_sw_params_set_sleep_min(handle, swparams, 0); - snd_pcm_sw_params_set_avail_min(handle, swparams, chunk_size); + snd_pcm_sw_params_set_avail_min(handle, swparams, period_size); /* round to closest transfer boundary */ start_threshold = (buffer_size / xfer_align) * xfer_align; if (start_threshold < 1) @@ -146,7 +146,7 @@ static int alsa_init(void) if (snd_pcm_sw_params(handle, swparams) < 0) return -E_SW_PARAMS; bytes_per_frame = snd_pcm_format_physical_width(FORMAT) * conf.channels_arg / 8; - return chunk_size * bytes_per_frame; + return period_size * bytes_per_frame; } /** -- 2.39.5