From 9c386208eaad32dd0889fb9ef78e6ac709866146 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Sat, 3 Nov 2018 17:55:31 +0200 Subject: implement buffer_time_near --- src/pcm.c | 13 +++++++++++++ src/stubs.h | 1 - 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/pcm.c b/src/pcm.c index f1bc2a5..24dc00a 100644 --- a/src/pcm.c +++ b/src/pcm.c @@ -1048,6 +1048,19 @@ snd_pcm_hw_params_get_buffer_size_max(const snd_pcm_hw_params_t *params, snd_pcm return 0; } +int +snd_pcm_hw_params_set_buffer_time_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) +{ + if (dir) *dir = 0; + if (val) { + WARNX("%u", *val); + snd_pcm_uframes_t newv = MAX((*val * params->par.rate) / (uint64_t)1e6, params->par.round * 2); + snd_pcm_hw_params_set_buffer_size_near(pcm, params, &newv); + *val = (newv * (uint64_t)1e6) / params->par.rate; + } + return 0; +} + int snd_pcm_hw_params_get_period_size(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val, int *dir) { diff --git a/src/stubs.h b/src/stubs.h index d7c4174..7ab2178 100644 --- a/src/stubs.h +++ b/src/stubs.h @@ -566,7 +566,6 @@ int snd_pcm_hw_params_set_buffer_time(snd_pcm_t *pcm, snd_pcm_hw_params_t *param int snd_pcm_hw_params_set_buffer_time_min(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) { WARNX1("stub"); return 0; } int snd_pcm_hw_params_set_buffer_time_max(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) { WARNX1("stub"); return 0; } int snd_pcm_hw_params_set_buffer_time_minmax(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *min, int *mindir, unsigned int *max, int *maxdir) { WARNX1("stub"); return 0; } -int snd_pcm_hw_params_set_buffer_time_near(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) { WARNX1("stub"); return 0; } int snd_pcm_hw_params_set_buffer_time_first(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) { WARNX1("stub"); return 0; } int snd_pcm_hw_params_set_buffer_time_last(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) { WARNX1("stub"); return 0; } int snd_pcm_hw_params_test_buffer_size(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val) { WARNX1("stub"); return 0; } -- cgit v1.2.3