From a4f6598f4779e67da34872636cfad4c8b0008d64 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 6 Jul 2022 09:27:38 +0200 Subject: [PATCH] dsdfile: support DSD128/256/512 as well We need to scale the number of samples to read from the file depending on the bitrate. Fixes #2508 --- src/tools/dsffile.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tools/dsffile.c b/src/tools/dsffile.c index a16f38447..9c6ce0c3a 100644 --- a/src/tools/dsffile.c +++ b/src/tools/dsffile.c @@ -216,13 +216,15 @@ dsf_file_read(struct dsf_file *f, void *data, size_t samples, const struct dsf_l uint8_t *d = data; int step = SPA_ABS(layout->interleave); bool rev = layout->lsb != f->info.lsb; - size_t total, block, offset, pos; + size_t total, block, offset, pos, scale; block = f->offset / f->info.blocksize; offset = block * f->info.blocksize * f->info.channels; pos = f->offset % f->info.blocksize; + scale = SPA_CLAMP(f->info.rate / (44100u * 64u), 1u, 4u); samples *= step; + samples *= scale; for (total = 0; total < samples && offset + pos < f->info.length; total++) { const uint8_t *s = f->p + offset + pos;