mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2026-02-06 04:06:34 -05:00
test: latency - use snd_pcm_format_physical_width()
We need to allocate frames using the physical size not the sample bit size. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
152983f01b
commit
78b20e3caa
2 changed files with 9 additions and 4 deletions
|
|
@ -17,9 +17,13 @@
|
||||||
Liam Girdwood <liam.r.girdwood@linux.intel.com>
|
Liam Girdwood <liam.r.girdwood@linux.intel.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define ALSA_PCM_OLD_HW_PARAMS_API 1
|
||||||
|
#define ALSA_PCM_OLD_SW_PARAMS_API 1
|
||||||
|
#include "../../include/asoundlib.h"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
#include "tplg_local.h"
|
#include "tplg_local.h"
|
||||||
|
|
||||||
|
|
||||||
#define ENUM_VAL_SIZE (SNDRV_CTL_ELEM_ID_NAME_MAXLEN >> 2)
|
#define ENUM_VAL_SIZE (SNDRV_CTL_ELEM_ID_NAME_MAXLEN >> 2)
|
||||||
|
|
||||||
struct ctl_access_elem {
|
struct ctl_access_elem {
|
||||||
|
|
@ -71,7 +75,8 @@ static int parse_access_values(snd_config_t *cfg,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return snd_pcm_hw_params_get_channels(NULL);
|
||||||
|
//return snd_pcm_hw_params_get_access(NULL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -354,7 +354,7 @@ long readbuf(snd_pcm_t *handle, char *buf, long len, size_t *frames, size_t *max
|
||||||
}
|
}
|
||||||
// printf("read = %li\n", r);
|
// printf("read = %li\n", r);
|
||||||
} else {
|
} else {
|
||||||
int frame_bytes = (snd_pcm_format_width(format) / 8) * channels;
|
int frame_bytes = (snd_pcm_format_physical_width(format) / 8) * channels;
|
||||||
do {
|
do {
|
||||||
r = snd_pcm_readi(handle, buf, len);
|
r = snd_pcm_readi(handle, buf, len);
|
||||||
if (r > 0) {
|
if (r > 0) {
|
||||||
|
|
@ -374,7 +374,7 @@ long readbuf(snd_pcm_t *handle, char *buf, long len, size_t *frames, size_t *max
|
||||||
long writebuf(snd_pcm_t *handle, char *buf, long len, size_t *frames)
|
long writebuf(snd_pcm_t *handle, char *buf, long len, size_t *frames)
|
||||||
{
|
{
|
||||||
long r;
|
long r;
|
||||||
int frame_bytes = (snd_pcm_format_width(format) / 8) * channels;
|
int frame_bytes = (snd_pcm_format_physical_width(format) / 8) * channels;
|
||||||
|
|
||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
r = snd_pcm_writei(handle, buf, len);
|
r = snd_pcm_writei(handle, buf, len);
|
||||||
|
|
@ -579,7 +579,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
loop_limit = loop_sec * rate;
|
loop_limit = loop_sec * rate;
|
||||||
latency = latency_min - 4;
|
latency = latency_min - 4;
|
||||||
buffer = malloc((latency_max * snd_pcm_format_width(format) / 8) * 2);
|
buffer = malloc((latency_max * snd_pcm_format_physical_width(format) / 8) * 2);
|
||||||
|
|
||||||
setscheduler();
|
setscheduler();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue