#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;
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)
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)
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;
}
/**