make chunk_size a local var and rename it to period_size
authorAndre <maan@p133.(none)>
Mon, 17 Apr 2006 20:31:32 +0000 (22:31 +0200)
committerAndre <maan@p133.(none)>
Mon, 17 Apr 2006 20:31:32 +0000 (22:31 +0200)
play.c

diff --git a/play.c b/play.c
index ab54134..38203b4 100644 (file)
--- 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;
 }
 
 /**